Search in sources :

Example 1 with SpaceRace

use of micdoodle8.mods.galacticraft.core.dimension.SpaceRace in project Galacticraft by micdoodle8.

the class TickHandlerServer method restart.

public static void restart() {
    TickHandlerServer.scheduledBlockChanges.clear();
    TickHandlerServer.scheduledTorchUpdates.clear();
    TickHandlerServer.edgeChecks.clear();
    TickHandlerServer.networkTicks.clear();
    TickHandlerServer.serverFootprintMap.clear();
    TickHandlerServer.oxygenTransmitterUpdates.clear();
    // TickHandlerServer.hydrogenTransmitterUpdates.clear();
    TickHandlerServer.energyTransmitterUpdates.clear();
    TickHandlerServer.playersRequestingMapData.clear();
    TickHandlerServer.networkTicks.clear();
    for (SpaceRace race : SpaceRaceManager.getSpaceRaces()) {
        SpaceRaceManager.removeSpaceRace(race);
    }
    TickHandlerServer.spaceRaceData = null;
    TickHandlerServer.tickCount = 0L;
    TickHandlerServer.fluidNetworks.clear();
    MapUtil.reset();
}
Also used : SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace)

Example 2 with SpaceRace

use of micdoodle8.mods.galacticraft.core.dimension.SpaceRace in project Galacticraft by micdoodle8.

the class SpaceRace method saveToNBT.

public void saveToNBT(NBTTagCompound nbt) {
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Saving spacerace data for team " + this.teamName);
    }
    nbt.setString("TeamName", this.teamName);
    nbt.setInteger("SpaceRaceID", this.spaceRaceID);
    nbt.setLong("TicksSpent", this.ticksSpent);
    this.flagData.saveFlagData(nbt);
    nbt.setDouble("teamColorR", this.teamColor.x);
    nbt.setDouble("teamColorG", this.teamColor.y);
    nbt.setDouble("teamColorB", this.teamColor.z);
    NBTTagList tagList = new NBTTagList();
    for (String player : this.playerNames) {
        NBTTagCompound tagComp = new NBTTagCompound();
        tagComp.setString("PlayerName", player);
        tagList.appendTag(tagComp);
    }
    nbt.setTag("PlayerList", tagList);
    tagList = new NBTTagList();
    for (Entry<CelestialBody, Integer> celestialBody : this.celestialBodyStatusList.entrySet()) {
        NBTTagCompound tagComp = new NBTTagCompound();
        tagComp.setString("CelestialBodyName", celestialBody.getKey().getUnlocalizedName());
        tagComp.setInteger("TimeTaken", celestialBody.getValue());
        tagList.appendTag(tagComp);
    }
    nbt.setTag("CelestialBodyList", tagList);
    tagList = new NBTTagList();
    for (Entry<String, List<ItemStack>> schematic : this.schematicsToUnlock.entrySet()) {
        if (this.playerNames.contains(schematic.getKey())) {
            NBTTagCompound tagComp = new NBTTagCompound();
            tagComp.setString("Mem", schematic.getKey());
            final NBTTagList itemList = new NBTTagList();
            for (ItemStack stack : schematic.getValue()) {
                final NBTTagCompound itemTag = new NBTTagCompound();
                stack.writeToNBT(itemTag);
                itemList.appendTag(itemTag);
            }
            tagComp.setTag("Sch", itemList);
            tagList.appendTag(tagComp);
        }
    }
    nbt.setTag("SchList", tagList);
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Saved spacerace team data OK.");
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) ArrayList(java.util.ArrayList) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 3 with SpaceRace

use of micdoodle8.mods.galacticraft.core.dimension.SpaceRace in project Galacticraft by micdoodle8.

the class SpaceRace method loadFromNBT.

