Search in sources :

Example 1 with TileEntityAirLockController

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController in project MorePlanets by SteveKunG.

the class ComponentCrashedAlienShipPieces method replaceDataBlocks2.

@SuppressWarnings("deprecation")
private static void replaceDataBlocks2(World world, Random rand, Rotation rotation, Template template, BlockPos pos, PlacementSettings settings) {
    Map<BlockPos, String> map = template.getDataBlocks(pos, settings);
    for (Map.Entry<BlockPos, String> entry : map.entrySet()) {
        String dataName = entry.getValue();
        BlockPos dataPos = entry.getKey();
        if ("airlock".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.airLockFrame.getStateFromMeta(1), 3);
            TileEntity tile = world.getTileEntity(dataPos);
            if (tile instanceof TileEntityAirLockController) {
                ((TileEntityAirLockController) tile).playerDistanceSelection = 1;
            }
        } else if ("chest_or_crystals".equals(dataName)) {
            if (rand.nextFloat() > 0.95F) {
                world.setBlockState(dataPos, MPBlocks.ALIEN_CHEST.getDefaultState().withRotation(rotation), 3);
                TileEntity tile = world.getTileEntity(dataPos);
                if (tile instanceof TileEntityChestMP) {
                    ((TileEntityChestMP) tile).setLootTable(MPLootTables.CRASHED_ALIEN_SHIP, rand.nextLong());
                }
            } else if (rand.nextFloat() > 0.75F) {
                world.setBlockState(dataPos, GCBlocks.fallenMeteor.getDefaultState(), 3);
                TileEntity tile = world.getTileEntity(dataPos);
                if (tile instanceof TileEntityFallenMeteor) {
                    ((TileEntityFallenMeteor) tile).heatLevel = 0;
                }
            } else {
                world.setBlockState(dataPos, MPBlocks.INFECTED_PURLONITE_CRYSTAL.getDefaultState(), 3);
            }
        } else if ("arclamp_west".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.WEST)), 3);
        } else if ("arclamp_east".equals(dataName)) {
            world.setBlockState(dataPos, GCBlocks.brightLamp.getDefaultState().withProperty(BlockBrightLamp.FACING, rotation.rotate(EnumFacing.EAST)), 3);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAirLockController(micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController) TileEntityChestMP(stevekung.mods.moreplanets.utils.tileentity.TileEntityChestMP) TileEntityFallenMeteor(micdoodle8.mods.galacticraft.core.tile.TileEntityFallenMeteor) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map)

Example 2 with TileEntityAirLockController

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController in project Galacticraft by micdoodle8.

