Application of Behaviours and Tags as replacement for Materials
This commit is contained in:
parent
6713e03088
commit
4bf32937c1
60 changed files with 237 additions and 350 deletions
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.betterend.blocks;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.behaviours.interfaces.BehaviourWaterPlant;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
||||
import org.betterx.betterend.blocks.basis.EndUnderwaterPlantBlock;
|
||||
|
||||
|
@ -19,14 +21,17 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements AddMineableShears {
|
||||
public class BubbleCoralBlock extends EndUnderwaterPlantBlock implements BehaviourWaterPlant, AddMineableShears {
|
||||
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 14, 16);
|
||||
|
||||
public BubbleCoralBlock() {
|
||||
super(baseUnderwaterPlantSettings()
|
||||
.sound(SoundType.CORAL_BLOCK)
|
||||
.offsetType(BlockBehaviour.OffsetType.NONE)
|
||||
super(baseUnderwaterPlantSettings(
|
||||
BehaviourBuilders.createWaterPlant(),
|
||||
0
|
||||
)
|
||||
.sound(SoundType.CORAL_BLOCK)
|
||||
.offsetType(BlockBehaviour.OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ public class CavePumpkinVineBlock extends EndPlantWithAgeBlock {
|
|||
public void performBonemeal(ServerLevel world, RandomSource random, BlockPos pos, BlockState state) {
|
||||
int age = state.getValue(AGE);
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
if (down.getMaterial()
|
||||
.isReplaceable() || (down.is(EndBlocks.CAVE_PUMPKIN) && down.getValue(BlockProperties.SMALL))) {
|
||||
if (down.canBeReplaced() || (down.is(EndBlocks.CAVE_PUMPKIN) && down.getValue(BlockProperties.SMALL))) {
|
||||
if (age < 3) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(AGE, age + 1));
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.HalfTransparentBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
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;
|
||||
|
||||
|
@ -57,8 +56,8 @@ public class EmeraldIceBlock extends HalfTransparentBlock implements RenderLayer
|
|||
return;
|
||||
}
|
||||
|
||||
Material material = world.getBlockState(pos.below()).getMaterial();
|
||||
if (material.blocksMotion() || material.isLiquid()) {
|
||||
BlockState belowState = world.getBlockState(pos.below());
|
||||
if (belowState.blocksMotion() || belowState.liquid()) {
|
||||
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.betterend.blocks;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.blocks.BlockProperties;
|
||||
import org.betterx.bclib.blocks.BlockProperties.TripleShape;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
||||
|
@ -42,8 +43,11 @@ public class EndLilyBlock extends EndUnderwaterPlantBlock implements AddMineable
|
|||
private static final VoxelShape SHAPE_TOP = Block.box(2, 0, 2, 14, 6, 14);
|
||||
|
||||
public EndLilyBlock() {
|
||||
super(baseUnderwaterPlantSettings()
|
||||
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
|
||||
super(baseUnderwaterPlantSettings(
|
||||
BehaviourBuilders.createWaterPlant(),
|
||||
0
|
||||
)
|
||||
.lightLevel((state) -> state.getValue(SHAPE) == TripleShape.TOP ? 13 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.betterend.blocks;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.blocks.UnderwaterPlantBlock;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
|
@ -33,8 +34,11 @@ public class HydraluxBlock extends UnderwaterPlantBlock implements AddMineableSh
|
|||
public static final EnumProperty<HydraluxShape> SHAPE = EndBlockProperties.HYDRALUX_SHAPE;
|
||||
|
||||
public HydraluxBlock() {
|
||||
super(baseUnderwaterPlantSettings()
|
||||
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
|
||||
super(baseUnderwaterPlantSettings(
|
||||
BehaviourBuilders.createWaterPlant(),
|
||||
0
|
||||
)
|
||||
.lightLevel((state) -> state.getValue(SHAPE).hasGlow() ? 15 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.client.render.BCLRenderLayer;
|
|||
import org.betterx.bclib.interfaces.RenderLayerProvider;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableHoe;
|
||||
import org.betterx.betterend.registry.EndBlocks;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -73,14 +74,12 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements RenderLayerPr
|
|||
BlockPos blockPos2 = blockPos.relative(direction);
|
||||
BlockState blockState = world.getBlockState(blockPos2);
|
||||
FluidState fluidState = world.getFluidState(blockPos2);
|
||||
Material material = blockState.getMaterial();
|
||||
if (fluidState.is(FluidTags.WATER)) {
|
||||
if (blockState.getBlock() instanceof BucketPickup && !((BucketPickup) blockState.getBlock()).pickupBlock(
|
||||
world,
|
||||
blockPos2,
|
||||
blockState
|
||||
)
|
||||
.isEmpty()) {
|
||||
if (blockState.getBlock() instanceof BucketPickup
|
||||
&& !((BucketPickup) blockState.getBlock())
|
||||
.pickupBlock(world, blockPos2, blockState)
|
||||
.isEmpty()
|
||||
) {
|
||||
++i;
|
||||
if (j < 6) {
|
||||
queue.add(new Tuple<>(blockPos2, j + 1));
|
||||
|
@ -91,7 +90,7 @@ public class MengerSpongeBlock extends BaseBlockNotFull implements RenderLayerPr
|
|||
if (j < 6) {
|
||||
queue.add(new Tuple<>(blockPos2, j + 1));
|
||||
}
|
||||
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
|
||||
} else if (blockState.is(CommonBlockTags.WATER_PLANT)) {
|
||||
BlockEntity blockEntity = blockState.hasBlockEntity() ? world.getBlockEntity(blockPos2) : null;
|
||||
dropResources(blockState, world, blockPos2, blockEntity);
|
||||
world.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 3);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.betterend.blocks;
|
||||
|
||||
import org.betterx.bclib.behaviours.BehaviourBuilders;
|
||||
import org.betterx.bclib.interfaces.tools.AddMineableShears;
|
||||
import org.betterx.betterend.blocks.basis.EndUnderwaterPlantBlock;
|
||||
|
||||
|
@ -22,8 +23,11 @@ public class PondAnemoneBlock extends EndUnderwaterPlantBlock implements AddMine
|
|||
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
|
||||
|
||||
public PondAnemoneBlock() {
|
||||
super(baseUnderwaterPlantSettings(13).sound(SoundType.CORAL_BLOCK)
|
||||
.offsetType(OffsetType.NONE)
|
||||
super(baseUnderwaterPlantSettings(
|
||||
BehaviourBuilders.createWaterPlant(),
|
||||
13
|
||||
).sound(SoundType.CORAL_BLOCK)
|
||||
.offsetType(OffsetType.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class RespawnObeliskBlock extends BaseBlock.Stone implements CustomColorP
|
|||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!world.getBlockState(pos.above(i)).getMaterial().isReplaceable()) {
|
||||
if (!world.getBlockState(pos.above(i)).canBeReplaced()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@ package org.betterx.betterend.blocks.basis;
|
|||
import org.betterx.bclib.blocks.BaseBlockNotFull;
|
||||
import org.betterx.bclib.blocks.BlockProperties;
|
||||
import org.betterx.bclib.client.models.ModelsHelper;
|
||||
import org.betterx.bclib.interfaces.TagProvider;
|
||||
import org.betterx.betterend.blocks.EndBlockProperties;
|
||||
import org.betterx.betterend.blocks.EndBlockProperties.PedestalState;
|
||||
import org.betterx.betterend.blocks.InfusionPedestal;
|
||||
import org.betterx.betterend.blocks.entities.InfusionPedestalEntity;
|
||||
import org.betterx.betterend.blocks.entities.PedestalBlockEntity;
|
||||
import org.betterx.betterend.client.models.Patterns;
|
||||
import org.betterx.betterend.registry.EndTags;
|
||||
import org.betterx.betterend.rituals.InfusionRitual;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||
|
@ -19,9 +21,11 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
|
@ -55,7 +59,7 @@ import java.util.Optional;
|
|||
import java.util.function.ToIntFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
||||
public class PedestalBlock extends BaseBlockNotFull implements EntityBlock, TagProvider {
|
||||
public final static EnumProperty<PedestalState> STATE = EndBlockProperties.PEDESTAL_STATE;
|
||||
public static final BooleanProperty HAS_ITEM = EndBlockProperties.HAS_ITEM;
|
||||
public static final BooleanProperty HAS_LIGHT = BlockProperties.HAS_LIGHT;
|
||||
|
@ -462,6 +466,11 @@ public class PedestalBlock extends BaseBlockNotFull implements EntityBlock {
|
|||
SHAPE_COLUMN = Shapes.or(basin, SHAPE_PILLAR, columnTop);
|
||||
SHAPE_BOTTOM = Shapes.or(basin, SHAPE_PILLAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTags(List<TagKey<Block>> blockTags, List<TagKey<Item>> itemTags) {
|
||||
blockTags.add(EndTags.PEDESTALS);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Nullable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue