diff --git a/src/main/java/ru/betterend/blocks/NeonCactusBlock.java b/src/main/java/ru/betterend/blocks/NeonCactusBlock.java index 51955d76..a9ad12c8 100644 --- a/src/main/java/ru/betterend/blocks/NeonCactusBlock.java +++ b/src/main/java/ru/betterend/blocks/NeonCactusBlock.java @@ -11,8 +11,11 @@ import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; 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.level.BlockGetter; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelReader; 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.material.FluidState; 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.VoxelShape; import ru.betterend.blocks.BlockProperties.CactusBottom; @@ -38,6 +42,7 @@ import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndTags; import ru.betterend.util.BlocksHelper; +import ru.betterend.util.MHelper; public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterloggedBlock, IRenderTypeable { public static final EnumProperty SHAPE = BlockProperties.TRIPLE_SHAPE; @@ -99,13 +104,14 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg @Override 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)) { world.getLiquidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world)); } Direction dir = state.getValue(FACING); - if (!canSurvive(state, world, pos)) { - return Blocks.AIR.defaultBlockState(); - } BlockState downState = world.getBlockState(pos.relative(dir.getOpposite())); if (downState.is(Blocks.END_STONE) || downState.is(EndBlocks.ENDSTONE_DUST)) { state = state.setValue(CACTUS_BOTTOM, CactusBottom.SAND); @@ -119,6 +125,13 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg return state; } + @Override + public void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, Random random) { + if (!blockState.canSurvive(serverLevel, blockPos)) { + serverLevel.destroyBlock(blockPos, true); + } + } + @Override public ERenderLayer getRenderLayer() { return ERenderLayer.CUTOUT; @@ -154,11 +167,10 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { - Direction dir = state.getValue(FACING); if (!this.canSurvive(state, world, pos)) { - this.destroy(world, pos, state); return; } + Direction dir = state.getValue(FACING); if (!world.isEmptyBlock(pos.relative(dir))) { return; } @@ -187,6 +199,16 @@ public class NeonCactusBlock extends BlockBaseNotFull implements SimpleWaterlogg BlocksHelper.setWithoutUpdate(world, pos.relative(dir), placement); 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) { int length = 0; diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_big.json b/src/main/resources/assets/betterend/models/block/neon_cactus_big.json index 7e2dac87..9125516b 100644 --- a/src/main/resources/assets/betterend/models/block/neon_cactus_big.json +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_big.json @@ -12,8 +12,8 @@ "to": [ 14, 14, 14 ], "shade": false, "faces": { - "down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, - "up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, + "down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, "north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_big_moss.json b/src/main/resources/assets/betterend/models/block/neon_cactus_big_moss.json index d8c3232a..9141f6b1 100644 --- a/src/main/resources/assets/betterend/models/block/neon_cactus_big_moss.json +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_big_moss.json @@ -13,8 +13,8 @@ "to": [ 14, 14, 14 ], "shade": false, "faces": { - "down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, - "up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, + "down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, "north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_big_sand.json b/src/main/resources/assets/betterend/models/block/neon_cactus_big_sand.json index addf607a..af667304 100644 --- a/src/main/resources/assets/betterend/models/block/neon_cactus_big_sand.json +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_big_sand.json @@ -13,8 +13,8 @@ "to": [ 14, 14, 14 ], "shade": false, "faces": { - "down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, - "up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, + "down": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, + "up": { "uv": [ 2, 2, 14, 14 ], "texture": "#top" }, "north": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "south": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, "west": { "uv": [ 2, 0, 14, 16 ], "texture": "#side" }, diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_medium_moss.json b/src/main/resources/assets/betterend/models/block/neon_cactus_medium_moss.json new file mode 100644 index 00000000..d1400921 --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_medium_moss.json @@ -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" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_medium_sand.json b/src/main/resources/assets/betterend/models/block/neon_cactus_medium_sand.json index 807dbf17..8120468b 100644 --- a/src/main/resources/assets/betterend/models/block/neon_cactus_medium_sand.json +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_medium_sand.json @@ -1,9 +1,9 @@ { "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", "textures": { - "particle": "betterend:block/neon_cactus_small_side_moss", - "overlay": "betterend:block/neon_cactus_small_side_dust_overlay", - "side": "betterend:block/neon_cactus_medium_side", + "particle": "betterend:block/neon_cactus_medium_side", + "overlay": "betterend:block/neon_cactus_medium_side_dust_overlay", + "side": "betterend:block/neon_cactus_medium_side_dust", "top": "betterend:block/neon_cactus_medium_top" }, "elements": [ diff --git a/src/main/resources/assets/betterend/models/block/neon_cactus_small_moss.json b/src/main/resources/assets/betterend/models/block/neon_cactus_small_moss.json index 19596490..65825cc0 100644 --- a/src/main/resources/assets/betterend/models/block/neon_cactus_small_moss.json +++ b/src/main/resources/assets/betterend/models/block/neon_cactus_small_moss.json @@ -1,42 +1,42 @@ { "__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio", + "parent": "block/block", "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", - "side": "betterend:block/neon_cactus_medium_side", - "top": "betterend:block/neon_cactus_medium_top" + "side": "betterend:block/neon_cactus_small_side_moss", + "top": "betterend:block/neon_cactus_small_top" }, "elements": [ { "__comment": "Box1", - "from": [ 3, -3, 3 ], - "to": [ 13, 13, 13 ], + "from": [ 4, -4, 4 ], + "to": [ 12, 12, 12 ], "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" } + "down": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, + "up": { "uv": [ 4, 4, 12, 12 ], "texture": "#top" }, + "north": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" }, + "south": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" }, + "west": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" }, + "east": { "uv": [ 4, 0, 12, 16 ], "texture": "#side" } } }, { - "__comment": "Box1", - "from": [ 3, -3, 3 ], - "to": [ 13, 13, 13 ], + "from": [ 4, -4, 4 ], + "to": [ 12, 12, 12 ], "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" } + "north": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" }, + "south": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" }, + "west": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" }, + "east": { "uv": [ 4, 0, 12, 16 ], "texture": "#overlay" } } }, { "__comment": "PlaneX2", - "from": [ 0, -3, 0 ], - "to": [ 0.001, 13, 22.5 ], - "rotation": { "origin": [ 0, -3, 0 ], "axis": "y", "angle": 45 }, + "from": [ 0, -4, 0 ], + "to": [ 0.001, 12, 22.5 ], + "rotation": { "origin": [ 0, -4, 0 ], "axis": "y", "angle": 45 }, "shade": false, "faces": { "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" }, @@ -45,9 +45,9 @@ }, { "__comment": "PlaneX2", - "from": [ 16, -3, 0 ], - "to": [ 16.001, 13, 22.5 ], - "rotation": { "origin": [ 16, -3, 0 ], "axis": "y", "angle": -45 }, + "from": [ 16, -4, 0 ], + "to": [ 16.001, 12, 22.5 ], + "rotation": { "origin": [ 16, -4, 0 ], "axis": "y", "angle": -45 }, "shade": false, "faces": { "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side" },