the class BlockAirLockFrame method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityAirLockController && placer instanceof EntityPlayer) {
        ((TileEntityAirLockController) tile).ownerName = PlayerUtil.getName(((EntityPlayer) placer));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAirLockController(micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 3 with TileEntityAirLockController

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController in project Galacticraft by micdoodle8.

the class GuiHandler method getClientGuiElement.

@SideOnly(Side.CLIENT)
private Object getClientGuiElement(int ID, EntityPlayer player, World world, BlockPos position) {
    EntityPlayerSP playerClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false);
    if (ID == GuiIdsCore.GALAXY_MAP) {
        return new GuiCelestialSelection(true, null, true);
    } else if (ID == GuiIdsCore.ROCKET_INVENTORY && player.getRidingEntity() instanceof EntityTieredRocket) {
        return new GuiRocketInventory(player.inventory, (EntityTieredRocket) player.getRidingEntity(), ((EntityTieredRocket) player.getRidingEntity()).getType());
    } else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
        return new GuiExtendedInventory(player, ClientProxyCore.dummyInventory);
    } else if (ID == GuiIdsCore.SPACE_RACE_START) {
        return new GuiNewSpaceRace(player);
    } else if (ID == GuiIdsCore.SPACE_RACE_JOIN) {
        return new GuiJoinSpaceRace(playerClient);
    } else if (ID == GuiIdsCore.PRE_LAUNCH_CHECKLIST) {
        ItemStack checkList = GCCoreUtil.getMatchingItemEitherHand(playerClient, GCItems.prelaunchChecklist);
        return new GuiPreLaunchChecklist(WorldUtil.getAllChecklistKeys(), checkList != null && checkList.hasTagCompound() ? (NBTTagCompound) checkList.getTagCompound().getTag("checklistData") : null);
    }
    TileEntity tile = world.getTileEntity(position);
    if (tile != null) {
        if (tile instanceof TileEntityCrafting) {
            return new GuiCrafting(player.inventory, (TileEntityCrafting) tile);
        } else if (tile instanceof TileEntityRefinery) {
            return new GuiRefinery(player.inventory, (TileEntityRefinery) world.getTileEntity(position));
        } else if (tile instanceof TileEntityOxygenCollector) {
            return new GuiOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
        } else if (tile instanceof TileEntityOxygenDistributor) {
            return new GuiOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
        } else if (tile instanceof TileEntityFuelLoader) {
            return new GuiFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
        } else if (tile instanceof TileEntityOxygenSealer) {
            return new GuiOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
        } else if (tile instanceof TileEntityCargoLoader) {
            return new GuiCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
        } else if (tile instanceof TileEntityCargoUnloader) {
            return new GuiCargoUnloader(player.inventory, (TileEntityCargoUnloader) tile);
        } else if (tile instanceof TileEntityParaChest) {
            return new GuiParaChest(player.inventory, (TileEntityParaChest) tile);
        } else if (tile instanceof TileEntitySolar) {
            return new GuiSolar(player.inventory, (TileEntitySolar) tile);
        } else if (tile instanceof TileEntityAirLockController) {
            return new GuiAirLockController((TileEntityAirLockController) tile);
        } else if (tile instanceof TileEntityEnergyStorageModule) {
            return new GuiEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
        } else if (tile instanceof TileEntityCoalGenerator) {
            return new GuiCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
        } else if (tile instanceof TileEntityElectricFurnace) {
            return new GuiElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
        } else if (tile instanceof TileEntityIngotCompressor) {
            return new GuiIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
        } else if (tile instanceof TileEntityElectricIngotCompressor) {
            return new GuiElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
        } else if (tile instanceof TileEntityCircuitFabricator) {
            return new GuiCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
        } else if (tile instanceof TileEntityOxygenStorageModule) {
            return new GuiOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
        } else if (tile instanceof TileEntityOxygenCompressor) {
            return new GuiOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile);
        } else if (tile instanceof TileEntityOxygenDecompressor) {
            return new GuiOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile);
        } else if (tile instanceof TileEntityDeconstructor) {
            return new GuiDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
        } else if (tile instanceof TileEntityPainter) {
            return new GuiPainter(player.inventory, (TileEntityPainter) tile);
        }
    }
    if (playerClient != null) {
        GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerClient);
        for (ISchematicPage page : stats.getUnlockedSchematics()) {
            if (ID == page.getGuiID()) {
                GuiScreen screen = page.getResultScreen(playerClient, position);
                if (screen instanceof ISchematicResultPage) {
                    ((ISchematicResultPage) screen).setPageIndex(page.getPageID());
                }
                return screen;
            }
        }
    }
    return null;
}
Also used : EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) GuiJoinSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiJoinSpaceRace) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) ItemStack(net.minecraft.item.ItemStack) ISchematicResultPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicResultPage) TileEntity(net.minecraft.tileentity.TileEntity) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiNewSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiNewSpaceRace) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) GuiPreLaunchChecklist(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiPreLaunchChecklist) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with TileEntityAirLockController

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController in project Galacticraft by micdoodle8.

the class BlockAirLockFrame method breakBlock.

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity tile = worldIn.getTileEntity(pos);
    if (tile instanceof TileEntityAirLockController) {
        ((TileEntityAirLockController) tile).unsealAirLock();
    }
    super.breakBlock(worldIn, pos, state);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAirLockController(micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController)

