public void updateControllerSettings(IFuelDock dock) { HashSet<ILandingPadAttachable> connectedTiles = dock.getConnectedTiles(); try { Class<?> controllerClass = Class.forName( "micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController"); for (ILandingPadAttachable connectedTile : connectedTiles) { if (connectedTile != null) { TileEntity updatedTile = this.worldObj.getTileEntity(((TileEntity) connectedTile).getPos()); try { controllerClass.cast(updatedTile); } catch (ClassCastException e) { continue; } controllerClass.getField("attachedDock").set(updatedTile, dock); Boolean autoLaunchEnabled = controllerClass.getField("launchSchedulingEnabled").getBoolean(updatedTile); if (autoLaunchEnabled) { this.autoLaunchSetting = EnumAutoLaunch.values()[ controllerClass.getField("launchDropdownSelection").getInt(updatedTile)]; switch (this.autoLaunchSetting) { case INSTANT: // Small countdown to give player a moment to jump out of the rocket this.autoLaunchCountdown = 12; break; case TIME_10_SECONDS: this.autoLaunchCountdown = 200; break; case TIME_30_SECONDS: this.autoLaunchCountdown = 600; break; case TIME_1_MINUTE: this.autoLaunchCountdown = 1200; break; default: break; } } else { this.autoLaunchSetting = null; } break; } } } catch (Exception e) { e.printStackTrace(); } }
@Override protected void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); if (nbt.hasKey("fuelTank")) { this.fuelTank.readFromNBT(nbt.getCompoundTag("fuelTank")); } if (this.getSizeInventory() > 0) { final NBTTagList var2 = nbt.getTagList("Items", 10); this.cargoItems = new ItemStack[this.getSizeInventory()]; for (int var3 = 0; var3 < var2.tagCount(); ++var3) { final NBTTagCompound var4 = var2.getCompoundTagAt(var3); final int var5 = var4.getByte("Slot") & 255; if (var5 < this.cargoItems.length) { this.cargoItems[var5] = ItemStack.loadItemStackFromNBT(var4); } } } if (nbt.getBoolean("TargetValid") && nbt.hasKey("targetTileX")) { this.targetVec = new BlockPos( MathHelper.floor_double(nbt.getDouble("targetTileX")), MathHelper.floor_double(nbt.getDouble("targetTileY")), MathHelper.floor_double(nbt.getDouble("targetTileZ"))); } this.setWaitForPlayer(nbt.getBoolean("WaitingForPlayer")); this.landing = nbt.getBoolean("Landing"); int autoLaunchValue = nbt.getInteger("AutoLaunchSetting"); this.autoLaunchSetting = autoLaunchValue == -1 ? null : EnumAutoLaunch.values()[autoLaunchValue]; this.autoLaunchCountdown = nbt.getInteger("TimeUntilAutoLaunch"); this.destinationFrequency = nbt.getInteger("DestinationFrequency"); }