public EntityFishHook(World worldIn, Player fishingPlayer) { super(worldIn); this.ignoreFrustumCheck = true; this.angler = fishingPlayer; this.angler.fishEntity = this; this.setSize(0.25F, 0.25F); this.setLocationAndAngles( fishingPlayer.posX, fishingPlayer.posY + (double) fishingPlayer.getEyeHeight(), fishingPlayer.posZ, fishingPlayer.rotationYaw, fishingPlayer.rotationPitch); this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); float f = 0.4F; this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * f); this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * f); this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI) * f); this.handleHookCasting(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F); }
/** Called when a Block is right-clicked with this Item */ public boolean onItemUse( ItemStack stack, Player playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if (side != EnumFacing.UP) { return false; } else { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (!block.isReplaceable(worldIn, pos)) { pos = pos.offset(side); } if (!playerIn.canPlayerEdit(pos, side, stack)) { return false; } else if (!this.block.canPlaceBlockAt(worldIn, pos)) { return false; } else { placeDoor(worldIn, pos, EnumFacing.fromAngle((double) playerIn.rotationYaw), this.block); --stack.stackSize; return true; } } }
public boolean onBlockActivated( World worldIn, BlockPos pos, IBlockState state, Player playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityBeacon) { playerIn.displayGUIChest((TileEntityBeacon) tileentity); playerIn.triggerAchievement(StatList.field_181730_N); } return true; } }
/** Called when the container is closed. */ public void onContainerClosed(Player playerIn) { super.onContainerClosed(playerIn); for (int i = 0; i < 4; ++i) { ItemStack itemstack = this.craftMatrix.removeStackFromSlot(i); if (itemstack != null) { playerIn.dropPlayerItemWithRandomChoice(itemstack, false); } } this.craftResult.setInventorySlotContents(0, (ItemStack) null); }
private ItemStack fillBucket(ItemStack emptyBuckets, Player player, Item fullBucket) { if (player.capabilities.isCreativeMode) { return emptyBuckets; } else if (--emptyBuckets.stackSize <= 0) { return new ItemStack(fullBucket); } else { if (!player.inventory.addItemStackToInventory(new ItemStack(fullBucket))) { player.dropPlayerItemWithRandomChoice(new ItemStack(fullBucket, 1, 0), false); } return emptyBuckets; } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, Player playerIn) { boolean flag = this.isFull == Blocks.air; MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag); if (movingobjectposition == null) { return itemStackIn; } else { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { BlockPos blockpos = movingobjectposition.getBlockPos(); if (!worldIn.isBlockModifiable(playerIn, blockpos)) { return itemStackIn; } if (flag) { if (!playerIn.canPlayerEdit( blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn)) { return itemStackIn; } IBlockState iblockstate = worldIn.getBlockState(blockpos); Material material = iblockstate.getBlock().getMaterial(); if (material == Material.water && ((Integer) iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) { worldIn.setBlockToAir(blockpos); playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return this.fillBucket(itemStackIn, playerIn, Items.water_bucket); } if (material == Material.lava && ((Integer) iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) { worldIn.setBlockToAir(blockpos); playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket); } } else { if (this.isFull == Blocks.air) { return new ItemStack(Items.bucket); } BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit); if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn)) { return itemStackIn; } if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode) { playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return new ItemStack(Items.bucket); } } } return itemStackIn; } }