cactus fixes & destruction
This commit is contained in:
parent
56d10bfcda
commit
bd73d1c576
7 changed files with 118 additions and 38 deletions
|
@ -11,8 +11,11 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.LevelAccessor;
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
import net.minecraft.world.level.LevelReader;
|
import net.minecraft.world.level.LevelReader;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
@ -28,6 +31,7 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraft.world.level.material.Fluids;
|
import net.minecraft.world.level.material.Fluids;
|
||||||
|
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.betterend.blocks.BlockProperties.CactusBottom;
|
import ru.betterend.blocks.BlockProperties.CactusBottom;
|
||||||
|
@ -38,6 +42,7 @@ import ru.betterend.interfaces.IRenderTypeable;
|
||||||
import ru.betterend.registry.EndBlocks;
|
import ru.betterend.registry.EndBlocks;
|
||||||
import ru.betterend.registry.EndTags;
|
import ru.betterend.registry.EndTags;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
|
import ru.betterend.util.MHelper;
|
||||||
|
|
||||||
public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, IRenderTypeable {
|
public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, IRenderTypeable {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
|
@ -99,13 +104,14 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
|
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) {
|
||||||
|
if (!canSurvive(state, world, pos)) {
|
||||||
|
world.getBlockTicks().scheduleTick(pos, this, MHelper.randRange(1, 4, world.getRandom()));
|
||||||
|
return state;
|
||||||
|
}
|
||||||
if ((Boolean) state.getValue(WATERLOGGED)) {
|
if ((Boolean) state.getValue(WATERLOGGED)) {
|
||||||
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
||||||
}
|
}
|
||||||
Direction dir = state.getValue(FACING);
|
Direction dir = state.getValue(FACING);
|
||||||
if (!canSurvive(state, world, pos)) {
|
|
||||||
return Blocks.AIR.defaultBlockState();
|
|
||||||
}
|
|
||||||
BlockState downState = world.getBlockState(pos.relative(dir.getOpposite()));
|
BlockState downState = world.getBlockState(pos.relative(dir.getOpposite()));
|
||||||
if (downState.is(Blocks.END_STONE) || downState.is(EndBlocks.ENDSTONE_DUST)) {
|
if (downState.is(Blocks.END_STONE) || downState.is(EndBlocks.ENDSTONE_DUST)) {
|
||||||
state = state.setValue(CACTUS_BOTTOM, CactusBottom.SAND);
|
state = state.setValue(CACTUS_BOTTOM, CactusBottom.SAND);
|
||||||
|
@ -119,6 +125,13 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) {
|
||||||
|
if (!blockState.canSurvive(serverLevel, blockPos)) {
|
||||||
|
serverLevel.destroyBlock(blockPos, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ERenderLayer getRenderLayer() {
|
public ERenderLayer getRenderLayer() {
|
||||||
return ERenderLayer.CUTOUT;
|
return ERenderLayer.CUTOUT;
|
||||||
|
@ -154,11 +167,10 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||||
Direction dir = state.getValue(FACING);
|
|
||||||
if (!this.canSurvive(state, world, pos)) {
|
if (!this.canSurvive(state, world, pos)) {
|
||||||
this.destroy(world, pos, state);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Direction dir = state.getValue(FACING);
|
||||||
if (!world.isEmptyBlock(pos.relative(dir))) {
|
if (!world.isEmptyBlock(pos.relative(dir))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -187,6 +199,16 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg
|
||||||
BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement);
|
BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement);
|
||||||
mutateStem(placement, world, pos, MAX_LENGTH);
|
mutateStem(placement, world, pos, MAX_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) {
|
||||||
|
entity.hurt(DamageSource.CACTUS, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) {
|
private int getLength(BlockState state, ServerLevel world, BlockPos pos, int max) {
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
"to": [ 14, 14, 14 ],
|
"to": [ 14, 14, 14 ],
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
"to": [ 14, 14, 14 ],
|
"to": [ 14, 14, 14 ],
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
"to": [ 14, 14, 14 ],
|
"to": [ 14, 14, 14 ],
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
"up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" },
|
||||||
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
"west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" },
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
||||||
|
"textures": {
|
||||||
|
"particle": "betterend:block/neon_cactus_medium_side",
|
||||||
|
"overlay": "betterend:block/neon_cactus_medium_side_moss_overlay",
|
||||||
|
"side": "betterend:block/neon_cactus_medium_side_moss",
|
||||||
|
"top": "betterend:block/neon_cactus_medium_top"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"__comment": "Box1",
|
||||||
|
"from": [ 3, -3, 3 ],
|
||||||
|
"to": [ 13, 13, 13 ],
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"down": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
|
||||||
|
"up": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
|
||||||
|
"north": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
||||||
|
"south": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
||||||
|
"west": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
||||||
|
"east": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "Box1",
|
||||||
|
"from": [ 3, -3, 3 ],
|
||||||
|
"to": [ 13, 13, 13 ],
|
||||||
|
"faces": {
|
||||||
|
"north": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
||||||
|
"south": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
||||||
|
"west": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
||||||
|
"east": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "PlaneX2",
|
||||||
|
"from": [ 0, -3, 0 ],
|
||||||
|
"to": [ 0.001, 13, 22.5 ],
|
||||||
|
"rotation": { "origin": [ 0, -3, 0 ], "axis": "y", "angle": 45 },
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
||||||
|
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__comment": "PlaneX2",
|
||||||
|
"from": [ 16, -3, 0 ],
|
||||||
|
"to": [ 16.001, 13, 22.5 ],
|
||||||
|
"rotation": { "origin": [ 16, -3, 0 ], "axis": "y", "angle": -45 },
|
||||||
|
"shade": false,
|
||||||
|
"faces": {
|
||||||
|
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
||||||
|
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "betterend:block/neon_cactus_small_side_moss",
|
"particle": "betterend:block/neon_cactus_medium_side",
|
||||||
"overlay": "betterend:block/neon_cactus_small_side_dust_overlay",
|
"overlay": "betterend:block/neon_cactus_medium_side_dust_overlay",
|
||||||
"side": "betterend:block/neon_cactus_medium_side",
|
"side": "betterend:block/neon_cactus_medium_side_dust",
|
||||||
"top": "betterend:block/neon_cactus_medium_top"
|
"top": "betterend:block/neon_cactus_medium_top"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
{
|
{
|
||||||
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
|
||||||
|
"parent": "block/block",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "betterend:block/neon_cactus_small_side_moss",
|
"particle": "betterend:block/neon_cactus_small_side",
|
||||||
"overlay": "betterend:block/neon_cactus_small_side_moss_overlay",
|
"overlay": "betterend:block/neon_cactus_small_side_moss_overlay",
|
||||||
"side": "betterend:block/neon_cactus_medium_side",
|
"side": "betterend:block/neon_cactus_small_side_moss",
|
||||||
"top": "betterend:block/neon_cactus_medium_top"
|
"top": "betterend:block/neon_cactus_small_top"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"__comment": "Box1",
|
"__comment": "Box1",
|
||||||
"from": [ 3, -3, 3 ],
|
"from": [ 4, -4, 4 ],
|
||||||
"to": [ 13, 13, 13 ],
|
"to": [ 12, 12, 12 ],
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
|
"down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
||||||
"up": { "uv": [ 3, 3, 13, 13 ], "texture": "#top" },
|
"up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" },
|
||||||
"north": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
"north": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" },
|
||||||
"south": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
"south": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" },
|
||||||
"west": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" },
|
"west": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" },
|
||||||
"east": { "uv": [ 3, 0, 13, 16 ], "texture": "#side" }
|
"east": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__comment": "Box1",
|
"from": [ 4, -4, 4 ],
|
||||||
"from": [ 3, -3, 3 ],
|
"to": [ 12, 12, 12 ],
|
||||||
"to": [ 13, 13, 13 ],
|
|
||||||
"faces": {
|
"faces": {
|
||||||
"north": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
"north": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" },
|
||||||
"south": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
"south": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" },
|
||||||
"west": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" },
|
"west": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" },
|
||||||
"east": { "uv": [ 3, 0, 13, 16 ], "texture": "#overlay" }
|
"east": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__comment": "PlaneX2",
|
"__comment": "PlaneX2",
|
||||||
"from": [ 0, -3, 0 ],
|
"from": [ 0, -4, 0 ],
|
||||||
"to": [ 0.001, 13, 22.5 ],
|
"to": [ 0.001, 12, 22.5 ],
|
||||||
"rotation": { "origin": [ 0, -3, 0 ], "axis": "y", "angle": 45 },
|
"rotation": { "origin": [ 0, -4, 0 ], "axis": "y", "angle": 45 },
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
||||||
|
@ -45,9 +45,9 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__comment": "PlaneX2",
|
"__comment": "PlaneX2",
|
||||||
"from": [ 16, -3, 0 ],
|
"from": [ 16, -4, 0 ],
|
||||||
"to": [ 16.001, 13, 22.5 ],
|
"to": [ 16.001, 12, 22.5 ],
|
||||||
"rotation": { "origin": [ 16, -3, 0 ], "axis": "y", "angle": -45 },
|
"rotation": { "origin": [ 16, -4, 0 ], "axis": "y", "angle": -45 },
|
||||||
"shade": false,
|
"shade": false,
|
||||||
"faces": {
|
"faces": {
|
||||||
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue