diff --git a/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java index 8ee1fdc2..eb6f1a3b 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseCropBlock.java @@ -1,5 +1,6 @@ package org.betterx.bclib.blocks; +import org.betterx.bclib.complexmaterials.BehaviourBuilders; import org.betterx.bclib.util.BlocksHelper; import org.betterx.bclib.util.MHelper; @@ -37,7 +38,7 @@ public class BaseCropBlock extends BasePlantBlock { private final Item drop; public BaseCropBlock(Item drop, Block... terrain) { - this(basePlantSettings().randomTicks(), drop, terrain); + this(BehaviourBuilders.applyBasePlantSettings().randomTicks(), drop, terrain); } protected BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) { diff --git a/src/main/java/org/betterx/bclib/blocks/BaseLeavesBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseLeavesBlock.java index e488ace6..eabab5d4 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseLeavesBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseLeavesBlock.java @@ -21,7 +21,6 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; @@ -38,17 +37,12 @@ import java.util.function.Consumer; public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, RenderLayerProvider, TagProvider, AddMineableShears, AddMineableHoe { protected final Block sapling; - private static BlockBehaviour.Properties makeLeaves(MapColor color) { - return BehaviourBuilders.createLeaves(color) - .copy(Blocks.OAK_LEAVES); - } - public BaseLeavesBlock( Block sapling, MapColor color, Consumer customizeProperties ) { - super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color))); + super(BaseBlock.acceptAndReturn(customizeProperties, BehaviourBuilders.createLeaves(color, true))); this.sapling = sapling; } @@ -58,17 +52,20 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider, int light, Consumer customizeProperties ) { - super(BaseBlock.acceptAndReturn(customizeProperties, makeLeaves(color).lightLevel(state -> light))); + super(BaseBlock.acceptAndReturn( + customizeProperties, + BehaviourBuilders.createLeaves(color, true).lightLevel(state -> light) + )); this.sapling = sapling; } public BaseLeavesBlock(Block sapling, MapColor color) { - super(makeLeaves(color)); + super(BehaviourBuilders.createLeaves(color, true)); this.sapling = sapling; } public BaseLeavesBlock(Block sapling, MapColor color, int light) { - super(makeLeaves(color).lightLevel(state -> light)); + super(BehaviourBuilders.createLeaves(color, true).lightLevel(state -> light)); this.sapling = sapling; } diff --git a/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java index f4014ef9..9b1d6aae 100644 --- a/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BasePlantBlock.java @@ -44,41 +44,14 @@ import java.util.Optional; import org.jetbrains.annotations.Nullable; public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock { - public static Properties basePlantSettings() { - return basePlantSettings(false, 0); - } - - public static Properties basePlantSettings(int light) { - return basePlantSettings(false, light); - } - - public static Properties basePlantSettings(boolean replaceable) { - return basePlantSettings(replaceable, 0); - } - - public static Properties basePlantSettings(boolean replaceable, int light) { - return basePlantSettings(replaceable - ? BehaviourBuilders.createReplaceablePlant() - : BehaviourBuilders.createPlant(), light); - } - - public static Properties basePlantSettings(BlockBehaviour.Properties props, int light) { - props - .sound(SoundType.GRASS) - .noCollission() - .offsetType(BlockBehaviour.OffsetType.XZ); - if (light > 0) props.lightLevel(s -> light); - return props; - } - private static final VoxelShape SHAPE = box(4, 0, 4, 12, 14, 12); public BasePlantBlock() { - this(basePlantSettings()); + this(BehaviourBuilders.applyBasePlantSettings()); } public BasePlantBlock(int light) { - this(basePlantSettings(light)); + this(BehaviourBuilders.applyBasePlantSettings(light)); } @Deprecated(forRemoval = true) @@ -87,7 +60,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL } public BasePlantBlock(boolean replaceable) { - this(basePlantSettings(replaceable)); + this(BehaviourBuilders.applyBasePlantSettings(replaceable)); } @Deprecated(forRemoval = true) @@ -97,7 +70,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL public BasePlantBlock(boolean replaceable, int light) { - this(basePlantSettings(replaceable, light)); + this(BehaviourBuilders.applyBasePlantSettings(replaceable, light)); } @Deprecated(forRemoval = true) diff --git a/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java b/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java index d1b56fa2..14055eed 100644 --- a/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BasePlantWithAgeBlock.java @@ -1,5 +1,7 @@ package org.betterx.bclib.blocks; +import org.betterx.bclib.complexmaterials.BehaviourBuilders; + import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; @@ -21,7 +23,7 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock { @Deprecated(forRemoval = true) public BasePlantWithAgeBlock(Function propMod) { - this(propMod.apply(basePlantSettings().randomTicks())); + this(propMod.apply(BehaviourBuilders.applyBasePlantSettings().randomTicks())); } protected BasePlantWithAgeBlock(Properties settings) { diff --git a/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java index d42730f9..2dcc6a9c 100644 --- a/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/BaseWallPlantBlock.java @@ -1,5 +1,6 @@ package org.betterx.bclib.blocks; +import org.betterx.bclib.complexmaterials.BehaviourBuilders; import org.betterx.bclib.util.BlocksHelper; import net.minecraft.core.BlockPos; @@ -30,11 +31,11 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock { public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; public BaseWallPlantBlock() { - this(basePlantSettings()); + this(BehaviourBuilders.applyBasePlantSettings()); } public BaseWallPlantBlock(int light) { - this(basePlantSettings(light)); + this(BehaviourBuilders.applyBasePlantSettings(light)); } protected BaseWallPlantBlock(Properties settings) { diff --git a/src/main/java/org/betterx/bclib/blocks/SimpleLeavesBlock.java b/src/main/java/org/betterx/bclib/blocks/SimpleLeavesBlock.java index 067298a6..40e04ea3 100644 --- a/src/main/java/org/betterx/bclib/blocks/SimpleLeavesBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/SimpleLeavesBlock.java @@ -22,7 +22,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr public SimpleLeavesBlock(MapColor color) { this( BehaviourBuilders - .createLeaves(color) + .createLeaves(color, true) .sound(SoundType.GRASS) ); } @@ -30,7 +30,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerPr public SimpleLeavesBlock(MapColor color, int light) { this( BehaviourBuilders - .createLeaves(color) + .createLeaves(color, true) .lightLevel(ignored -> light) .sound(SoundType.GRASS) ); diff --git a/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java b/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java index 67e56def..bf71476c 100644 --- a/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/WallMushroomBlock.java @@ -1,5 +1,7 @@ package org.betterx.bclib.blocks; +import org.betterx.bclib.complexmaterials.BehaviourBuilders; + import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; @@ -15,7 +17,7 @@ import java.util.List; public abstract class WallMushroomBlock extends BaseWallPlantBlock { public WallMushroomBlock(int light) { - super(basePlantSettings(light).destroyTime(0.2F).sound(SoundType.WOOD)); + super(BehaviourBuilders.applyBasePlantSettings(light).destroyTime(0.2F).sound(SoundType.WOOD)); } protected WallMushroomBlock(BlockBehaviour.Properties properties) { diff --git a/src/main/java/org/betterx/bclib/blocks/signs/BaseHangingSignBlock.java b/src/main/java/org/betterx/bclib/blocks/signs/BaseHangingSignBlock.java index 6ade17fa..16d46c40 100644 --- a/src/main/java/org/betterx/bclib/blocks/signs/BaseHangingSignBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/signs/BaseHangingSignBlock.java @@ -20,16 +20,16 @@ public class BaseHangingSignBlock extends CeilingHangingSignBlock implements Blo public final BaseWallHangingSignBlock wallSign; public BaseHangingSignBlock(WoodType type) { - this(type, MapColor.WOOD); + this(type, MapColor.WOOD, true); } public BaseHangingSignBlock(BCLWoodTypeWrapper type) { - this(type.type, type.color); + this(type.type, type.color, type.flammable); } - public BaseHangingSignBlock(WoodType type, MapColor color) { - super(BehaviourBuilders.createSign(color), type); - this.wallSign = new BaseWallHangingSignBlock(BehaviourBuilders.createWallSign(color, this), type); + public BaseHangingSignBlock(WoodType type, MapColor color, boolean flammable) { + super(BehaviourBuilders.createSign(color, flammable), type); + this.wallSign = new BaseWallHangingSignBlock(BehaviourBuilders.createWallSign(color, this, flammable), type); } diff --git a/src/main/java/org/betterx/bclib/blocks/signs/BaseSignBlock.java b/src/main/java/org/betterx/bclib/blocks/signs/BaseSignBlock.java index 263088a9..f15ea46a 100644 --- a/src/main/java/org/betterx/bclib/blocks/signs/BaseSignBlock.java +++ b/src/main/java/org/betterx/bclib/blocks/signs/BaseSignBlock.java @@ -20,16 +20,16 @@ public class BaseSignBlock extends StandingSignBlock implements BlockModelProvid public final BaseWallSignBlock wallSign; public BaseSignBlock(WoodType type) { - this(type, MapColor.WOOD); + this(type, MapColor.WOOD, true); } public BaseSignBlock(BCLWoodTypeWrapper type) { - this(type.type, type.color); + this(type.type, type.color, type.flammable); } - public BaseSignBlock(WoodType type, MapColor color) { - super(BehaviourBuilders.createSign(color), type); - this.wallSign = new BaseWallSignBlock(BehaviourBuilders.createWallSign(color, this), type); + public BaseSignBlock(WoodType type, MapColor color, boolean flammable) { + super(BehaviourBuilders.createSign(color, flammable), type); + this.wallSign = new BaseWallSignBlock(BehaviourBuilders.createWallSign(color, this, flammable), type); } diff --git a/src/main/java/org/betterx/bclib/complexmaterials/BCLWoodTypeWrapper.java b/src/main/java/org/betterx/bclib/complexmaterials/BCLWoodTypeWrapper.java index bd5b85e9..0a12669d 100644 --- a/src/main/java/org/betterx/bclib/complexmaterials/BCLWoodTypeWrapper.java +++ b/src/main/java/org/betterx/bclib/complexmaterials/BCLWoodTypeWrapper.java @@ -14,11 +14,13 @@ public final class BCLWoodTypeWrapper { public final ResourceLocation id; public final WoodType type; public final MapColor color; + public final boolean flammable; - protected BCLWoodTypeWrapper(ResourceLocation id, WoodType type, MapColor color) { + protected BCLWoodTypeWrapper(ResourceLocation id, WoodType type, MapColor color, boolean flammable) { this.id = id; this.type = type; this.color = color; + this.flammable = flammable; } public static Builder create(String modID, String string) { @@ -73,10 +75,12 @@ public final class BCLWoodTypeWrapper { private final ResourceLocation id; private BlockSetType setType; private MapColor color; + private boolean flammable; public Builder(ResourceLocation id) { this.id = id; this.color = MapColor.WOOD; + this.flammable = true; } public Builder setBlockSetType(BlockSetType setType) { @@ -89,11 +93,16 @@ public final class BCLWoodTypeWrapper { return this; } + public Builder setFlammable(boolean flammable) { + this.flammable = flammable; + return this; + } + public BCLWoodTypeWrapper build() { if (setType == null) setType = BlockSetTypeRegistry.registerWood(id); final WoodType type = WoodTypeRegistry.register(id, setType); - return new BCLWoodTypeWrapper(id, type, color); + return new BCLWoodTypeWrapper(id, type, color, flammable); } } } diff --git a/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java b/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java index b1ab7ea5..eeaabbc7 100644 --- a/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java +++ b/src/main/java/org/betterx/bclib/complexmaterials/BehaviourBuilders.java @@ -2,6 +2,7 @@ package org.betterx.bclib.complexmaterials; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.material.MapColor; @@ -9,19 +10,38 @@ import net.minecraft.world.level.material.PushReaction; public class BehaviourBuilders { public static BlockBehaviour.Properties createPlant() { + return createPlant(MapColor.PLANT); + } + + public static BlockBehaviour.Properties createPlant(MapColor color) { return BlockBehaviour.Properties.of() - .mapColor(MapColor.PLANT) + .mapColor(color) .noCollission() .instabreak() .pushReaction(PushReaction.DESTROY); } + public static BlockBehaviour.Properties createGrass(MapColor color, boolean flammable) { + final BlockBehaviour.Properties p = createPlant(color); + if (flammable) + p.ignitedByLava(); + return p; + } + public static BlockBehaviour.Properties createTickingPlant() { - return createPlant().randomTicks(); + return createTickingPlant(MapColor.PLANT); + } + + public static BlockBehaviour.Properties createTickingPlant(MapColor color) { + return createPlant(color).randomTicks(); } public static BlockBehaviour.Properties createReplaceablePlant() { - return createPlant().replaceable(); + return createReplaceablePlant(MapColor.PLANT); + } + + public static BlockBehaviour.Properties createReplaceablePlant(MapColor color) { + return createPlant(color).replaceable(); } public static BlockBehaviour.Properties createWaterPlant() { @@ -37,21 +57,26 @@ public class BehaviourBuilders { } public static BlockBehaviour.Properties createLeaves() { - return createLeaves(MapColor.PLANT); + return createLeaves(MapColor.PLANT, true); } - public static BlockBehaviour.Properties createLeaves(MapColor color) { - return BlockBehaviour.Properties.of() - .mapColor(color) - .strength(0.2f) - .randomTicks() - .noOcclusion() - .isValidSpawn(Blocks::ocelotOrParrot) - .isSuffocating(Blocks::never) - .isViewBlocking(Blocks::never) - .ignitedByLava() - .pushReaction(PushReaction.DESTROY) - .isRedstoneConductor(Blocks::never); + public static BlockBehaviour.Properties createLeaves(MapColor color, boolean flammable) { + final BlockBehaviour.Properties p = BlockBehaviour.Properties + .of() + .mapColor(color) + .strength(0.2f) + .randomTicks() + .noOcclusion() + .isValidSpawn(Blocks::ocelotOrParrot) + .isSuffocating(Blocks::never) + .isViewBlocking(Blocks::never) + .pushReaction(PushReaction.DESTROY) + .isRedstoneConductor(Blocks::never) + .sound(SoundType.GRASS); + if (flammable) { + p.ignitedByLava(); + } + return p; } public static BlockBehaviour.Properties createStone() { @@ -61,21 +86,71 @@ public class BehaviourBuilders { public static BlockBehaviour.Properties createStone(MapColor color) { return BlockBehaviour.Properties.of() .mapColor(color) + .strength(1.5F, 6.0F) .instrument(NoteBlockInstrument.BASEDRUM); } - public static BlockBehaviour.Properties createSign(MapColor color) { - return BlockBehaviour.Properties.of() - .mapColor(color) - .forceSolidOn() - .instrument(NoteBlockInstrument.BASS) - .noCollission() - .strength(1.0f) - .ignitedByLava(); + public static BlockBehaviour.Properties createWood() { + return createWood(MapColor.WOOD, true); } - public static BlockBehaviour.Properties createWallSign(MapColor color, Block dropBlock) { - return createSign(color).dropsLike(dropBlock); + public static BlockBehaviour.Properties createWood(MapColor color, boolean flammable) { + final BlockBehaviour.Properties p = BlockBehaviour.Properties + .of() + .mapColor(color) + .instrument(NoteBlockInstrument.BASS) + .strength(2.0F) + .sound(SoundType.WOOD); + + if (flammable) { + p.ignitedByLava(); + } + return p; + } + + public static BlockBehaviour.Properties createSign(MapColor color, boolean flammable) { + final BlockBehaviour.Properties p = BlockBehaviour.Properties + .of() + .mapColor(color) + .forceSolidOn() + .instrument(NoteBlockInstrument.BASS) + .noCollission() + .strength(1.0f); + if (flammable) { + p.ignitedByLava(); + } + return p; + } + + public static BlockBehaviour.Properties createWallSign(MapColor color, Block dropBlock, boolean flammable) { + return createSign(color, flammable).dropsLike(dropBlock); + + } + + public static BlockBehaviour.Properties applyBasePlantSettings() { + return applyBasePlantSettings(false, 0); + } + + public static BlockBehaviour.Properties applyBasePlantSettings(int light) { + return applyBasePlantSettings(false, light); + } + + public static BlockBehaviour.Properties applyBasePlantSettings(boolean replaceable) { + return applyBasePlantSettings(replaceable, 0); + } + + public static BlockBehaviour.Properties applyBasePlantSettings(boolean replaceable, int light) { + return applyBasePlantSettings(replaceable + ? createReplaceablePlant() + : createPlant(), light); + } + + public static BlockBehaviour.Properties applyBasePlantSettings(BlockBehaviour.Properties props, int light) { + props + .sound(SoundType.GRASS) + .offsetType(BlockBehaviour.OffsetType.XZ); + if (light > 0) props.lightLevel(s -> light); + return props; } }