Advertisement
Guest User

Untitled

a guest
Jun 20th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
  2.     {
  3.         if (!world.isRemote) {
  4.             EntityDataLoyalist loyalist = new EntityDataLoyalist(world);
  5.             MovingObjectPosition mop = player.rayTrace(5, 1);
  6.            
  7.             if (mop != null) {
  8.                 if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
  9.                     // We hit a block.
  10.                    
  11.                     int sideHit = mop.sideHit;
  12.                     Coordinate target = new Coordinate(mop.blockX, mop.blockY, mop.blockZ);
  13.                     ForgeDirection direction = ForgeDirection.UNKNOWN;
  14.                    
  15.                     if (sideHit == 0) {
  16.                         // If we hit the down of a block.
  17.                         direction = ForgeDirection.DOWN;
  18.                     } else if (sideHit == 1) {
  19.                         // If we hit the up of a block;
  20.                         direction = ForgeDirection.UP;
  21.                     } else if (sideHit == 2) {
  22.                         direction = ForgeDirection.EAST;
  23.                     } else if (sideHit == 3) {
  24.                         direction = ForgeDirection.WEST;
  25.                     } else if (sideHit == 4) {
  26.                         direction = ForgeDirection.NORTH;
  27.                     } else if (sideHit == 5) {
  28.                         direction = ForgeDirection.SOUTH;
  29.                     }
  30.                    
  31.                     if (direction != ForgeDirection.UNKNOWN) {
  32.                         target.translate(direction);
  33.                         loyalist.setLocationAndAngles(target.x, target.y, target.z, 0, 0);
  34.                        
  35.                         if (!world.isRemote) {
  36.                             world.spawnEntityInWorld(loyalist);
  37.                         }
  38.                     }
  39.                    
  40.                 }
  41.             }
  42.         }
  43.         return false;
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement