Search in sources :

Example 6 with CelestialBody

use of micdoodle8.mods.galacticraft.api.galaxies.CelestialBody in project Galacticraft by micdoodle8.

the class GuiCelestialSelection method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int button) throws IOException {
    super.mouseClicked(x, y, button);
    boolean clickHandled = false;
    final int LHS = GuiCelestialSelection.BORDER_SIZE + GuiCelestialSelection.BORDER_EDGE_SIZE;
    final int RHS = width - LHS;
    final int TOP = LHS;
    if (this.selectedBody != null && x > LHS && x < LHS + 88 && y > TOP && y < TOP + 13) {
        this.unselectCelestialBody();
        return;
    }
    if (!this.mapMode) {
        if (x >= RHS - 95 && x < RHS && y > TOP + 181 + canCreateOffset && y < TOP + 182 + 12 + canCreateOffset) {
            if (this.selectedBody != null) {
                SpaceStationRecipe recipe = WorldUtil.getSpaceStationRecipe(this.selectedBody.getDimensionID());
                if (recipe != null && this.canCreateSpaceStation(this.selectedBody)) {
                    if (recipe.matches(this.mc.thePlayer, false) || this.mc.thePlayer.capabilities.isCreativeMode) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_BIND_SPACE_STATION_ID, GCCoreUtil.getDimensionID(this.mc.theWorld), new Object[] { this.selectedBody.getDimensionID() }));
                        // Zoom in on Overworld to show the new SpaceStation if not already zoomed
                        if (!this.isZoomed()) {
                            this.selectionState = EnumSelection.ZOOMED;
                            this.preSelectZoom = this.zoom;
                            this.preSelectPosition = this.position;
                            this.ticksSinceSelection = 0;
                            this.doneZooming = false;
                        }
                        return;
                    }
                    clickHandled = true;
                }
            }
        }
    }
    if (this.mapMode) {
        if (x > RHS - 88 && x < RHS && y > TOP && y < TOP + 13) {
            this.mc.displayGuiScreen(null);
            this.mc.setIngameFocus();
            clickHandled = true;
        }
    }
    if (this.selectedBody != null && !this.mapMode) {
        if (x > RHS - 88 && x < RHS && y > TOP && y < TOP + 13) {
            if (!(this.selectedBody instanceof Satellite) || !this.selectedStationOwner.equals("")) {
                this.teleportToSelectedBody();
            }
            clickHandled = true;
        }
    }
    // Need unscaled mouse coords
    int mouseX = Mouse.getX();
    int mouseY = Mouse.getY() * -1 + Minecraft.getMinecraft().displayHeight - 1;
    if (this.selectedBody instanceof Satellite) {
        if (this.renamingSpaceStation) {
            if (x >= width / 2 - 90 && x <= width / 2 + 90 && y >= this.height / 2 - 38 && y <= this.height / 2 + 38) {
                // Apply
                if (x >= width / 2 - 90 + 17 && x <= width / 2 - 90 + 17 + 72 && y >= this.height / 2 - 38 + 59 && y <= this.height / 2 - 38 + 59 + 12) {
                    String strName = PlayerUtil.getName(this.mc.thePlayer);
                    // Integer spacestationID = this.spaceStationIDs.get(strName);
                    // if (spacestationID == null) spacestationID = this.spaceStationIDs.get(strName.toLowerCase());
                    Satellite selectedSatellite = (Satellite) this.selectedBody;
                    Integer spacestationID = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName).getStationDimensionID();
                    if (spacestationID == null) {
                        spacestationID = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName.toLowerCase()).getStationDimensionID();
                    }
                    if (spacestationID != null) {
                        this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName).setStationName(this.renamingString);
                        // this.spaceStationNames.put(strName, this.renamingString);
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_RENAME_SPACE_STATION, GCCoreUtil.getDimensionID(this.mc.theWorld), new Object[] { this.renamingString, spacestationID }));
                    }
                    this.renamingSpaceStation = false;
                }
                // Cancel
                if (x >= width / 2 && x <= width / 2 + 72 && y >= this.height / 2 - 38 + 59 && y <= this.height / 2 - 38 + 59 + 12) {
                    this.renamingSpaceStation = false;
                }
                clickHandled = true;
            }
        } else {
            this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
            if (x >= width / 2 - 47 && x <= width / 2 - 47 + 94 && y >= TOP && y <= TOP + 11) {
                if (this.selectedStationOwner.length() != 0 && this.selectedStationOwner.equalsIgnoreCase(PlayerUtil.getName(this.mc.thePlayer))) {
                    this.renamingSpaceStation = true;
                    this.renamingString = null;
                    clickHandled = true;
                }
            }
            Satellite selectedSatellite = (Satellite) this.selectedBody;
            int stationListSize = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).size();
            int max = Math.min((this.height / 2) / 14, stationListSize);
            int xPos;
            int yPos;
            // Up button
            xPos = RHS - 85;
            yPos = TOP + 45;
            if (x >= xPos && x <= xPos + 61 && y >= yPos && y <= yPos + 4) {
                if (this.spaceStationListOffset > 0) {
                    this.spaceStationListOffset--;
                }
                clickHandled = true;
            }
            // Down button
            xPos = RHS - 85;
            yPos = TOP + 49 + max * 14;
            if (x >= xPos && x <= xPos + 61 && y >= yPos && y <= yPos + 4) {
                if (max + spaceStationListOffset < stationListSize) {
                    this.spaceStationListOffset++;
                }
                clickHandled = true;
            }
            Iterator<Map.Entry<String, StationDataGUI>> it = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).entrySet().iterator();
            int i = 0;
            int j = 0;
            while (it.hasNext() && i < max) {
                Map.Entry<String, StationDataGUI> e = it.next();
                if (j >= this.spaceStationListOffset) {
                    int xOffset = 0;
                    if (e.getKey().equalsIgnoreCase(this.selectedStationOwner)) {
                        xOffset -= 5;
                    }
                    xPos = RHS - 95 + xOffset;
                    yPos = TOP + 50 + i * 14;
                    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12) {
                        this.selectedStationOwner = e.getKey();
                        clickHandled = true;
                    }
                    i++;
                }
                j++;
            }
        }
    }
    int xPos = LHS + 2;
    int yPos = TOP + 10;
    boolean planetZoomedMoon = this.isZoomed() && this.selectedParent instanceof Planet;
    // Top yellow button e.g. Sol
    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12 && this.selectedParent instanceof CelestialBody) {
        if (this.selectedBody == null) {
            this.preSelectZoom = this.zoom;
            this.preSelectPosition = this.position;
        }
        EnumSelection selectionCountOld = this.selectionState;
        if (this.isSelected()) {
            this.unselectCelestialBody();
        }
        if (selectionCountOld == EnumSelection.ZOOMED) {
            this.selectionState = EnumSelection.SELECTED;
        }
        this.selectedBody = (CelestialBody) this.selectedParent;
        this.ticksSinceSelection = 0;
        this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
        if (this.isZoomed() && !planetZoomedMoon) {
            this.ticksSinceMenuOpen = 0;
        }
        clickHandled = true;
    }
    yPos += 22;
    // First blue button - normally the Selected Body (but it's the parent planet if this is a moon)
    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12) {
        if (planetZoomedMoon) {
            if (this.selectedBody == null) {
                this.preSelectZoom = this.zoom;
                this.preSelectPosition = this.position;
            }
            EnumSelection selectionCountOld = this.selectionState;
            if (this.isSelected()) {
                this.unselectCelestialBody();
            }
            if (selectionCountOld == EnumSelection.ZOOMED) {
                this.selectionState = EnumSelection.SELECTED;
            }
            this.selectedBody = (CelestialBody) this.selectedParent;
            this.ticksSinceSelection = 0;
            this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
        }
        clickHandled = true;
    }
    if (!clickHandled) {
        List<CelestialBody> children = this.getChildren(this.isZoomed() ? this.selectedBody : this.selectedParent);
        yPos = TOP + 50;
        for (CelestialBody child : children) {
            clickHandled = this.testClicked(child, child.equals(this.selectedBody) ? 5 : 0, yPos, x, y, false);
            yPos += 14;
            if (!clickHandled && !this.isZoomed() && child.equals(this.selectedBody)) {
                List<CelestialBody> grandchildren = this.getChildren(child);
                int gOffset = 0;
                for (CelestialBody grandchild : grandchildren) {
                    if (gOffset + 14 > this.animateGrandchildren) {
                        break;
                    }
                    clickHandled = this.testClicked(grandchild, 10, yPos, x, y, true);
                    yPos += 14;
                    gOffset += 14;
                    if (clickHandled)
                        break;
                }
                yPos += this.animateGrandchildren - gOffset;
            }
            if (clickHandled)
                break;
        }
    }
    if (!clickHandled) {
        for (Map.Entry<CelestialBody, Vector3f> e : this.planetPosMap.entrySet()) {
            CelestialBody bodyClicked = e.getKey();
            if (this.selectedBody == null && bodyClicked instanceof IChildBody) {
                continue;
            }
            // Z value holds size on-screen
            float iconSize = e.getValue().z;
            if (mouseX >= e.getValue().x - iconSize && mouseX <= e.getValue().x + iconSize && mouseY >= e.getValue().y - iconSize && mouseY <= e.getValue().y + iconSize) {
                if (this.selectedBody != bodyClicked || !this.isZoomed()) {
                    if (this.isSelected() && this.selectedBody != bodyClicked) {
                        if (!(this.selectedBody instanceof IChildBody && ((IChildBody) this.selectedBody).getParentPlanet() == bodyClicked)) {
                            this.unselectCelestialBody();
                        } else if (this.isZoomed()) {
                            this.selectionState = EnumSelection.SELECTED;
                        }
                    }
                    this.doneZooming = false;
                    this.planetZoom = 0.0F;
                    if (bodyClicked != this.selectedBody) {
                        this.lastSelectedBody = this.selectedBody;
                    }
                    this.selectedBody = bodyClicked;
                    this.ticksSinceSelection = 0;
                    this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
                    if (this.isZoomed()) {
                        this.ticksSinceMenuOpen = 0;
                    }
                    // Auto select if it's a spacestation and there is only a single entry
                    if (this.selectedBody instanceof Satellite && this.spaceStationMap.get(this.getSatelliteParentID((Satellite) this.selectedBody)).size() == 1) {
                        Iterator<Map.Entry<String, StationDataGUI>> it = this.spaceStationMap.get(this.getSatelliteParentID((Satellite) this.selectedBody)).entrySet().iterator();
                        this.selectedStationOwner = it.next().getKey();
                    }
                    clickHandled = true;
                    break;
                }
            }
        }
    }
    if (!clickHandled) {
        if (this.selectedBody != null) {
            this.unselectCelestialBody();
            this.planetZoom = 0.0F;
        }
        mouseDragging = true;
    }
    Object selectedParent = this.selectedParent;
    if (this.selectedBody instanceof IChildBody) {
        selectedParent = ((IChildBody) this.selectedBody).getParentPlanet();
    } else if (this.selectedBody instanceof Planet) {
        selectedParent = ((Planet) this.selectedBody).getParentSolarSystem();
    } else if (this.selectedBody == null) {
        selectedParent = GalacticraftCore.solarSystemSol;
    }
    if (this.selectedParent != selectedParent) {
        this.selectedParent = selectedParent;
    }
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) SpaceStationRecipe(micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe) Vector3f(org.lwjgl.util.vector.Vector3f)

