diff --git a/common/net/minecraftforge/common/DimensionManager.java b/common/net/minecraftforge/common/DimensionManager.java index a1215684e..e3aa00350 100644 --- a/common/net/minecraftforge/common/DimensionManager.java +++ b/common/net/minecraftforge/common/DimensionManager.java @@ -1,20 +1,23 @@ package net.minecraftforge.common; import java.util.Hashtable; +import java.util.Map.Entry; import java.util.logging.Level; import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.server.MinecraftServer; import net.minecraft.src.*; public class DimensionManager { - private static Hashtable providers = new Hashtable(); + private static Hashtable> providers = new Hashtable>(); private static Hashtable spawnSettings = new Hashtable(); - private static Hashtable worlds = new Hashtable(); + private static Hashtable worlds = new Hashtable(); private static boolean hasInit = false; + private static Hashtable dimensions = new Hashtable(); - public static boolean registerDimension(int id, WorldProvider provider, boolean keepLoaded) + public static boolean registerProviderType(int id, Class provider, boolean keepLoaded) { if (providers.containsValue(id)) { @@ -31,38 +34,79 @@ public class DimensionManager { return; } - registerDimension( 0, new WorldProviderSurface(), true); - registerDimension(-1, new WorldProviderHell(), true); - registerDimension( 1, new WorldProviderEnd(), false); + registerProviderType( 0, WorldProviderSurface.class, true); + registerProviderType(-1, WorldProviderHell.class, true); + registerProviderType( 1, WorldProviderEnd.class, false); + registerDimension( 0, 0); + registerDimension(-1, -1); + registerDimension( 1, 1); } - public static WorldProvider getProvider(int id) + public static void registerDimension(int id, int providerType) { - return providers.get(id); + if (!providers.containsKey(providerType)) + { + throw new IllegalArgumentException(String.format("Failed to register dimensiuon for id %d, provider type %d does not exist", id, providerType)); + } + if (dimensions.containsKey(id)) + { + throw new IllegalArgumentException(String.format("Failed to register dimensiuon for id %d, One is already registered", id)); + } + dimensions.put(id, providerType); + } + + public static int getProviderType(int dim) + { + if (!dimensions.containsKey(dim)) + { + throw new IllegalArgumentException(String.format("Could not get provider type for dimension %d, does not exist", dim)); + } + return dimensions.get(dim); } public static Integer[] getIDs() { - return providers.keySet().toArray(new Integer[0]); + return dimensions.keySet().toArray(new Integer[0]); } - public static void setWorld(int id, World world) + public static void setWorld(int id, WorldServer world) { worlds.put(id, world); + + WorldServer[] tmp = new WorldServer[worlds.size() > 3 ? worlds.size() : 3]; + for (int x = -1; x <= 1; x++) + { + tmp[(x == 0 ? 0 : x == -1 ? 1 : 2)] = worlds.get(x); + } + + int x = 3; + for (Entry entry : worlds.entrySet()) + { + int dim = entry.getKey(); + if (dim >= -1 && dim <= 1) + { + continue; + } + tmp[x++] = entry.getValue(); + } + + MinecraftServer.getServer().dimensionServerList = tmp; + MinecraftServer.getServer().worldTickTimes.put(id, new long[100]); } - public static World getWorld(int id) + public static WorldServer getWorld(int id) { return worlds.get(id); } - public static World[] getWorlds() + public static WorldServer[] getWorlds() { - return worlds.values().toArray(new World[0]); + return worlds.values().toArray(new WorldServer[0]); } - public static boolean shouldLoadSpawn(int id) + public static boolean shouldLoadSpawn(int dim) { + int id = getProviderType(dim); return spawnSettings.contains(id) && spawnSettings.get(id); } @@ -71,15 +115,25 @@ public class DimensionManager init(); } - public static WorldProvider createProviderFor(int i) { - try { - if (providers.containsKey(i)) - return getProvider(i).getClass().newInstance(); - else - return null; - } catch (Exception e) { - FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE,String.format("An error occured trying to create an instance of WorldProvider %d (%s)",i,getProvider(i).getClass().getSimpleName()),e); - throw new RuntimeException(e); - } - } + public static WorldProvider createProviderFor(int dim) + { + try + { + if (dimensions.containsKey(dim)) + { + return providers.get(getProviderType(dim)).newInstance(); + } + else + { + return null; + } + } + catch (Exception e) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.SEVERE,String.format("An error occured trying to create an instance of WorldProvider %d (%s)", + dim, + providers.get(getProviderType(dim)).getSimpleName()),e); + throw new RuntimeException(e); + } + } } diff --git a/common/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/common/net/minecraftforge/event/entity/player/AttackEntityEvent.java new file mode 100644 index 000000000..67b84be1e --- /dev/null +++ b/common/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.src.Entity; +import net.minecraft.src.EntityPlayer; +import net.minecraftforge.event.Cancelable; + +@Cancelable +public class AttackEntityEvent extends PlayerEvent +{ + public final Entity target; + public AttackEntityEvent(EntityPlayer player, Entity target) + { + super(player); + this.target = target; + } +} diff --git a/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Forge-Server.launch b/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Forge-Server.launch index 02e778906..896e6fa11 100644 --- a/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Forge-Server.launch +++ b/eclipse/.metadata/.plugins/org.eclipse.debug.core/.launches/Forge-Server.launch @@ -1,7 +1,7 @@ - + diff --git a/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index b3fc13aa4..2c2d88d9f 100644 --- a/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/eclipse/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -86,8 +86,8 @@ - - + + @@ -104,7 +104,7 @@ - + newtablook org.eclipse.e4.secondaryDataStack @@ -216,72 +216,57 @@ categoryTag:Help - + newtablook org.eclipse.e4.primaryDataStack EditorStack - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - + + Editor removeOnHide - - - Editor - removeOnHide - - - - Editor - removeOnHide - - - - Editor - removeOnHide - - - + + Editor removeOnHide @@ -297,9 +282,14 @@ - + View categoryTag:Java + + ViewMenu + menuContribution:menu + + View @@ -309,7 +299,7 @@ View categoryTag:General - + View categoryTag:General @@ -328,7 +318,7 @@ categoryTag:Java - + View categoryTag:General diff --git a/fml-src-2.9.118.214.zip b/fml-src-2.9.128.224.zip similarity index 87% rename from fml-src-2.9.118.214.zip rename to fml-src-2.9.128.224.zip index 880e466fa..9b2450078 100644 Binary files a/fml-src-2.9.118.214.zip and b/fml-src-2.9.128.224.zip differ diff --git a/patches/common/net/minecraft/server/MinecraftServer.java.patch b/patches/common/net/minecraft/server/MinecraftServer.java.patch new file mode 100644 index 000000000..f5c366e43 --- /dev/null +++ b/patches/common/net/minecraft/server/MinecraftServer.java.patch @@ -0,0 +1,203 @@ +--- ../src_base/common/net/minecraft/server/MinecraftServer.java ++++ ../src_work/common/net/minecraft/server/MinecraftServer.java +@@ -9,6 +9,7 @@ + import java.text.SimpleDateFormat; + import java.util.ArrayList; + import java.util.Date; ++import java.util.Hashtable; + import java.util.Iterator; + import java.util.List; + import java.util.logging.Level; +@@ -58,6 +59,7 @@ + import net.minecraft.src.WorldServerMulti; + import net.minecraft.src.WorldSettings; + import net.minecraft.src.WorldType; ++import net.minecraftforge.common.DimensionManager; + + public abstract class MinecraftServer implements Runnable, IPlayerUsage, ICommandSender + { +@@ -81,6 +83,9 @@ + private String hostname; + private int serverPort = -1; + public WorldServer[] dimensionServerList; ++ public List worlds = new ArrayList(); ++ public Hashtable worldTickTimes = new Hashtable(); ++ public int spawnProtectionSize = 16; + + /** The ServerConfigurationManager instance. */ + private ServerConfigurationManager serverConfigManager; +@@ -127,7 +132,7 @@ + public final long[] tickTimeArray = new long[100]; + + /** stats are [dimension][tick%100] system.nanoTime is stored. */ +- public long[][] timeOfLastDimenstionTick; ++ //public long[][] timeOfLastDimenstionTick; + private KeyPair serverKeyPair; + + /** Username of the server owner (for integrated servers) */ +@@ -194,8 +199,8 @@ + { + this.convertMapIfNeeded(par1Str); + this.setUserMessage("menu.loadingLevel"); +- this.dimensionServerList = new WorldServer[3]; +- this.timeOfLastDimenstionTick = new long[this.dimensionServerList.length][100]; ++ //this.dimensionServerList = new WorldServer[3]; ++ //this.timeOfLastDimenstionTick = new long[this.dimensionServerList.length][100]; + ISaveHandler var6 = this.anvilConverterForAnvilFile.getSaveLoader(par1Str, true); + WorldInfo var8 = var6.loadWorldInfo(); + WorldSettings var7; +@@ -214,46 +219,20 @@ + var7.enableBonusChest(); + } + +- for (int var9 = 0; var9 < this.dimensionServerList.length; ++var9) +- { +- byte var10 = 0; +- +- if (var9 == 1) +- { +- var10 = -1; +- } +- +- if (var9 == 2) +- { +- var10 = 1; +- } +- +- if (var9 == 0) +- { +- if (this.isDemo()) +- { +- this.dimensionServerList[var9] = new DemoWorldServer(this, var6, par2Str, var10, this.theProfiler); +- } +- else +- { +- this.dimensionServerList[var9] = new WorldServer(this, var6, par2Str, var10, var7, this.theProfiler); +- } +- } +- else +- { +- this.dimensionServerList[var9] = new WorldServerMulti(this, var6, par2Str, var10, var7, this.dimensionServerList[0], this.theProfiler); +- } +- +- this.dimensionServerList[var9].addWorldAccess(new WorldManager(this, this.dimensionServerList[var9])); ++ WorldServer overWorld = (isDemo() ? new DemoWorldServer(this, var6, par2Str, 0, theProfiler) : new WorldServer(this, var6, par2Str, 0, var7, theProfiler)); ++ for (int dim : DimensionManager.getIDs()) ++ { ++ WorldServer world = (dim == 0 ? overWorld : new WorldServerMulti(this, var6, par2Str, dim, var7, overWorld, theProfiler)); ++ ++ world.addWorldAccess(new WorldManager(this, world)); + + if (!this.isSinglePlayer()) + { +- this.dimensionServerList[var9].getWorldInfo().setGameType(this.getGameType()); +- } +- +- this.serverConfigManager.setPlayerManager(this.dimensionServerList); +- } +- ++ world.getWorldInfo().setGameType(this.getGameType()); ++ } ++ } ++ ++ this.serverConfigManager.setPlayerManager(new WorldServer[]{ overWorld }); + this.setDifficultyForAllDimensions(this.getDifficulty()); + this.initialWorldChunkLoad(); + } +@@ -264,10 +243,10 @@ + long var2 = System.currentTimeMillis(); + this.setUserMessage("menu.generatingTerrain"); + +- for (int var4 = 0; var4 < 1; ++var4) +- { +- logger.info("Preparing start region for level " + var4); +- WorldServer var5 = this.dimensionServerList[var4]; ++ for (Integer id : DimensionManager.getIDs()) ++ { ++ logger.info("Preparing start region for level " + id); ++ WorldServer var5 = (WorldServer)DimensionManager.getWorld(id); + ChunkCoordinates var6 = var5.getSpawnPoint(); + + for (int var7 = -var1; var7 <= var1 && this.isServerRunning(); var7 += 16) +@@ -342,7 +321,7 @@ + { + if (!this.worldIsBeingDeleted) + { +- WorldServer[] var2 = this.dimensionServerList; ++ WorldServer[] var2 = DimensionManager.getWorlds(); + int var3 = var2.length; + + for (int var4 = 0; var4 < var3; ++var4) +@@ -392,7 +371,7 @@ + + logger.info("Saving worlds"); + this.saveAllDimensions(false); +- WorldServer[] var1 = this.dimensionServerList; ++ WorldServer[] var1 = DimensionManager.getWorlds(); + int var2 = var1.length; + + for (int var3 = 0; var3 < var2; ++var3) +@@ -440,7 +419,7 @@ + FMLCommonHandler.instance().handleServerStarted(); + long var1 = System.currentTimeMillis(); + +- FMLCommonHandler.instance().onWorldLoadTick(dimensionServerList); ++ FMLCommonHandler.instance().onWorldLoadTick(DimensionManager.getWorlds()); + + for (long var50 = 0L; this.serverShouldContinueRunning; this.serverIsRunning = true) + { +@@ -463,7 +442,7 @@ + var50 += var7; + var1 = var5; + +- if (this.dimensionServerList[0].areAllPlayersAsleep()) ++ if (DimensionManager.getWorld(0).areAllPlayersAsleep()) + { + this.tick(); + var50 = 0L; +@@ -609,13 +588,13 @@ + { + this.theProfiler.startSection("levels"); + +- for (int var1 = 0; var1 < this.dimensionServerList.length; ++var1) ++ for (Integer id : DimensionManager.getIDs()) + { + long var2 = System.nanoTime(); + +- if (var1 == 0 || this.getAllowNether()) +- { +- WorldServer var4 = this.dimensionServerList[var1]; ++ if (id == 0 || this.getAllowNether()) ++ { ++ WorldServer var4 = DimensionManager.getWorld(id); + this.theProfiler.startSection(var4.getWorldInfo().getWorldName()); + + if (this.tickCounter % 20 == 0) +@@ -651,7 +630,7 @@ + } + } + +- this.timeOfLastDimenstionTick[var1][this.tickCounter % 100] = System.nanoTime() - var2; ++ worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - var2; + } + + this.theProfiler.endStartSection("connection"); +@@ -700,7 +679,8 @@ + + public WorldServer worldServerForDimension(int par1) + { +- return par1 == -1 ? this.dimensionServerList[1] : (par1 == 1 ? this.dimensionServerList[2] : this.dimensionServerList[0]); ++ WorldServer ret = DimensionManager.getWorld(par1); ++ return (ret != null ? ret : DimensionManager.getWorld(0)); + } + + @SideOnly(Side.SERVER) +@@ -789,7 +769,7 @@ + + public String getServerModName() + { +- return "vanilla"; ++ return "forge,fml"; + } + + /** diff --git a/patches/common/net/minecraft/src/BlockTallGrass.java.patch b/patches/common/net/minecraft/src/BlockTallGrass.java.patch index 10a29e7da..8305e59a8 100644 --- a/patches/common/net/minecraft/src/BlockTallGrass.java.patch +++ b/patches/common/net/minecraft/src/BlockTallGrass.java.patch @@ -17,7 +17,7 @@ { protected BlockTallGrass(int par1, int par2) { -@@ -57,7 +62,7 @@ +@@ -27,7 +32,7 @@ */ public int idDropped(int par1, Random par2Random, int par3) { @@ -26,7 +26,7 @@ } /** -@@ -74,15 +79,7 @@ +@@ -44,15 +49,7 @@ */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { diff --git a/patches/common/net/minecraft/src/Chunk.java.patch b/patches/common/net/minecraft/src/Chunk.java.patch index 8dd3beac1..dda21cffb 100644 --- a/patches/common/net/minecraft/src/Chunk.java.patch +++ b/patches/common/net/minecraft/src/Chunk.java.patch @@ -299,7 +299,7 @@ if (var4 < 0) { -@@ -1225,6 +1282,15 @@ +@@ -1227,6 +1284,15 @@ */ public void fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4) { @@ -315,7 +315,7 @@ int var5 = 0; int var6; -@@ -1321,12 +1387,26 @@ +@@ -1323,12 +1389,26 @@ } this.generateHeightMap(); diff --git a/patches/common/net/minecraft/src/DedicatedServer.java.patch b/patches/common/net/minecraft/src/DedicatedServer.java.patch new file mode 100644 index 000000000..064804a2b --- /dev/null +++ b/patches/common/net/minecraft/src/DedicatedServer.java.patch @@ -0,0 +1,10 @@ +--- ../src_base/common/net/minecraft/src/DedicatedServer.java ++++ ../src_work/common/net/minecraft/src/DedicatedServer.java +@@ -66,6 +66,7 @@ + this.setAllowFlight(this.settings.getOrSetBoolProperty("allow-flight", false)); + this.setTexturePack(this.settings.getOrSetProperty("texture-pack", "")); + this.setMOTD(this.settings.getOrSetProperty("motd", "A Minecraft Server")); ++ spawnProtectionSize = this.settings.getOrSetIntProperty("spawn-protection-size", 16); + this.canSpawnStructures = this.settings.getOrSetBoolProperty("generate-structures", true); + int var2 = this.settings.getOrSetIntProperty("gamemode", EnumGameType.SURVIVAL.getID()); + this.gameType = WorldSettings.getGameTypeById(var2); diff --git a/patches/common/net/minecraft/src/EntityMinecart.java.patch b/patches/common/net/minecraft/src/EntityMinecart.java.patch index 4ec76c099..05d657f59 100644 --- a/patches/common/net/minecraft/src/EntityMinecart.java.patch +++ b/patches/common/net/minecraft/src/EntityMinecart.java.patch @@ -416,7 +416,7 @@ } } -@@ -717,12 +587,7 @@ +@@ -718,12 +588,7 @@ } else { diff --git a/patches/common/net/minecraft/src/EntityPlayer.java.patch b/patches/common/net/minecraft/src/EntityPlayer.java.patch index e7a25ac22..5d09d659d 100644 --- a/patches/common/net/minecraft/src/EntityPlayer.java.patch +++ b/patches/common/net/minecraft/src/EntityPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src_base/common/net/minecraft/src/EntityPlayer.java +++ ../src_work/common/net/minecraft/src/EntityPlayer.java -@@ -6,6 +6,13 @@ +@@ -7,6 +7,14 @@ import java.util.Iterator; import java.util.List; @@ -9,12 +9,13 @@ +import net.minecraftforge.common.ISpecialArmor.ArmorProperties; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; ++import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; public abstract class EntityPlayer extends EntityLiving implements ICommandSender { -@@ -220,6 +227,7 @@ +@@ -222,6 +230,7 @@ if (var1 == this.itemInUse) { @@ -22,7 +23,7 @@ if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) { this.updateItemUse(var1, 5); -@@ -624,7 +632,16 @@ +@@ -627,7 +636,16 @@ */ public EntityItem dropOneItem() { @@ -40,7 +41,7 @@ } /** -@@ -690,13 +707,21 @@ +@@ -693,13 +711,21 @@ /** * Returns how strong the player is against the specified block at this moment @@ -65,7 +66,7 @@ { var2 += (float)(var3 * var3 + 1); } -@@ -989,12 +1014,23 @@ +@@ -992,12 +1018,23 @@ */ protected void damageEntity(DamageSource par1DamageSource, int par2) { @@ -90,7 +91,7 @@ par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); this.addExhaustion(par1DamageSource.getHungerDamage()); this.health -= par2; -@@ -1029,6 +1065,10 @@ +@@ -1032,6 +1069,10 @@ public boolean interactWith(Entity par1Entity) { @@ -101,7 +102,7 @@ if (par1Entity.interact(this)) { return true; -@@ -1072,7 +1112,9 @@ +@@ -1075,7 +1116,9 @@ */ public void destroyCurrentEquippedItem() { @@ -111,11 +112,11 @@ } /** -@@ -1101,6 +1143,15 @@ +@@ -1104,6 +1147,15 @@ */ public void attackTargetEntityWithCurrentItem(Entity par1Entity) { -+ if (!ForgeHooks.onEntityInteract(this, par1Entity, true)) ++ if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(this, par1Entity))) + { + return; + } @@ -127,7 +128,7 @@ if (par1Entity.canAttackWithItem()) { int var2 = this.inventory.getDamageVsEntity(par1Entity); -@@ -1244,6 +1295,12 @@ +@@ -1247,6 +1299,12 @@ */ public EnumStatus sleepInBedAt(int par1, int par2, int par3) { @@ -140,7 +141,7 @@ if (!this.worldObj.isRemote) { if (this.isPlayerSleeping() || !this.isEntityAlive()) -@@ -1283,6 +1340,11 @@ +@@ -1286,6 +1344,11 @@ { int var9 = this.worldObj.getBlockMetadata(par1, par2, par3); int var5 = BlockBed.getDirection(var9); @@ -152,7 +153,7 @@ float var10 = 0.5F; float var7 = 0.5F; -@@ -1353,10 +1415,12 @@ +@@ -1356,10 +1419,12 @@ ChunkCoordinates var4 = this.playerLocation; ChunkCoordinates var5 = this.playerLocation; @@ -169,7 +170,7 @@ if (var5 == null) { -@@ -1393,7 +1457,9 @@ +@@ -1396,7 +1461,9 @@ */ private boolean isInBed() { @@ -180,7 +181,7 @@ } /** -@@ -1408,13 +1474,15 @@ +@@ -1411,13 +1478,15 @@ var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); @@ -198,7 +199,7 @@ return var3; } } -@@ -1428,8 +1496,11 @@ +@@ -1431,8 +1500,11 @@ { if (this.playerLocation != null) { @@ -212,7 +213,7 @@ switch (var2) { -@@ -1722,6 +1793,7 @@ +@@ -1725,6 +1797,7 @@ return 101; } } diff --git a/patches/common/net/minecraft/src/Item.java.patch b/patches/common/net/minecraft/src/Item.java.patch index 4a014cadc..a840f6bce 100644 --- a/patches/common/net/minecraft/src/Item.java.patch +++ b/patches/common/net/minecraft/src/Item.java.patch @@ -18,7 +18,7 @@ } itemsList[256 + par1] = this; -@@ -651,4 +654,185 @@ +@@ -650,4 +653,185 @@ { StatList.initStats(); } diff --git a/patches/common/net/minecraft/src/ItemMap.java.patch b/patches/common/net/minecraft/src/ItemMap.java.patch index f67222462..a16c71251 100644 --- a/patches/common/net/minecraft/src/ItemMap.java.patch +++ b/patches/common/net/minecraft/src/ItemMap.java.patch @@ -1,6 +1,6 @@ --- ../src_base/common/net/minecraft/src/ItemMap.java +++ ../src_work/common/net/minecraft/src/ItemMap.java -@@ -87,7 +87,7 @@ +@@ -88,7 +88,7 @@ byte var23 = 0; byte var24 = 0; byte var25 = 0; @@ -9,7 +9,7 @@ Chunk var27 = par1World.getChunkFromBlockCoords(var21, var22); if (!var27.isEmpty()) -@@ -186,7 +186,7 @@ +@@ -187,7 +187,7 @@ var33 = 0; var34 = 0; diff --git a/patches/common/net/minecraft/src/WorldServer.java.patch b/patches/common/net/minecraft/src/WorldServer.java.patch index e35c7166b..8ca34d4f0 100644 --- a/patches/common/net/minecraft/src/WorldServer.java.patch +++ b/patches/common/net/minecraft/src/WorldServer.java.patch @@ -1,15 +1,61 @@ --- ../src_base/common/net/minecraft/src/WorldServer.java +++ ../src_work/common/net/minecraft/src/WorldServer.java -@@ -10,6 +10,8 @@ +@@ -10,6 +10,9 @@ import java.util.Set; import java.util.TreeSet; import net.minecraft.server.MinecraftServer; ++import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; public class WorldServer extends World { -@@ -689,6 +691,7 @@ +@@ -70,6 +73,7 @@ + { + this.pendingTickListEntries = new TreeSet(); + } ++ DimensionManager.setWorld(par4, this); + } + + /** +@@ -538,15 +542,27 @@ + public List getAllTileEntityInBox(int par1, int par2, int par3, int par4, int par5, int par6) + { + ArrayList var7 = new ArrayList(); +- Iterator var8 = this.loadedTileEntityList.iterator(); +- +- while (var8.hasNext()) +- { +- TileEntity var9 = (TileEntity)var8.next(); +- +- if (var9.xCoord >= par1 && var9.yCoord >= par2 && var9.zCoord >= par3 && var9.xCoord < par4 && var9.yCoord < par5 && var9.zCoord < par6) +- { +- var7.add(var9); ++ ++ for(int x = (par1 >> 4); x <= (par4 >> 4); x++) ++ { ++ for(int z = (par3 >> 4); z <= (par6 >> 4); z++) ++ { ++ Chunk chunk = getChunkFromChunkCoords(x, z); ++ if (chunk != null) ++ { ++ for(Object obj : chunk.chunkTileEntityMap.values()) ++ { ++ TileEntity entity = (TileEntity)obj; ++ if (!entity.isInvalid()) ++ { ++ if (entity.xCoord >= par1 && entity.yCoord >= par2 && entity.zCoord >= par3 && ++ entity.xCoord <= par4 && entity.yCoord <= par5 && entity.zCoord <= par6) ++ { ++ var7.add(entity); ++ } ++ } ++ } ++ } + } + } + +@@ -689,6 +705,7 @@ } this.chunkProvider.saveChunks(par1, par2IProgressUpdate); diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index ac57841b4..52328724b 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -8,7 +8,7 @@ import org.lwjgl.LWJGLException; import org.lwjgl.Sys; -@@ -2102,80 +2103,12 @@ +@@ -2109,80 +2110,12 @@ if (this.objectMouseOver != null) { boolean var1 = this.thePlayer.capabilities.isCreativeMode; diff --git a/patches/minecraft/net/minecraft/src/GuiStatsComponent.java.patch b/patches/minecraft/net/minecraft/src/GuiStatsComponent.java.patch new file mode 100644 index 000000000..4e6b22bdd --- /dev/null +++ b/patches/minecraft/net/minecraft/src/GuiStatsComponent.java.patch @@ -0,0 +1,40 @@ +--- ../src_base/minecraft/net/minecraft/src/GuiStatsComponent.java ++++ ../src_work/minecraft/net/minecraft/src/GuiStatsComponent.java +@@ -8,6 +8,7 @@ + import java.text.DecimalFormat; + import javax.swing.JComponent; + import net.minecraft.server.MinecraftServer; ++import net.minecraftforge.common.DimensionManager; + + @SideOnly(Side.SERVER) + public class GuiStatsComponent extends JComponent +@@ -41,6 +42,7 @@ + */ + private void updateStats() + { ++ this.displayStrings = new String[5 + DimensionManager.getIDs().length]; + long var1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.gc(); + this.displayStrings[0] = "Memory use: " + var1 / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; +@@ -51,14 +53,17 @@ + + if (this.field_79017_e.dimensionServerList != null) + { +- for (int var3 = 0; var3 < this.field_79017_e.dimensionServerList.length; ++var3) ++ int x = 0; ++ for (Integer id : DimensionManager.getIDs()) + { +- this.displayStrings[5 + var3] = "Lvl " + var3 + " tick: " + field_79020_a.format(this.func_79015_a(this.field_79017_e.timeOfLastDimenstionTick[var3]) * 1.0E-6D) + " ms"; ++ this.displayStrings[5 + x] = "Lvl " + id + " tick: " + field_79020_a.format(this.func_79015_a(this.field_79017_e.worldTickTimes.get(id)) * 1.0E-6D) + " ms"; + +- if (this.field_79017_e.dimensionServerList[var3] != null && this.field_79017_e.dimensionServerList[var3].theChunkProviderServer != null) ++ WorldServer world = DimensionManager.getWorld(id); ++ if (world != null && world.theChunkProviderServer != null) + { +- this.displayStrings[5 + var3] = this.displayStrings[5 + var3] + ", " + this.field_79017_e.dimensionServerList[var3].theChunkProviderServer.makeString(); ++ this.displayStrings[5 + x] = this.displayStrings[5 + x] + ", " + world.theChunkProviderServer.makeString(); + } ++ x++; + } + } + diff --git a/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch new file mode 100644 index 000000000..04a22db0b --- /dev/null +++ b/patches/minecraft/net/minecraft/src/IntegratedServer.java.patch @@ -0,0 +1,67 @@ +--- ../src_base/minecraft/net/minecraft/src/IntegratedServer.java ++++ ../src_work/minecraft/net/minecraft/src/IntegratedServer.java +@@ -6,6 +6,7 @@ + import cpw.mods.fml.common.FMLCommonHandler; + import net.minecraft.client.Minecraft; + import net.minecraft.server.MinecraftServer; ++import net.minecraftforge.common.DimensionManager; + + public class IntegratedServer extends MinecraftServer + { +@@ -43,44 +44,22 @@ + protected void loadAllDimensions(String par1Str, String par2Str, long par3, WorldType par5WorldType) + { + this.convertMapIfNeeded(par1Str); +- this.dimensionServerList = new WorldServer[3]; +- this.timeOfLastDimenstionTick = new long[this.dimensionServerList.length][100]; + ISaveHandler var6 = this.getActiveAnvilConverter().getSaveLoader(par1Str, true); + +- for (int var7 = 0; var7 < this.dimensionServerList.length; ++var7) +- { +- byte var8 = 0; +- +- if (var7 == 1) ++ WorldServer overWorld = (isDemo() ? new DemoWorldServer(this, var6, par2Str, 0, theProfiler) : new WorldServer(this, var6, par2Str, 0, field_71350_m, theProfiler)); ++ for (int dim : DimensionManager.getIDs()) ++ { ++ WorldServer world = (dim == 0 ? overWorld : new WorldServerMulti(this, var6, par2Str, dim, field_71350_m, overWorld, theProfiler)); ++ ++ world.addWorldAccess(new WorldManager(this, world)); ++ ++ if (!this.isSinglePlayer()) + { +- var8 = -1; ++ world.getWorldInfo().setGameType(this.getGameType()); + } +- +- if (var7 == 2) +- { +- var8 = 1; +- } +- +- if (var7 == 0) +- { +- if (this.isDemo()) +- { +- this.dimensionServerList[var7] = new DemoWorldServer(this, var6, par2Str, var8, this.theProfiler); +- } +- else +- { +- this.dimensionServerList[var7] = new WorldServer(this, var6, par2Str, var8, this.field_71350_m, this.theProfiler); +- } +- } +- else +- { +- this.dimensionServerList[var7] = new WorldServerMulti(this, var6, par2Str, var8, this.field_71350_m, this.dimensionServerList[0], this.theProfiler); +- } +- +- this.dimensionServerList[var7].addWorldAccess(new WorldManager(this, this.dimensionServerList[var7])); +- this.getConfigurationManager().setPlayerManager(this.dimensionServerList); +- } +- ++ } ++ ++ this.getConfigurationManager().setPlayerManager(new WorldServer[]{ overWorld }); + this.setDifficultyForAllDimensions(this.getDifficulty()); + this.initialWorldChunkLoad(); + } diff --git a/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch b/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch index b8fbe6bae..a05642175 100644 --- a/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch +++ b/patches/minecraft/net/minecraft/src/RenderBlocks.java.patch @@ -9,7 +9,7 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -@@ -423,9 +425,8 @@ +@@ -489,9 +491,8 @@ public boolean renderBlockBed(Block par1Block, int par2, int par3, int par4) { Tessellator var5 = Tessellator.instance; @@ -21,7 +21,7 @@ float var9 = 0.5F; float var10 = 1.0F; float var11 = 0.8F; -@@ -1890,7 +1891,7 @@ +@@ -1956,7 +1957,7 @@ double var30; double var32; @@ -30,7 +30,7 @@ { float var36 = 0.2F; float var19 = 0.0625F; -@@ -1910,7 +1911,7 @@ +@@ -1976,7 +1977,7 @@ var9 = var20; } @@ -39,7 +39,7 @@ { var5.addVertexWithUV((double)((float)par2 + var36), (double)((float)par3 + var17 + var19), (double)(par4 + 1), var11, var13); var5.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 0) + var19), (double)(par4 + 1), var11, var15); -@@ -1922,7 +1923,7 @@ +@@ -1988,7 +1989,7 @@ var5.addVertexWithUV((double)((float)par2 + var36), (double)((float)par3 + var17 + var19), (double)(par4 + 1), var11, var13); } @@ -48,7 +48,7 @@ { var5.addVertexWithUV((double)((float)(par2 + 1) - var36), (double)((float)par3 + var17 + var19), (double)(par4 + 0), var9, var13); var5.addVertexWithUV((double)(par2 + 1 - 0), (double)((float)(par3 + 0) + var19), (double)(par4 + 0), var9, var15); -@@ -1934,7 +1935,7 @@ +@@ -2000,7 +2001,7 @@ var5.addVertexWithUV((double)((float)(par2 + 1) - var36), (double)((float)par3 + var17 + var19), (double)(par4 + 0), var9, var13); } @@ -57,7 +57,7 @@ { var5.addVertexWithUV((double)(par2 + 0), (double)((float)par3 + var17 + var19), (double)((float)par4 + var36), var11, var13); var5.addVertexWithUV((double)(par2 + 0), (double)((float)(par3 + 0) + var19), (double)(par4 + 0), var11, var15); -@@ -1946,7 +1947,7 @@ +@@ -2012,7 +2013,7 @@ var5.addVertexWithUV((double)(par2 + 0), (double)((float)par3 + var17 + var19), (double)((float)par4 + var36), var11, var13); } @@ -66,7 +66,7 @@ { var5.addVertexWithUV((double)(par2 + 1), (double)((float)par3 + var17 + var19), (double)((float)(par4 + 1) - var36), var9, var13); var5.addVertexWithUV((double)(par2 + 1), (double)((float)(par3 + 0) + var19), (double)(par4 + 1 - 0), var9, var15); -@@ -1958,7 +1959,7 @@ +@@ -2024,7 +2025,7 @@ var5.addVertexWithUV((double)(par2 + 1), (double)((float)par3 + var17 + var19), (double)((float)(par4 + 1) - var36), var9, var13); } @@ -75,7 +75,7 @@ { var20 = (double)par2 + 0.5D + 0.5D; var22 = (double)par2 + 0.5D - 0.5D; -@@ -4142,7 +4143,7 @@ +@@ -4208,7 +4209,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 2); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -84,7 +84,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -4265,7 +4266,7 @@ +@@ -4331,7 +4332,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3)); @@ -93,7 +93,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -4388,7 +4389,7 @@ +@@ -4454,7 +4455,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 4); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -102,7 +102,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -4511,7 +4512,7 @@ +@@ -4577,7 +4578,7 @@ var27 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 5); this.renderSouthFace(par1Block, (double)par2, (double)par3, (double)par4, var27); @@ -111,7 +111,7 @@ { this.colorRedTopLeft *= par5; this.colorRedBottomLeft *= par5; -@@ -4623,7 +4624,7 @@ +@@ -4689,7 +4690,7 @@ var28 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 2); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, var28); @@ -120,7 +120,7 @@ { var8.setColorOpaque_F(var18 * par5, var21 * par6, var24 * par7); this.renderEastFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4639,7 +4640,7 @@ +@@ -4705,7 +4706,7 @@ var28 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 3); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, var28); @@ -129,7 +129,7 @@ { var8.setColorOpaque_F(var18 * par5, var21 * par6, var24 * par7); this.renderWestFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4655,7 +4656,7 @@ +@@ -4721,7 +4722,7 @@ var28 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 4); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, var28); @@ -138,7 +138,7 @@ { var8.setColorOpaque_F(var19 * par5, var22 * par6, var25 * par7); this.renderNorthFace(par1Block, (double)par2, (double)par3, (double)par4, 38); -@@ -4671,7 +4672,7 @@ +@@ -4737,7 +4738,7 @@ var28 = par1Block.getBlockTexture(this.blockAccess, par2, par3, par4, 5); this.renderSouthFace(par1Block, (double)par2, (double)par3, (double)par4, var28); diff --git a/patches/minecraft_server/net/minecraft/src/GuiStatsComponent.java.patch b/patches/minecraft_server/net/minecraft/src/GuiStatsComponent.java.patch new file mode 100644 index 000000000..d5241b88f --- /dev/null +++ b/patches/minecraft_server/net/minecraft/src/GuiStatsComponent.java.patch @@ -0,0 +1,40 @@ +--- ../src_base/minecraft_server/net/minecraft/src/GuiStatsComponent.java ++++ ../src_work/minecraft_server/net/minecraft/src/GuiStatsComponent.java +@@ -9,6 +9,7 @@ + import javax.swing.JComponent; + import javax.swing.Timer; + import net.minecraft.server.MinecraftServer; ++import net.minecraftforge.common.DimensionManager; + + @SideOnly(Side.SERVER) + public class GuiStatsComponent extends JComponent +@@ -42,6 +43,7 @@ + */ + private void updateStats() + { ++ this.displayStrings = new String[5 + DimensionManager.getIDs().length]; + long var1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.gc(); + this.displayStrings[0] = "Memory use: " + var1 / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; +@@ -52,14 +54,17 @@ + + if (this.field_79017_e.dimensionServerList != null) + { +- for (int var3 = 0; var3 < this.field_79017_e.dimensionServerList.length; ++var3) ++ int x = 0; ++ for (Integer id : DimensionManager.getIDs()) + { +- this.displayStrings[5 + var3] = "Lvl " + var3 + " tick: " + field_79020_a.format(this.func_79015_a(this.field_79017_e.timeOfLastDimenstionTick[var3]) * 1.0E-6D) + " ms"; ++ this.displayStrings[5 + x] = "Lvl " + id + " tick: " + field_79020_a.format(this.func_79015_a(this.field_79017_e.worldTickTimes.get(id)) * 1.0E-6D) + " ms"; + +- if (this.field_79017_e.dimensionServerList[var3] != null && this.field_79017_e.dimensionServerList[var3].theChunkProviderServer != null) ++ WorldServer world = DimensionManager.getWorld(id); ++ if (world != null && world.theChunkProviderServer != null) + { +- this.displayStrings[5 + var3] = this.displayStrings[5 + var3] + ", " + this.field_79017_e.dimensionServerList[var3].theChunkProviderServer.makeString(); ++ this.displayStrings[5 + x] = this.displayStrings[5 + x] + ", " + world.theChunkProviderServer.makeString(); + } ++ x++; + } + } +