@SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { if (event.side.isClient() && event.phase == TickEvent.Phase.START && event.player != null && event.player == ClientUtils.mc().renderViewEntity) { skyhookGrabableConnections.clear(); EntityPlayer player = event.player; ItemStack stack = player.getCurrentEquippedItem(); if (stack != null && stack.getItem() instanceof ItemSkyhook) { TileEntity connector = null; double lastDist = 0; Connection line = null; double py = player.posY + player.getEyeHeight(); for (int xx = -2; xx <= 2; xx++) for (int zz = -2; zz <= 2; zz++) for (int yy = 0; yy <= 3; yy++) { TileEntity tile = player.worldObj.getTileEntity( (int) player.posX + xx, (int) py + yy, (int) player.posZ + zz); if (tile != null) { Connection con = SkylineHelper.getTargetConnection( player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord, player, null); if (con != null) { double d = tile.getDistanceFrom(player.posX, py, player.posZ); if (connector == null || d < lastDist) { connector = tile; lastDist = d; line = con; } } } } if (line != null && connector != null) skyhookGrabableConnections.add(line); } } if (event.side.isClient() && event.phase == TickEvent.Phase.END && event.player != null) { EntityPlayer player = event.player; ItemStack stack = player.getCurrentEquippedItem(); if (stack != null && stack.getItem() instanceof ItemDrill && (player != ClientUtils.mc().renderViewEntity || ClientUtils.mc().gameSettings.thirdPersonView != 0)) { if (player.getItemInUseCount() <= 0) { player.clearItemInUse(); player.setItemInUse(stack, 2147483647); } } } }
public void reachedTarget(TileEntity end) { this.setDead(); IELogger.debug("last tick at " + System.currentTimeMillis()); if (!(this.riddenByEntity instanceof EntityPlayer)) return; ItemStack hook = ((EntityPlayer) this.riddenByEntity).getCurrentEquippedItem(); if (hook == null || !(hook.getItem() instanceof ItemSkyhook)) return; Connection line = SkylineHelper.getTargetConnection( worldObj, target.posX, target.posY, target.posZ, (EntityLivingBase) this.riddenByEntity, connection); if (line != null) { ((EntityPlayer) this.riddenByEntity) .setItemInUse(hook, hook.getItem().getMaxItemUseDuration(hook)); SkylineHelper.spawnHook((EntityPlayer) this.riddenByEntity, end, line); // ChunkCoordinates cc0 = line.end==target?line.start:line.end; // ChunkCoordinates cc1 = line.end==target?line.end:line.start; // double dx = cc0.posX-cc1.posX; // double dy = cc0.posY-cc1.posY; // double dz = cc0.posZ-cc1.posZ; // // EntityZiplineHook zip = new EntityZiplineHook(worldObj, // target.posX+.5,target.posY+.5,target.posZ+.5, line, cc0); // zip.motionX = dx*.05f; // zip.motionY = dy*.05f; // zip.motionZ = dz*.05f; // if(!worldObj.isRemote) // worldObj.spawnEntityInWorld(zip); // ItemSkyHook.existingHooks.put(this.riddenByEntity.getCommandSenderName(), zip); // this.riddenByEntity.mountEntity(zip); } else { ((EntityPlayer) this.riddenByEntity).motionX = motionX; ((EntityPlayer) this.riddenByEntity).motionY = motionY; ((EntityPlayer) this.riddenByEntity).motionZ = motionZ; IELogger.debug( "player motion: " + ((EntityPlayer) this.riddenByEntity).motionX + "," + ((EntityPlayer) this.riddenByEntity).motionY + "," + ((EntityPlayer) this.riddenByEntity).motionZ); } }