Example 5 with TileEntityAirLockController

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController 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.connection.sendPacket(new SPacketRespawn(player.dimension, player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), playerBase.interactionManager.getGameType()));
            break;
        case S_TELEPORT_ENTITY:
            TickHandlerServer.scheduleNewDimensionChange(new ScheduledDimensionChange(playerBase, (int) PacketSimple.this.data.get(0)));
            break;
        case S_IGNITE_ROCKET:
            if (!player.world.isRemote && !player.isDead && player.getRidingEntity() != null && !player.getRidingEntity().isDead && player.getRidingEntity() instanceof EntityTieredRocket) {
                final EntityTieredRocket ship = (EntityTieredRocket) player.getRidingEntity();
                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.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.rocket.warning.noparachute")));
                            stats.setChatCooldown(80);
                            stats.setLaunchAttempts(1);
                        }
                    } else if (stats.getChatCooldown() == 0) {
                        player.sendMessage(new TextComponentString(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.world, (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));
            }
            break;
        case S_OPEN_FUEL_GUI:
            if (player.getRidingEntity() instanceof EntityBuggy) {
                GCCoreUtil.openBuggyInv(playerBase, (EntityBuggy) player.getRidingEntity(), ((EntityBuggy) player.getRidingEntity()).getType());
            } else if (player.getRidingEntity() instanceof EntitySpaceshipBase) {
                player.openGui(GalacticraftCore.instance, GuiIdsCore.ROCKET_INVENTORY, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
            }
            break;
        case S_UPDATE_SHIP_YAW:
            if (player.getRidingEntity() instanceof EntitySpaceshipBase) {
                final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.getRidingEntity();
                if (ship != null) {
                    ship.rotationYaw = (Float) this.data.get(0);
                }
            }
            break;
        case S_UPDATE_SHIP_PITCH:
            if (player.getRidingEntity() instanceof EntitySpaceshipBase) {
                final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.getRidingEntity();
                if (ship != null) {
                    ship.rotationPitch = (Float) this.data.get(0);
                }
            }
            break;
        case S_SET_ENTITY_FIRE:
            Entity entity = player.world.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)) {
                    GCTriggers.CREATE_SPACE_STATION.trigger(playerBase);
                    WorldUtil.bindSpaceStationToNewDimension(playerBase.world, 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.isEmpty()) {
                    final ISchematicPage page = SchematicRegistry.getMatchingRecipeForItemStack(stack);
                    if (page != null) {
                        SchematicRegistry.unlockNewPage(playerBase, stack);
                        SpaceRaceManager.teamUnlockSchematic(playerBase, stack);
                        stack.shrink(1);
                        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.world.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.sendMessage(new TextComponentString(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.world, (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.world, 0, 0, 0);
            break;
        case S_ON_ADVANCED_GUI_CLICKED_INT:
            TileEntity tile1 = player.world.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.world.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.world.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.sendMessage(new TextComponentString(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)).setStyle(new Style().setColor(TextFormatting.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.sendMessage(new TextComponentString(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.sendMessage(new TextComponentString(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.add_success", EnumColor.BRIGHT_GREEN + playerToAdd + EnumColor.DARK_AQUA)).setStyle(new Style().setColor(TextFormatting.DARK_AQUA)));
                        }
                    }
                } else {
                    player.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.space_race.chat.already_part")).setStyle(new Style().setColor(TextFormatting.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.connection.disconnect(new TextComponentString("Missing Galacticraft Celestial Objects:\n\n " + missingObjects));
            }
            break;
        case S_REQUEST_GEAR_DATA1:
        case S_REQUEST_GEAR_DATA2:
            UUID id = (UUID) this.data.get(0);
            if (id != null) {
                EntityPlayer otherPlayer = player.world.getPlayerEntityByUUID(id);
                if (otherPlayer instanceof EntityPlayerMP) {
                    GCPlayerHandler.checkGear((EntityPlayerMP) otherPlayer, GCPlayerStats.get(otherPlayer), 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).world, cx, cz, playerBase);
            break;
        case S_REQUEST_PLAYERSKIN:
            String strName = (String) this.data.get(0);
            EntityPlayerMP playerRequested = server.getPlayerList().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.getRidingEntity() != null && player.getRidingEntity() instanceof IControllableEntity) {
                ((IControllableEntity) player.getRidingEntity()).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).connection.floatingTickCount = 0;
                }
            } else if (player instanceof EntityPlayerMP) {
                EntityPlayerMP emp = ((EntityPlayerMP) player);
                try {
                    Field f = emp.interactionManager.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "gameType" : "field_73091_c");
                    f.setAccessible(true);
                    if (noClip == false) {
                        emp.fallDistance = 0.0F;
                        emp.connection.floatingTickCount = 0;
                        GameType gt = savedSettings.get(emp);
                        if (gt != null) {
                            savedSettings.remove(emp);
                            f.set(emp.interactionManager, gt);
                        }
                    } else {
                        savedSettings.put(emp, emp.interactionManager.getGameType());
                        f.set(emp.interactionManager, GameType.SPECTATOR);
                    }
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
            }
            break;
        case S_REQUEST_DATA:
            WorldServer worldServer = server.getWorld((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:
            for (EnumHand enumhand : EnumHand.values()) {
                ItemStack stack = player.getHeldItem(enumhand);
                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.world.getTileEntity((BlockPos) this.data.get(0));
            if (tile3 instanceof ITileClientUpdates) {
                ((ITileClientUpdates) tile3).sendUpdateToClient(playerBase);
            }
            break;
        case S_REQUEST_CONTAINER_SLOT_REFRESH:
            // server -> client
            if (player.openContainer.windowId == (Integer) this.data.get(0)) {
                for (int i = 0; i < player.openContainer.inventoryItemStacks.size(); ++i) {
                    player.openContainer.inventoryItemStacks.set(i, ItemStack.EMPTY);
                }
            }
            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) TextComponentString(net.minecraft.util.text.TextComponentString) GameType(net.minecraft.world.GameType) 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) SPacketRespawn(net.minecraft.network.play.server.SPacketRespawn) ContainerSchematic(micdoodle8.mods.galacticraft.core.inventory.ContainerSchematic) EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) TextComponentString(net.minecraft.util.text.TextComponentString) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) 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) EnumHand(net.minecraft.util.EnumHand) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Style(net.minecraft.util.text.Style) 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)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)5 TileEntityAirLockController (micdoodle8.mods.galacticraft.core.tile.TileEntityAirLockController)3 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Map (java.util.Map)1 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)1 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)1 EntityAutoRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket)1 EntitySpaceshipBase (micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase)1 ISchematicResultPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicResultPage)1 IDisableableMachine (micdoodle8.mods.galacticraft.api.tile.IDisableableMachine)1 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)1 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1