Example 7 with CelestialBody

use of micdoodle8.mods.galacticraft.api.galaxies.CelestialBody in project Galacticraft by micdoodle8.

the class GuiCelestialSelection method canCreateSpaceStation.

protected boolean canCreateSpaceStation(CelestialBody atBody) {
    if (this.mapMode || ConfigManagerCore.disableSpaceStationCreation) {
        return false;
    }
    if (!atBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(atBody))) {
        // If parent body is unreachable, the satellite is also unreachable
        return false;
    }
    boolean foundRecipe = false;
    for (SpaceStationType type : GalacticraftRegistry.getSpaceStationData()) {
        if (type.getWorldToOrbitID() == atBody.getDimensionID()) {
            foundRecipe = true;
        }
    }
    if (!foundRecipe) {
        return false;
    }
    if (!ClientProxyCore.clientSpaceStationID.containsKey(atBody.getDimensionID())) {
        return true;
    }
    int resultID = ClientProxyCore.clientSpaceStationID.get(atBody.getDimensionID());
    return !(resultID != 0 && resultID != -1);
}
Also used : SpaceStationType(micdoodle8.mods.galacticraft.api.world.SpaceStationType)

Example 8 with CelestialBody

use of micdoodle8.mods.galacticraft.api.galaxies.CelestialBody in project Galacticraft by micdoodle8.

