mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
If the lasers still disconnect on their own now I'm gonna jump out of the window
This commit is contained in:
parent
8409d10f74
commit
eae2d1d288
6 changed files with 28 additions and 25 deletions
|
@ -43,7 +43,6 @@ import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.update.UpdateChecker;
|
import ellpeck.actuallyadditions.update.UpdateChecker;
|
||||||
import ellpeck.actuallyadditions.util.ModUtil;
|
import ellpeck.actuallyadditions.util.ModUtil;
|
||||||
import ellpeck.actuallyadditions.util.Util;
|
import ellpeck.actuallyadditions.util.Util;
|
||||||
import ellpeck.actuallyadditions.util.playerdata.PersistentServerData;
|
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
|
||||||
|
@ -129,10 +128,4 @@ public class ActuallyAdditions{
|
||||||
|
|
||||||
WorldData.init(MinecraftServer.getServer());
|
WorldData.init(MinecraftServer.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void serverStopped(FMLServerStoppedEvent event){
|
|
||||||
//Clear Data so that it won't be carried over to other worlds
|
|
||||||
PersistentServerData.playerSaveData.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class CraftEvent{
|
||||||
NBTTagCompound compound = PersistentServerData.getDataFromPlayer(event.player);
|
NBTTagCompound compound = PersistentServerData.getDataFromPlayer(event.player);
|
||||||
if(compound != null && !compound.getBoolean("BookGottenAlready")){
|
if(compound != null && !compound.getBoolean("BookGottenAlready")){
|
||||||
compound.setBoolean("BookGottenAlready", true);
|
compound.setBoolean("BookGottenAlready", true);
|
||||||
WorldData.makeDirty();
|
WorldData.makeDirty(false);
|
||||||
|
|
||||||
EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemLexicon));
|
EntityItem entityItem = new EntityItem(event.player.worldObj, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemLexicon));
|
||||||
entityItem.delayBeforeCanPickup = 0;
|
entityItem.delayBeforeCanPickup = 0;
|
||||||
|
|
|
@ -26,12 +26,11 @@ public class WorldLoadingEvents{
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onUnload(WorldEvent.Unload event){
|
public void onUnload(WorldEvent.Unload event){
|
||||||
//Clear Data so that it won't be carried over to other worlds
|
WorldData.makeDirty(true);
|
||||||
LaserRelayConnectionHandler.getInstance().networks.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onSave(WorldEvent.Save event){
|
public void onSave(WorldEvent.Save event){
|
||||||
WorldData.makeDirty();
|
WorldData.makeDirty(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class LaserRelayConnectionHandler{
|
||||||
}
|
}
|
||||||
//System.out.println("Removing a Relay from the Network!");
|
//System.out.println("Removing a Relay from the Network!");
|
||||||
}
|
}
|
||||||
WorldData.makeDirty();
|
WorldData.makeDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +140,7 @@ public class LaserRelayConnectionHandler{
|
||||||
else if(secondNetwork != null){
|
else if(secondNetwork != null){
|
||||||
secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay));
|
||||||
}
|
}
|
||||||
WorldData.makeDirty();
|
WorldData.makeDirty(false);
|
||||||
//System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
|
//System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString());
|
||||||
//System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
|
//System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString());
|
||||||
//System.out.println(this.networks);
|
//System.out.println(this.networks);
|
||||||
|
@ -156,7 +156,7 @@ public class LaserRelayConnectionHandler{
|
||||||
firstNetwork.connections.add(secondPair);
|
firstNetwork.connections.add(secondPair);
|
||||||
}
|
}
|
||||||
this.networks.remove(secondNetwork);
|
this.networks.remove(secondNetwork);
|
||||||
WorldData.makeDirty();
|
WorldData.makeDirty(false);
|
||||||
//System.out.println("Merged Two Networks!");
|
//System.out.println("Merged Two Networks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,16 @@ public class WorldData extends WorldSavedData{
|
||||||
public static final String DATA_TAG = ModUtil.MOD_ID+"WorldData";
|
public static final String DATA_TAG = ModUtil.MOD_ID+"WorldData";
|
||||||
public static WorldData instance;
|
public static WorldData instance;
|
||||||
|
|
||||||
|
public boolean shouldClearAfterSave;
|
||||||
|
|
||||||
public WorldData(String tag){
|
public WorldData(String tag){
|
||||||
super(tag);
|
super(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void makeDirty(){
|
public static void makeDirty(boolean shouldClearAfterSave){
|
||||||
if(instance != null){
|
if(instance != null){
|
||||||
instance.markDirty();
|
instance.markDirty();
|
||||||
|
instance.shouldClearAfterSave = shouldClearAfterSave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,5 +93,13 @@ public class WorldData extends WorldSavedData{
|
||||||
playerList.appendTag(theSave.toNBT());
|
playerList.appendTag(theSave.toNBT());
|
||||||
}
|
}
|
||||||
compound.setTag("PlayerData", playerList);
|
compound.setTag("PlayerData", playerList);
|
||||||
|
|
||||||
|
if(this.shouldClearAfterSave){
|
||||||
|
ModUtil.LOGGER.info("Clearing WorldData after saving! (Probably because the world is getting unloaded)");
|
||||||
|
this.shouldClearAfterSave = false;
|
||||||
|
|
||||||
|
PersistentServerData.playerSaveData.clear();
|
||||||
|
LaserRelayConnectionHandler.getInstance().networks.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,19 +87,19 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){
|
||||||
if(pkt != null){
|
WorldPos thisPos = new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||||
NBTTagCompound compound = pkt.func_148857_g();
|
if(pkt != null && pkt.func_148857_g() != null){
|
||||||
|
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos);
|
||||||
|
|
||||||
if(compound != null){
|
NBTTagList list = pkt.func_148857_g().getTagList("Connections", 10);
|
||||||
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(new WorldPos(this.worldObj, this.xCoord, this.yCoord, this.zCoord));
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
|
LaserRelayConnectionHandler.ConnectionPair pair = LaserRelayConnectionHandler.ConnectionPair.readFromNBT(list.getCompoundTagAt(i));
|
||||||
NBTTagList list = compound.getTagList("Connections", 10);
|
LaserRelayConnectionHandler.getInstance().addConnection(pair.firstRelay, pair.secondRelay);
|
||||||
for(int i = 0; i < list.tagCount(); i++){
|
|
||||||
LaserRelayConnectionHandler.ConnectionPair pair = LaserRelayConnectionHandler.ConnectionPair.readFromNBT(list.getCompoundTagAt(i));
|
|
||||||
LaserRelayConnectionHandler.getInstance().addConnection(pair.firstRelay, pair.secondRelay);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(thisPos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue