|
1 | 1 | package com.robotgryphon.compactmachines.block.walls; |
2 | 2 |
|
3 | | -public class SolidWallBlock extends WallBlock { |
| 3 | +import com.robotgryphon.compactmachines.core.Registration; |
| 4 | +import net.minecraft.block.Block; |
| 5 | +import net.minecraft.block.BlockState; |
| 6 | +import net.minecraft.entity.Entity; |
| 7 | +import net.minecraft.entity.EntitySpawnPlacementRegistry; |
| 8 | +import net.minecraft.entity.EntityType; |
| 9 | +import net.minecraft.entity.player.PlayerEntity; |
| 10 | +import net.minecraft.entity.player.ServerPlayerEntity; |
| 11 | +import net.minecraft.fluid.FluidState; |
| 12 | +import net.minecraft.item.ItemStack; |
| 13 | +import net.minecraft.util.ActionResultType; |
| 14 | +import net.minecraft.util.Hand; |
| 15 | +import net.minecraft.util.math.BlockPos; |
| 16 | +import net.minecraft.util.math.BlockRayTraceResult; |
| 17 | +import net.minecraft.world.Explosion; |
| 18 | +import net.minecraft.world.IBlockReader; |
| 19 | +import net.minecraft.world.IWorldReader; |
| 20 | +import net.minecraft.world.World; |
| 21 | + |
| 22 | +import javax.annotation.Nullable; |
| 23 | + |
| 24 | +public class SolidWallBlock extends Block { |
4 | 25 | public SolidWallBlock(Properties props) { |
5 | 26 | super(props); |
6 | 27 | } |
| 28 | + |
| 29 | + @Override |
| 30 | + public void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion) { |
| 31 | + // NO-Op, do not destroy on explosions |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public boolean canEntityDestroy(BlockState state, IBlockReader world, BlockPos pos, Entity entity) { |
| 36 | + return false; |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos) { |
| 41 | + return false; |
| 42 | + } |
| 43 | + |
| 44 | + @Override |
| 45 | + public boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) { |
| 46 | + return false; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, @Nullable EntityType<?> entityType) { |
| 51 | + return pos.getY() == 40; |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { |
| 56 | + ItemStack held = player.getHeldItemMainhand(); |
| 57 | + |
| 58 | + if (held.isEmpty()) |
| 59 | + return ActionResultType.PASS; |
| 60 | + |
| 61 | + if (player.isSneaking()) |
| 62 | + return ActionResultType.PASS; |
| 63 | + |
| 64 | + // TODO: Tunnels and Personal Shrinking Device |
| 65 | + |
| 66 | + return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); |
| 67 | + } |
7 | 68 | } |
0 commit comments