Advertisement
Camellias_

Untitled

Jul 30th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.92 KB | None | 0 0
  1.     @Override
  2.     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  3.     {
  4.         if(!world.isRemote)
  5.         {
  6.             TileVoidaicAltar altar = (TileVoidaicAltar) world.getTileEntity(pos);
  7.            
  8.             if(!player.getHeldItem(hand).isEmpty()
  9.                 && player.getHeldItem(hand).getItem() != ModItems.WHITEWOOD_STAFF)
  10.             {
  11.                 if(!player.isCreative())
  12.                 {
  13.                     if(altar.handler.getStackInSlot(0).getCount() < 1)
  14.                         altar.handler.setStackInSlot(0, player.getHeldItem(hand).splitStack(1));
  15.                    
  16.                     if(altar.handler.getStackInSlot(1).getCount() < 1 && altar.handler.getStackInSlot(0).getCount() > 0)
  17.                         altar.handler.setStackInSlot(1, player.getHeldItem(hand).splitStack(1));
  18.                    
  19.                     if(altar.handler.getStackInSlot(2).getCount() < 1 && altar.handler.getStackInSlot(1).getCount() > 0)
  20.                         altar.handler.setStackInSlot(2, player.getHeldItem(hand).splitStack(1));
  21.                    
  22.                     if(altar.handler.getStackInSlot(3).getCount() < 1 && altar.handler.getStackInSlot(2).getCount() > 0)
  23.                         altar.handler.setStackInSlot(3, player.getHeldItem(hand).splitStack(1));
  24.                 }
  25.                 else
  26.                 {
  27.                     ItemStack stack = new ItemStack(player.getHeldItem(hand).getItem(), 1, player.getHeldItem(hand).getMetadata());
  28.                    
  29.                     if(altar.handler.getStackInSlot(0).getCount() < 1)
  30.                         altar.handler.setStackInSlot(0, stack);
  31.                    
  32.                     if(altar.handler.getStackInSlot(1).getCount() < 1 && altar.handler.getStackInSlot(0).getCount() > 0)
  33.                         altar.handler.setStackInSlot(1, stack);
  34.                    
  35.                     if(altar.handler.getStackInSlot(2).getCount() < 1 && altar.handler.getStackInSlot(1).getCount() > 0)
  36.                         altar.handler.setStackInSlot(2, stack);
  37.                    
  38.                     if(altar.handler.getStackInSlot(3).getCount() < 1 && altar.handler.getStackInSlot(2).getCount() > 0)
  39.                         altar.handler.setStackInSlot(3, stack);
  40.                 }
  41.             }
  42.             else if(player.getHeldItem(hand).isEmpty())
  43.             {
  44.                 if(altar.handler.getStackInSlot(3).getCount() > 0)
  45.                     player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(3));
  46.                
  47.                 if(altar.handler.getStackInSlot(2).getCount() > 0 && altar.handler.getStackInSlot(3).getCount() < 1)
  48.                     player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(2));
  49.                
  50.                 if(altar.handler.getStackInSlot(1).getCount() > 0 && altar.handler.getStackInSlot(2).getCount() < 1)
  51.                     player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(1));
  52.                
  53.                 if(altar.handler.getStackInSlot(0).getCount() > 0 && altar.handler.getStackInSlot(1).getCount() < 1)
  54.                     player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(0));
  55.             }
  56.             else if(player.getHeldItem(hand).getItem() == ModItems.WHITEWOOD_STAFF)
  57.             {
  58.                 if(!altar.isCasting()) altar.startCasting(player);
  59.                 else altar.stopCasting();
  60.             }
  61.         }
  62.        
  63.         state = world.getBlockState(pos);
  64.        
  65.         world.notifyBlockUpdate(pos, state, state, 2);
  66.        
  67.         return true;
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement