12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- package me.km.blocks;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.util.BlockRenderLayer;
- import net.minecraft.util.math.AxisAlignedBB;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class BlockTrap extends BlockBase
- {
- protected static final AxisAlignedBB BOX = new AxisAlignedBB(0, 0, 0, 1, 0.0625d, 1);
-
- public BlockTrap(Material material, String name, String local)
- {
- super(material, name, local);
- }
-
- @Override
- public void neighborChanged(IBlockState state, World w, BlockPos pos, Block b, BlockPos fromPos)
- {
- if(!w.getBlockState(pos.down()).getMaterial().isSolid())
- {
- this.dropBlockAsItem(w, pos, state, 0);
- w.setBlockToAir(pos);
- }
- super.neighborChanged(state, w, pos, b, fromPos);
- }
-
- @Override
- public boolean canPlaceBlockAt(World w, BlockPos pos)
- {
- return w.getBlockState(pos.down()).getMaterial().isSolid() && super.canPlaceBlockAt(w, pos);
- }
- @Override
- public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
- {
- return BOX;
- }
- @Override
- public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
- {
- return NULL_AABB;
- }
-
- @Override
- public boolean isOpaqueCube(IBlockState state)
- {
- return false;
- }
- @Override
- public boolean isFullCube(IBlockState state)
- {
- return false;
- }
-
- @Override
- public boolean canSpawnInBlock()
- {
- return false;
- }
-
- @SideOnly(Side.CLIENT)
- @Override
- public BlockRenderLayer getBlockLayer()
- {
- return BlockRenderLayer.CUTOUT;
- }
-
- @Override
- public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
- {
- return true;
- }
- }
|