Guest User

BlockBlockholeWall

a guest
Jan 31st, 2017
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.limplungs.blockhole.blocks;
  2.  
  3. import java.util.List;
  4.  
  5. import com.limplungs.blockhole.tileentities.TileEntityBlockholeWall;
  6.  
  7. import net.minecraft.block.properties.IProperty;
  8. import net.minecraft.block.properties.PropertyInteger;
  9. import net.minecraft.block.state.BlockStateContainer;
  10. import net.minecraft.block.state.IBlockState;
  11. import net.minecraft.entity.EntityLivingBase;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.init.Blocks;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraft.tileentity.TileEntity;
  16. import net.minecraft.util.EnumBlockRenderType;
  17. import net.minecraft.util.EnumFacing;
  18. import net.minecraft.util.EnumHand;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.util.math.RayTraceResult;
  21. import net.minecraft.world.ChunkCache;
  22. import net.minecraft.world.IBlockAccess;
  23. import net.minecraft.world.World;
  24. import net.minecraft.world.chunk.Chunk;
  25.  
  26. public class BlockBlockholeWall extends BlockBasic
  27. {
  28.     public static final PropertyInteger INDEX = PropertyInteger.create("index", 0, 195);
  29.    
  30.     public BlockBlockholeWall(BlockData blockdata)
  31.     {
  32.         super(blockdata);
  33.         this.setBlockUnbreakable();
  34.         this.setResistance(4096F);
  35.         this.setLightLevel(1.0F);
  36.         this.setDefaultState(this.blockState.getBaseState().withProperty(INDEX, 0));
  37.     }
  38.    
  39.     @Override
  40.     protected BlockStateContainer createBlockState()
  41.     {
  42.         return new BlockStateContainer(this, new IProperty[]{INDEX});
  43.     }
  44.  
  45.    
  46.     @Override
  47.     public TileEntity createTileEntity(World world, IBlockState state)
  48.     {
  49.         return new TileEntityBlockholeWall();
  50.     }
  51.    
  52.    
  53.     @Override
  54.     public boolean hasTileEntity()
  55.     {
  56.         return true;
  57.     }
  58.    
  59.    
  60.     @Override
  61.     public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
  62.     {
  63.         TileEntityBlockholeWall tile = (TileEntityBlockholeWall) (world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos));
  64.        
  65.         tile = new TileEntityBlockholeWall();
  66.        
  67.         tile.setIndex((pos.getX()-1) * 14 + (pos.getY()-1));
  68.        
  69.         return state.withProperty(INDEX, tile.getIndex());
  70.     }
  71.    
  72.     @Override
  73.     public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
  74.     {
  75.         ((TileEntityBlockholeWall)world.getTileEntity(pos)).setIndex(0);
  76.     }
  77.    
  78.     public void changeBlockTexture(int i, int j, int k, World world, BlockPos ijkPos)
  79.     {
  80.         TileEntityBlockholeWall tile = ((TileEntityBlockholeWall)world.getTileEntity(ijkPos));
  81.         tile.setIndex((i-1) * 14 + (k-1));
  82.     }
  83.    
  84.     @Override
  85.     public int getMetaFromState(IBlockState state)
  86.     {
  87.         return 0;
  88.     }
  89.    
  90.    
  91.     @Override
  92.     public IBlockState getStateFromMeta(int meta)
  93.     {
  94.         return this.getDefaultState();
  95.     }
  96.  
  97.    
  98.     @Override
  99.     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
  100.     {
  101.         if (player.isSneaking())
  102.         {
  103.            
  104.         }
  105.        
  106.         return false;
  107.     }
  108.    
  109.    
  110.     @Override
  111.     public EnumBlockRenderType getRenderType(IBlockState state)
  112.     {
  113.         return EnumBlockRenderType.MODEL;
  114.     }
  115.    
  116.    
  117.     @Override
  118.     public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
  119.     {
  120.         return new ItemStack(Blocks.BEDROCK);
  121.     }
  122.    
  123.    
  124.     @Override
  125.     public boolean isOpaqueCube(IBlockState state)
  126.     {
  127.         return true;
  128.     }
  129.    
  130.     @Override
  131.     public boolean isFullCube(IBlockState state)
  132.     {
  133.         return true;
  134.     }
  135.    
  136.     @Override
  137.     public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side)
  138.     {
  139.         return true;
  140.     }
  141.    
  142.     @Override
  143.     public void onBlockDestroyedByPlayer(World world, BlockPos pos, IBlockState state)
  144.     {
  145.        
  146.     }
  147.    
  148.     @Override
  149.     public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player)
  150.     {
  151.        
  152.     }
  153.    
  154.     @Override
  155.     public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
  156.     {
  157.         return false;
  158.     }
  159.    
  160.     @Override
  161.     public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
  162.     {
  163.         tooltip.add("If you somehow got one of these blocks,\nDO NOT PLACE IT!\n");
  164.         tooltip.add("If accidentally placed, remove it with\n/setblock x y z minecraft:air");
  165.     }
  166. }
RAW Paste Data