Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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_)
- {
- if (!world.isRemote) {
- EntityDataLoyalist loyalist = new EntityDataLoyalist(world);
- MovingObjectPosition mop = player.rayTrace(5, 1);
- if (mop != null) {
- if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- // We hit a block.
- int sideHit = mop.sideHit;
- Coordinate target = new Coordinate(mop.blockX, mop.blockY, mop.blockZ);
- ForgeDirection direction = ForgeDirection.UNKNOWN;
- if (sideHit == 0) {
- // If we hit the down of a block.
- direction = ForgeDirection.DOWN;
- } else if (sideHit == 1) {
- // If we hit the up of a block;
- direction = ForgeDirection.UP;
- } else if (sideHit == 2) {
- direction = ForgeDirection.EAST;
- } else if (sideHit == 3) {
- direction = ForgeDirection.WEST;
- } else if (sideHit == 4) {
- direction = ForgeDirection.NORTH;
- } else if (sideHit == 5) {
- direction = ForgeDirection.SOUTH;
- }
- if (direction != ForgeDirection.UNKNOWN) {
- target.translate(direction);
- loyalist.setLocationAndAngles(target.x, target.y, target.z, 0, 0);
- if (!world.isRemote) {
- world.spawnEntityInWorld(loyalist);
- }
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement