diff --git a/common/src/main/java/com/faboslav/friendsandfoes/block/Oxidizable.java b/common/src/main/java/com/faboslav/friendsandfoes/block/Oxidizable.java index a4c8a3d20..40206dc65 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/block/Oxidizable.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/block/Oxidizable.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableBiMap; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import java.util.Optional; import java.util.function.Supplier; @@ -18,6 +19,9 @@ public interface Oxidizable extends net.minecraft.block.Oxidizable .put(ModBlocks.COPPER_BUTTON.get(), ModBlocks.EXPOSED_COPPER_BUTTON.get()) .put(ModBlocks.EXPOSED_COPPER_BUTTON.get(), ModBlocks.WEATHERED_COPPER_BUTTON.get()) .put(ModBlocks.WEATHERED_COPPER_BUTTON.get(), ModBlocks.OXIDIZED_COPPER_BUTTON.get()) + .put(Blocks.LIGHTNING_ROD, ModBlocks.EXPOSED_LIGHTNING_ROD.get()) + .put(ModBlocks.EXPOSED_LIGHTNING_ROD.get(), ModBlocks.WEATHERED_LIGHTNING_ROD.get()) + .put(ModBlocks.WEATHERED_LIGHTNING_ROD.get(), ModBlocks.OXIDIZED_LIGHTNING_ROD.get()) .build(); }); Supplier> OXIDATION_LEVEL_DECREASES = Suppliers.memoize(() -> { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/block/OxidizableLightningRodBlock.java b/common/src/main/java/com/faboslav/friendsandfoes/block/OxidizableLightningRodBlock.java new file mode 100644 index 000000000..d81564898 --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/block/OxidizableLightningRodBlock.java @@ -0,0 +1,41 @@ +package com.faboslav.friendsandfoes.block; + +import net.minecraft.block.BlockState; +import net.minecraft.block.LightningRodBlock; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; + +@SuppressWarnings("deprecation") +public final class OxidizableLightningRodBlock extends LightningRodBlock implements Oxidizable +{ + private final OxidationLevel OxidationLevel; + + public OxidizableLightningRodBlock( + OxidationLevel OxidationLevel, + Settings settings + ) { + super(settings); + this.OxidationLevel = OxidationLevel; + } + + @Override + public void randomTick( + BlockState state, + ServerWorld world, + BlockPos pos, + Random random + ) { + super.randomTick(state, world, pos, random); + this.tickDegradation(state, world, pos, random); + } + + @Override + public boolean hasRandomTicks(BlockState state) { + return Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent(); + } + + public OxidationLevel getDegradationLevel() { + return this.OxidationLevel; + } +} \ No newline at end of file diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java index 208cf6f13..f58722e3f 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/CopperGolemEntity.java @@ -498,6 +498,7 @@ public void onStruckByLightning( ) { super.onStruckByLightning(serverWorld, lightning); + this.setOnFire(false); this.setHealth(this.getMaxHealth()); if (this.isDegraded()) { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/init/ModBlocks.java b/common/src/main/java/com/faboslav/friendsandfoes/init/ModBlocks.java index 888978ef6..67adce3ef 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/init/ModBlocks.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/init/ModBlocks.java @@ -35,6 +35,13 @@ public final class ModBlocks public static final RegistrySupplier WAXED_EXPOSED_COPPER_BUTTON; public static final RegistrySupplier WAXED_WEATHERED_COPPER_BUTTON; public static final RegistrySupplier WAXED_OXIDIZED_COPPER_BUTTON; + public static final RegistrySupplier EXPOSED_LIGHTNING_ROD; + public static final RegistrySupplier WEATHERED_LIGHTNING_ROD; + public static final RegistrySupplier OXIDIZED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_EXPOSED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_WEATHERED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_OXIDIZED_LIGHTNING_ROD; static { BUTTERCUP = BLOCKS.register("buttercup", () -> new FlowerBlock(StatusEffects.SATURATION, 6, AbstractBlock.Settings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS))); @@ -55,6 +62,13 @@ public final class ModBlocks WAXED_EXPOSED_COPPER_BUTTON = BLOCKS.register("waxed_exposed_copper_button", () -> new ExposedCopperButtonBlock(AbstractBlock.Settings.copy(COPPER_BUTTON.get()))); WAXED_WEATHERED_COPPER_BUTTON = BLOCKS.register("waxed_weathered_copper_button", () -> new WeatheredCopperButtonBlock(AbstractBlock.Settings.copy(COPPER_BUTTON.get()))); WAXED_OXIDIZED_COPPER_BUTTON = BLOCKS.register("waxed_oxidized_copper_button", () -> new OxidizedCopperButtonBlock(AbstractBlock.Settings.copy(COPPER_BUTTON.get()))); + EXPOSED_LIGHTNING_ROD = BLOCKS.register("exposed_lightning_rod", () -> new OxidizableLightningRodBlock(Oxidizable.OxidationLevel.EXPOSED, AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + WEATHERED_LIGHTNING_ROD = BLOCKS.register("weathered_lightning_rod", () -> new OxidizableLightningRodBlock(Oxidizable.OxidationLevel.WEATHERED, AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + OXIDIZED_LIGHTNING_ROD = BLOCKS.register("oxidized_lightning_rod", () -> new OxidizableLightningRodBlock(Oxidizable.OxidationLevel.OXIDIZED, AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + WAXED_LIGHTNING_ROD = BLOCKS.register("waxed_lightning_rod", () -> new LightningRodBlock(AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + WAXED_EXPOSED_LIGHTNING_ROD = BLOCKS.register("waxed_exposed_lightning_rod", () -> new LightningRodBlock(AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + WAXED_WEATHERED_LIGHTNING_ROD = BLOCKS.register("waxed_weathered_lightning_rod", () -> new LightningRodBlock(AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); + WAXED_OXIDIZED_LIGHTNING_ROD = BLOCKS.register("waxed_oxidized_lightning_rod", () -> new LightningRodBlock(AbstractBlock.Settings.copy(Blocks.LIGHTNING_ROD))); } public static void initRegister() { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/init/ModItems.java b/common/src/main/java/com/faboslav/friendsandfoes/init/ModItems.java index 30457e029..bfba98950 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/init/ModItems.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/init/ModItems.java @@ -41,6 +41,13 @@ public final class ModItems public static final RegistrySupplier WAXED_EXPOSED_COPPER_BUTTON; public static final RegistrySupplier WAXED_WEATHERED_COPPER_BUTTON; public static final RegistrySupplier WAXED_OXIDIZED_COPPER_BUTTON; + public static final RegistrySupplier EXPOSED_LIGHTNING_ROD; + public static final RegistrySupplier WEATHERED_LIGHTNING_ROD; + public static final RegistrySupplier OXIDIZED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_EXPOSED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_WEATHERED_LIGHTNING_ROD; + public static final RegistrySupplier WAXED_OXIDIZED_LIGHTNING_ROD; static { COPPER_GOLEM_SPAWN_EGG = ITEMS.register("copper_golem_spawn_egg", () -> new ArchitecturySpawnEggItem(ModEntityTypes.COPPER_GOLEM, 0x9A5038, 0xE3826C, new Item.Settings().maxCount(64).group(ItemGroup.MISC))); @@ -66,6 +73,13 @@ public final class ModItems WAXED_EXPOSED_COPPER_BUTTON = ITEMS.register("waxed_exposed_copper_button", () -> new BlockItem(ModBlocks.WAXED_EXPOSED_COPPER_BUTTON.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); WAXED_WEATHERED_COPPER_BUTTON = ITEMS.register("waxed_weathered_copper_button", () -> new BlockItem(ModBlocks.WAXED_WEATHERED_COPPER_BUTTON.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); WAXED_OXIDIZED_COPPER_BUTTON = ITEMS.register("waxed_oxidized_copper_button", () -> new BlockItem(ModBlocks.WAXED_OXIDIZED_COPPER_BUTTON.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + EXPOSED_LIGHTNING_ROD = ITEMS.register("exposed_lightning_rod", () -> new BlockItem(ModBlocks.EXPOSED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + WEATHERED_LIGHTNING_ROD = ITEMS.register("weathered_lightning_rod", () -> new BlockItem(ModBlocks.WEATHERED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + OXIDIZED_LIGHTNING_ROD = ITEMS.register("oxidized_lightning_rod", () -> new BlockItem(ModBlocks.OXIDIZED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + WAXED_LIGHTNING_ROD = ITEMS.register("waxed_lightning_rod", () -> new BlockItem(ModBlocks.WAXED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + WAXED_EXPOSED_LIGHTNING_ROD = ITEMS.register("waxed_exposed_lightning_rod", () -> new BlockItem(ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + WAXED_WEATHERED_LIGHTNING_ROD = ITEMS.register("waxed_weathered_lightning_rod", () -> new BlockItem(ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); + WAXED_OXIDIZED_LIGHTNING_ROD = ITEMS.register("waxed_oxidized_lightning_rod", () -> new BlockItem(ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get(), new Item.Settings().group(ItemGroup.REDSTONE).maxCount(64))); } public static void initRegister() { diff --git a/common/src/main/java/com/faboslav/friendsandfoes/init/ModTags.java b/common/src/main/java/com/faboslav/friendsandfoes/init/ModTags.java index f86d8a952..709535634 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/init/ModTags.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/init/ModTags.java @@ -13,11 +13,10 @@ public class ModTags { public static final TagKey COPPER_BUTTONS = blockTag("copper_buttons"); + public static final TagKey LIGHTNING_RODS = blockTag("lightning_rods"); public static final TagKey GLARE_SPAWNABLE_ON = blockTag("glare_spawnable_on"); public static final TagKey MAULERS_SPAWNABLE_ON = blockTag("maulers_spawnable_on"); - public static final TagKey> MAULER_PREY = entityTypeTag("mauler_prey"); - public static final TagKey HAS_BADLANDS_MAULER = biomeTag("has_badlands_mauler"); public static final TagKey HAS_DESERT_MAULER = biomeTag("has_desert_mauler"); public static final TagKey HAS_GLARE = biomeTag("has_glare"); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/AxeItemMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/AxeItemMixin.java index f23dbf033..dd6aa4374 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/AxeItemMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/AxeItemMixin.java @@ -1,11 +1,7 @@ package com.faboslav.friendsandfoes.mixin; import com.faboslav.friendsandfoes.block.Oxidizable; -import com.faboslav.friendsandfoes.init.ModBlocks; -import com.google.common.base.Suppliers; -import com.google.common.collect.BiMap; -import com.google.common.collect.ImmutableBiMap; -import net.minecraft.block.Block; +import com.faboslav.friendsandfoes.util.WaxableBlocksMap; import net.minecraft.block.BlockState; import net.minecraft.item.AxeItem; import net.minecraft.item.ItemUsageContext; @@ -16,21 +12,10 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import java.util.Optional; -import java.util.function.Supplier; @Mixin(AxeItem.class) -@SuppressWarnings({"rawtypes", "unchecked"}) public abstract class AxeItemMixin { - private static final Supplier> WAXED_TO_UNWAXED_BLOCKS = Suppliers.memoize(() -> { - return (BiMap) ImmutableBiMap.builder() - .put(ModBlocks.WAXED_COPPER_BUTTON.get(), ModBlocks.COPPER_BUTTON.get()) - .put(ModBlocks.WAXED_EXPOSED_COPPER_BUTTON.get(), ModBlocks.EXPOSED_COPPER_BUTTON.get()) - .put(ModBlocks.WAXED_WEATHERED_COPPER_BUTTON.get(), ModBlocks.WEATHERED_COPPER_BUTTON.get()) - .put(ModBlocks.WAXED_OXIDIZED_COPPER_BUTTON.get(), ModBlocks.OXIDIZED_COPPER_BUTTON.get()) - .build(); - }); - @ModifyVariable( method = "useOnBlock", ordinal = 1, @@ -72,6 +57,6 @@ private Optional modifyWaxedBlock( BlockPos blockPos = context.getBlockPos(); BlockState blockState = world.getBlockState(blockPos); - return Optional.ofNullable(WAXED_TO_UNWAXED_BLOCKS.get().get(blockState.getBlock())).map((block) -> block.getStateWithProperties(blockState)); + return Optional.ofNullable(WaxableBlocksMap.WAXED_TO_UNWAXED_BLOCKS.get().get(blockState.getBlock())).map((block) -> block.getStateWithProperties(blockState)); } } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/HoneycombItemMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/HoneycombItemMixin.java index 5520e3c6c..ed05e50be 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/HoneycombItemMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/HoneycombItemMixin.java @@ -1,9 +1,7 @@ package com.faboslav.friendsandfoes.mixin; -import com.faboslav.friendsandfoes.init.ModBlocks; -import com.google.common.base.Suppliers; +import com.faboslav.friendsandfoes.util.WaxableBlocksMap; import com.google.common.collect.BiMap; -import com.google.common.collect.ImmutableBiMap; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.HoneycombItem; @@ -13,21 +11,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Optional; -import java.util.function.Supplier; @Mixin(HoneycombItem.class) -@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings({"rawtypes"}) public abstract class HoneycombItemMixin { - private static final Supplier> UNWAXED_TO_WAXED_BUTTON_BLOCKS = Suppliers.memoize(() -> { - return (BiMap) ImmutableBiMap.builder() - .put(ModBlocks.COPPER_BUTTON.get(), ModBlocks.WAXED_COPPER_BUTTON.get()) - .put(ModBlocks.EXPOSED_COPPER_BUTTON.get(), ModBlocks.WAXED_EXPOSED_COPPER_BUTTON.get()) - .put(ModBlocks.WEATHERED_COPPER_BUTTON.get(), ModBlocks.WAXED_WEATHERED_COPPER_BUTTON.get()) - .put(ModBlocks.OXIDIZED_COPPER_BUTTON.get(), ModBlocks.WAXED_OXIDIZED_COPPER_BUTTON.get()) - .build(); - }); - @Inject( method = "getWaxedState", at = @At("RETURN"), @@ -40,7 +28,7 @@ private static void getWaxedState( var blockState = callbackInfo.getReturnValue(); if (blockState.isEmpty()) { - blockState = Optional.ofNullable((Block) ((BiMap) UNWAXED_TO_WAXED_BUTTON_BLOCKS.get()).get(state.getBlock())).map((block) -> { + blockState = Optional.ofNullable((Block) ((BiMap) WaxableBlocksMap.UNWAXED_TO_WAXED_BUTTON_BLOCKS.get()).get(state.getBlock())).map((block) -> { return block.getStateWithProperties(state); }); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningEntityMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningEntityMixin.java new file mode 100644 index 000000000..e8e76d68b --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningEntityMixin.java @@ -0,0 +1,112 @@ +package com.faboslav.friendsandfoes.mixin; + +import com.faboslav.friendsandfoes.block.Oxidizable; +import com.faboslav.friendsandfoes.init.ModTags; +import net.minecraft.block.BlockState; +import net.minecraft.block.LightningRodBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LightningEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Iterator; +import java.util.Optional; + +@Mixin(LightningEntity.class) +public abstract class LightningEntityMixin extends Entity +{ + public LightningEntityMixin(EntityType type, World world) { + super(type, world); + } + + @Shadow + protected abstract BlockPos getAffectedBlockPos(); + + @Inject( + method = "powerLightningRod", + at = @At("HEAD") + ) + public void friendsAndFoesPowerLightningRod(CallbackInfo ci) { + BlockPos blockPos = this.getAffectedBlockPos(); + BlockState blockState = this.world.getBlockState(blockPos); + + if (blockState.isIn(ModTags.LIGHTNING_RODS)) { + ((LightningRodBlock) blockState.getBlock()).setPowered(blockState, this.world, blockPos); + } + } + + @Inject( + method = "cleanOxidation", + at = @At("HEAD") + ) + private static void friendsAndFoesCleanOxidation( + World world, + BlockPos pos, + CallbackInfo ci + ) { + BlockState blockState = world.getBlockState(pos); + BlockPos blockPos; + BlockState blockState2; + + if (blockState.isIn(ModTags.LIGHTNING_RODS)) { + blockPos = pos.offset(blockState.get(LightningRodBlock.FACING).getOpposite()); + blockState2 = world.getBlockState(blockPos); + } else { + blockPos = pos; + blockState2 = blockState; + } + + if (blockState2.getBlock() instanceof Oxidizable) { + world.setBlockState(blockPos, Oxidizable.getUnaffectedOxidationState(world.getBlockState(blockPos))); + BlockPos.Mutable mutable = pos.mutableCopy(); + int i = world.random.nextInt(3) + 3; + + for (int j = 0; j < i; ++j) { + int k = world.random.nextInt(8) + 1; + LightningEntity.cleanOxidationAround(world, blockPos, mutable, k); + } + } + } + + public void customCleanOxidationAround(World world, BlockPos pos, BlockPos.Mutable mutablePos, int count) { + mutablePos.set(pos); + + for(int i = 0; i < count; ++i) { + Optional optional = cleanOxidationAround(world, mutablePos); + if (!optional.isPresent()) { + break; + } + + mutablePos.set((Vec3i)optional.get()); + } + + } + + private static Optional cleanOxidationAround(World world, BlockPos pos) { + Iterator var2 = BlockPos.iterateRandomly(world.random, 10, pos, 1).iterator(); + + BlockPos blockPos; + BlockState blockState; + do { + if (!var2.hasNext()) { + return Optional.empty(); + } + + blockPos = (BlockPos)var2.next(); + blockState = world.getBlockState(blockPos); + } while(!(blockState.getBlock() instanceof net.minecraft.block.Oxidizable)); + + net.minecraft.block.Oxidizable.getDecreasedOxidationState(blockState).ifPresent((state) -> { + world.setBlockState(blockPos, state); + }); + world.syncWorldEvent(3002, blockPos, -1); + return Optional.of(blockPos); + } +} diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningRodBlockMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningRodBlockMixin.java index 3f7300f1d..e66906662 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningRodBlockMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/LightningRodBlockMixin.java @@ -1,7 +1,9 @@ package com.faboslav.friendsandfoes.mixin; import com.faboslav.friendsandfoes.FriendsAndFoes; +import com.faboslav.friendsandfoes.block.Oxidizable; import com.faboslav.friendsandfoes.entity.CopperGolemEntity; +import com.faboslav.friendsandfoes.init.ModBlocks; import com.faboslav.friendsandfoes.init.ModEntityTypes; import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.*; @@ -9,8 +11,10 @@ import net.minecraft.block.pattern.BlockPatternBuilder; import net.minecraft.block.pattern.CachedBlockPosition; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.random.Random; import net.minecraft.world.World; import net.minecraft.world.WorldEvents; import org.jetbrains.annotations.Nullable; @@ -22,12 +26,21 @@ import java.util.function.Predicate; @Mixin(LightningRodBlock.class) -public abstract class LightningRodBlockMixin extends RodBlock +public abstract class LightningRodBlockMixin extends RodBlock implements Oxidizable { @Nullable private BlockPattern copperGolemPattern; - private static final Predicate IS_GOLEM_LIGHTNING_ROD_PREDICATE = state -> state != null && (state == Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.FACING, Direction.UP)); + private static final Predicate IS_GOLEM_LIGHTNING_ROD_PREDICATE = state -> state != null && ( + state == Blocks.LIGHTNING_ROD.getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.WEATHERED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.EXPOSED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.OXIDIZED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.WAXED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + || state == ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get().getDefaultState().with(LightningRodBlock.FACING, Direction.UP) + ); private static final Predicate IS_GOLEM_HEAD_PREDICATE = state -> state != null && (state.isOf(Blocks.CARVED_PUMPKIN) || state.isOf(Blocks.JACK_O_LANTERN)); private static final Predicate IS_GOLEM_BODY_PREDICATE = state -> state != null && ( state.isOf(Blocks.COPPER_BLOCK) @@ -40,7 +53,7 @@ public abstract class LightningRodBlockMixin extends RodBlock || state.isOf(Blocks.WAXED_OXIDIZED_COPPER) ); - protected LightningRodBlockMixin(Settings settings) { + public LightningRodBlockMixin(Settings settings) { super(settings); } @@ -53,7 +66,7 @@ private void customOnBlockAdded( boolean notify, CallbackInfo ci ) { - if (!oldState.isOf(state.getBlock())) { + if (oldState.isOf(state.getBlock()) == false) { this.tryToSpawnCopperGolem( world, pos @@ -75,9 +88,42 @@ private void tryToSpawnCopperGolem( return; } + BlockState lightningRodBlockState = patternSearchResult.translate(0, 0, 0).getBlockState(); BlockState headBlockState = patternSearchResult.translate(0, 1, 0).getBlockState(); BlockState bodyBlockState = patternSearchResult.translate(0, 2, 0).getBlockState(); + Oxidizable.OxidationLevel lightningRodOxidationLevel; + + if (lightningRodBlockState.isOf(ModBlocks.WAXED_LIGHTNING_ROD.get())) { + lightningRodOxidationLevel = Oxidizable.OxidationLevel.UNAFFECTED; + } else if (lightningRodBlockState.isOf(ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get())) { + lightningRodOxidationLevel = Oxidizable.OxidationLevel.WEATHERED; + } else if (lightningRodBlockState.isOf(ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get())) { + lightningRodOxidationLevel = Oxidizable.OxidationLevel.EXPOSED; + } else if (lightningRodBlockState.isOf(ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get())) { + lightningRodOxidationLevel = Oxidizable.OxidationLevel.OXIDIZED; + } else { + lightningRodOxidationLevel = ((LightningRodBlockMixin) lightningRodBlockState.getBlock()).getDegradationLevel(); + } + + Oxidizable.OxidationLevel bodyOxidationLevel; + + if (bodyBlockState.isOf(Blocks.WAXED_COPPER_BLOCK)) { + bodyOxidationLevel = Oxidizable.OxidationLevel.UNAFFECTED; + } else if (bodyBlockState.isOf(Blocks.WAXED_WEATHERED_COPPER)) { + bodyOxidationLevel = Oxidizable.OxidationLevel.WEATHERED; + } else if (bodyBlockState.isOf(Blocks.WAXED_EXPOSED_COPPER)) { + bodyOxidationLevel = Oxidizable.OxidationLevel.EXPOSED; + } else if (bodyBlockState.isOf(Blocks.WAXED_OXIDIZED_COPPER)) { + bodyOxidationLevel = Oxidizable.OxidationLevel.OXIDIZED; + } else { + bodyOxidationLevel = ((OxidizableBlock) bodyBlockState.getBlock()).getDegradationLevel(); + } + + if (lightningRodOxidationLevel != bodyOxidationLevel) { + return; + } + for (int i = 0; i < this.getCopperGolemPattern().getHeight(); ++i) { CachedBlockPosition cachedBlockPosition = patternSearchResult.translate(0, i, 0); world.setBlockState( @@ -105,23 +151,15 @@ private void tryToSpawnCopperGolem( copperGolemEntity.setSpawnYaw(copperGolemYaw); world.spawnEntity(copperGolemEntity); - Oxidizable.OxidationLevel oxidationLevel; + copperGolemEntity.setOxidationLevel(bodyOxidationLevel); - if (bodyBlockState.isOf(Blocks.WAXED_COPPER_BLOCK)) { - oxidationLevel = Oxidizable.OxidationLevel.UNAFFECTED; - } else if (bodyBlockState.isOf(Blocks.WAXED_WEATHERED_COPPER)) { - oxidationLevel = Oxidizable.OxidationLevel.WEATHERED; - } else if (bodyBlockState.isOf(Blocks.WAXED_EXPOSED_COPPER)) { - oxidationLevel = Oxidizable.OxidationLevel.EXPOSED; - } else if (bodyBlockState.isOf(Blocks.WAXED_OXIDIZED_COPPER)) { - oxidationLevel = Oxidizable.OxidationLevel.OXIDIZED; - } else { - oxidationLevel = ((OxidizableBlock) bodyBlockState.getBlock()).getDegradationLevel(); + if (lightningRodOxidationLevel != Oxidizable.OxidationLevel.OXIDIZED) { + boolean isHeadBlockWaxed = this.isCopperBlockWaxed(headBlockState); + boolean isBodyBlockWaxed = this.isCopperBlockWaxed(bodyBlockState); + boolean isWaxed = isHeadBlockWaxed && isBodyBlockWaxed; + copperGolemEntity.setIsWaxed(isWaxed); } - copperGolemEntity.setOxidationLevel(oxidationLevel); - copperGolemEntity.setIsWaxed(this.isCopperBlockWaxed(bodyBlockState)); - for (ServerPlayerEntity serverPlayerEntity : world.getNonSpectatingEntities( ServerPlayerEntity.class, copperGolemEntity.getBoundingBox().expand(5.0D) @@ -154,6 +192,31 @@ private boolean isCopperBlockWaxed( return blockState.isOf(Blocks.WAXED_COPPER_BLOCK) || blockState.isOf(Blocks.WAXED_WEATHERED_COPPER) || blockState.isOf(Blocks.WAXED_EXPOSED_COPPER) - || blockState.isOf(Blocks.WAXED_OXIDIZED_COPPER); + || blockState.isOf(Blocks.WAXED_OXIDIZED_COPPER) + || blockState.isOf(ModBlocks.WAXED_LIGHTNING_ROD.get()) + || blockState.isOf(ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get()) + || blockState.isOf(ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get()) + || blockState.isOf(ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get()); + } + + @Override + public void randomTick( + BlockState state, + ServerWorld world, + BlockPos pos, + Random random + ) { + super.randomTick(state, world, pos, random); + this.tickDegradation(state, world, pos, random); + } + + @Override + public boolean hasRandomTicks(BlockState state) { + return Oxidizable.getIncreasedOxidationBlock(state.getBlock()).isPresent(); + } + + @Override + public OxidationLevel getDegradationLevel() { + return net.minecraft.block.Oxidizable.OxidationLevel.UNAFFECTED; } } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/util/WaxableBlocksMap.java b/common/src/main/java/com/faboslav/friendsandfoes/util/WaxableBlocksMap.java new file mode 100644 index 000000000..524ac234f --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/util/WaxableBlocksMap.java @@ -0,0 +1,36 @@ +package com.faboslav.friendsandfoes.util; + +import com.faboslav.friendsandfoes.init.ModBlocks; +import com.google.common.base.Suppliers; +import com.google.common.collect.BiMap; +import com.google.common.collect.ImmutableBiMap; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; + +import java.util.function.Supplier; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public final class WaxableBlocksMap +{ + public static final Supplier> WAXED_TO_UNWAXED_BLOCKS = Suppliers.memoize(() -> (BiMap) ImmutableBiMap.builder() + .put(ModBlocks.WAXED_COPPER_BUTTON.get(), ModBlocks.COPPER_BUTTON.get()) + .put(ModBlocks.WAXED_EXPOSED_COPPER_BUTTON.get(), ModBlocks.EXPOSED_COPPER_BUTTON.get()) + .put(ModBlocks.WAXED_WEATHERED_COPPER_BUTTON.get(), ModBlocks.WEATHERED_COPPER_BUTTON.get()) + .put(ModBlocks.WAXED_OXIDIZED_COPPER_BUTTON.get(), ModBlocks.OXIDIZED_COPPER_BUTTON.get()) + .put(ModBlocks.WAXED_LIGHTNING_ROD.get(), Blocks.LIGHTNING_ROD) + .put(ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get(), ModBlocks.EXPOSED_LIGHTNING_ROD.get()) + .put(ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get(), ModBlocks.WEATHERED_LIGHTNING_ROD.get()) + .put(ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get(), ModBlocks.OXIDIZED_LIGHTNING_ROD.get()) + .build()); + + public static final Supplier> UNWAXED_TO_WAXED_BUTTON_BLOCKS = Suppliers.memoize(() -> (BiMap) ImmutableBiMap.builder() + .put(ModBlocks.COPPER_BUTTON.get(), ModBlocks.WAXED_COPPER_BUTTON.get()) + .put(ModBlocks.EXPOSED_COPPER_BUTTON.get(), ModBlocks.WAXED_EXPOSED_COPPER_BUTTON.get()) + .put(ModBlocks.WEATHERED_COPPER_BUTTON.get(), ModBlocks.WAXED_WEATHERED_COPPER_BUTTON.get()) + .put(ModBlocks.OXIDIZED_COPPER_BUTTON.get(), ModBlocks.WAXED_OXIDIZED_COPPER_BUTTON.get()) + .put(Blocks.LIGHTNING_ROD, ModBlocks.WAXED_LIGHTNING_ROD.get()) + .put(ModBlocks.EXPOSED_LIGHTNING_ROD.get(), ModBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get()) + .put(ModBlocks.WEATHERED_LIGHTNING_ROD.get(), ModBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get()) + .put(ModBlocks.OXIDIZED_LIGHTNING_ROD.get(), ModBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get()) + .build()); +} diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/exposed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/exposed_lightning_rod.json new file mode 100644 index 000000000..1bc9001fc --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/exposed_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/oxidized_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/oxidized_lightning_rod.json new file mode 100644 index 000000000..ce408558b --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/oxidized_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_exposed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_exposed_lightning_rod.json new file mode 100644 index 000000000..1bc9001fc --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_exposed_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/exposed_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/exposed_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_lightning_rod.json new file mode 100644 index 000000000..8ca9fee79 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "minecraft:block/lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "minecraft:block/lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "minecraft:block/lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "minecraft:block/lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "minecraft:block/lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "minecraft:block/lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "minecraft:block/lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "minecraft:block/lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "minecraft:block/lightning_rod" + }, + "facing=up,powered=true": { + "model": "minecraft:block/lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "minecraft:block/lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "minecraft:block/lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_oxidized_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_oxidized_lightning_rod.json new file mode 100644 index 000000000..ce408558b --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_oxidized_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/oxidized_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/oxidized_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_weathered_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_weathered_lightning_rod.json new file mode 100644 index 000000000..0549ca1e6 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/waxed_weathered_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/blockstates/weathered_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/blockstates/weathered_lightning_rod.json new file mode 100644 index 000000000..0549ca1e6 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/blockstates/weathered_lightning_rod.json @@ -0,0 +1,56 @@ +{ + "variants": { + "facing=down,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 180 + }, + "facing=down,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 180 + }, + "facing=east,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 90 + }, + "facing=east,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 90 + }, + "facing=north,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90 + }, + "facing=north,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90 + }, + "facing=south,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 180 + }, + "facing=south,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 180 + }, + "facing=up,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod" + }, + "facing=up,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on" + }, + "facing=west,powered=false": { + "model": "friendsandfoes:block/weathered_lightning_rod", + "x": 90, + "y": 270 + }, + "facing=west,powered=true": { + "model": "friendsandfoes:block/weathered_lightning_rod_on", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/lang/en_us.json b/common/src/main/resources/assets/friendsandfoes/lang/en_us.json index 31cf7d353..3d6c11620 100644 --- a/common/src/main/resources/assets/friendsandfoes/lang/en_us.json +++ b/common/src/main/resources/assets/friendsandfoes/lang/en_us.json @@ -33,6 +33,13 @@ "block.friendsandfoes.waxed_exposed_copper_button": "Waxed Exposed Copper Button", "block.friendsandfoes.waxed_weathered_copper_button": "Waxed Weathered Copper Button", "block.friendsandfoes.waxed_oxidized_copper_button": "Waxed Oxidized Copper Button", + "block.friendsandfoes.exposed_lightning_rod": "Exposed Lightning Rod", + "block.friendsandfoes.weathered_lightning_rod": "Weathered Lightning Rod", + "block.friendsandfoes.oxidized_lightning_rod": "Oxidized Lightning Rod", + "block.friendsandfoes.waxed_lightning_rod": "Waxed Lightning Rod", + "block.friendsandfoes.waxed_exposed_lightning_rod": "Waxed Exposed Lightning Rod", + "block.friendsandfoes.waxed_weathered_lightning_rod": "Waxed Weathered Lightning Rod", + "block.friendsandfoes.waxed_oxidized_lightning_rod": "Waxed Oxidized Lightning Rod", "entity.minecraft.villager.beekeeper": "Beekeeper", "entity.minecraft.villager.friendsandfoes.beekeeper": "Beekeeper", "entity.friendsandfoes.copper_golem": "Copper Golem", diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod.json new file mode 100644 index 000000000..89752f3d0 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod.json @@ -0,0 +1,163 @@ +{ + "parent": "block/block", + "display": { + "head": { + "rotation": [ + -180, + 0, + 0 + ], + "translation": [ + 8.5, + 4, + 0 + ] + }, + "thirdperson_righthand": { + "translation": [ + 0, + 2, + 0.5 + ], + "scale": [ + 0.40, + 0.40, + 0.40 + ] + } + }, + "ambientocclusion": false, + "textures": { + "texture": "friendsandfoes:block/exposed_lightning_rod", + "particle": "friendsandfoes:block/exposed_lightning_rod" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 6 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod_on.json b/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod_on.json new file mode 100644 index 000000000..692aeed62 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/exposed_lightning_rod_on.json @@ -0,0 +1,139 @@ +{ + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "texture": "block/lightning_rod_on", + "particle": "block/lightning_rod_on" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod.json new file mode 100644 index 000000000..1012206c5 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod.json @@ -0,0 +1,163 @@ +{ + "parent": "block/block", + "display": { + "head": { + "rotation": [ + -180, + 0, + 0 + ], + "translation": [ + 8.5, + 4, + 0 + ] + }, + "thirdperson_righthand": { + "translation": [ + 0, + 2, + 0.5 + ], + "scale": [ + 0.40, + 0.40, + 0.40 + ] + } + }, + "ambientocclusion": false, + "textures": { + "texture": "friendsandfoes:block/oxidized_lightning_rod", + "particle": "friendsandfoes:block/oxidized_lightning_rod" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 6 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod_on.json b/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod_on.json new file mode 100644 index 000000000..692aeed62 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/oxidized_lightning_rod_on.json @@ -0,0 +1,139 @@ +{ + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "texture": "block/lightning_rod_on", + "particle": "block/lightning_rod_on" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod.json new file mode 100644 index 000000000..ff59b21a8 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod.json @@ -0,0 +1,163 @@ +{ + "parent": "block/block", + "display": { + "head": { + "rotation": [ + -180, + 0, + 0 + ], + "translation": [ + 8.5, + 4, + 0 + ] + }, + "thirdperson_righthand": { + "translation": [ + 0, + 2, + 0.5 + ], + "scale": [ + 0.40, + 0.40, + 0.40 + ] + } + }, + "ambientocclusion": false, + "textures": { + "texture": "friendsandfoes:block/weathered_lightning_rod", + "particle": "friendsandfoes:block/weathered_lightning_rod" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 6 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod_on.json b/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod_on.json new file mode 100644 index 000000000..692aeed62 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/block/weathered_lightning_rod_on.json @@ -0,0 +1,139 @@ +{ + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "texture": "block/lightning_rod_on", + "particle": "block/lightning_rod_on" + }, + "elements": [ + { + "from": [ + 6, + 12, + 6 + ], + "to": [ + 10, + 16, + 10 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 0, + 4, + 4 + ], + "texture": "#texture" + }, + "up": { + "uv": [ + 4, + 4, + 0, + 0 + ], + "texture": "#texture" + } + } + }, + { + "from": [ + 7, + 0, + 7 + ], + "to": [ + 9, + 12, + 9 + ], + "shade": false, + "faces": { + "north": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "south": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "west": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "east": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + }, + "down": { + "uv": [ + 0, + 4, + 2, + 16 + ], + "texture": "#texture" + } + } + } + ] +} diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/exposed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/exposed_lightning_rod.json new file mode 100644 index 000000000..22ae02a9c --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/exposed_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/exposed_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/oxidized_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/oxidized_lightning_rod.json new file mode 100644 index 000000000..e9713dc45 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/oxidized_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/oxidized_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/waxed_exposed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_exposed_lightning_rod.json new file mode 100644 index 000000000..22ae02a9c --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_exposed_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/exposed_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/waxed_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_lightning_rod.json new file mode 100644 index 000000000..d701601a0 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "minecraft:block/lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/waxed_oxidized_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_oxidized_lightning_rod.json new file mode 100644 index 000000000..e9713dc45 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_oxidized_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/oxidized_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/waxed_weathered_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_weathered_lightning_rod.json new file mode 100644 index 000000000..32c18dd62 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/waxed_weathered_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/weathered_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/models/item/weathered_lightning_rod.json b/common/src/main/resources/assets/friendsandfoes/models/item/weathered_lightning_rod.json new file mode 100644 index 000000000..32c18dd62 --- /dev/null +++ b/common/src/main/resources/assets/friendsandfoes/models/item/weathered_lightning_rod.json @@ -0,0 +1,3 @@ +{ + "parent": "friendsandfoes:block/weathered_lightning_rod" +} \ No newline at end of file diff --git a/common/src/main/resources/assets/friendsandfoes/textures/block/exposed_lightning_rod.png b/common/src/main/resources/assets/friendsandfoes/textures/block/exposed_lightning_rod.png new file mode 100644 index 000000000..7ec8ab2c1 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/textures/block/exposed_lightning_rod.png differ diff --git a/common/src/main/resources/assets/friendsandfoes/textures/block/oxidized_lightning_rod.png b/common/src/main/resources/assets/friendsandfoes/textures/block/oxidized_lightning_rod.png new file mode 100644 index 000000000..d686bbf20 Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/textures/block/oxidized_lightning_rod.png differ diff --git a/common/src/main/resources/assets/friendsandfoes/textures/block/weathered_lightning_rod.png b/common/src/main/resources/assets/friendsandfoes/textures/block/weathered_lightning_rod.png new file mode 100644 index 000000000..94dee5f0a Binary files /dev/null and b/common/src/main/resources/assets/friendsandfoes/textures/block/weathered_lightning_rod.png differ diff --git a/common/src/main/resources/data/friendsandfoes/tags/blocks/lightning_rods.json b/common/src/main/resources/data/friendsandfoes/tags/blocks/lightning_rods.json new file mode 100644 index 000000000..b69f6e13d --- /dev/null +++ b/common/src/main/resources/data/friendsandfoes/tags/blocks/lightning_rods.json @@ -0,0 +1,12 @@ +{ + "replace": false, + "values": [ + "friendsandfoes:exposed_lightning_rod", + "friendsandfoes:weathered_lightning_rod", + "friendsandfoes:oxidized_lightning_rod", + "friendsandfoes:waxed_lightning_rod", + "friendsandfoes:waxed_exposed_lightning_rod", + "friendsandfoes:waxed_oxidized_lightning_rod", + "friendsandfoes:waxed_weathered_lightning_rod" + ] +} \ No newline at end of file diff --git a/common/src/main/resources/friendsandfoes-common.mixins.json b/common/src/main/resources/friendsandfoes-common.mixins.json index c2a573df5..1cff90ba9 100644 --- a/common/src/main/resources/friendsandfoes-common.mixins.json +++ b/common/src/main/resources/friendsandfoes-common.mixins.json @@ -15,6 +15,7 @@ "ChickenEntityMixin", "HoneycombItemMixin", "IllusionerEntityMixin", + "LightningEntityMixin", "LightningRodBlockMixin", "PatrolSpawnerAccessor", "PatrolSpawnerMixin",