Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
- {
- if(!world.isRemote)
- {
- TileVoidaicAltar altar = (TileVoidaicAltar) world.getTileEntity(pos);
- if(!player.getHeldItem(hand).isEmpty()
- && player.getHeldItem(hand).getItem() != ModItems.WHITEWOOD_STAFF)
- {
- if(!player.isCreative())
- {
- if(altar.handler.getStackInSlot(0).getCount() < 1)
- altar.handler.setStackInSlot(0, player.getHeldItem(hand).splitStack(1));
- if(altar.handler.getStackInSlot(1).getCount() < 1 && altar.handler.getStackInSlot(0).getCount() > 0)
- altar.handler.setStackInSlot(1, player.getHeldItem(hand).splitStack(1));
- if(altar.handler.getStackInSlot(2).getCount() < 1 && altar.handler.getStackInSlot(1).getCount() > 0)
- altar.handler.setStackInSlot(2, player.getHeldItem(hand).splitStack(1));
- if(altar.handler.getStackInSlot(3).getCount() < 1 && altar.handler.getStackInSlot(2).getCount() > 0)
- altar.handler.setStackInSlot(3, player.getHeldItem(hand).splitStack(1));
- }
- else
- {
- ItemStack stack = new ItemStack(player.getHeldItem(hand).getItem(), 1, player.getHeldItem(hand).getMetadata());
- if(altar.handler.getStackInSlot(0).getCount() < 1)
- altar.handler.setStackInSlot(0, stack);
- if(altar.handler.getStackInSlot(1).getCount() < 1 && altar.handler.getStackInSlot(0).getCount() > 0)
- altar.handler.setStackInSlot(1, stack);
- if(altar.handler.getStackInSlot(2).getCount() < 1 && altar.handler.getStackInSlot(1).getCount() > 0)
- altar.handler.setStackInSlot(2, stack);
- if(altar.handler.getStackInSlot(3).getCount() < 1 && altar.handler.getStackInSlot(2).getCount() > 0)
- altar.handler.setStackInSlot(3, stack);
- }
- }
- else if(player.getHeldItem(hand).isEmpty())
- {
- if(altar.handler.getStackInSlot(3).getCount() > 0)
- player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(3));
- if(altar.handler.getStackInSlot(2).getCount() > 0 && altar.handler.getStackInSlot(3).getCount() < 1)
- player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(2));
- if(altar.handler.getStackInSlot(1).getCount() > 0 && altar.handler.getStackInSlot(2).getCount() < 1)
- player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(1));
- if(altar.handler.getStackInSlot(0).getCount() > 0 && altar.handler.getStackInSlot(1).getCount() < 1)
- player.inventory.addItemStackToInventory(altar.handler.getStackInSlot(0));
- }
- else if(player.getHeldItem(hand).getItem() == ModItems.WHITEWOOD_STAFF)
- {
- if(!altar.isCasting()) altar.startCasting(player);
- else altar.stopCasting();
- }
- }
- state = world.getBlockState(pos);
- world.notifyBlockUpdate(pos, state, state, 2);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement