More Behaviours
This commit is contained in:
parent
f69c1c8588
commit
4c472c8307
13 changed files with 160 additions and 38 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package org.betterx.bclib.behaviours.interfaces;
|
||||
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
|
||||
|
||||
public interface BehaviourSapling extends AddMineableHoe, BehaviourCompostable {
|
||||
}
|
|
@ -8,5 +8,5 @@ import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
|||
* <p>
|
||||
* 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 {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package org.betterx.bclib.behaviours.interfaces;
|
||||
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
|
||||
|
||||
public interface BehaviourWaterPlant extends AddMineableHoe, BehaviourCompostable {
|
||||
}
|
|
@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||
private static final VoxelShape VOXEL_SHAPE = box(2, 0, 2, 14, 16, 14);
|
||||
|
||||
|
|
|
@ -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<Properties, Properties> 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<Properties, Properties> propMod) {
|
||||
this(
|
||||
propMod.apply(baseUnderwaterPlantSettings(light))
|
||||
propMod.apply(baseUnderwaterPlantSettings(
|
||||
BehaviourBuilders.createWaterPlant(),
|
||||
light
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue