@Override public void onLivingUpdate() { if (this.worldObj.provider instanceof WorldProviderOrbit && ((WorldProviderOrbit) this.worldObj.provider).doSpinning) { ((WorldProviderOrbit) this.worldObj.provider).spinUpdate(this); } if (this.boundingBox != null && this.boundingBoxBefore == null) { this.boundingBoxBefore = this.boundingBox; this.boundingBox.setBounds( this.boundingBoxBefore.minX + 0.4, this.boundingBoxBefore.minY + 0.9, this.boundingBoxBefore.minZ + 0.4, this.boundingBoxBefore.maxX - 0.4, this.boundingBoxBefore.maxY - 0.9, this.boundingBoxBefore.maxZ - 0.4); } else if (this.boundingBox != null && this.boundingBoxBefore != null) { this.boundingBox.setBB(this.boundingBoxBefore); } super.onLivingUpdate(); // // If the player is on the moon, not airbourne and not riding anything // if (this.worldObj != null && this.worldObj.provider instanceof GCMoonWorldProvider && // this.onGround && this.ridingEntity == null) // { // int iPosX = (int)Math.floor(this.posX); // int iPosY = (int)Math.floor(this.posY - 2); // int iPosZ = (int)Math.floor(this.posZ); // // // If the block below is the moon block // if (this.worldObj.getBlock(iPosX, iPosY, iPosZ) == GCCoreBlocks.blockMoon) // { // // And is the correct metadata (moon turf) // if (this.worldObj.getBlockMetadata(iPosX, iPosY, iPosZ) == 5) // { // // If it has been long enough since the last step // if (this.distanceSinceLastStep > 0.09) // { // Vector3 pos = new Vector3(this); // // Set the footprint position to the block below and add random number to stop // z-fighting // pos.y = MathHelper.floor_double(this.posY - 1) + this.rand.nextFloat() / 100.0F; // // // Adjust footprint to left or right depending on step count // switch (this.lastStep) // { // case 0: // pos.translate(new Vector3(Math.sin(Math.toRadians(-this.rotationYaw + 90)) * 0.25, 0, // Math.cos(Math.toRadians(-this.rotationYaw + 90)) * 0.25)); // break; // case 1: // pos.translate(new Vector3(Math.sin(Math.toRadians(-this.rotationYaw - 90)) * 0.25, 0, // Math.cos(Math.toRadians(-this.rotationYaw - 90)) * 0.25)); // break; // } // // ClientProxyCore.footprintRenderer.addFootprint(pos, this.rotationYaw); // // // Increment and cap step counter at 1 // this.lastStep++; // this.lastStep %= 2; // this.distanceSinceLastStep = 0; // } // else // { // double motionSqrd = (this.motionX * this.motionX + this.motionZ * this.motionZ); // // // Even when the player is still, motion isn't exactly zero // if (motionSqrd > 0.001) // { // this.distanceSinceLastStep += motionSqrd; // } // } // } // } // } if (!this.onGround && this.lastOnGround) { this.touchedGround = true; } if (this.getParachute()) { this.fallDistance = 0.0F; } PlayerGearData gearData = null; for (PlayerGearData gearData2 : ClientProxyCore.playerItemData) { if (gearData2 .getPlayer() .getGameProfile() .getName() .equals(this.getGameProfile().getName())) { gearData = gearData2; break; } } this.usingParachute = false; if (gearData != null) { this.usingParachute = gearData.getParachute() != null; } if (this.getParachute() && this.onGround) { this.setParachute(false); FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = this.getThirdPersonView(); } if (!this.lastUsingParachute && this.usingParachute) { FMLClientHandler.instance() .getClient() .getSoundHandler() .playSound( new PositionedSoundRecord( new ResourceLocation(GalacticraftCore.ASSET_PREFIX + "player.parachute"), (float) this.posX, (float) this.posY, (float) this.posZ, 0.95F + this.rand.nextFloat() * 0.1F, 1.0F)); } this.lastUsingParachute = this.usingParachute; this.lastOnGround = this.onGround; }
@SideOnly(Side.CLIENT) @Override public void handleClientSide(EntityPlayer player) { GCEntityClientPlayerMP playerBaseClient = null; if (player instanceof GCEntityClientPlayerMP) { playerBaseClient = (GCEntityClientPlayerMP) player; } else { return; } switch (this.type) { case C_AIR_REMAINING: if (String.valueOf(this.data.get(2)) .equals( String.valueOf( FMLClientHandler.instance() .getClient() .thePlayer .getGameProfile() .getName()))) { TickHandlerClient.airRemaining = (Integer) this.data.get(0); TickHandlerClient.airRemaining2 = (Integer) this.data.get(1); } break; case C_UPDATE_DIMENSION_LIST: if (String.valueOf(this.data.get(0)) .equals(FMLClientHandler.instance().getClient().thePlayer.getGameProfile().getName())) { final String[] destinations = ((String) this.data.get(1)).split("\\."); if (FMLClientHandler.instance().getClient().theWorld != null && !(FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection || FMLClientHandler.instance().getClient().currentScreen instanceof GuiGalaxyMap)) { FMLClientHandler.instance().getClient().displayGuiScreen(new GuiCelestialSelection()); } } break; case C_SPAWN_SPARK_PARTICLES: int x, y, z; x = (Integer) this.data.get(0); y = (Integer) this.data.get(1); z = (Integer) this.data.get(2); Minecraft mc = Minecraft.getMinecraft(); for (int i = 0; i < 4; i++) { if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null && mc.theWorld != null) { final EntityFX fx = new EntityFXSparks( mc.theWorld, x - 0.15 + 0.5, y + 1.2, z + 0.15 + 0.5, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20, mc.theWorld.rand.nextDouble() / 20 - mc.theWorld.rand.nextDouble() / 20); if (fx != null) { mc.effectRenderer.addEffect(fx); } } } break; case C_UPDATE_GEAR_SLOT: int subtype = (Integer) this.data.get(2); EntityPlayer gearDataPlayer = null; MinecraftServer server = MinecraftServer.getServer(); if (server != null) { gearDataPlayer = server.getConfigurationManager().getPlayerForUsername((String) this.data.get(0)); } else { gearDataPlayer = player.worldObj.getPlayerEntityByName((String) this.data.get(0)); } if (gearDataPlayer != null) { PlayerGearData gearData = ClientProxyCore.playerItemData.get(gearDataPlayer.getPersistentID()); if (gearData == null) { gearData = new PlayerGearData(player); } EnumModelPacket type = EnumModelPacket.values()[(Integer) this.data.get(1)]; switch (type) { case ADDMASK: gearData.setMask(0); break; case REMOVEMASK: gearData.setMask(-1); break; case ADDGEAR: gearData.setGear(0); break; case REMOVEGEAR: gearData.setGear(-1); break; case ADDLEFTGREENTANK: gearData.setLeftTank(0); break; case ADDLEFTORANGETANK: gearData.setLeftTank(1); break; case ADDLEFTREDTANK: gearData.setLeftTank(2); break; case ADDRIGHTGREENTANK: gearData.setRightTank(0); break; case ADDRIGHTORANGETANK: gearData.setRightTank(1); break; case ADDRIGHTREDTANK: gearData.setRightTank(2); break; case REMOVE_LEFT_TANK: gearData.setLeftTank(-1); break; case REMOVE_RIGHT_TANK: gearData.setRightTank(-1); break; case ADD_PARACHUTE: String name = ""; if (subtype != -1) { name = ItemParaChute.names[subtype]; gearData.setParachute( new ResourceLocation( GalacticraftCore.ASSET_DOMAIN, "textures/model/parachute/" + name + ".png")); } break; case REMOVE_PARACHUTE: gearData.setParachute(null); break; case ADD_FREQUENCY_MODULE: gearData.setFrequencyModule(0); break; case REMOVE_FREQUENCY_MODULE: gearData.setFrequencyModule(-1); break; case ADD_THERMAL_HELMET: gearData.setThermalPadding(0, 0); break; case ADD_THERMAL_CHESTPLATE: gearData.setThermalPadding(1, 0); break; case ADD_THERMAL_LEGGINGS: gearData.setThermalPadding(2, 0); break; case ADD_THERMAL_BOOTS: gearData.setThermalPadding(3, 0); break; case REMOVE_THERMAL_HELMET: gearData.setThermalPadding(0, -1); break; case REMOVE_THERMAL_CHESTPLATE: gearData.setThermalPadding(1, -1); break; case REMOVE_THERMAL_LEGGINGS: gearData.setThermalPadding(2, -1); break; case REMOVE_THERMAL_BOOTS: gearData.setThermalPadding(3, -1); break; default: break; } ClientProxyCore.playerItemData.put(playerBaseClient.getPersistentID(), gearData); } break; case C_CLOSE_GUI: FMLClientHandler.instance().getClient().displayGuiScreen(null); break; case C_RESET_THIRD_PERSON: FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = playerBaseClient.getThirdPersonView(); break; case C_UPDATE_SPACESTATION_LIST: try { if (WorldUtil.registeredSpaceStations != null) { for (Integer registeredID : WorldUtil.registeredSpaceStations) { DimensionManager.unregisterDimension(registeredID); } } WorldUtil.registeredSpaceStations = new ArrayList<Integer>(); if (this.data.size() > 0) { if (this.data.get(0) instanceof Integer) { for (Object o : this.data) { Integer dimID = (Integer) o; if (!WorldUtil.registeredSpaceStations.contains(dimID)) { WorldUtil.registeredSpaceStations.add(dimID); if (!DimensionManager.isDimensionRegistered(dimID)) { DimensionManager.registerDimension( dimID, ConfigManagerCore.idDimensionOverworldOrbit); } else { GCLog.severe( "Dimension already registered on client: unable to register space station dimension " + dimID); } } } } else if (this.data.get(0) instanceof Integer[]) { for (Object o : (Integer[]) this.data.get(0)) { Integer dimID = (Integer) o; if (!WorldUtil.registeredSpaceStations.contains(dimID)) { WorldUtil.registeredSpaceStations.add(dimID); if (!DimensionManager.isDimensionRegistered(dimID)) { DimensionManager.registerDimension( dimID, ConfigManagerCore.idDimensionOverworldOrbit); } else { GCLog.severe( "Dimension already registered on client: unable to register space station dimension " + dimID); } } } } } break; } catch (final Exception e) { e.printStackTrace(); } case C_UPDATE_SPACESTATION_DATA: SpaceStationWorldData var4 = SpaceStationWorldData.getMPSpaceStationData( player.worldObj, (Integer) this.data.get(0), player); var4.readFromNBT((NBTTagCompound) this.data.get(1)); break; case C_UPDATE_SPACESTATION_CLIENT_ID: ClientProxyCore.clientSpaceStationID = (Integer) this.data.get(0); break; case C_UPDATE_PLANETS_LIST: try { if (WorldUtil.registeredPlanets != null) { for (Integer registeredID : WorldUtil.registeredPlanets) { DimensionManager.unregisterDimension(registeredID); } } WorldUtil.registeredPlanets = new ArrayList<Integer>(); if (this.data.size() > 0) { if (this.data.get(0) instanceof Integer) { for (Object o : this.data) { Integer dimID = (Integer) o; if (!WorldUtil.registeredPlanets.contains(dimID)) { WorldUtil.registeredPlanets.add(dimID); DimensionManager.registerDimension(dimID, dimID); } } } else if (this.data.get(0) instanceof Integer[]) { for (Object o : (Integer[]) this.data.get(0)) { Integer dimID = (Integer) o; if (!WorldUtil.registeredPlanets.contains(dimID)) { WorldUtil.registeredPlanets.add(dimID); DimensionManager.registerDimension(dimID, dimID); } } } } break; } catch (final Exception e) { e.printStackTrace(); } case C_ADD_NEW_SCHEMATIC: final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0)); if (!playerBaseClient.unlockedSchematics.contains(page)) { playerBaseClient.unlockedSchematics.add(page); } break; case C_UPDATE_SCHEMATIC_LIST: for (Object o : this.data) { Integer schematicID = (Integer) o; if (schematicID != -2) { Collections.sort(playerBaseClient.unlockedSchematics); if (!playerBaseClient.unlockedSchematics.contains( SchematicRegistry.getMatchingRecipeForID(Integer.valueOf(schematicID)))) { playerBaseClient.unlockedSchematics.add( SchematicRegistry.getMatchingRecipeForID(Integer.valueOf(schematicID))); } } } break; case C_PLAY_SOUND_BOSS_DEATH: player.playSound(GalacticraftCore.ASSET_PREFIX + "entity.bossdeath", 10.0F, 0.8F); break; case C_PLAY_SOUND_EXPLODE: player.playSound("random.explode", 10.0F, 0.7F); break; case C_PLAY_SOUND_BOSS_LAUGH: player.playSound(GalacticraftCore.ASSET_PREFIX + "entity.bosslaugh", 10.0F, 0.2F); break; case C_PLAY_SOUND_BOW: player.playSound("random.bow", 10.0F, 0.2F); break; case C_UPDATE_OXYGEN_VALIDITY: playerBaseClient.oxygenSetupValid = (Boolean) this.data.get(0); break; case C_OPEN_PARACHEST_GUI: switch ((Integer) this.data.get(1)) { case 0: if (player.ridingEntity instanceof EntityBuggy) { FMLClientHandler.instance() .getClient() .displayGuiScreen( new GuiBuggy( player.inventory, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType())); player.openContainer.windowId = (Integer) this.data.get(0); } break; case 1: int entityID = (Integer) this.data.get(2); Entity entity = player.worldObj.getEntityByID(entityID); if (entity != null && entity instanceof IInventorySettable) { FMLClientHandler.instance() .getClient() .displayGuiScreen( new GuiParaChest(player.inventory, (IInventorySettable) entity)); } player.openContainer.windowId = (Integer) this.data.get(0); break; } break; case C_UPDATE_WIRE_BOUNDS: TileEntity tile = player.worldObj.getTileEntity( (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2)); if (tile instanceof TileEntityConductor) { ((TileEntityConductor) tile).adjacentConnections = null; player .worldObj .getBlock(tile.xCoord, tile.yCoord, tile.zCoord) .setBlockBoundsBasedOnState(player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord); } break; case C_OPEN_SPACE_RACE_GUI: if (Minecraft.getMinecraft().currentScreen == null) { TickHandlerClient.spaceRaceGuiScheduled = false; player.openGui( GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); } else { TickHandlerClient.spaceRaceGuiScheduled = true; } break; case C_UPDATE_SPACE_RACE_DATA: Integer teamID = (Integer) this.data.get(0); String teamName = (String) this.data.get(1); FlagData flagData = (FlagData) this.data.get(2); Vector3 teamColor = (Vector3) this.data.get(3); List<String> playerList = new ArrayList<String>(); for (int i = 4; i < this.data.size(); i++) { String playerName = (String) this.data.get(i); ClientProxyCore.flagRequestsSent.remove(playerName); playerList.add(playerName); } SpaceRace race = new SpaceRace(playerList, teamName, flagData, teamColor); race.setSpaceRaceID(teamID); SpaceRaceManager.addSpaceRace(race); break; case C_OPEN_JOIN_RACE_GUI: playerBaseClient.spaceRaceInviteTeamID = (Integer) this.data.get(0); player.openGui( GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_JOIN, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); break; case C_UPDATE_FOOTPRINT_LIST: ClientProxyCore.footprintRenderer.footprints.clear(); for (int i = 0; i < this.data.size(); i++) { Footprint print = (Footprint) this.data.get(i); ClientProxyCore.footprintRenderer.addFootprint(print); } break; case C_UPDATE_STATION_SPIN: if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) { ((WorldProviderOrbit) playerBaseClient.worldObj.provider) .setSpinRate((Float) this.data.get(0), (Boolean) this.data.get(1)); } break; case C_UPDATE_STATION_DATA: if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) { ((WorldProviderOrbit) playerBaseClient.worldObj.provider) .setSpinCentre((Double) this.data.get(0), (Double) this.data.get(1)); } break; case C_UPDATE_STATION_BOX: if (playerBaseClient.worldObj.provider instanceof WorldProviderOrbit) { ((WorldProviderOrbit) playerBaseClient.worldObj.provider) .setSpinBox( (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3), (Integer) this.data.get(4), (Integer) this.data.get(5)); } break; case C_UPDATE_THERMAL_LEVEL: playerBaseClient.thermalLevel = (Integer) this.data.get(0); break; case C_DISPLAY_ROCKET_CONTROLS: player.addChatMessage( new ChatComponentText( Keyboard.getKeyName(KeyHandlerClient.spaceKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.launch.name"))); player.addChatMessage( new ChatComponentText( Keyboard.getKeyName(KeyHandlerClient.leftKey.getKeyCode()) + " / " + Keyboard.getKeyName(KeyHandlerClient.rightKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.turn.name"))); player.addChatMessage( new ChatComponentText( Keyboard.getKeyName(KeyHandlerClient.accelerateKey.getKeyCode()) + " / " + Keyboard.getKeyName(KeyHandlerClient.decelerateKey.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.updown.name"))); player.addChatMessage( new ChatComponentText( Keyboard.getKeyName(KeyHandlerClient.openFuelGui.getKeyCode()) + " - " + GCCoreUtil.translate("gui.rocket.inv.name"))); break; default: break; } }
@Override public void onLivingUpdatePost(EntityPlayerSP player) { GCPlayerStatsClient stats = GCPlayerStatsClient.get(player); if (player.worldObj.provider instanceof WorldProviderOrbit) { ((WorldProviderOrbit) player.worldObj.provider).postVanillaMotion(player); if (stats.inFreefall) { // No limb swing player.limbSwing -= player.limbSwingAmount; player.limbSwingAmount = player.prevLimbSwingAmount; float adjust = Math.min(Math.abs(player.limbSwing), Math.abs(player.limbSwingAmount) / 3); if (player.limbSwing < 0) player.limbSwing += adjust; else if (player.limbSwing > 0) player.limbSwing -= adjust; player.limbSwingAmount *= 0.9; } else { if (stats.inFreefallLast && this.downMot2 < -0.01D) { stats.landingTicks = 2 - (int) (Math.min(this.downMot2, stats.downMotionLast) * 75); if (stats.landingTicks > 6) stats.landingTicks = 6; } } if (stats.landingTicks > 0) stats.landingTicks--; } else stats.inFreefall = false; boolean ridingThirdPersonEntity = player.ridingEntity instanceof ICameraZoomEntity && ((ICameraZoomEntity) player.ridingEntity).defaultThirdPerson(); if (ridingThirdPersonEntity && !stats.lastRidingCameraZoomEntity) { FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = 1; } if (player.ridingEntity != null && player.ridingEntity instanceof ICameraZoomEntity) { stats.lastZoomed = true; TickHandlerClient.zoom(((ICameraZoomEntity) player.ridingEntity).getCameraZoom()); } else if (stats.lastZoomed) { stats.lastZoomed = false; TickHandlerClient.zoom(4.0F); } stats.lastRidingCameraZoomEntity = ridingThirdPersonEntity; if (stats.usingParachute) { player.fallDistance = 0.0F; } PlayerGearData gearData = ModelPlayerGC.getGearData(player); stats.usingParachute = false; if (gearData != null) { stats.usingParachute = gearData.getParachute() != null; if (gearData.getMask() >= 0) { player.height = 1.9375F; } else { player.height = 1.8F; } AxisAlignedBB bounds = player.getEntityBoundingBox(); player.setEntityBoundingBox( new AxisAlignedBB( bounds.minX, bounds.minY, bounds.minZ, bounds.maxX, bounds.minY + (double) player.height, bounds.maxZ)); } if (stats.usingParachute && player.onGround) { stats.setParachute(false); FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.thirdPersonView; } if (!stats.lastUsingParachute && stats.usingParachute) { FMLClientHandler.instance() .getClient() .getSoundHandler() .playSound( new PositionedSoundRecord( new ResourceLocation(GalacticraftCore.TEXTURE_PREFIX + "player.parachute"), 0.95F + player.getRNG().nextFloat() * 0.1F, 1.0F, (float) player.posX, (float) player.posY, (float) player.posZ)); } stats.lastUsingParachute = stats.usingParachute; stats.lastOnGround = player.onGround; }