the class SpaceRaceManager method tick.

public static void tick() {
    for (SpaceRace race : SpaceRaceManager.spaceRaces) {
        boolean playerOnline = false;
        for (EntityPlayerMP player : PlayerUtil.getPlayersOnline()) {
            if (race.getPlayerNames().contains(PlayerUtil.getName(player))) {
                CelestialBody body = GalaxyRegistry.getCelestialBodyFromDimensionID(GCCoreUtil.getDimensionID(player.worldObj));
                if (body != null) {
                    if (!race.getCelestialBodyStatusList().containsKey(body)) {
                        race.setCelestialBodyReached(body);
                    }
                }
                playerOnline = true;
            }
        }
        if (playerOnline) {
            race.tick();
        }
    }
}
Also used : CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 9 with CelestialBody

use of micdoodle8.mods.galacticraft.api.galaxies.CelestialBody in project Galacticraft by micdoodle8.

the class PacketSimple method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    final EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase == null) {
        return;
    }
    final MinecraftServer server = playerBase.mcServer;
    final GCPlayerStats stats = GCPlayerStats.get(playerBase);
    switch(this.type) {
        case S_RESPAWN_PLAYER:
            playerBase.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), playerBase.theItemInWorldManager.getGameType()));
            break;
        case S_TELEPORT_ENTITY:
            TickHandlerServer.scheduleNewDimensionChange(new ScheduledDimensionChange(playerBase, (String) PacketSimple.this.data.get(0)));
            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.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
                    if (ship.hasValidFuel()) {
                        ItemStack stack2 = stats.getExtendedInventory().getStackInSlot(4);
                        if (stack2 != null && stack2.getItem() instanceof ItemParaChute || stats.getLaunchAttempts() > 0) {
                            ship.igniteCheckingCooldown();
                            stats.setLaunchAttempts(0);
                        } else if (stats.getChatCooldown() == 0 && stats.getLaunchAttempts() == 0) {
                            player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.noparachute")));
                            stats.setChatCooldown(250);
                            stats.setLaunchAttempts(1);
                        }
                    } else if (stats.getChatCooldown() == 0) {
                        player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nofuel")));
                        stats.setChatCooldown(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, (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));
            }
            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 EntityLivingBase) {
                ((EntityLivingBase) entity).setFire(3);
            }
            break;
        case S_BIND_SPACE_STATION_ID:
            int homeID = (Integer) this.data.get(0);
            if ((!stats.getSpaceStationDimensionData().containsKey(homeID) || stats.getSpaceStationDimensionData().get(homeID) == -1 || stats.getSpaceStationDimensionData().get(homeID) == 0) && !ConfigManagerCore.disableSpaceStationCreation) {
                if (playerBase.capabilities.isCreativeMode || WorldUtil.getSpaceStationRecipe(homeID).matches(playerBase, true)) {
                    WorldUtil.bindSpaceStationToNewDimension(playerBase.worldObj, playerBase, homeID);
                }
            }
            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);
                        SpaceRaceManager.teamUnlockSchematic(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, getDimensionID(), new Object[] { page.getPageID() }), playerBase);
                    }
                }
            }
            break;
        case S_UPDATE_DISABLEABLE_BUTTON:
            final TileEntity tileAt = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tileAt instanceof IDisableableMachine) {
                final IDisableableMachine machine = (IDisableableMachine) tileAt;
                machine.setDisabled((Integer) this.data.get(1), !machine.getDisabled((Integer) this.data.get(1)));
            }
            break;
        case S_ON_FAILED_CHEST_UNLOCK:
            if (stats.getChatCooldown() == 0) {
                player.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.chest.warning.wrongkey", this.data.get(0))));
                stats.setChatCooldown(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(PlayerUtil.getName(player))) {
                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((BlockPos) this.data.get(1));
            switch((Integer) this.data.get(0)) {
                case 0:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.redstoneActivation = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 1:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerDistanceActivation = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 2:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerDistanceSelection = (Integer) this.data.get(2);
                    }
                    break;
                case 3:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerNameMatches = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 4:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.invertSelection = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 5:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.lastHorizontalModeEnabled = airlockController.horizontalModeEnabled;
                        airlockController.horizontalModeEnabled = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 6:
                    if (tile1 instanceof IBubbleProvider) {
                        IBubbleProvider distributor = (IBubbleProvider) tile1;
                        distributor.setBubbleVisible((Integer) this.data.get(2) == 1);
                    }
                    break;
                default:
                    break;
            }
            break;
        case S_ON_ADVANCED_GUI_CLICKED_STRING:
            TileEntity tile2 = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
            switch((Integer) this.data.get(0)) {
                case 0:
                    if (tile2 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile2;
                        airlockController.playerToOpenFor = (String) this.data.get(2);
                    }
                    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(server, null, SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(playerBase)));
            }
            break;
        case S_REQUEST_FLAG_DATA:
            SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromPlayer((String) this.data.get(0)));
            break;
        case S_INVITE_RACE_PLAYER:
            EntityPlayerMP playerInvited = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, (String) this.data.get(0), true);
            if (playerInvited != null) {
                Integer teamInvitedTo = (Integer) this.data.get(1);
                SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);
                if (race != null) {
                    GCPlayerStats.get(playerInvited).setSpaceRaceInviteTeamID(teamInvitedTo);
                    String dA = EnumColor.DARK_AQUA.getCode();
                    String bG = EnumColor.BRIGHT_GREEN.getCode();
                    String dB = EnumColor.PURPLE.getCode();
                    String teamNameTotal = "";
                    String[] teamNameSplit = race.getTeamName().split(" ");
                    for (String teamNamePart : teamNameSplit) {
                        teamNameTotal = teamNameTotal.concat(dB + teamNamePart + " ");
                    }
                    playerInvited.addChatMessage(new ChatComponentText(dA + GCCoreUtil.translateWithFormat("gui.space_race.chat.invite_received", bG + PlayerUtil.getName(player) + dA) + "  " + GCCoreUtil.translateWithFormat("gui.space_race.chat.to_join", teamNameTotal, EnumColor.AQUA + "/joinrace" + dA)).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(GCCoreUtil.translateWithFormat("gui.space_race.chat.not_found", playerToRemove)));
                } else {
                    SpaceRaceManager.onPlayerRemoval(server, 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(server, null, spaceRaceToAddPlayer);
                    for (String member : spaceRaceToAddPlayer.getPlayerNames()) {
                        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
                        if (memberObj != null) {
                            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.add_success", EnumColor.BRIGHT_GREEN + playerToAdd + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
                        }
                    }
                } else {
                    player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.space_race.chat.already_part")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
                }
            }
            break;
        case S_COMPLETE_CBODY_HANDSHAKE:
            String completeList = (String) this.data.get(0);
            List<String> clientObjects = Arrays.asList(completeList.split(";"));
            List<String> serverObjects = Lists.newArrayList();
            String missingObjects = "";
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
                serverObjects.add(solarSystem.getUnlocalizedName());
            }
            for (String str : serverObjects) {
                if (!clientObjects.contains(str)) {
                    missingObjects = missingObjects.concat(str + "\n");
                }
            }
            if (missingObjects.length() > 0) {
                playerBase.playerNetServerHandler.kickPlayerFromServer("Missing Galacticraft Celestial Objects:\n\n " + missingObjects);
            }
            break;
        case S_REQUEST_GEAR_DATA:
            String name = (String) this.data.get(0);
            EntityPlayerMP e = PlayerUtil.getPlayerBaseServerFromPlayerUsername(name, true);
            if (e != null) {
                GCPlayerHandler.checkGear(e, GCPlayerStats.get(e), true);
            }
            break;
        case S_BUILDFLAGS_UPDATE:
            stats.setBuildFlags((Integer) this.data.get(0));
            break;
        case S_REQUEST_OVERWORLD_IMAGE:
            MapUtil.sendOverworldToClient(playerBase);
            break;
        case S_REQUEST_MAP_IMAGE:
            int dim = (Integer) this.data.get(0);
            int cx = (Integer) this.data.get(1);
            int cz = (Integer) this.data.get(2);
            MapUtil.sendOrCreateMap(WorldUtil.getProviderForDimensionServer(dim).worldObj, cx, cz, playerBase);
            break;
        case S_REQUEST_PLAYERSKIN:
            String strName = (String) this.data.get(0);
            EntityPlayerMP playerRequested = server.getConfigurationManager().getPlayerByUsername(strName);
            // Player not online
            if (playerRequested == null) {
                return;
            }
            GameProfile gp = playerRequested.getGameProfile();
            if (gp == null) {
                return;
            }
            Property property = (Property) Iterables.getFirst(gp.getProperties().get("textures"), (Object) null);
            if (property == null) {
                return;
            }
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_SEND_PLAYERSKIN, getDimensionID(), new Object[] { strName, property.getValue(), property.getSignature(), playerRequested.getUniqueID().toString() }), playerBase);
            break;
        case S_CONTROL_ENTITY:
            if (player.ridingEntity != null && player.ridingEntity instanceof IControllableEntity) {
                ((IControllableEntity) player.ridingEntity).pressKey((Integer) this.data.get(0));
            }
            break;
        case S_NOCLIP_PLAYER:
            boolean noClip = (Boolean) this.data.get(0);
            if (player instanceof GCEntityPlayerMP) {
                GalacticraftCore.proxy.player.setNoClip((EntityPlayerMP) player, noClip);
                if (noClip == false) {
                    player.fallDistance = 0.0F;
                    ((EntityPlayerMP) player).playerNetServerHandler.floatingTickCount = 0;
                }
            } else if (player instanceof EntityPlayerMP) {
                EntityPlayerMP emp = ((EntityPlayerMP) player);
                try {
                    Field f = emp.theItemInWorldManager.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "gameType" : "field_73091_c");
                    f.setAccessible(true);
                    if (noClip == false) {
                        emp.fallDistance = 0.0F;
                        emp.playerNetServerHandler.floatingTickCount = 0;
                        WorldSettings.GameType gt = savedSettings.get(emp);
                        if (gt != null) {
                            savedSettings.remove(emp);
                            f.set(emp.theItemInWorldManager, gt);
                        }
                    } else {
                        savedSettings.put(emp, emp.theItemInWorldManager.getGameType());
                        f.set(emp.theItemInWorldManager, WorldSettings.GameType.SPECTATOR);
                    }
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
            }
            break;
        case S_REQUEST_DATA:
            WorldServer worldServer = server.worldServerForDimension((Integer) this.data.get(0));
            if (worldServer != null) {
                TileEntity requestedTile = worldServer.getTileEntity((BlockPos) this.data.get(1));
                if (requestedTile instanceof INetworkProvider) {
                    if (((INetworkProvider) requestedTile).getNetwork() instanceof FluidNetwork) {
                        FluidNetwork network = (FluidNetwork) ((INetworkProvider) requestedTile).getNetwork();
                        network.addUpdate(playerBase);
                    }
                }
            }
            break;
        case S_UPDATE_CHECKLIST:
            ItemStack stack = player.getHeldItem();
            if (stack != null && stack.getItem() == GCItems.prelaunchChecklist) {
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound == null) {
                    tagCompound = new NBTTagCompound();
                }
                NBTTagCompound tagCompoundRead = (NBTTagCompound) this.data.get(0);
                tagCompound.setTag("checklistData", tagCompoundRead);
                stack.setTagCompound(tagCompound);
            }
            break;
        case S_REQUEST_MACHINE_DATA:
            TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile3 instanceof ITileClientUpdates) {
                ((ITileClientUpdates) tile3).sendUpdateToClient(playerBase);
            }
            break;
        default:
            break;
    }
}
Also used : IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) SolarSystem(micdoodle8.mods.galacticraft.api.galaxies.SolarSystem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) Container(net.minecraft.inventory.Container) EntityBuggy(micdoodle8.mods.galacticraft.core.entities.EntityBuggy) IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) IDisableableMachine(micdoodle8.mods.galacticraft.api.tile.IDisableableMachine) ContainerSchematic(micdoodle8.mods.galacticraft.core.inventory.ContainerSchematic) S07PacketRespawn(net.minecraft.network.play.server.S07PacketRespawn) EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) GameProfile(com.mojang.authlib.GameProfile) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ITileClientUpdates(micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates) TileEntity(net.minecraft.tileentity.TileEntity) Field(java.lang.reflect.Field) ItemParaChute(micdoodle8.mods.galacticraft.core.items.ItemParaChute) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ScheduledDimensionChange(micdoodle8.mods.galacticraft.core.wrappers.ScheduledDimensionChange) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Property(com.mojang.authlib.properties.Property) EntitySpaceshipBase(micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase) SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IBubbleProvider(micdoodle8.mods.galacticraft.core.entities.IBubbleProvider) IOException(java.io.IOException) MinecraftServer(net.minecraft.server.MinecraftServer) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Example 10 with CelestialBody

