@Override public void initGui() { super.initGui(); List<String> batterySlotDesc = new ArrayList<String>(); batterySlotDesc.add(GCCoreUtil.translate("gui.batterySlot.desc.0")); batterySlotDesc.add(GCCoreUtil.translate("gui.batterySlot.desc.1")); this.infoRegions.add( new GuiElementInfoRegion( (this.width - this.xSize) / 2 + 31, (this.height - this.ySize) / 2 + 26, 18, 18, batterySlotDesc, this.width, this.height, this)); this.oxygenInfoRegion.xPosition = (this.width - this.xSize) / 2 + 112; this.oxygenInfoRegion.yPosition = (this.height - this.ySize) / 2 + 24; this.oxygenInfoRegion.parentWidth = this.width; this.oxygenInfoRegion.parentHeight = this.height; this.infoRegions.add(this.oxygenInfoRegion); this.electricInfoRegion.xPosition = (this.width - this.xSize) / 2 + 112; this.electricInfoRegion.yPosition = (this.height - this.ySize) / 2 + 37; this.electricInfoRegion.parentWidth = this.width; this.electricInfoRegion.parentHeight = this.height; this.infoRegions.add(this.electricInfoRegion); }
@Override public String getShiftDescription(int meta) { switch (meta) { case METADATA_CARGO_LOADER: return GCCoreUtil.translate("tile.cargo_loader.description"); case METADATA_CARGO_UNLOADER: return GCCoreUtil.translate("tile.cargo_unloader.description"); } return ""; }
private String getStatus() { if (this.collector.getEnergyStoredGC() == 0) { return EnumColor.DARK_RED + GCCoreUtil.translate("gui.status.missingpower.name"); } if (this.collector.lastOxygenCollected <= 0.0F) { return EnumColor.DARK_RED + GCCoreUtil.translate("gui.status.missingleaves.name"); } return EnumColor.DARK_GREEN + GCCoreUtil.translate("gui.status.active.name"); }
@SideOnly(Side.CLIENT) public String getSendingStatus() { if (!this.addressValid) { return EnumColor.RED + GCCoreUtil.translate("gui.message.invalid_target_address.name"); } if (this.targetAddressResult == TileEntityShortRangeTelepad.EnumTelepadSearchResult.TOO_FAR) { return EnumColor.RED + GCCoreUtil.translateWithFormat("gui.message.telepad_too_far.name", TELEPORTER_RANGE); } if (this.targetAddressResult == TileEntityShortRangeTelepad.EnumTelepadSearchResult.WRONG_DIM) { return EnumColor.RED + GCCoreUtil.translate("gui.message.telepad_wrong_dim.name"); } if (this.targetAddressResult == TileEntityShortRangeTelepad.EnumTelepadSearchResult.NOT_FOUND) { return EnumColor.RED + GCCoreUtil.translate("gui.message.telepad_not_found.name"); } if (this.getEnergyStoredGC() <= 0.0F) { return EnumColor.RED + GCCoreUtil.translate("gui.message.no_energy.name"); } if (this.getEnergyStoredGC() <= ENERGY_USE_ON_TELEPORT) { return EnumColor.RED + GCCoreUtil.translate("gui.message.not_enough_energy.name"); } if (this.getDisabled(0)) { return EnumColor.ORANGE + GCCoreUtil.translate("gui.status.disabled.name"); } return EnumColor.BRIGHT_GREEN + GCCoreUtil.translate("gui.message.sending_active.name"); }
public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); final int var5 = (this.width - this.width / 4) / 2; final int var6 = (this.height - this.height / 4) / 2; if (this.initialized) { this.drawCenteredString( this.fontRendererObj, "Join Space Race", this.width / 2, this.height / 2 - this.height / 3 - 15, 16777215); this.drawFlagButton(par1, par2); this.drawCenteredString( this.fontRendererObj, "Owner: " + this.spaceRaceData.getPlayerNames().get(0), this.width / 2, (int) (this.buttonFlag_yPosition + this.buttonFlag_height + 25), GCCoreUtil.to32BitColor(255, 150, 150, 150)); this.drawCenteredString( this.fontRendererObj, this.spaceRaceData.getPlayerNames().size() + " members", this.width / 2, (int) (this.buttonFlag_yPosition + this.buttonFlag_height + 40), GCCoreUtil.to32BitColor(255, 150, 150, 150)); GL11.glPushMatrix(); GL11.glTranslatef( this.width / 2, (int) (this.buttonFlag_yPosition + this.buttonFlag_height + 5) + FMLClientHandler.instance().getClient().fontRenderer.FONT_HEIGHT / 2, 0); GL11.glScalef(1.5F, 1.5F, 1.0F); GL11.glTranslatef( -this.width / 2, (int) -(this.buttonFlag_yPosition + this.buttonFlag_height + 5) - FMLClientHandler.instance().getClient().fontRenderer.FONT_HEIGHT / 2, 0); this.drawCenteredString( this.fontRendererObj, this.spaceRaceData.getTeamName(), this.width / 2, (int) (this.buttonFlag_yPosition + this.buttonFlag_height + 5), GCCoreUtil.to32BitColor(255, 100, 150, 20)); GL11.glPopMatrix(); } super.drawScreen(par1, par2, par3); }
@Override public void onLivingUpdate() { final EntityPlayer player = this.worldObj.getClosestPlayer(this.posX, this.posY, this.posZ, 20.0); if (player != null && !player.equals(this.targetEntity)) { if (this.getDistanceSqToEntity(player) < 400.0D) { this.getNavigator().getPathToEntityLiving(player); this.targetEntity = player; } } else { this.targetEntity = null; } new Vector3(this); if (this.roomCoords != null && this.roomSize != null) { @SuppressWarnings("unchecked") List<Entity> entitiesWithin = this.worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getBoundingBox( this.roomCoords.intX() - 1, this.roomCoords.intY() - 1, this.roomCoords.intZ() - 1, this.roomCoords.intX() + this.roomSize.intX(), this.roomCoords.intY() + this.roomSize.intY(), this.roomCoords.intZ() + this.roomSize.intZ())); this.entitiesWithin = entitiesWithin.size(); if (this.entitiesWithin == 0 && this.entitiesWithinLast != 0) { @SuppressWarnings("unchecked") List<EntityPlayer> entitiesWithin2 = this.worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.getBoundingBox( this.roomCoords.intX() - 11, this.roomCoords.intY() - 11, this.roomCoords.intZ() - 11, this.roomCoords.intX() + this.roomSize.intX() + 10, this.roomCoords.intY() + this.roomSize.intY() + 10, this.roomCoords.intZ() + this.roomSize.intZ() + 10)); for (EntityPlayer p : entitiesWithin2) { p.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.skeletonBoss.message"))); } this.setDead(); if (this.spawner != null) { this.spawner.playerCheated = true; } return; } } super.onLivingUpdate(); }
@Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(GuiOxygenCollector.collectorTexture); final int var5 = (this.width - this.xSize) / 2; final int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6 + 5, 0, 0, this.xSize, 181); if (this.collector != null) { int scale = this.collector.getCappedScaledOxygenLevel(54); this.drawTexturedModalRect(var5 + 113, var6 + 25, 197, 7, Math.min(scale, 54), 7); scale = this.collector.getScaledElecticalLevel(54); this.drawTexturedModalRect(var5 + 113, var6 + 38, 197, 0, Math.min(scale, 54), 7); if (this.collector.getEnergyStoredGC() > 0) { this.drawTexturedModalRect(var5 + 99, var6 + 37, 176, 0, 11, 10); } if (this.collector.storedOxygen > 0) { this.drawTexturedModalRect(var5 + 100, var6 + 24, 187, 0, 10, 10); } List<String> oxygenDesc = new ArrayList<String>(); oxygenDesc.add(GCCoreUtil.translate("gui.oxygenStorage.desc.0")); oxygenDesc.add( EnumColor.YELLOW + GCCoreUtil.translate("gui.oxygenStorage.desc.1") + ": " + ((int) Math.floor(this.collector.storedOxygen) + " / " + (int) Math.floor(this.collector.maxOxygen))); this.oxygenInfoRegion.tooltipStrings = oxygenDesc; List<String> electricityDesc = new ArrayList<String>(); electricityDesc.add(GCCoreUtil.translate("gui.energyStorage.desc.0")); EnergyDisplayHelper.getEnergyDisplayTooltip( this.collector.getEnergyStoredGC(), this.collector.getMaxEnergyStoredGC(), electricityDesc); // electricityDesc.add(EnumColor.YELLOW + GCCoreUtil.translate("gui.energyStorage.desc.1") + // ((int) Math.floor(this.collector.getEnergyStoredGC()) + " / " + (int) // Math.floor(this.collector.getMaxEnergyStoredGC()))); this.electricInfoRegion.tooltipStrings = electricityDesc; } }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) { if (itemStack != null && itemStack.getItemDamage() == 3) { if (player.worldObj.isRemote) { list.add(EnumChatFormatting.GRAY + GCCoreUtil.translate("tier10.heavyDutyPlate.name")); } } }
public void cancelLaunch() { this.setLaunchPhase(EnumLaunchPhase.UNIGNITED); this.timeUntilLaunch = 0; if (!this.worldObj.isRemote && this.riddenByEntity instanceof EntityPlayerMP) { ((EntityPlayerMP) this.riddenByEntity) .addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nogyroscope"))); } }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @SideOnly(Side.CLIENT) public void addInformation( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (par1ItemStack.getItemDamage() > 14 && par1ItemStack.getItemDamage() < 19) { par3List.add( EnumColor.BRIGHT_GREEN + GCCoreUtil.translate( this.getUnlocalizedName() + "." + ItemBasic.names[par1ItemStack.getItemDamage()] + ".name")); } else if (par1ItemStack.getItemDamage() == 19) { par3List.add(EnumColor.AQUA + GCCoreUtil.translate("gui.frequencyModule.desc.0")); par3List.add(EnumColor.AQUA + GCCoreUtil.translate("gui.frequencyModule.desc.1")); } }
@SideOnly(Side.CLIENT) public String getReceivingStatus() { if (!this.addressValid) { return EnumColor.RED + GCCoreUtil.translate("gui.message.invalid_address.name"); } if (this.getEnergyStoredGC() <= 0.0F) { return EnumColor.RED + GCCoreUtil.translate("gui.message.no_energy.name"); } if (this.getEnergyStoredGC() <= ENERGY_USE_ON_TELEPORT) { return EnumColor.RED + GCCoreUtil.translate("gui.message.not_enough_energy.name"); } if (this.getDisabled(0)) { return EnumColor.ORANGE + GCCoreUtil.translate("gui.status.disabled.name"); } return EnumColor.BRIGHT_GREEN + GCCoreUtil.translate("gui.message.receiving_active.name"); }
@SuppressWarnings({"unchecked", "rawtypes"}) @Override @SideOnly(Side.CLIENT) public void addInformation( ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage() > 0) { par3List.add( GCCoreUtil.translate("item.canister.LOX.name") + ": " + (par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage())); } }
@Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRendererObj.drawString(this.collector.getInventoryName(), 8, 10, 4210752); this.fontRendererObj.drawString( GCCoreUtil.translate("gui.message.out.name") + ":", 81, 25, 4210752); this.fontRendererObj.drawString( GCCoreUtil.translate("gui.message.in.name") + ":", 87, 37, 4210752); String status = GCCoreUtil.translate("gui.message.status.name") + ": " + this.getStatus(); this.fontRendererObj.drawString( status, this.xSize / 2 - this.fontRendererObj.getStringWidth(status) / 2, 50, 4210752); status = GCCoreUtil.translate("gui.status.collecting.name") + ": " + (int) Math.min( this.collector.lastOxygenCollected, TileEntityOxygenCollector.OUTPUT_PER_TICK) * 20 + GCCoreUtil.translate("gui.perSecond"); this.fontRendererObj.drawString( status, this.xSize / 2 - this.fontRendererObj.getStringWidth(status) / 2, 60, 4210752); // status = EnergyDisplayHelper.getEnergyDisplayS(TileEntityOxygenCollector.WATTS_PER_TICK) + // "gJ/t"; // this.fontRendererObj.drawString(status, this.xSize / 2 - // this.fontRendererObj.getStringWidth(status) / 2, 70, 4210752); // status = ElectricityDisplay.getDisplay(this.collector.getVoltage(), ElectricUnit.VOLTAGE); // this.fontRendererObj.drawString(status, this.xSize / 2 - // this.fontRendererObj.getStringWidth(status) / 2, 80, 4210752); this.fontRendererObj.drawString( GCCoreUtil.translate("container.inventory"), 8, this.ySize - 90 + 2, 4210752); }
@Override public void drawScreen(int par1, int par2, float par3) { final int var5 = (this.width - this.xSize) / 2; final int var6 = (this.height - this.ySize) / 2; this.mc.renderEngine.bindTexture(GuiAirLockController.airLockControllerGui); this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(var5 + 15, var6 + 51, 176, 0, 7, 9); String displayString = this.controller.ownerName + "\'s " + "Air Lock Controller"; this.fontRendererObj.drawString( displayString, this.width / 2 - this.fontRendererObj.getStringWidth(displayString) / 2, this.height / 2 - 65, 4210752); if (this.cannotEditTimer > 0) { this.fontRendererObj.drawString( this.controller.ownerName, this.width / 2 - this.fontRendererObj.getStringWidth(displayString) / 2, this.height / 2 - 65, this.cannotEditTimer % 30 < 15 ? GCCoreUtil.to32BitColor(255, 255, 100, 100) : 4210752); this.cannotEditTimer--; } displayString = "Status:"; this.fontRendererObj.drawString( displayString, this.width / 2 - this.fontRendererObj.getStringWidth(displayString) / 2, this.height / 2 + 45, 4210752); displayString = "Air Lock Closed"; if (this.controller.active) { displayString = "Air Lock Closed"; } else { displayString = "Air Lock Open"; } this.fontRendererObj.drawString( displayString, this.width / 2 - this.fontRendererObj.getStringWidth(displayString) / 2, this.height / 2 + 55, 4210752); super.drawScreen(par1, par2, par3); }
@Override public void onBlockPlacedBy( World world, int x0, int y0, int z0, EntityLivingBase entityLiving, ItemStack itemStack) { super.onBlockPlacedBy(world, x0, y0, z0, entityLiving, itemStack); TileEntity tile = world.getTileEntity(x0, y0, z0); boolean validSpot = true; for (int x = -1; x <= 1; x++) { for (int y = 0; y < 3; y += 2) { for (int z = -1; z <= 1; z++) { if (!(x == 0 && y == 0 && z == 0)) { Block blockAt = world.getBlock(x0 + x, y0 + y, z0 + z); if (!blockAt.getMaterial().isReplaceable()) { validSpot = false; } } } } } if (!validSpot) { world.setBlockToAir(x0, y0, z0); if (entityLiving instanceof EntityPlayer) { if (!world.isRemote) { ((EntityPlayer) entityLiving) .addChatMessage( new ChatComponentText( EnumColor.RED + GCCoreUtil.translate("gui.warning.noroom"))); } ((EntityPlayer) entityLiving) .inventory.addItemStackToInventory(new ItemStack(Item.getItemFromBlock(this), 1, 0)); } return; } if (tile instanceof TileEntityShortRangeTelepad) { ((TileEntityShortRangeTelepad) tile).onCreate(new BlockVec3(x0, y0, z0)); ((TileEntityShortRangeTelepad) tile) .setOwner(((EntityPlayer) entityLiving).getGameProfile().getName()); } }
@Override public boolean onLeftClickEntity(ItemStack itemStack, EntityPlayer player, Entity entity) { if (itemStack.getItemDamage() != 19) return false; // Frequency module if (!player.worldObj.isRemote && entity != null && !(entity instanceof EntityPlayer)) { if (itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } itemStack.stackTagCompound.setLong( "linkedUUIDMost", entity.getUniqueID().getMostSignificantBits()); itemStack.stackTagCompound.setLong( "linkedUUIDLeast", entity.getUniqueID().getLeastSignificantBits()); player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.tracking.message"))); return true; } return false; }
@Override public String getName() { return GCCoreUtil.translate("container.short_range_telepad.name"); }
@Override public int getTextColor(GuiElementTextBox textBox) { return GCCoreUtil.to32BitColor(255, 200, 200, 200); }
@Override public void handleServerSide(EntityPlayer player) { GCEntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false); if (playerBase == null) { return; } switch (this.type) { case S_RESPAWN_PLAYER: playerBase.playerNetServerHandler.sendPacket( new S07PacketRespawn( player.dimension, player.worldObj.difficultySetting, player.worldObj.getWorldInfo().getTerrainType(), playerBase.theItemInWorldManager.getGameType())); break; case S_TELEPORT_ENTITY: try { final WorldProvider provider = WorldUtil.getProviderForName((String) this.data.get(0)); final Integer dim = provider.dimensionId; GCLog.info( "Found matching world (" + dim.toString() + ") for name: " + (String) this.data.get(0)); if (playerBase.worldObj instanceof WorldServer) { final WorldServer world = (WorldServer) playerBase.worldObj; if (provider instanceof IOrbitDimension) { WorldUtil.transferEntityToDimension(playerBase, dim, world); } else { WorldUtil.transferEntityToDimension(playerBase, dim, world); } } playerBase.getPlayerStats().teleportCooldown = 300; GalacticraftCore.packetPipeline.sendTo( new PacketSimple(EnumSimplePacket.C_CLOSE_GUI, new Object[] {}), playerBase); } catch (final Exception e) { GCLog.severe( "Error occurred when attempting to transfer entity to dimension: " + (String) this.data.get(0)); e.printStackTrace(); } break; case S_IGNITE_ROCKET: if (!player.worldObj.isRemote && !player.isDead && player.ridingEntity != null && !player.ridingEntity.isDead && player.ridingEntity instanceof EntityTieredRocket) { final EntityTieredRocket ship = (EntityTieredRocket) player.ridingEntity; if (!ship.landing) { if (ship.hasValidFuel()) { ItemStack stack2 = playerBase.getPlayerStats().extendedInventory.getStackInSlot(4); if (stack2 != null && stack2.getItem() instanceof ItemParaChute || playerBase.getPlayerStats().launchAttempts > 0) { ship.igniteCheckingCooldown(); playerBase.getPlayerStats().launchAttempts = 0; } else if (playerBase.getPlayerStats().chatCooldown == 0 && playerBase.getPlayerStats().launchAttempts == 0) { player.addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.noparachute"))); playerBase.getPlayerStats().chatCooldown = 250; playerBase.getPlayerStats().launchAttempts = 1; } } else if (playerBase.getPlayerStats().chatCooldown == 0) { player.addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nofuel"))); playerBase.getPlayerStats().chatCooldown = 250; } } } break; case S_OPEN_SCHEMATIC_PAGE: if (player != null) { final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0)); player.openGui( GalacticraftCore.instance, page.getGuiID(), player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); } break; case S_OPEN_FUEL_GUI: if (player.ridingEntity instanceof EntityBuggy) { GCCoreUtil.openBuggyInv( playerBase, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType()); } else if (player.ridingEntity instanceof EntitySpaceshipBase) { player.openGui( GalacticraftCore.instance, GuiIdsCore.ROCKET_INVENTORY, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); } break; case S_UPDATE_SHIP_YAW: if (player.ridingEntity instanceof EntitySpaceshipBase) { final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity; if (ship != null) { ship.rotationYaw = (Float) this.data.get(0); } } break; case S_UPDATE_SHIP_PITCH: if (player.ridingEntity instanceof EntitySpaceshipBase) { final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity; if (ship != null) { ship.rotationPitch = (Float) this.data.get(0); } } break; case S_SET_ENTITY_FIRE: Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0)); if (entity instanceof EntityLiving) { ((EntityLiving) entity).setFire(3); } break; case S_OPEN_REFINERY_GUI: player.openGui( GalacticraftCore.instance, -1, player.worldObj, (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2)); break; case S_BIND_SPACE_STATION_ID: if ((playerBase.getPlayerStats().spaceStationDimensionID == -1 || playerBase.getPlayerStats().spaceStationDimensionID == 0) && !ConfigManagerCore.disableSpaceStationCreation) { WorldUtil.bindSpaceStationToNewDimension(playerBase.worldObj, playerBase); WorldUtil.getSpaceStationRecipe((Integer) this.data.get(0)).matches(playerBase, true); } break; case S_UNLOCK_NEW_SCHEMATIC: final Container container = player.openContainer; if (container instanceof ContainerSchematic) { final ContainerSchematic schematicContainer = (ContainerSchematic) container; ItemStack stack = schematicContainer.craftMatrix.getStackInSlot(0); if (stack != null) { final ISchematicPage page = SchematicRegistry.getMatchingRecipeForItemStack(stack); if (page != null) { SchematicRegistry.unlockNewPage(playerBase, stack); if (--stack.stackSize <= 0) { stack = null; } schematicContainer.craftMatrix.setInventorySlotContents(0, stack); schematicContainer.craftMatrix.markDirty(); GalacticraftCore.packetPipeline.sendTo( new PacketSimple( EnumSimplePacket.C_ADD_NEW_SCHEMATIC, new Object[] {page.getPageID()}), playerBase); } } } break; case S_UPDATE_DISABLEABLE_BUTTON: final TileEntity tileAt = player.worldObj.getTileEntity( (Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2)); if (tileAt instanceof IDisableableMachine) { final IDisableableMachine machine = (IDisableableMachine) tileAt; machine.setDisabled( (Integer) this.data.get(3), !machine.getDisabled((Integer) this.data.get(3))); } break; case S_ON_FAILED_CHEST_UNLOCK: if (playerBase.getPlayerStats().chatCooldown == 0) { player.addChatMessage( new ChatComponentText( GCCoreUtil.translateWithFormat("gui.chest.warning.wrongkey", this.data.get(0)))); playerBase.getPlayerStats().chatCooldown = 100; } break; case S_RENAME_SPACE_STATION: final SpaceStationWorldData ssdata = SpaceStationWorldData.getStationData( playerBase.worldObj, (Integer) this.data.get(1), playerBase); if (ssdata != null && ssdata.getOwner().equalsIgnoreCase(player.getGameProfile().getName())) { ssdata.setSpaceStationName((String) this.data.get(0)); ssdata.setDirty(true); } break; case S_OPEN_EXTENDED_INVENTORY: player.openGui( GalacticraftCore.instance, GuiIdsCore.EXTENDED_INVENTORY, player.worldObj, 0, 0, 0); break; case S_ON_ADVANCED_GUI_CLICKED_INT: TileEntity tile1 = player.worldObj.getTileEntity( (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3)); switch ((Integer) this.data.get(0)) { case 0: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.redstoneActivation = (Integer) this.data.get(4) == 1; } break; case 1: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.playerDistanceActivation = (Integer) this.data.get(4) == 1; } break; case 2: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.playerDistanceSelection = (Integer) this.data.get(4); } break; case 3: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.playerNameMatches = (Integer) this.data.get(4) == 1; } break; case 4: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.invertSelection = (Integer) this.data.get(4) == 1; } break; case 5: if (tile1 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile1; launchController.lastHorizontalModeEnabled = launchController.horizontalModeEnabled; launchController.horizontalModeEnabled = (Integer) this.data.get(4) == 1; } break; case 6: if (tile1 instanceof IBubbleProvider) { IBubbleProvider distributor = (IBubbleProvider) tile1; distributor.setBubbleVisible((Integer) this.data.get(4) == 1); } break; default: break; } break; case S_ON_ADVANCED_GUI_CLICKED_STRING: TileEntity tile2 = player.worldObj.getTileEntity( (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3)); switch ((Integer) this.data.get(0)) { case 0: if (tile2 instanceof TileEntityAirLockController) { TileEntityAirLockController launchController = (TileEntityAirLockController) tile2; launchController.playerToOpenFor = (String) this.data.get(4); } break; default: break; } break; case S_UPDATE_SHIP_MOTION_Y: int entityID = (Integer) this.data.get(0); boolean up = (Boolean) this.data.get(1); Entity entity2 = player.worldObj.getEntityByID(entityID); if (entity2 instanceof EntityAutoRocket) { EntityAutoRocket autoRocket = (EntityAutoRocket) entity2; autoRocket.motionY += up ? 0.02F : -0.02F; } break; case S_START_NEW_SPACE_RACE: 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++) { playerList.add((String) this.data.get(i)); } boolean previousData = SpaceRaceManager.getSpaceRaceFromID(teamID) != null; SpaceRace newRace = new SpaceRace(playerList, teamName, flagData, teamColor); if (teamID > 0) { newRace.setSpaceRaceID(teamID); } SpaceRaceManager.addSpaceRace(newRace); if (previousData) { SpaceRaceManager.sendSpaceRaceData( null, SpaceRaceManager.getSpaceRaceFromPlayer(playerBase.getGameProfile().getName())); } break; case S_REQUEST_FLAG_DATA: SpaceRaceManager.sendSpaceRaceData( playerBase, SpaceRaceManager.getSpaceRaceFromPlayer((String) this.data.get(0))); break; case S_INVITE_RACE_PLAYER: GCEntityPlayerMP playerInvited = PlayerUtil.getPlayerBaseServerFromPlayerUsername((String) this.data.get(0), true); if (playerInvited != null) { Integer teamInvitedTo = (Integer) this.data.get(1); SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo); if (race != null) { playerInvited.getPlayerStats().spaceRaceInviteTeamID = teamInvitedTo; String dA = EnumColor.DARK_AQUA.code; String bG = EnumColor.BRIGHT_GREEN.code; String dB = EnumColor.PURPLE.code; String teamNameTotal = ""; String[] teamNameSplit = race.getTeamName().split(" "); for (String teamNamePart : teamNameSplit) { teamNameTotal = teamNameTotal.concat(dB + teamNamePart + " "); } playerInvited.addChatMessage( new ChatComponentText( "Received Space Race Team Invite from " + bG + player.getGameProfile().getName() + dA + ". To join " + teamNameTotal + dA + "use command " + EnumColor.AQUA + "/joinrace") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA))); } } break; case S_REMOVE_RACE_PLAYER: Integer teamInvitedTo = (Integer) this.data.get(1); SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo); if (race != null) { String playerToRemove = (String) this.data.get(0); if (!race.getPlayerNames().remove(playerToRemove)) { player.addChatMessage( new ChatComponentText("Could not find player with name: " + playerToRemove)); } else { SpaceRaceManager.onPlayerRemoval(playerToRemove, race); } } break; case S_ADD_RACE_PLAYER: Integer teamToAddPlayer = (Integer) this.data.get(1); SpaceRace spaceRaceToAddPlayer = SpaceRaceManager.getSpaceRaceFromID(teamToAddPlayer); if (spaceRaceToAddPlayer != null) { String playerToAdd = (String) this.data.get(0); if (!spaceRaceToAddPlayer.getPlayerNames().contains(playerToAdd)) { SpaceRace oldRace = null; while ((oldRace = SpaceRaceManager.getSpaceRaceFromPlayer(playerToAdd)) != null) { SpaceRaceManager.removeSpaceRace(oldRace); } spaceRaceToAddPlayer.getPlayerNames().add(playerToAdd); SpaceRaceManager.sendSpaceRaceData(null, spaceRaceToAddPlayer); for (String member : spaceRaceToAddPlayer.getPlayerNames()) { EntityPlayerMP memberObj = MinecraftServer.getServer() .getConfigurationManager() .getPlayerForUsername(member); if (memberObj != null) { memberObj.addChatMessage( new ChatComponentText( EnumColor.BRIGHT_GREEN + playerToAdd + EnumColor.DARK_AQUA + " has joined the Space Race!") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA))); } } } else { player.addChatMessage( new ChatComponentText("You are already a part of this space race!") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED))); } } break; default: break; } }
@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 onBuild(int i, EntityPlayerSP player) { // 0 : opened GC inventory tab // 1,2,3 : Compressor, CF, Standard Wrench // 4,5,6 : Fuel loader, Launchpad, NASA Workbench // 7: oil found 8: placed rocket GCPlayerStatsClient stats = GCPlayerStatsClient.get(player); int flag = stats.buildFlags; if (flag == -1) flag = 0; int repeatCount = flag >> 9; if (repeatCount <= 3) { repeatCount++; } if ((flag & 1 << i) > 0) return; flag |= 1 << i; stats.buildFlags = (flag & 511) + (repeatCount << 9); GalacticraftCore.packetPipeline.sendToServer( new PacketSimple( EnumSimplePacket.S_BUILDFLAGS_UPDATE, player.worldObj.provider.getDimensionId(), new Object[] {stats.buildFlags})); switch (i) { case 0: case 1: case 2: case 3: player.addChatMessage( IChatComponent.Serializer.jsonToComponent( "[{\"text\":\"" + GCCoreUtil.translate("gui.message.help1") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + GalacticraftCore.PREFIX + "com/wiki/1" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + GalacticraftCore.PREFIX + "com/wiki/1" + "\"}}]")); player.addChatMessage( new ChatComponentText( GCCoreUtil.translate("gui.message.help1a") + EnumColor.AQUA + " /gchelp")); break; case 4: case 5: case 6: player.addChatMessage( IChatComponent.Serializer.jsonToComponent( "[{\"text\":\"" + GCCoreUtil.translate("gui.message.help2") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + GalacticraftCore.PREFIX + "com/wiki/2" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + GalacticraftCore.PREFIX + "com/wiki/2" + "\"}}]")); break; case 7: player.addChatMessage( IChatComponent.Serializer.jsonToComponent( "[{\"text\":\"" + GCCoreUtil.translate("gui.message.help3") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + GalacticraftCore.PREFIX + "com/wiki/oil" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + GalacticraftCore.PREFIX + "com/wiki/oil" + "\"}}]")); break; case 8: player.addChatMessage( IChatComponent.Serializer.jsonToComponent( "[{\"text\":\"" + GCCoreUtil.translate("gui.message.prelaunch") + ": \",\"color\":\"white\"}," + "{\"text\":\" " + EnumColor.BRIGHT_GREEN + "wiki." + GalacticraftCore.PREFIX + "com/wiki/pre" + "\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"" + GCCoreUtil.translate("gui.message.clicklink") + "\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + "http://wiki." + GalacticraftCore.PREFIX + "com/wiki/pre" + "\"}}]")); break; } }
@Override public void tickStart(EnumSet<TickType> type, Object... tickData) { final Minecraft minecraft = FMLClientHandler.instance().getClient(); final WorldClient world = minecraft.theWorld; final EntityClientPlayerMP player = minecraft.thePlayer; if (type.equals(EnumSet.of(TickType.CLIENT))) { if (GCCoreTickHandlerClient.tickCount >= Long.MAX_VALUE) { GCCoreTickHandlerClient.tickCount = 0; } GCCoreTickHandlerClient.tickCount++; if (GCCoreTickHandlerClient.tickCount % 20 == 0) { if (player != null && player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof GCCoreItemSensorGlasses) { ClientProxyCore.valueableBlocks.clear(); for (int i = -4; i < 5; i++) { for (int j = -4; j < 5; j++) { for (int k = -4; k < 5; k++) { int x = MathHelper.floor_double(player.posX + i); int y = MathHelper.floor_double(player.posY + j); int z = MathHelper.floor_double(player.posZ + k); final int id = player.worldObj.getBlockId(x, y, z); if (id != 0) { final Block block = Block.blocksList[id]; int metadata = world.getBlockMetadata(x, y, z); boolean isDetectable = false; for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) { if (blockMetaList.getBlockID() == id && blockMetaList.getMetaList().contains(metadata)) { isDetectable = true; break; } } if (isDetectable) { if (!this.alreadyContainsBlock(x, y, z)) { ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z)); } } else if (block instanceof IDetectableResource && ((IDetectableResource) block).isValueable(metadata)) { if (!this.alreadyContainsBlock(x, y, z)) { ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z)); } List<Integer> metaList = Lists.newArrayList(); metaList.add(metadata); for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) { if (blockMetaList.getBlockID() == id) { metaList.addAll(blockMetaList.getMetaList()); break; } } ClientProxyCore.detectableBlocks.add(new BlockMetaList(id, metaList)); } } } } } } } if (GCCoreTickHandlerClient.addTabsNextTick) { if (minecraft.currentScreen.getClass().equals(GuiInventory.class)) { GCCoreTickHandlerClient.addTabsToInventory((GuiContainer) minecraft.currentScreen); } GCCoreTickHandlerClient.addTabsNextTick = false; } if (minecraft.currentScreen != null && minecraft.currentScreen instanceof GuiMainMenu) { GalacticraftCore.playersServer.clear(); GalacticraftCore.playersClient.clear(); ClientProxyCore.playerItemData.clear(); if (GCCoreTickHandlerClient.missingRequirementThread == null) { GCCoreTickHandlerClient.missingRequirementThread = new GCCoreThreadRequirementMissing(FMLCommonHandler.instance().getEffectiveSide()); GCCoreTickHandlerClient.missingRequirementThread.start(); } } if (world != null && GCCoreTickHandlerClient.checkedVersion) { GCCoreUtil.checkVersion(Side.CLIENT); GCCoreTickHandlerClient.checkedVersion = false; } if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntitySpaceshipBase) { final Object[] toSend = {player.ridingEntity.rotationPitch}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend)); final Object[] toSend2 = {player.ridingEntity.rotationYaw}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend2)); } if (world != null && world.provider instanceof WorldProviderSurface) { if (world.provider.getSkyRenderer() == null && player.ridingEntity != null && player.ridingEntity.posY >= 200) { world.provider.setSkyRenderer(new GCCoreSkyProviderOverworld()); } else if (world.provider.getSkyRenderer() != null && world.provider.getSkyRenderer() instanceof GCCoreSkyProviderOverworld && (player.ridingEntity == null || player.ridingEntity.posY < 200)) { world.provider.setSkyRenderer(null); } } if (world != null && world.provider instanceof GCCoreWorldProviderSpaceStation) { if (world.provider.getSkyRenderer() == null) { world.provider.setSkyRenderer( new GCCoreSkyProviderOrbit( new ResourceLocation( GalacticraftCore.ASSET_DOMAIN, "textures/gui/planets/overworld.png"), true, true)); } if (world.provider.getCloudRenderer() == null) { world.provider.setCloudRenderer(new GCCoreCloudRenderer()); } } if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntitySpaceshipBase) { final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity; if (minecraft.gameSettings.keyBindLeft.pressed) { ship.turnYaw(-1.0F); final Object[] toSend = {ship.rotationYaw}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend)); } if (minecraft.gameSettings.keyBindRight.pressed) { ship.turnYaw(1.0F); final Object[] toSend = {ship.rotationYaw}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_YAW, toSend)); } if (minecraft.gameSettings.keyBindForward.pressed) { if (ship.getLaunched()) { ship.turnPitch(-0.7F); final Object[] toSend = {ship.rotationPitch}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend)); } } if (minecraft.gameSettings.keyBindBack.pressed) { if (ship.getLaunched()) { ship.turnPitch(0.7F); final Object[] toSend = {ship.rotationPitch}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.UPDATE_SHIP_PITCH, toSend)); } } } if (world != null) { for (int i = 0; i < world.loadedEntityList.size(); i++) { final Entity e = (Entity) world.loadedEntityList.get(i); if (e != null) { if (e instanceof GCCoreEntityRocketT1) { final GCCoreEntityRocketT1 eship = (GCCoreEntityRocketT1) e; if (eship.rocketSoundUpdater == null) { eship.rocketSoundUpdater = new GCCoreSoundUpdaterSpaceship( FMLClientHandler.instance().getClient().sndManager, eship, FMLClientHandler.instance().getClient().thePlayer); } } } } } if (FMLClientHandler.instance().getClient().currentScreen instanceof GCCoreGuiChoosePlanet) { player.motionY = 0; } if (world != null && world.provider instanceof IGalacticraftWorldProvider) { world.setRainStrength(0.0F); } if (!minecraft.gameSettings.keyBindJump.pressed) { ClientProxyCore.lastSpacebarDown = false; } if (player != null && player.ridingEntity != null && minecraft.gameSettings.keyBindJump.pressed && !ClientProxyCore.lastSpacebarDown) { final Object[] toSend = {0}; PacketDispatcher.sendPacketToServer( PacketUtil.createPacket( GalacticraftCore.CHANNEL, EnumPacketServer.IGNITE_ROCKET, toSend)); ClientProxyCore.lastSpacebarDown = true; } } }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tile = null; if (worldIn.isRemote || playerIn == null) { return false; } else { final Block id = worldIn.getBlockState(pos).getBlock(); if (id == GCBlocks.fakeBlock) { tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityMulti) { tile = ((TileEntityMulti) tile).getMainBlockTile(); } } if (id == AsteroidBlocks.minerBaseFull) { tile = worldIn.getTileEntity(pos); } if (tile instanceof TileEntityMinerBase) { if (worldIn.provider instanceof WorldProviderOrbit) { playerIn.addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner7.fail"))); return false; } if (((TileEntityMinerBase) tile).getLinkedMiner() != null) { playerIn.addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner.fail"))); return false; } // Gives a chance for any loaded Astro Miner to link itself if (((TileEntityMinerBase) tile).ticks < 15L) { return false; } EntityPlayerMP playerMP = (EntityPlayerMP) playerIn; int astroCount = GCPlayerStats.get(playerMP).astroMinerCount; if (astroCount >= ConfigManagerAsteroids.astroMinerMax && (!playerIn.capabilities.isCreativeMode)) { playerIn.addChatMessage( new ChatComponentText(GCCoreUtil.translate("gui.message.astro_miner2.fail"))); return false; } if (!((TileEntityMinerBase) tile).spawnMiner(playerMP)) { playerIn.addChatMessage( new ChatComponentText( GCCoreUtil.translate("gui.message.astro_miner1.fail") + " " + GCCoreUtil.translate(EntityAstroMiner.blockingBlock.toString()))); return false; } if (!playerIn.capabilities.isCreativeMode) { GCPlayerStats.get(playerMP).astroMinerCount++; --stack.stackSize; } return true; } } return false; }
@Override public String getName() { return GCCoreUtil.translate("container.spaceship.name"); }
public String getTitle() { return GCCoreUtil.translate("gui.message." + this.title + ".name"); }
@Override public void update() { if (this.ticks % 40 == 0 && !worldObj.isRemote) { this.setAddress(this.address); this.setTargetAddress(this.targetAddress); } if (!this.worldObj.isRemote) { if (this.targetAddressResult == EnumTelepadSearchResult.VALID && (this.ticks % 5 == 0 || teleporting)) { List containedEntities = worldObj.getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB.fromBounds( this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX() + 1, this.getPos().getY() + 2, this.getPos().getZ() + 1)); if (containedEntities.size() > 0 && this.getEnergyStoredGC() >= ENERGY_USE_ON_TELEPORT) { ShortRangeTelepadHandler.TelepadEntry entry = ShortRangeTelepadHandler.getLocationFromAddress(this.targetAddress); if (entry != null) { teleporting = true; } } else { teleporting = false; } } if (this.teleporting) { this.teleportTime++; if (teleportTime >= MAX_TELEPORT_TIME) { ShortRangeTelepadHandler.TelepadEntry entry = ShortRangeTelepadHandler.getLocationFromAddress(this.targetAddress); BlockVec3 finalPos = (entry == null) ? null : entry.position; if (finalPos != null) { TileEntity tileAt = finalPos.getTileEntity(this.worldObj); List<EntityLivingBase> containedEntities = worldObj.getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB.fromBounds( this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX() + 1, this.getPos().getY() + 2, this.getPos().getZ() + 1)); if (tileAt != null && tileAt instanceof TileEntityShortRangeTelepad) { TileEntityShortRangeTelepad destTelepad = (TileEntityShortRangeTelepad) tileAt; int teleportResult = destTelepad.canTeleportHere(); if (teleportResult == 0) { for (EntityLivingBase e : containedEntities) { e.setPosition(finalPos.x + 0.5F, finalPos.y + 1.0F, finalPos.z + 0.5F); this.worldObj.updateEntityWithOptionalForce(e, true); if (e instanceof EntityPlayerMP) { ((EntityPlayerMP) e) .playerNetServerHandler.setPlayerLocation( finalPos.x, finalPos.y, finalPos.z, e.rotationYaw, e.rotationPitch); } GalacticraftCore.packetPipeline.sendToDimension( new PacketSimpleAsteroids( PacketSimpleAsteroids.EnumSimplePacketAsteroids.C_TELEPAD_SEND, this.worldObj.provider.getDimensionId(), new Object[] {finalPos, e.getEntityId()}), this.worldObj.provider.getDimensionId()); } if (containedEntities.size() > 0) { this.storage.setEnergyStored( this.storage.getEnergyStoredGC() - ENERGY_USE_ON_TELEPORT); destTelepad.storage.setEnergyStored( this.storage.getEnergyStoredGC() - ENERGY_USE_ON_TELEPORT); } } else { switch (teleportResult) { case -1: for (EntityLivingBase e : containedEntities) { if (e instanceof EntityPlayer) { ((EntityPlayer) e) .addChatComponentMessage( new ChatComponentText( "Cannot Send client-side")); // No need for translation, since // this should never happen } } break; case 1: for (EntityLivingBase e : containedEntities) { if (e instanceof EntityPlayer) { ((EntityPlayer) e) .addChatComponentMessage( new ChatComponentText( "Target address invalid")); // No need for translation, since // this should never happen } } break; case 2: for (EntityLivingBase e : containedEntities) { if (e instanceof EntityPlayer) { ((EntityPlayer) e) .addChatComponentMessage( new ChatComponentText( GCCoreUtil.translate("gui.message.target_no_energy.name"))); } } break; } } } } this.teleportTime = 0; this.teleporting = false; } } else { this.teleportTime = Math.max(--this.teleportTime, 0); } } super.update(); }
@Override public String getShiftDescription(int meta) { return GCCoreUtil.translate(this.getUnlocalizedName() + ".description"); }