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();
}
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.");
}
}
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.");
}
}
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);
}
}
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;
}
}
Aggregations