diff --git a/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java b/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java index 93807532..6e075fdb 100644 --- a/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java +++ b/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java @@ -200,7 +200,7 @@ public class PostInitAPI { } } - if (block instanceof BehaviourWaterPlant) { + if (block instanceof BehaviourWaterPlantLike) { TagManager.BLOCKS.add(block, CommonBlockTags.WATER_PLANT); } @@ -209,14 +209,14 @@ public class PostInitAPI { } - if (block instanceof BehaviourSeed) { + if (block instanceof BehaviourSeedLike) { TagManager.BLOCKS.add(block, CommonBlockTags.SEEDS); if (item != null && item != Items.AIR) { TagManager.ITEMS.add(block, CommonItemTags.SEEDS); } } - if (block instanceof BehaviourSapling) { + if (block instanceof BehaviourSaplingLike) { TagManager.BLOCKS.add(block, CommonBlockTags.SAPLINGS, BlockTags.SAPLINGS); if (item != null && item != Items.AIR) { TagManager.ITEMS.add(block, CommonItemTags.SAPLINGS, ItemTags.SAPLINGS); diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java index 55a6bc72..202e48f0 100644 --- a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java @@ -2,5 +2,5 @@ package org.betterx.bclib.behaviours.interfaces; import org.betterx.bclib.interfaces.tools.AddMineableHoe; -public interface BehaviourSapling extends AddMineableHoe, BehaviourCompostable, BehaviourPlantLike { +public interface BehaviourSapling extends AddMineableHoe, BehaviourCompostable, BehaviourPlantLike, BehaviourSaplingLike { } diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSaplingLike.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSaplingLike.java new file mode 100644 index 00000000..00616443 --- /dev/null +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSaplingLike.java @@ -0,0 +1,4 @@ +package org.betterx.bclib.behaviours.interfaces; + +public interface BehaviourSaplingLike { +} diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeed.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeed.java index 43e005d8..d3e4be00 100644 --- a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeed.java +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeed.java @@ -2,5 +2,5 @@ package org.betterx.bclib.behaviours.interfaces; import org.betterx.bclib.interfaces.tools.AddMineableHoe; -public interface BehaviourSeed extends AddMineableHoe, BehaviourCompostable, BehaviourPlantLike { +public interface BehaviourSeed extends AddMineableHoe, BehaviourCompostable, BehaviourPlantLike, BehaviourSeedLike { } diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeedLike.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeedLike.java new file mode 100644 index 00000000..050ca656 --- /dev/null +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSeedLike.java @@ -0,0 +1,4 @@ +package org.betterx.bclib.behaviours.interfaces; + +public interface BehaviourSeedLike { +} diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java index 8a2f8a22..5edb07da 100644 --- a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java @@ -2,5 +2,5 @@ package org.betterx.bclib.behaviours.interfaces; import org.betterx.bclib.interfaces.tools.AddMineableHoe; -public interface BehaviourWaterPlant extends AddMineableHoe, BehaviourPlantLike, BehaviourCompostable { +public interface BehaviourWaterPlant extends AddMineableHoe, BehaviourWaterPlantLike, BehaviourCompostable { } diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantLike.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantLike.java new file mode 100644 index 00000000..988d95d9 --- /dev/null +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantLike.java @@ -0,0 +1,4 @@ +package org.betterx.bclib.behaviours.interfaces; + +public interface BehaviourWaterPlantLike extends BehaviourPlantLike { +} diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSapling.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSapling.java new file mode 100644 index 00000000..ee00edf9 --- /dev/null +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSapling.java @@ -0,0 +1,6 @@ +package org.betterx.bclib.behaviours.interfaces; + +import org.betterx.bclib.interfaces.tools.AddMineableHoe; + +public interface BehaviourWaterPlantSapling extends AddMineableHoe, BehaviourCompostable, BehaviourWaterPlantLike, BehaviourSaplingLike { +} diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSeed.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSeed.java new file mode 100644 index 00000000..aec0f51a --- /dev/null +++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlantSeed.java @@ -0,0 +1,6 @@ +package org.betterx.bclib.behaviours.interfaces; + +import org.betterx.bclib.interfaces.tools.AddMineableHoe; + +public interface BehaviourWaterPlantSeed extends AddMineableHoe, BehaviourCompostable, BehaviourWaterPlantLike, BehaviourSeedLike { +} diff --git a/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java index 6295afa7..5e613948 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java @@ -1,6 +1,7 @@ package org.betterx.bclib.blocks; import org.betterx.bclib.behaviours.BehaviourBuilders; +import org.betterx.bclib.interfaces.SurvivesOnBlocks; import org.betterx.bclib.util.BlocksHelper; import org.betterx.bclib.util.MHelper; @@ -16,6 +17,7 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; @@ -30,21 +32,25 @@ import com.google.common.collect.Lists; import java.util.Collections; import java.util.List; -public class BaseCropBlock extends BasePlantBlock { +public class BaseCropBlock extends BasePlantBlock implements SurvivesOnBlocks { public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3); private static final VoxelShape SHAPE = box(2, 0, 2, 14, 14, 14); - private final Block[] terrain; + private final List terrain; private final Item drop; public BaseCropBlock(Item drop, Block... terrain) { - this(BehaviourBuilders.applyBasePlantSettings().randomTicks(), drop, terrain); + this( + BehaviourBuilders.createPlant().randomTicks().sound(SoundType.CROP).offsetType(OffsetType.XZ), + drop, + terrain + ); } protected BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) { super(properties); this.drop = drop; - this.terrain = terrain; + this.terrain = List.of(terrain); this.registerDefaultState(defaultBlockState().setValue(AGE, 0)); } @@ -53,16 +59,6 @@ public class BaseCropBlock extends BasePlantBlock { stateManager.add(AGE); } - @Override - protected boolean isTerrain(BlockState state) { - for (Block block : terrain) { - if (state.is(block)) { - return true; - } - } - return false; - } - @Override public List getDrops(BlockState state, LootParams.Builder builder) { if (state.getValue(AGE) < 3) { @@ -113,4 +109,14 @@ public class BaseCropBlock extends BasePlantBlock { public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) { return SHAPE; } + + @Override + public List getSurvivableBlocks() { + return terrain; + } + + @Override + public boolean isTerrain(BlockState state) { + return SurvivesOnBlocks.super.isTerrain(state); + } } diff --git a/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java index acff0a57..6396b54c 100644 --- a/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java @@ -1,12 +1,10 @@ package org.betterx.bclib.blocks; -import org.betterx.bclib.behaviours.BehaviourBuilders; import org.betterx.bclib.client.models.BasePatterns; import org.betterx.bclib.client.models.ModelsHelper; import org.betterx.bclib.client.models.PatternsHelper; import org.betterx.bclib.client.render.BCLRenderLayer; import org.betterx.bclib.interfaces.RenderLayerProvider; -import org.betterx.bclib.interfaces.SettingsExtender; import org.betterx.bclib.items.tool.BaseShearsItem; import net.minecraft.client.renderer.block.model.BlockModel; @@ -25,8 +23,6 @@ import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BonemealableBlock; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; @@ -46,48 +42,6 @@ import org.jetbrains.annotations.Nullable; public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock { private static final VoxelShape SHAPE = box(4, 0, 4, 12, 14, 12); - public BasePlantBlock() { - this(BehaviourBuilders.applyBasePlantSettings()); - } - - public BasePlantBlock(int light) { - this(BehaviourBuilders.applyBasePlantSettings(light)); - } - - @Deprecated(forRemoval = true) - public BasePlantBlock(int light, SettingsExtender propMod) { - this(false, light, propMod); - } - - public BasePlantBlock(boolean replaceable) { - this(BehaviourBuilders.applyBasePlantSettings(replaceable)); - } - - @Deprecated(forRemoval = true) - public BasePlantBlock(boolean replaceable, SettingsExtender propMod) { - this(replaceable, 0, propMod); - } - - - public BasePlantBlock(boolean replaceable, int light) { - this(BehaviourBuilders.applyBasePlantSettings(replaceable, light)); - } - - @Deprecated(forRemoval = true) - public BasePlantBlock(boolean replaceable, int light, SettingsExtender propMod) { - this( - propMod.amend( - (replaceable - ? BehaviourBuilders.createReplaceablePlant() - : BehaviourBuilders.createPlant() - ) - .lightLevel((state) -> light) - .sound(SoundType.GRASS) - .offsetType(BlockBehaviour.OffsetType.XZ) - ) - ); - } - protected BasePlantBlock(Properties settings) { super(settings); } diff --git a/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java b/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java index 36097767..57374a82 100644 --- a/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java @@ -1,7 +1,5 @@ package org.betterx.bclib.blocks; -import org.betterx.bclib.behaviours.BehaviourBuilders; - import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; @@ -12,22 +10,11 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; -import java.util.function.Function; - public abstract class BasePlantWithAgeBlock extends BasePlantBlock { public static final IntegerProperty AGE = BlockProperties.AGE; - public BasePlantWithAgeBlock() { - this(p -> p); - } - - @Deprecated(forRemoval = true) - public BasePlantWithAgeBlock(Function propMod) { - this(propMod.apply(BehaviourBuilders.applyBasePlantSettings().randomTicks())); - } - protected BasePlantWithAgeBlock(Properties settings) { - super(settings); + super(settings.randomTicks()); } @Override diff --git a/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java index 8be7b12f..5155c804 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java @@ -1,6 +1,5 @@ package org.betterx.bclib.blocks; -import org.betterx.bclib.behaviours.BehaviourBuilders; import org.betterx.bclib.behaviours.interfaces.BehaviourWaterPlant; import net.minecraft.core.BlockPos; @@ -14,20 +13,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer, BehaviourWaterPlant { - - public BaseUnderwaterWallPlantBlock() { - this(0); - } - - public BaseUnderwaterWallPlantBlock(int light) { - this( - UnderwaterPlantBlock.baseUnderwaterPlantSettings( - BehaviourBuilders.createWaterPlant(), - light - ) - ); - } - public BaseUnderwaterWallPlantBlock(Properties settings) { super(settings); } diff --git a/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java index 0822c838..4c9c06d2 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java @@ -1,6 +1,5 @@ package org.betterx.bclib.blocks; -import org.betterx.bclib.behaviours.BehaviourBuilders; import org.betterx.bclib.util.BlocksHelper; import net.minecraft.core.BlockPos; @@ -30,14 +29,6 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock { )); public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; - public BaseWallPlantBlock() { - this(BehaviourBuilders.applyBasePlantSettings()); - } - - public BaseWallPlantBlock(int light) { - this(BehaviourBuilders.applyBasePlantSettings(light)); - } - protected BaseWallPlantBlock(Properties settings) { super(settings.offsetType(OffsetType.NONE)); } diff --git a/src/main/java/org/betterx/bclib/blocks/FeatureSaplingBlock.java b/src/main/java/org/betterx/bclib/blocks/FeatureSaplingBlock.java index de8effa9..17972946 100644 --- a/src/main/java/org/betterx/bclib/blocks/FeatureSaplingBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/FeatureSaplingBlock.java @@ -50,16 +50,13 @@ public class FeatureSaplingBlock, FC extends FeatureConfig private final FeatureSupplier feature; public FeatureSaplingBlock(FeatureSupplier featureSupplier) { - this( - BehaviourBuilders.createTickingPlant() - .sound(SoundType.GRASS), - featureSupplier - ); + this(0, featureSupplier); } public FeatureSaplingBlock(int light, FeatureSupplier featureSupplier) { this( - BehaviourBuilders.createTickingPlant() + BehaviourBuilders.createPlant().randomTicks() + .noCollission() .lightLevel(state -> light) .sound(SoundType.GRASS), featureSupplier diff --git a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java index 1aba7e39..7fbabb9b 100644 --- a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java @@ -1,7 +1,5 @@ package org.betterx.bclib.blocks; -import org.betterx.bclib.behaviours.BehaviourBuilders; -import org.betterx.bclib.behaviours.interfaces.BehaviourWaterPlant; import org.betterx.bclib.client.render.BCLRenderLayer; import org.betterx.bclib.interfaces.RenderLayerProvider; import org.betterx.bclib.items.tool.BaseShearsItem; @@ -21,8 +19,6 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.LiquidBlockContainer; -import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; @@ -36,49 +32,10 @@ import net.minecraft.world.phys.shapes.VoxelShape; import com.google.common.collect.Lists; import java.util.List; -import java.util.function.Function; - -public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer, BehaviourWaterPlant { - - public static Properties baseUnderwaterPlantSettings(BlockBehaviour.Properties props, int light) { - props - .sound(SoundType.WET_GRASS) - .noCollission() - .offsetType(BlockBehaviour.OffsetType.XZ); - if (light > 0) props.lightLevel(s -> light); - return props; - } +public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer { private static final VoxelShape SHAPE = box(4, 0, 4, 12, 14, 12); - public UnderwaterPlantBlock() { - this(p -> p); - } - - @Deprecated(forRemoval = true) - public UnderwaterPlantBlock(Function propMod) { - this( - propMod.apply(baseUnderwaterPlantSettings( - BehaviourBuilders.createWaterPlant(), - 0 - )) - ); - } - - public UnderwaterPlantBlock(int light) { - this(light, p -> p); - } - - @Deprecated(forRemoval = true) - public UnderwaterPlantBlock(int light, Function propMod) { - this( - propMod.apply(baseUnderwaterPlantSettings( - BehaviourBuilders.createWaterPlant(), - light - )) - ); - } - public UnderwaterPlantBlock(Properties settings) { super(settings); } diff --git a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java index f6af2ac1..319a36b1 100644 --- a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java @@ -7,6 +7,8 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; @@ -14,11 +16,16 @@ import net.minecraft.world.level.block.state.properties.IntegerProperty; public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock { public static final IntegerProperty AGE = BlockProperties.AGE; + public UnderwaterPlantWithAgeBlock(BlockBehaviour.Properties properties) { + super(properties.randomTicks()); + } + public UnderwaterPlantWithAgeBlock() { - super(baseUnderwaterPlantSettings( - BehaviourBuilders.createWaterPlant(), - 0 - ).randomTicks()); + this(BehaviourBuilders + .createWaterPlant() + .sound(SoundType.WET_GRASS) + .offsetType(BlockBehaviour.OffsetType.XZ) + ); } @Override diff --git a/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java b/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java index b455935a..2ff7115b 100644 --- a/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java @@ -17,7 +17,11 @@ import java.util.List; public abstract class WallMushroomBlock extends BaseWallPlantBlock { public WallMushroomBlock(int light) { - super(BehaviourBuilders.applyBasePlantSettings(light).destroyTime(0.2F).sound(SoundType.WOOD)); + super(BehaviourBuilders.createPlant() + .destroyTime(0.2F) + .lightLevel(state -> light) + .sound(SoundType.WOOD) + ); } protected WallMushroomBlock(BlockBehaviour.Properties properties) {