From aced8fd98b066a55535dd302e754ee08154f6c91 Mon Sep 17 00:00:00 2001 From: Builderdog841 Date: Mon, 17 Jun 2024 16:18:36 +0200 Subject: [PATCH] Block Code Refactor --- .../block/AncientAetherBlockBuilders.java | 76 +++++++++++++++++++ .../block/AncientAetherBlocks.java | 66 +--------------- 2 files changed, 77 insertions(+), 65 deletions(-) create mode 100644 src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlockBuilders.java diff --git a/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlockBuilders.java b/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlockBuilders.java new file mode 100644 index 000000000..d1d1266df --- /dev/null +++ b/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlockBuilders.java @@ -0,0 +1,76 @@ +package net.builderdog.ancient_aether.block; + +import com.aetherteam.aether.block.natural.AetherDoubleDropsLeaves; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.material.MapColor; +import net.minecraft.world.level.material.PushReaction; + +public class AncientAetherBlockBuilders { + + public static Block leaves(MapColor mapColor, SoundType sound) { + return new AetherDoubleDropsLeaves( + BlockBehaviour.Properties.of() + .mapColor(mapColor) + .strength(0.2F) + .randomTicks() + .sound(sound) + .noOcclusion() + .isValidSpawn(AncientAetherBlocks::ocelotOrParrot) + .isSuffocating(AncientAetherBlocks::never) + .isViewBlocking(AncientAetherBlocks::never) + .ignitedByLava() + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor(AncientAetherBlocks::never) + ); + } + + public static WallBlock logWall() { + return new WallBlock( + BlockBehaviour.Properties.of() + .mapColor(MapColor.WOOD) + .instrument(NoteBlockInstrument.BASS) + .ignitedByLava().strength(2.0F) + .sound(SoundType.WOOD) + ); + } + + public static Block dungeonBlock(MapColor mapColor) { + return new Block( + BlockBehaviour.Properties.of() + .mapColor(mapColor) + .instrument(NoteBlockInstrument.BASEDRUM) + .strength(0.5F, 6.0F) + .requiresCorrectToolForDrops() + ); + } + + public static RotatedPillarBlock dungeonMosaic(MapColor mapColor) { + return new RotatedPillarBlock( + BlockBehaviour.Properties.of() + .mapColor(mapColor) + .instrument(NoteBlockInstrument.BASEDRUM) + .strength(0.5F, 6.0F) + .requiresCorrectToolForDrops() + ); + } + + public static boolean never(BlockState test1, BlockGetter test2, BlockPos test3) { + return false; + } + public static boolean always(BlockState test1, BlockGetter test2, BlockPos test3) { + return true; + } + + public static boolean ocelotOrParrot(BlockState state, BlockGetter getter, BlockPos pos, EntityType entity) { + return entity == EntityType.OCELOT || entity == EntityType.PARROT; + } +} \ No newline at end of file diff --git a/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlocks.java b/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlocks.java index afc636ff9..e34859247 100644 --- a/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlocks.java +++ b/src/main/java/net/builderdog/ancient_aether/block/AncientAetherBlocks.java @@ -5,7 +5,6 @@ import com.aetherteam.aether.block.dungeon.TrappedBlock; import com.aetherteam.aether.block.dungeon.TreasureDoorwayBlock; import com.aetherteam.aether.block.natural.AetherDoubleDropBlock; -import com.aetherteam.aether.block.natural.AetherDoubleDropsLeaves; import com.aetherteam.aether.block.natural.AetherDoubleDropsOreBlock; import com.aetherteam.aether.block.natural.AetherLogBlock; import com.aetherteam.aether.effect.AetherEffects; @@ -17,18 +16,13 @@ import net.builderdog.ancient_aether.entity.AncientAetherEntityTypes; import net.builderdog.ancient_aether.item.AncientAetherItems; import net.builderdog.ancient_aether.world.tree.AncientAetherTreeGrowers; -import net.minecraft.core.BlockPos; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; -import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; import net.neoforged.neoforge.registries.DeferredBlock; @@ -39,7 +33,7 @@ import static net.minecraft.world.level.block.Blocks.*; @SuppressWarnings("deprecation") -public class AncientAetherBlocks { +public class AncientAetherBlocks extends AncientAetherBlockBuilders { public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(AncientAether.MODID); public static final DeferredBlock GRAVITY_GRAVEL = register("gravity_gravel", () -> new AetherDoubleDropBlock(Block.Properties.of().mapColor(MapColor.TERRACOTTA_PURPLE).jumpFactor(1.5F).strength(0.25F).sound(SoundType.GRAVEL))); @@ -226,53 +220,6 @@ public class AncientAetherBlocks { public static final DeferredBlock POTTED_WYND_THISTLE = BLOCKS.register("potted_wynd_thistle", () -> new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, WYND_THISTLE, Block.Properties.ofFullCopy(Blocks.FLOWER_POT))); public static final DeferredBlock POTTED_ELEVETIA = BLOCKS.register("potted_elevetia", () -> new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, ELEVETIA, Block.Properties.ofFullCopy(Blocks.FLOWER_POT))); - private static Block leaves(MapColor mapColor, SoundType sound) { - return new AetherDoubleDropsLeaves( - BlockBehaviour.Properties.of() - .mapColor(mapColor) - .strength(0.2F) - .randomTicks() - .sound(sound) - .noOcclusion() - .isValidSpawn(AncientAetherBlocks::ocelotOrParrot) - .isSuffocating(AncientAetherBlocks::never) - .isViewBlocking(AncientAetherBlocks::never) - .ignitedByLava() - .pushReaction(PushReaction.DESTROY) - .isRedstoneConductor(AncientAetherBlocks::never) - ); - } - - private static WallBlock logWall() { - return new WallBlock( - BlockBehaviour.Properties.of() - .mapColor(MapColor.WOOD) - .instrument(NoteBlockInstrument.BASS) - .ignitedByLava().strength(2.0F) - .sound(SoundType.WOOD) - ); - } - - private static Block dungeonBlock(MapColor mapColor) { - return new Block( - BlockBehaviour.Properties.of() - .mapColor(mapColor) - .instrument(NoteBlockInstrument.BASEDRUM) - .strength(0.5F, 6.0F) - .requiresCorrectToolForDrops() - ); - } - - private static RotatedPillarBlock dungeonMosaic(MapColor mapColor) { - return new RotatedPillarBlock( - BlockBehaviour.Properties.of() - .mapColor(mapColor) - .instrument(NoteBlockInstrument.BASEDRUM) - .strength(0.5F, 6.0F) - .requiresCorrectToolForDrops() - ); - } - public static void registerPots() { FlowerPotBlock pot = (FlowerPotBlock) Blocks.FLOWER_POT; pot.addPlant(AncientAetherBlocks.CRYSTAL_SKYROOT_SAPLING.getId(), AncientAetherBlocks.POTTED_CRYSTAL_SKYROOT_SAPLING); @@ -335,17 +282,6 @@ public static void registerFlammability() { fireBlockAccessor.callSetFlammable(AncientAetherBlocks.SAKURA_FENCE.get(), 5, 20); } - private static boolean never(BlockState test1, BlockGetter test2, BlockPos test3) { - return false; - } - private static boolean always(BlockState test1, BlockGetter test2, BlockPos test3) { - return true; - } - - private static boolean ocelotOrParrot(BlockState state, BlockGetter getter, BlockPos pos, EntityType entity) { - return entity == EntityType.OCELOT || entity == EntityType.PARROT; - } - private static DeferredBlock register(String name, Supplier block) { DeferredBlock toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn);