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 d9ea6680..c2e738ef 100644
--- a/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java
+++ b/src/main/java/org/betterx/bclib/api/v2/PostInitAPI.java
@@ -184,6 +184,28 @@ public class PostInitAPI {
}
}
+ if (block instanceof BehaviourWaterPlant) {
+ TagManager.BLOCKS.add(block, CommonBlockTags.WATER_PLANT);
+ }
+
+ if (block instanceof BehaviourPlant) {
+ TagManager.BLOCKS.add(block, CommonBlockTags.PLANT);
+ }
+
+ if (block instanceof BehaviourSeed) {
+ TagManager.BLOCKS.add(block, CommonBlockTags.SEEDS);
+ if (item != null && item != Items.AIR) {
+ TagManager.ITEMS.add(block, CommonItemTags.SEEDS);
+ }
+ }
+
+ if (block instanceof BehaviourSapling) {
+ TagManager.BLOCKS.add(block, CommonBlockTags.SAPLINGS);
+ if (item != null && item != Items.AIR) {
+ TagManager.ITEMS.add(block, CommonItemTags.SAPLINGS);
+ }
+ }
+
if (block instanceof BehaviourClimable c) {
TagManager.BLOCKS.add(block, BlockTags.CLIMBABLE);
}
@@ -209,7 +231,7 @@ public class PostInitAPI {
if (block instanceof BehaviourOre) {
TagManager.BLOCKS.add(block, CommonBlockTags.ORES);
}
-
+
if (block instanceof Fuel fl) {
FuelRegistry.INSTANCE.add(block, fl.getFuelTime());
}
diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourPlant.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourPlant.java
index 9aa5d6c1..d8c71e8d 100644
--- a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourPlant.java
+++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourPlant.java
@@ -2,5 +2,5 @@ package org.betterx.bclib.behaviours.interfaces;
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
-public interface BehaviourPlant extends AddMineableHoe {
+public interface BehaviourPlant extends AddMineableHoe, BehaviourCompostable {
}
diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java
new file mode 100644
index 00000000..1b4b7ea9
--- /dev/null
+++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourSapling.java
@@ -0,0 +1,6 @@
+package org.betterx.bclib.behaviours.interfaces;
+
+import org.betterx.bclib.interfaces.tools.AddMineableHoe;
+
+public interface BehaviourSapling extends AddMineableHoe, BehaviourCompostable {
+}
diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourVine.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourVine.java
index 8fd09d90..46c33d2b 100644
--- a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourVine.java
+++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourVine.java
@@ -8,5 +8,5 @@ import org.betterx.bclib.interfaces.tools.AddMineableShears;
*
* This will add the {@link AddMineableShears}, {@link AddMineableHoe} and {@link BehaviourCompostable} behaviours.
*/
-public interface BehaviourVine extends AddMineableShears, AddMineableHoe, BehaviourCompostable {
+public interface BehaviourVine extends AddMineableShears, AddMineableHoe, BehaviourCompostable, BehaviourClimable {
}
diff --git a/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java
new file mode 100644
index 00000000..c815b07b
--- /dev/null
+++ b/src/main/java/org/betterx/bclib/behaviours/interfaces/BehaviourWaterPlant.java
@@ -0,0 +1,6 @@
+package org.betterx.bclib.behaviours.interfaces;
+
+import org.betterx.bclib.interfaces.tools.AddMineableHoe;
+
+public interface BehaviourWaterPlant extends AddMineableHoe, BehaviourCompostable {
+}
diff --git a/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java
index 389e9fdc..8be7b12f 100644
--- a/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java
+++ b/src/main/java/org/betterx/bclib/blocks/BaseUnderwaterWallPlantBlock.java
@@ -1,5 +1,8 @@
package org.betterx.bclib.blocks;
+import org.betterx.bclib.behaviours.BehaviourBuilders;
+import org.betterx.bclib.behaviours.interfaces.BehaviourWaterPlant;
+
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
@@ -10,7 +13,7 @@ import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
-public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer {
+public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer, BehaviourWaterPlant {
public BaseUnderwaterWallPlantBlock() {
this(0);
@@ -18,7 +21,10 @@ public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock im
public BaseUnderwaterWallPlantBlock(int light) {
this(
- UnderwaterPlantBlock.baseUnderwaterPlantSettings(light)
+ UnderwaterPlantBlock.baseUnderwaterPlantSettings(
+ BehaviourBuilders.createWaterPlant(),
+ light
+ )
);
}
diff --git a/src/main/java/org/betterx/bclib/blocks/BaseVineBlock.java b/src/main/java/org/betterx/bclib/blocks/BaseVineBlock.java
index 4e5e99e1..10ae5473 100644
--- a/src/main/java/org/betterx/bclib/blocks/BaseVineBlock.java
+++ b/src/main/java/org/betterx/bclib/blocks/BaseVineBlock.java
@@ -1,6 +1,7 @@
package org.betterx.bclib.blocks;
import org.betterx.bclib.behaviours.BehaviourBuilders;
+import org.betterx.bclib.behaviours.interfaces.BehaviourVine;
import org.betterx.bclib.blocks.BlockProperties.TripleShape;
import org.betterx.bclib.client.render.BCLRenderLayer;
import org.betterx.bclib.interfaces.RenderLayerProvider;
@@ -40,7 +41,7 @@ import java.util.List;
import java.util.function.Function;
@SuppressWarnings("deprecation")
-public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
+public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, BehaviourVine {
public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE;
private static final VoxelShape VOXEL_SHAPE = box(2, 0, 2, 14, 16, 14);
diff --git a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java
index 3d2b1e4a..ea7a5646 100644
--- a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java
+++ b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantBlock.java
@@ -1,6 +1,7 @@
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;
@@ -26,43 +27,21 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
-import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
-import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
-
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 {
- public static Properties baseUnderwaterPlantSettings() {
- return baseUnderwaterPlantSettings(false, 0);
- }
+public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer, BehaviourWaterPlant {
- public static Properties baseUnderwaterPlantSettings(int light) {
- return baseUnderwaterPlantSettings(false, light);
- }
-
- public static Properties baseUnderwaterPlantSettings(boolean replaceable) {
- return baseUnderwaterPlantSettings(replaceable, 0);
- }
-
- public static Properties baseUnderwaterPlantSettings(boolean replaceable, int light) {
- return baseUnderwaterPlantSettings(
- replaceable ? Material.REPLACEABLE_WATER_PLANT : Material.WATER_PLANT,
- light
- );
- }
-
- public static Properties baseUnderwaterPlantSettings(Material mat, int light) {
- Properties props = FabricBlockSettings
- .of(mat)
+ public static Properties baseUnderwaterPlantSettings(BlockBehaviour.Properties props, int light) {
+ props
.sound(SoundType.WET_GRASS)
.noCollission()
.offsetType(BlockBehaviour.OffsetType.XZ);
@@ -79,7 +58,10 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
@Deprecated(forRemoval = true)
public UnderwaterPlantBlock(Function propMod) {
this(
- propMod.apply(baseUnderwaterPlantSettings())
+ propMod.apply(baseUnderwaterPlantSettings(
+ BehaviourBuilders.createWaterPlant(),
+ 0
+ ))
);
}
@@ -90,7 +72,10 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
@Deprecated(forRemoval = true)
public UnderwaterPlantBlock(int light, Function propMod) {
this(
- propMod.apply(baseUnderwaterPlantSettings(light))
+ propMod.apply(baseUnderwaterPlantSettings(
+ BehaviourBuilders.createWaterPlant(),
+ light
+ ))
);
}
diff --git a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java
index 56acdc8e..f6af2ac1 100644
--- a/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java
+++ b/src/main/java/org/betterx/bclib/blocks/UnderwaterPlantWithAgeBlock.java
@@ -1,5 +1,7 @@
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;
@@ -13,7 +15,10 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
public static final IntegerProperty AGE = BlockProperties.AGE;
public UnderwaterPlantWithAgeBlock() {
- super(baseUnderwaterPlantSettings().randomTicks());
+ super(baseUnderwaterPlantSettings(
+ BehaviourBuilders.createWaterPlant(),
+ 0
+ ).randomTicks());
}
@Override
diff --git a/src/main/java/org/betterx/bclib/util/BlocksHelper.java b/src/main/java/org/betterx/bclib/util/BlocksHelper.java
index d385855b..3b11d940 100644
--- a/src/main/java/org/betterx/bclib/util/BlocksHelper.java
+++ b/src/main/java/org/betterx/bclib/util/BlocksHelper.java
@@ -1,5 +1,7 @@
package org.betterx.bclib.util;
+import org.betterx.bclib.behaviours.interfaces.BehaviourPlant;
+import org.betterx.bclib.behaviours.interfaces.BehaviourSeed;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
@@ -8,13 +10,11 @@ import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.Blocks;
-import net.minecraft.world.level.block.Mirror;
-import net.minecraft.world.level.block.Rotation;
+import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.material.LavaFluid;
+import net.minecraft.world.level.material.PushReaction;
import com.google.common.collect.Maps;
@@ -348,4 +348,23 @@ public class BlocksHelper {
public static boolean isTerrainOrFluid(BlockState state) {
return state.is(CommonBlockTags.TERRAIN) || isFluid(state);
}
+
+ public static Boolean replaceableOrPlant(BlockState state) {
+ final Block block = state.getBlock();
+ if (state.is(CommonBlockTags.PLANT) || state.is(CommonBlockTags.WATER_PLANT) || block instanceof BehaviourPlant || block instanceof BehaviourSeed) {
+ return true;
+ }
+ if (state.getPistonPushReaction() == PushReaction.DESTROY && block.defaultDestroyTime() == 0) return true;
+
+ if (state.getSoundType() == SoundType.GRASS
+ || state.getSoundType() == SoundType.WET_GRASS
+ || state.getSoundType() == SoundType.CROP
+ || state.getSoundType() == SoundType.CAVE_VINES
+
+ ) {
+ return true;
+ }
+
+ return state.canBeReplaced();
+ }
}
diff --git a/src/main/java/org/betterx/worlds/together/tag/v3/CommonBlockTags.java b/src/main/java/org/betterx/worlds/together/tag/v3/CommonBlockTags.java
index 0e66ea99..5804b017 100644
--- a/src/main/java/org/betterx/worlds/together/tag/v3/CommonBlockTags.java
+++ b/src/main/java/org/betterx/worlds/together/tag/v3/CommonBlockTags.java
@@ -23,6 +23,7 @@ public class CommonBlockTags {
public static final TagKey ORES = TagManager.BLOCKS.makeCommonTag("ores");
public static final TagKey END_ORES = TagManager.BLOCKS.makeCommonTag("end_ores");
public static final TagKey SAPLINGS = TagManager.BLOCKS.makeCommonTag("saplings");
+ public static final TagKey SEEDS = TagManager.BLOCKS.makeCommonTag("seeds");
public static final TagKey SOUL_GROUND = TagManager.BLOCKS.makeCommonTag("soul_ground");
public static final TagKey SCULK_LIKE = TagManager.BLOCKS.makeCommonTag("sculk_like");
public static final TagKey WOODEN_BARREL = TagManager.BLOCKS.makeCommonTag("wooden_barrels");
@@ -38,8 +39,13 @@ public class CommonBlockTags {
public static final TagKey TERRAIN = TagManager.BLOCKS.makeCommonTag("terrain");
public static final TagKey NETHER_TERRAIN = TagManager.BLOCKS.makeCommonTag("nether_terrain");
public static final TagKey BUDDING_BLOCKS = TagManager.BLOCKS.makeCommonTag("budding_blocks");
+ public static final TagKey WATER_PLANT = TagManager.BLOCKS.makeCommonTag("water_plant");
+ ;
+ public static final TagKey PLANT = TagManager.BLOCKS.makeCommonTag("plant");
+ ;
static void prepareTags() {
+ TagManager.BLOCKS.addOtherTags(MINABLE_WITH_HAMMER, BlockTags.MINEABLE_WITH_PICKAXE);
TagManager.BLOCKS.add(SCULK_LIKE, Blocks.SCULK);
TagManager.BLOCKS.addOtherTags(DRAGON_IMMUNE, BlockTags.DRAGON_IMMUNE);
@@ -125,5 +131,69 @@ public class CommonBlockTags {
WOODEN_CHEST,
WORKBENCHES
);
+
+ TagManager.BLOCKS.add(WATER_PLANT, Blocks.KELP, Blocks.KELP_PLANT, Blocks.SEAGRASS, Blocks.TALL_SEAGRASS);
+ TagManager.BLOCKS.add(
+ SAPLINGS,
+ Blocks.OAK_SAPLING,
+ Blocks.SPRUCE_SAPLING,
+ Blocks.BIRCH_SAPLING,
+ Blocks.JUNGLE_SAPLING,
+ Blocks.ACACIA_SAPLING,
+ Blocks.DARK_OAK_SAPLING,
+ Blocks.MANGROVE_PROPAGULE
+ );
+ TagManager.BLOCKS.addOtherTags(PLANT, SAPLINGS);
+ TagManager.BLOCKS.add(
+ PLANT,
+ Blocks.MANGROVE_LEAVES,
+ Blocks.GRASS,
+ Blocks.FERN,
+ Blocks.DANDELION,
+ Blocks.TORCHFLOWER,
+ Blocks.POPPY,
+ Blocks.BLUE_ORCHID,
+ Blocks.ALLIUM,
+ Blocks.AZURE_BLUET,
+ Blocks.RED_TULIP,
+ Blocks.ORANGE_TULIP,
+ Blocks.WHITE_TULIP,
+ Blocks.PINK_TULIP,
+ Blocks.OXEYE_DAISY,
+ Blocks.CORNFLOWER,
+ Blocks.WITHER_ROSE,
+ Blocks.LILY_OF_THE_VALLEY,
+ Blocks.WHEAT,
+ Blocks.CACTUS,
+ Blocks.SUGAR_CANE,
+ Blocks.ATTACHED_PUMPKIN_STEM,
+ Blocks.ATTACHED_MELON_STEM,
+ Blocks.PUMPKIN_STEM,
+ Blocks.MELON_STEM,
+ Blocks.VINE,
+ Blocks.LILY_PAD,
+ Blocks.COCOA,
+ Blocks.CARROTS,
+ Blocks.POTATOES,
+ Blocks.SUNFLOWER,
+ Blocks.LILAC,
+ Blocks.ROSE_BUSH,
+ Blocks.PEONY,
+ Blocks.TALL_GRASS,
+ Blocks.LARGE_FERN,
+ Blocks.TORCHFLOWER_CROP,
+ Blocks.BEETROOTS,
+ Blocks.BAMBOO,
+ Blocks.SWEET_BERRY_BUSH,
+ Blocks.CAVE_VINES,
+ Blocks.CAVE_VINES_PLANT,
+ Blocks.SPORE_BLOSSOM,
+ Blocks.AZALEA,
+ Blocks.FLOWERING_AZALEA,
+ Blocks.PINK_PETALS,
+ Blocks.BIG_DRIPLEAF,
+ Blocks.BIG_DRIPLEAF_STEM,
+ Blocks.SMALL_DRIPLEAF
+ );
}
}
diff --git a/src/main/java/org/betterx/worlds/together/tag/v3/CommonItemTags.java b/src/main/java/org/betterx/worlds/together/tag/v3/CommonItemTags.java
index 143d00f2..52526447 100644
--- a/src/main/java/org/betterx/worlds/together/tag/v3/CommonItemTags.java
+++ b/src/main/java/org/betterx/worlds/together/tag/v3/CommonItemTags.java
@@ -14,6 +14,7 @@ public class CommonItemTags {
public static final TagKey- IRON_INGOTS = TagManager.ITEMS.makeCommonTag("iron_ingots");
public static final TagKey
- LEAVES = TagManager.ITEMS.makeCommonTag("leaves");
public static final TagKey
- SAPLINGS = TagManager.ITEMS.makeCommonTag("saplings");
+ public static final TagKey
- SEEDS = TagManager.ITEMS.makeCommonTag("seeds");
public static final TagKey
- SOUL_GROUND = TagManager.ITEMS.makeCommonTag("soul_ground");
public static final TagKey
- WOODEN_BARREL = TagManager.ITEMS.makeCommonTag("wooden_barrels");
public static final TagKey
- WOODEN_CHEST = TagManager.ITEMS.makeCommonTag("wooden_chests");
diff --git a/src/main/resources/bclib.mixins.common.json b/src/main/resources/bclib.mixins.common.json
index 156fa086..2338a104 100644
--- a/src/main/resources/bclib.mixins.common.json
+++ b/src/main/resources/bclib.mixins.common.json
@@ -31,6 +31,7 @@
"RegistryDataLoaderMixin",
"ServerLevelMixin",
"ShovelItemAccessor",
+ "SpongeBlockMixin",
"SurfaceRulesContextAccessor",
"TheEndBiomesMixin",
"WorldGenRegionMixin",