Some more tweaks to the chunkloading code. The world.load event fires slightly later- once the entity watcher is
set up, so entities can actually load into the server world. Also, tickets actually save and load properly and null entities don't break the server
This commit is contained in:
parent
4dd3d2cfd7
commit
384f795d52
4 changed files with 43 additions and 31 deletions
|
@ -236,8 +236,8 @@ public class ForgeChunkManager
|
|||
|
||||
static void loadWorld(World world)
|
||||
{
|
||||
ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.<String, Ticket>create();
|
||||
tickets.put(world, loadedTickets);
|
||||
ArrayListMultimap<String, Ticket> newTickets = ArrayListMultimap.<String, Ticket>create();
|
||||
tickets.put(world, newTickets);
|
||||
|
||||
SetMultimap<ChunkCoordIntPair,Ticket> forcedChunkMap = LinkedHashMultimap.create();
|
||||
forcedChunks.put(world, forcedChunkMap);
|
||||
|
@ -253,6 +253,7 @@ public class ForgeChunkManager
|
|||
|
||||
if (chunkLoaderData.exists() && chunkLoaderData.isFile())
|
||||
{
|
||||
ArrayListMultimap<String, Ticket> loadedTickets = ArrayListMultimap.<String, Ticket>create();
|
||||
NBTTagCompound forcedChunkData;
|
||||
try
|
||||
{
|
||||
|
@ -638,19 +639,23 @@ public class ForgeChunkManager
|
|||
for (Ticket tick : ticketSet.get(modId))
|
||||
{
|
||||
NBTTagCompound ticket = new NBTTagCompound();
|
||||
tickets.appendTag(ticket);
|
||||
ticket.setByte("Type", (byte) tick.ticketType.ordinal());
|
||||
ticket.setByte("ChunkListDepth", (byte) tick.maxDepth);
|
||||
if (tick.modData != null)
|
||||
{
|
||||
ticket.setCompoundTag("ModData", tick.modData);
|
||||
}
|
||||
if (tick.ticketType == Type.ENTITY)
|
||||
if (tick.ticketType == Type.ENTITY && tick.entity != null)
|
||||
{
|
||||
ticket.setInteger("chunkX", MathHelper.floor_double(tick.entity.chunkCoordX));
|
||||
ticket.setInteger("chunkZ", MathHelper.floor_double(tick.entity.chunkCoordZ));
|
||||
ticket.setLong("PersistentIDMSB", tick.entity.getPersistentID().getMostSignificantBits());
|
||||
ticket.setLong("PersistentIDLSB", tick.entity.getPersistentID().getLeastSignificantBits());
|
||||
tickets.appendTag(ticket);
|
||||
}
|
||||
else if (tick.ticketType != Type.ENTITY)
|
||||
{
|
||||
tickets.appendTag(ticket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,15 +8,17 @@
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -58,6 +59,7 @@
|
||||
@@ -58,6 +59,9 @@
|
||||
import net.minecraft.src.WorldServerMulti;
|
||||
import net.minecraft.src.WorldSettings;
|
||||
import net.minecraft.src.WorldType;
|
||||
+import net.minecraftforge.common.DimensionManager;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
public abstract class MinecraftServer implements Runnable, IPlayerUsage, ICommandSender
|
||||
{
|
||||
@@ -137,7 +139,9 @@
|
||||
@@ -137,7 +141,9 @@
|
||||
public final long[] tickTimeArray = new long[100];
|
||||
|
||||
/** Stats are [dimension][tick%100] system.nanoTime is stored. */
|
||||
|
@ -27,7 +29,7 @@
|
|||
private KeyPair serverKeyPair;
|
||||
|
||||
/** Username of the server owner (for integrated servers) */
|
||||
@@ -204,8 +208,6 @@
|
||||
@@ -204,8 +210,6 @@
|
||||
{
|
||||
this.convertMapIfNeeded(par1Str);
|
||||
this.setUserMessage("menu.loadingLevel");
|
||||
|
@ -36,7 +38,7 @@
|
|||
ISaveHandler var6 = this.anvilConverterForAnvilFile.getSaveLoader(par1Str, true);
|
||||
WorldInfo var8 = var6.loadWorldInfo();
|
||||
WorldSettings var7;
|
||||
@@ -224,46 +226,21 @@
|
||||
@@ -224,46 +228,22 @@
|
||||
var7.enableBonusChest();
|
||||
}
|
||||
|
||||
|
@ -84,13 +86,16 @@
|
|||
}
|
||||
|
||||
this.serverConfigManager.setPlayerManager(this.worldServers);
|
||||
}
|
||||
|
||||
- }
|
||||
-
|
||||
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
|
||||
+ }
|
||||
+
|
||||
+ this.serverConfigManager.setPlayerManager(new WorldServer[]{ overWorld });
|
||||
this.setDifficultyForAllWorlds(this.getDifficulty());
|
||||
this.initialWorldChunkLoad();
|
||||
}
|
||||
@@ -622,13 +599,13 @@
|
||||
@@ -622,13 +602,13 @@
|
||||
{
|
||||
this.theProfiler.startSection("levels");
|
||||
|
||||
|
@ -108,7 +113,7 @@
|
|||
this.theProfiler.startSection(var4.getWorldInfo().getWorldName());
|
||||
|
||||
if (this.tickCounter % 20 == 0)
|
||||
@@ -659,7 +636,7 @@
|
||||
@@ -659,7 +639,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,7 @@
|
|||
}
|
||||
|
||||
this.theProfiler.endStartSection("connection");
|
||||
@@ -717,7 +694,8 @@
|
||||
@@ -717,7 +697,8 @@
|
||||
*/
|
||||
public WorldServer worldServerForDimension(int par1)
|
||||
{
|
||||
|
@ -127,7 +132,7 @@
|
|||
}
|
||||
|
||||
@SideOnly(Side.SERVER)
|
||||
@@ -830,7 +808,7 @@
|
||||
@@ -830,7 +811,7 @@
|
||||
|
||||
public String getServerModName()
|
||||
{
|
||||
|
|
|
@ -21,16 +21,15 @@
|
|||
|
||||
public class WorldServer extends World
|
||||
{
|
||||
@@ -71,6 +78,8 @@
|
||||
@@ -71,6 +78,7 @@
|
||||
{
|
||||
this.pendingTickListEntries = new TreeSet();
|
||||
}
|
||||
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(this));
|
||||
+ DimensionManager.setWorld(par4, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,10 +188,7 @@
|
||||
@@ -179,10 +187,7 @@
|
||||
|
||||
private void resetRainAndThunder()
|
||||
{
|
||||
|
@ -42,7 +41,7 @@
|
|||
}
|
||||
|
||||
public boolean areAllPlayersAsleep()
|
||||
@@ -270,7 +276,7 @@
|
||||
@@ -270,7 +275,7 @@
|
||||
int var10;
|
||||
int var11;
|
||||
|
||||
|
@ -51,7 +50,7 @@
|
|||
{
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
var8 = this.updateLCG >> 2;
|
||||
@@ -288,7 +294,7 @@
|
||||
@@ -288,7 +293,7 @@
|
||||
this.theProfiler.endStartSection("iceandsnow");
|
||||
int var13;
|
||||
|
||||
|
@ -60,7 +59,7 @@
|
|||
{
|
||||
this.updateLCG = this.updateLCG * 3 + 1013904223;
|
||||
var8 = this.updateLCG >> 2;
|
||||
@@ -362,7 +368,8 @@
|
||||
@@ -362,7 +367,8 @@
|
||||
public void scheduleBlockUpdate(int par1, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
NextTickListEntry var6 = new NextTickListEntry(par1, par2, par3, par4);
|
||||
|
@ -70,7 +69,7 @@
|
|||
|
||||
if (this.scheduledUpdatesAreImmediate)
|
||||
{
|
||||
@@ -418,7 +425,7 @@
|
||||
@@ -418,7 +424,7 @@
|
||||
*/
|
||||
public void updateEntities()
|
||||
{
|
||||
|
@ -79,7 +78,7 @@
|
|||
{
|
||||
if (this.updateEntityTick++ >= 60)
|
||||
{
|
||||
@@ -462,7 +469,8 @@
|
||||
@@ -462,7 +468,8 @@
|
||||
|
||||
this.pendingTickListEntries.remove(var4);
|
||||
this.field_73064_N.remove(var4);
|
||||
|
@ -89,7 +88,7 @@
|
|||
|
||||
if (this.checkChunksExist(var4.xCoord - var5, var4.yCoord - var5, var4.zCoord - var5, var4.xCoord + var5, var4.yCoord + var5, var4.zCoord + var5))
|
||||
{
|
||||
@@ -559,15 +567,27 @@
|
||||
@@ -559,15 +566,27 @@
|
||||
public List getAllTileEntityInBox(int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
ArrayList var7 = new ArrayList();
|
||||
|
@ -126,7 +125,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -578,6 +598,11 @@
|
||||
@@ -578,6 +597,11 @@
|
||||
* Called when checking if a certain block can be mined or not. The 'spawn safe zone' check is located here.
|
||||
*/
|
||||
public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
|
||||
|
@ -138,7 +137,7 @@
|
|||
{
|
||||
int var5 = MathHelper.abs_int(par2 - this.worldInfo.getSpawnX());
|
||||
int var6 = MathHelper.abs_int(par4 - this.worldInfo.getSpawnZ());
|
||||
@@ -587,7 +612,7 @@
|
||||
@@ -587,7 +611,7 @@
|
||||
var6 = var5;
|
||||
}
|
||||
|
||||
|
@ -147,7 +146,7 @@
|
|||
}
|
||||
|
||||
protected void initialize(WorldSettings par1WorldSettings)
|
||||
@@ -670,7 +695,7 @@
|
||||
@@ -670,7 +694,7 @@
|
||||
*/
|
||||
protected void createBonusChest()
|
||||
{
|
||||
|
@ -156,7 +155,7 @@
|
|||
|
||||
for (int var2 = 0; var2 < 10; ++var2)
|
||||
{
|
||||
@@ -713,6 +738,7 @@
|
||||
@@ -713,6 +737,7 @@
|
||||
}
|
||||
|
||||
this.chunkProvider.saveChunks(par1, par2IProgressUpdate);
|
||||
|
@ -164,7 +163,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -971,4 +997,9 @@
|
||||
@@ -971,4 +996,9 @@
|
||||
{
|
||||
return this.thePlayerManager;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/IntegratedServer.java
|
||||
+++ ../src_work/minecraft/net/minecraft/src/IntegratedServer.java
|
||||
@@ -8,6 +8,7 @@
|
||||
@@ -8,6 +8,9 @@
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraftforge.common.DimensionManager;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class IntegratedServer extends MinecraftServer
|
||||
@@ -48,44 +49,20 @@
|
||||
@@ -48,44 +51,21 @@
|
||||
protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType)
|
||||
{
|
||||
this.convertMapIfNeeded(par1Str);
|
||||
|
@ -57,13 +59,14 @@
|
|||
- this.getConfigurationManager().setPlayerManager(this.worldServers);
|
||||
- }
|
||||
-
|
||||
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
|
||||
+ }
|
||||
+
|
||||
+ this.getConfigurationManager().setPlayerManager(new WorldServer[]{ overWorld });
|
||||
this.setDifficultyForAllWorlds(this.getDifficulty());
|
||||
this.initialWorldChunkLoad();
|
||||
}
|
||||
@@ -106,6 +83,7 @@
|
||||
@@ -106,6 +86,7 @@
|
||||
this.loadAllWorlds(this.getFolderName(), this.getWorldName(), this.theWorldSettings.getSeed(), this.theWorldSettings.getTerrainType());
|
||||
this.setMOTD(this.getServerOwner() + " - " + this.worldServers[0].getWorldInfo().getWorldName());
|
||||
FMLCommonHandler.instance().handleServerStarting(this);
|
||||
|
|
Loading…
Reference in a new issue