public void loadFromNBT(NBTTagCompound nbt) {
    this.teamName = nbt.getString("TeamName");
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loading spacerace data for team " + this.teamName);
    }
    this.spaceRaceID = nbt.getInteger("SpaceRaceID");
    // Deal with legacy error
    this.ticksSpent = (int) nbt.getLong("TicksSpent");
    this.flagData = FlagData.readFlagData(nbt);
    this.teamColor = new Vector3(nbt.getDouble("teamColorR"), nbt.getDouble("teamColorG"), nbt.getDouble("teamColorB"));
    NBTTagList tagList = nbt.getTagList("PlayerList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        this.playerNames.add(tagAt.getString("PlayerName"));
    }
    tagList = nbt.getTagList("CelestialBodyList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        CelestialBody body = GalaxyRegistry.getCelestialBodyFromUnlocalizedName(tagAt.getString("CelestialBodyName"));
        if (body != null) {
            this.celestialBodyStatusList.put(body, tagAt.getInteger("TimeTaken"));
        }
    }
    tagList = nbt.getTagList("SchList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        String name = tagAt.getString("Mem");
        if (name != null && this.playerNames.contains(name)) {
            final NBTTagList itemList = tagAt.getTagList("Sch", 10);
            for (int j = 0; j < itemList.tagCount(); ++j) {
                addNewSchematic(name, ItemStack.loadItemStackFromNBT(itemList.getCompoundTagAt(j)));
            }
        }
    }
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loaded spacerace team data OK.");
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 4 with SpaceRace

use of micdoodle8.mods.galacticraft.core.dimension.SpaceRace in project Galacticraft by micdoodle8.

the class SpaceRaceManager method onPlayerRemoval.

public static void onPlayerRemoval(MinecraftServer server, String player, SpaceRace race) {
    for (String member : race.getPlayerNames()) {
        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
        if (memberObj != null) {
            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.remove_success", EnumColor.RED + player + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
        }
    }
    List<String> playerList = new ArrayList<String>();
    playerList.add(player);
    SpaceRace newRace = SpaceRaceManager.addSpaceRace(new SpaceRace(playerList, SpaceRace.DEFAULT_NAME, new FlagData(48, 32), new Vector3(1, 1, 1)));
    EntityPlayerMP playerToRemove = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, player, true);
    if (playerToRemove != null) {
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, newRace);
        SpaceRaceManager.sendSpaceRaceData(server, playerToRemove, race);
    }
}
Also used : ChatStyle(net.minecraft.util.ChatStyle) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ArrayList(java.util.ArrayList) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 5 with SpaceRace

use of micdoodle8.mods.galacticraft.core.dimension.SpaceRace in project Galacticraft by micdoodle8.

the class GuiNewSpaceRace method actionPerformed.

@Override
protected void actionPerformed(GuiButton buttonClicked) {
    switch(buttonClicked.id) {
        case 0:
            if (this.currentState == EnumSpaceRaceGui.CHANGE_TEAM_COLOR) {
                this.markDirty();
            }
            this.exitCurrentScreen(true);
            break;
        case 1:
            break;
        case 2:
            if (this.currentState == EnumSpaceRaceGui.MAIN && this.canEdit) {
                this.currentState = EnumSpaceRaceGui.ADD_PLAYER;
                this.initGui();
            } else if (this.currentState == EnumSpaceRaceGui.ADD_PLAYER) {
                ListElement playerToInvite = this.gradientListAddPlayers.getSelectedElement();
                if (playerToInvite != null && !this.recentlyInvited.containsKey(playerToInvite.value)) {
                    SpaceRace race = SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(this.thePlayer));
                    if (race != null) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_INVITE_RACE_PLAYER, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { playerToInvite.value, race.getSpaceRaceID() }));
                        this.recentlyInvited.put(playerToInvite.value, 20 * 60);
                    }
                }
            } else if (this.currentState == EnumSpaceRaceGui.REMOVE_PLAYER) {
                ListElement playerToRemove = this.gradientListRemovePlayers.getSelectedElement();
                if (playerToRemove != null) {
                    SpaceRace race = SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(this.thePlayer));
                    if (race != null) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_REMOVE_RACE_PLAYER, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { playerToRemove.value, race.getSpaceRaceID() }));
                    }
                }
            }
            break;
        case 3:
            if (this.currentState == EnumSpaceRaceGui.MAIN && this.canEdit) {
                this.currentState = EnumSpaceRaceGui.REMOVE_PLAYER;
                this.initGui();
            }
            break;
        default:
            break;
    }
}
Also used : SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ListElement(micdoodle8.mods.galacticraft.core.client.gui.element.GuiElementGradientList.ListElement) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple)

Aggregations

SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)7 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)5 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 ArrayList (java.util.ArrayList)3 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)3 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)3 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)3 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)3 ItemStack (net.minecraft.item.ItemStack)3 WorldServer (net.minecraft.world.WorldServer)3 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)2 EntityBuggy (micdoodle8.mods.galacticraft.core.entities.EntityBuggy)2