use of micdoodle8.mods.galacticraft.api.galaxies.CelestialBody in project Galacticraft by micdoodle8.

the class PacketSimple method handleClientSide.

@SideOnly(Side.CLIENT)
@Override
public void handleClientSide(EntityPlayer player) {
    EntityPlayerSP playerBaseClient = null;
    GCPlayerStatsClient stats = null;
    if (player instanceof EntityPlayerSP) {
        playerBaseClient = (EntityPlayerSP) player;
        stats = GCPlayerStatsClient.get(playerBaseClient);
    } else {
        if (type != EnumSimplePacket.C_UPDATE_SPACESTATION_LIST && type != EnumSimplePacket.C_UPDATE_PLANETS_LIST && type != EnumSimplePacket.C_UPDATE_CONFIGS) {
            return;
        }
    }
    switch(this.type) {
        case C_AIR_REMAINING:
            if (String.valueOf(this.data.get(2)).equals(String.valueOf(PlayerUtil.getName(player)))) {
                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(PlayerUtil.getName(player))) {
                String dimensionList = (String) this.data.get(1);
                if (ConfigManagerCore.enableDebug) {
                    if (!dimensionList.equals(PacketSimple.spamCheckString)) {
                        GCLog.info("DEBUG info: " + dimensionList);
                        PacketSimple.spamCheckString = dimensionList;
                    }
                }
                final String[] destinations = dimensionList.split("\\?");
                List<CelestialBody> possibleCelestialBodies = Lists.newArrayList();
                Map<Integer, Map<String, GuiCelestialSelection.StationDataGUI>> spaceStationData = Maps.newHashMap();
                for (String str : destinations) {
                    CelestialBody celestialBody = WorldUtil.getReachableCelestialBodiesForName(str);
                    if (celestialBody == null && str.contains("$")) {
                        String[] values = str.split("\\$");
                        int homePlanetID = Integer.parseInt(values[4]);
                        for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
                            if (satellite.getParentPlanet().getDimensionID() == homePlanetID) {
                                celestialBody = satellite;
                                break;
                            }
                        }
                        if (!spaceStationData.containsKey(homePlanetID)) {
                            spaceStationData.put(homePlanetID, new HashMap<String, GuiCelestialSelection.StationDataGUI>());
                        }
                        spaceStationData.get(homePlanetID).put(values[1], new GuiCelestialSelection.StationDataGUI(values[2], Integer.parseInt(values[3])));
                    // spaceStationNames.put(values[1], values[2]);
                    // spaceStationIDs.put(values[1], Integer.parseInt(values[3]));
                    // spaceStationHomes.put(values[1], Integer.parseInt(values[4]));
                    }
                    if (celestialBody != null) {
                        possibleCelestialBodies.add(celestialBody);
                    }
                }
                if (FMLClientHandler.instance().getClient().theWorld != null) {
                    if (!(FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection)) {
                        GuiCelestialSelection gui = new GuiCelestialSelection(false, possibleCelestialBodies);
                        gui.spaceStationMap = spaceStationData;
                        // gui.spaceStationNames = spaceStationNames;
                        // gui.spaceStationIDs = spaceStationIDs;
                        FMLClientHandler.instance().getClient().displayGuiScreen(gui);
                    } else {
                        ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).possibleBodies = possibleCelestialBodies;
                        ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationMap = spaceStationData;
                    // ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationNames = spaceStationNames;
                    // ((GuiCelestialSelection) FMLClientHandler.instance().getClient().currentScreen).spaceStationIDs = spaceStationIDs;
                    }
                }
            }
            break;
        case C_SPAWN_SPARK_PARTICLES:
            BlockPos pos = (BlockPos) this.data.get(0);
            Minecraft mc = Minecraft.getMinecraft();
            for (int i = 0; i < 4; i++) {
                if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null && mc.theWorld != null) {
                    final EntityFX fx = new EntityFXSparks(mc.theWorld, pos.getX() - 0.15 + 0.5, pos.getY() + 1.2, pos.getZ() + 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(3);
            String gearName = (String) this.data.get(0);
            EntityPlayer gearDataPlayer = player.worldObj.getPlayerEntityByName(gearName);
            if (gearDataPlayer != null) {
                PlayerGearData gearData = ClientProxyCore.playerItemData.get(PlayerUtil.getName(gearDataPlayer));
                if (gearData == null) {
                    gearData = new PlayerGearData(player);
                    if (!ClientProxyCore.gearDataRequests.contains(gearName)) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_REQUEST_GEAR_DATA, getDimensionID(), new Object[] { gearName }));
                        ClientProxyCore.gearDataRequests.add(gearName);
                    }
                } else {
                    ClientProxyCore.gearDataRequests.remove(gearName);
                }
                EnumExtendedInventorySlot type = EnumExtendedInventorySlot.values()[(Integer) this.data.get(2)];
                EnumModelPacketType typeChange = EnumModelPacketType.values()[(Integer) this.data.get(1)];
                switch(type) {
                    case MASK:
                        gearData.setMask(subtype);
                        break;
                    case GEAR:
                        gearData.setGear(subtype);
                        break;
                    case LEFT_TANK:
                        gearData.setLeftTank(subtype);
                        break;
                    case RIGHT_TANK:
                        gearData.setRightTank(subtype);
                        break;
                    case PARACHUTE:
                        if (typeChange == EnumModelPacketType.ADD) {
                            String name;
                            if (subtype != -1) {
                                name = ItemParaChute.names[subtype];
                                gearData.setParachute(new ResourceLocation(Constants.ASSET_PREFIX, "textures/model/parachute/" + name + ".png"));
                            }
                        } else {
                            gearData.setParachute(null);
                        }
                        break;
                    case FREQUENCY_MODULE:
                        gearData.setFrequencyModule(subtype);
                        break;
                    case THERMAL_HELMET:
                        gearData.setThermalPadding(0, subtype);
                        break;
                    case THERMAL_CHESTPLATE:
                        gearData.setThermalPadding(1, subtype);
                        break;
                    case THERMAL_LEGGINGS:
                        gearData.setThermalPadding(2, subtype);
                        break;
                    case THERMAL_BOOTS:
                        gearData.setThermalPadding(3, subtype);
                        break;
                    case SHIELD_CONTROLLER:
                        gearData.setShieldController(subtype);
                        break;
                    default:
                        break;
                }
                ClientProxyCore.playerItemData.put(gearName, gearData);
            }
            break;
        case C_CLOSE_GUI:
            FMLClientHandler.instance().getClient().displayGuiScreen(null);
            break;
        case C_RESET_THIRD_PERSON:
            FMLClientHandler.instance().getClient().gameSettings.thirdPersonView = stats.getThirdPersonView();
            break;
        case C_UPDATE_SPACESTATION_LIST:
            WorldUtil.decodeSpaceStationListClient(data);
            break;
        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 = WorldUtil.stringToSpaceStationData((String) this.data.get(0));
            break;
        case C_UPDATE_PLANETS_LIST:
            WorldUtil.decodePlanetsListClient(data);
            break;
        case C_UPDATE_CONFIGS:
            ConfigManagerCore.saveClientConfigOverrideable();
            ConfigManagerCore.setConfigOverride(data);
            break;
        case C_ADD_NEW_SCHEMATIC:
            final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
            if (!stats.getUnlockedSchematics().contains(page)) {
                stats.getUnlockedSchematics().add(page);
            }
            break;
        case C_UPDATE_SCHEMATIC_LIST:
            for (Object o : this.data) {
                Integer schematicID = (Integer) o;
                if (schematicID != -2) {
                    Collections.sort(stats.getUnlockedSchematics());
                    if (!stats.getUnlockedSchematics().contains(SchematicRegistry.getMatchingRecipeForID(schematicID))) {
                        stats.getUnlockedSchematics().add(SchematicRegistry.getMatchingRecipeForID(schematicID));
                    }
                }
            }
            break;
        case C_PLAY_SOUND_BOSS_DEATH:
            player.playSound(Constants.TEXTURE_PREFIX + "entity.bossdeath", 10.0F, (Float) this.data.get(0));
            break;
        case C_PLAY_SOUND_EXPLODE:
            player.playSound("random.explode", 10.0F, 0.7F);
            break;
        case C_PLAY_SOUND_BOSS_LAUGH:
            player.playSound(Constants.TEXTURE_PREFIX + "entity.bosslaugh", 10.0F, 1.1F);
            break;
        case C_PLAY_SOUND_BOW:
            player.playSound("random.bow", 10.0F, 0.2F);
            break;
        case C_UPDATE_OXYGEN_VALIDITY:
            stats.setOxygenSetupValid((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((BlockPos) this.data.get(0));
            if (tile instanceof TileBaseConductor) {
                ((TileBaseConductor) tile).adjacentConnections = null;
                player.worldObj.getBlockState(tile.getPos()).getBlock().setBlockBoundsBasedOnState(player.worldObj, tile.getPos());
            }
            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:
            stats.setSpaceRaceInviteTeamID((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_DUNGEON_DIRECTION:
            stats.setDungeonDirection((Float) this.data.get(0));
            break;
        case C_UPDATE_FOOTPRINT_LIST:
            List<Footprint> printList = new ArrayList<Footprint>();
            long chunkKey = (Long) this.data.get(0);
            for (int i = 1; i < this.data.size(); i++) {
                Footprint print = (Footprint) this.data.get(i);
                if (!print.owner.equals(player.getName())) {
                    printList.add(print);
                }
            }
            FootprintRenderer.setFootprints(chunkKey, printList);
            break;
        case C_FOOTPRINTS_REMOVED:
            long chunkKey0 = (Long) this.data.get(0);
            BlockVec3 position = (BlockVec3) this.data.get(1);
            List<Footprint> footprintList = FootprintRenderer.footprints.get(chunkKey0);
            List<Footprint> toRemove = new ArrayList<Footprint>();
            if (footprintList != null) {
                for (Footprint footprint : footprintList) {
                    if (footprint.position.x > position.x && footprint.position.x < position.x + 1 && footprint.position.z > position.z && footprint.position.z < position.z + 1) {
                        toRemove.add(footprint);
                    }
                }
            }
            if (!toRemove.isEmpty()) {
                footprintList.removeAll(toRemove);
                FootprintRenderer.footprints.put(chunkKey0, footprintList);
            }
            break;
        case C_UPDATE_STATION_SPIN:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinRate((Float) this.data.get(0), (Boolean) this.data.get(1));
            }
            break;
        case C_UPDATE_STATION_DATA:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().setSpinCentre((Double) this.data.get(0), (Double) this.data.get(1));
            }
            break;
        case C_UPDATE_STATION_BOX:
            if (playerBaseClient.worldObj.provider instanceof WorldProviderSpaceStation) {
                ((WorldProviderSpaceStation) playerBaseClient.worldObj.provider).getSpinManager().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:
            stats.setThermalLevel((Integer) this.data.get(0));
            stats.setThermalLevelNormalising((Boolean) this.data.get(1));
            break;
        case C_DISPLAY_ROCKET_CONTROLS:
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.spaceKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.launch.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.leftKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.rightKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.turn.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.accelerateKey.getKeyCode()) + " / " + GameSettings.getKeyDisplayString(KeyHandlerClient.decelerateKey.getKeyCode()) + "  - " + GCCoreUtil.translate("gui.rocket.updown.name")));
            player.addChatMessage(new ChatComponentText(GameSettings.getKeyDisplayString(KeyHandlerClient.openFuelGui.getKeyCode()) + "       - " + GCCoreUtil.translate("gui.rocket.inv.name")));
            break;
        case C_GET_CELESTIAL_BODY_LIST:
            String str = "";
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
                str = str.concat(cBody.getUnlocalizedName() + ";");
            }
            for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
                str = str.concat(solarSystem.getUnlocalizedName() + ";");
            }
            GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_COMPLETE_CBODY_HANDSHAKE, getDimensionID(), new Object[] { str }));
            break;
        case C_UPDATE_ENERGYUNITS:
            CommandGCEnergyUnits.handleParamClientside((Integer) this.data.get(0));
            break;
        case C_RESPAWN_PLAYER:
            final WorldProvider provider = WorldUtil.getProviderForNameClient((String) this.data.get(0));
            final int dimID = GCCoreUtil.getDimensionID(provider);
            if (ConfigManagerCore.enableDebug) {
                GCLog.info("DEBUG: Client receiving respawn packet for dim " + dimID);
            }
            int par2 = (Integer) this.data.get(1);
            String par3 = (String) this.data.get(2);
            int par4 = (Integer) this.data.get(3);
            WorldUtil.forceRespawnClient(dimID, par2, par3, par4);
            break;
        case C_UPDATE_STATS:
            stats.setBuildFlags((Integer) this.data.get(0));
            BlockPanelLighting.updateClient(this.data);
            break;
        case C_UPDATE_TELEMETRY:
            tile = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityTelemetry) {
                ((TileEntityTelemetry) tile).receiveUpdate(data, this.getDimensionID());
            }
            break;
        case C_SEND_PLAYERSKIN:
            String strName = (String) this.data.get(0);
            String s1 = (String) this.data.get(1);
            String s2 = (String) this.data.get(2);
            String strUUID = (String) this.data.get(3);
            GameProfile gp = PlayerUtil.getOtherPlayerProfile(strName);
            if (gp == null) {
                gp = PlayerUtil.makeOtherPlayerProfile(strName, strUUID);
            }
            gp.getProperties().put("textures", new Property("textures", s1, s2));
            break;
        case C_SEND_OVERWORLD_IMAGE:
            try {
                int cx = (Integer) this.data.get(0);
                int cz = (Integer) this.data.get(1);
                byte[] bytes = (byte[]) this.data.get(2);
                MapUtil.receiveOverworldImageCompressed(cx, cz, bytes);
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case C_RECOLOR_PIPE:
            TileEntity tileEntity = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tileEntity instanceof TileEntityFluidPipe) {
                TileEntityFluidPipe pipe = (TileEntityFluidPipe) tileEntity;
                pipe.getNetwork().split(pipe);
                pipe.setNetwork(null);
            }
            break;
        case C_RECOLOR_ALL_GLASS:
            BlockSpaceGlass.updateGlassColors((Integer) this.data.get(0), (Integer) this.data.get(1), (Integer) this.data.get(2));
            break;
        case C_UPDATE_MACHINE_DATA:
            TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile3 instanceof ITileClientUpdates) {
                ((ITileClientUpdates) tile3).updateClient(this.data);
            }
            break;
        case C_LEAK_DATA:
            TileEntity tile4 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile4 instanceof TileEntityOxygenSealer) {
                ((ITileClientUpdates) tile4).updateClient(this.data);
            }
            break;
        case C_SPAWN_HANGING_SCHEMATIC:
            EntityHangingSchematic entity = new EntityHangingSchematic(player.worldObj, (BlockPos) this.data.get(0), EnumFacing.getFront((Integer) this.data.get(2)), (Integer) this.data.get(3));
            ((WorldClient) player.worldObj).addEntityToWorld((Integer) this.data.get(1), entity);
            break;
        default:
            break;
    }
}
Also used : IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileBaseConductor(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseConductor) SolarSystem(micdoodle8.mods.galacticraft.api.galaxies.SolarSystem) EntityBuggy(micdoodle8.mods.galacticraft.core.entities.EntityBuggy) WorldProvider(net.minecraft.world.WorldProvider) EntityFXSparks(micdoodle8.mods.galacticraft.core.client.fx.EntityFXSparks) EntityFX(net.minecraft.client.particle.EntityFX) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) EnumExtendedInventorySlot(micdoodle8.mods.galacticraft.api.item.EnumExtendedInventorySlot) GuiParaChest(micdoodle8.mods.galacticraft.core.client.gui.container.GuiParaChest) WorldClient(net.minecraft.client.multiplayer.WorldClient) EntityHangingSchematic(micdoodle8.mods.galacticraft.core.entities.EntityHangingSchematic) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) GuiBuggy(micdoodle8.mods.galacticraft.core.client.gui.container.GuiBuggy) SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ITileClientUpdates(micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates) Satellite(micdoodle8.mods.galacticraft.api.galaxies.Satellite) TileEntity(net.minecraft.tileentity.TileEntity) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData) EnumModelPacketType(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerHandler.EnumModelPacketType) Property(com.mojang.authlib.properties.Property) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) IInventorySettable(micdoodle8.mods.galacticraft.core.inventory.IInventorySettable) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) Minecraft(net.minecraft.client.Minecraft) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IOException(java.io.IOException) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)5 Vector3f (org.lwjgl.util.vector.Vector3f)5 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)3 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)3 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)3 ItemStack (net.minecraft.item.ItemStack)3 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)2 SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)2 EntityBuggy (micdoodle8.mods.galacticraft.core.entities.EntityBuggy)2 IControllableEntity (micdoodle8.mods.galacticraft.core.entities.IControllableEntity)2 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)2 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)2