MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / onItemRightClick

Method onItemRightClick

src/main/java/net/minecraft/item/ItemBoat.java:28–113  ·  view source on GitHub ↗

Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer

(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

Source from the content-addressed store, hash-verified

26 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
27 */
28 public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
29 {
30 float f = 1.0F;
31 float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch) * f;
32 float f2 = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw) * f;
33 double d0 = playerIn.prevPosX + (playerIn.posX - playerIn.prevPosX) * (double)f;
34 double d1 = playerIn.prevPosY + (playerIn.posY - playerIn.prevPosY) * (double)f + (double)playerIn.getEyeHeight();
35 double d2 = playerIn.prevPosZ + (playerIn.posZ - playerIn.prevPosZ) * (double)f;
36 Vec3 vec3 = new Vec3(d0, d1, d2);
37 float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
38 float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
39 float f5 = -MathHelper.cos(-f1 * 0.017453292F);
40 float f6 = MathHelper.sin(-f1 * 0.017453292F);
41 float f7 = f4 * f5;
42 float f8 = f3 * f5;
43 double d3 = 5.0D;
44 Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
45 MovingObjectPosition movingobjectposition = worldIn.rayTraceBlocks(vec3, vec31, true);
46
47 if (movingobjectposition == null)
48 {
49 return itemStackIn;
50 }
51 else
52 {
53 Vec3 vec32 = playerIn.getLook(f);
54 boolean flag = false;
55 float f9 = 1.0F;
56 List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, playerIn.getEntityBoundingBox().addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand(f9, f9, f9));
57
58 for (int i = 0; i < list.size(); ++i)
59 {
60 Entity entity = list.get(i);
61
62 if (entity.canBeCollidedWith())
63 {
64 float f10 = entity.getCollisionBorderSize();
65 AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand(f10, f10, f10);
66
67 if (axisalignedbb.isVecInside(vec3))
68 {
69 flag = true;
70 }
71 }
72 }
73
74 if (flag)
75 {
76 return itemStackIn;
77 }
78 else
79 {
80 if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
81 {
82 BlockPos blockpos = movingobjectposition.getBlockPos();
83
84 if (worldIn.getBlockState(blockpos).getBlock() == Blocks.snow_layer)
85 {

Callers

nothing calls this directly

Calls 15

cosMethod · 0.95
sinMethod · 0.95
addVectorMethod · 0.95
getEntityBoundingBoxMethod · 0.95
canBeCollidedWithMethod · 0.95
isVecInsideMethod · 0.95
getBlockPosMethod · 0.95
downMethod · 0.95
floor_doubleMethod · 0.95
getIdFromItemMethod · 0.95
rayTraceBlocksMethod · 0.80

Tested by

no test coverage detected