Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Called when the player uses this ItemStack on a Block (right-click). Places blocks, etc. (Legacy name:
- * tryPlaceItemIntoWorld)
- */
- public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
- {
- if (!worldIn.isRemote) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, playerIn, worldIn, pos, side, hitX, hitY, hitZ, hand);
- Item i = this.getItem();
- BlockSnapshot blockSnapshot = null;
- if(i instanceof ItemBlock)
- {
- BlockPos pos2 = pos;
- ItemBlock item = (ItemBlock)this.getItem();
- if(!item.getBlock().isReplaceable(worldIn, pos))
- {
- pos2 = pos2.offset(side);
- }
- blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(worldIn, pos2, 11);
- }
- EnumActionResult resault = this.getItem().onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ);
- if(i instanceof ItemBlock && resault == EnumActionResult.SUCCESS)
- {
- IBlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(side.getOpposite()));
- ClientBlockPlaceEvent e = new ClientBlockPlaceEvent(blockSnapshot, placedAgainst, playerIn, hand);
- MinecraftForge.EVENT_BUS.post(e);
- }
- else if (resault == EnumActionResult.SUCCESS)
- {
- playerIn.addStat(StatList.getObjectUseStats(this.item));
- }
- return resault;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement