From aa24916736d7e82bb9045c505f48b483a909f417 Mon Sep 17 00:00:00 2001 From: cpw Date: Wed, 9 Mar 2016 00:48:32 -0500 Subject: [PATCH] Finish world, chunkloading should work again? --- .../net/minecraft/world/World.java.patch | 6 ++++- .../minecraft/world/WorldServer.java.patch | 9 +++++++ .../net/minecraft/world/World.java.patch.rej | 9 ------- .../common/ForgeChunkManager.java | 25 +++++++++++++++++++ .../event/entity/player/PlayerDropsEvent.java | 2 +- 5 files changed, 40 insertions(+), 11 deletions(-) delete mode 100644 rejects/minecraft/net/minecraft/world/World.java.patch.rej diff --git a/patches.mcp/minecraft/net/minecraft/world/World.java.patch b/patches.mcp/minecraft/net/minecraft/world/World.java.patch index 1d0df9c775..b06145937f 100644 --- a/patches.mcp/minecraft/net/minecraft/world/World.java.patch +++ b/patches.mcp/minecraft/net/minecraft/world/World.java.patch @@ -792,7 +792,7 @@ } } } -@@ -3600,6 +3781,83 @@ +@@ -3600,6 +3781,87 @@ return i >= -k && i <= k && j >= -k && j <= k; } @@ -839,6 +839,10 @@ + return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this); + } + ++ public Iterator getPersistentChunkIterable(Iterator chunkIterator) ++ { ++ return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksIterableFor(this, chunkIterator); ++ } + /** + * Readded as it was removed, very useful helper function + * diff --git a/patches.mcp/minecraft/net/minecraft/world/WorldServer.java.patch b/patches.mcp/minecraft/net/minecraft/world/WorldServer.java.patch index 0b06244efd..3c4eda1149 100644 --- a/patches.mcp/minecraft/net/minecraft/world/WorldServer.java.patch +++ b/patches.mcp/minecraft/net/minecraft/world/WorldServer.java.patch @@ -80,6 +80,15 @@ } public boolean areAllPlayersAsleep() +@@ -368,7 +380,7 @@ + boolean flag1 = this.isThundering(); + this.theProfiler.startSection("pollingChunks"); + +- for (Iterator iterator = this.thePlayerManager.func_187300_b(); iterator.hasNext(); this.theProfiler.endSection()) ++ for (Iterator iterator = getPersistentChunkIterable(this.thePlayerManager.func_187300_b()); iterator.hasNext(); this.theProfiler.endSection()) + { + this.theProfiler.startSection("getChunk"); + Chunk chunk = (Chunk)iterator.next(); @@ -380,7 +392,7 @@ chunk.func_150804_b(false); this.theProfiler.endStartSection("thunder"); diff --git a/rejects/minecraft/net/minecraft/world/World.java.patch.rej b/rejects/minecraft/net/minecraft/world/World.java.patch.rej deleted file mode 100644 index bc80f2388c..0000000000 --- a/rejects/minecraft/net/minecraft/world/World.java.patch.rej +++ /dev/null @@ -1,9 +0,0 @@ -++++ REJECTED PATCH 40 - { - this.activeChunkSet.clear(); - this.theProfiler.startSection("buildList"); -+ this.activeChunkSet.addAll(getPersistentChunks().keySet()); - - for (int i = 0; i < this.playerEntities.size(); ++i) - { -++++ END PATCH diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java index 8c52939d62..c5eb772a96 100644 --- a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -14,6 +14,10 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; import org.apache.logging.log4j.Level; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -54,6 +58,8 @@ import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; import net.minecraftforge.common.util.Constants; +import javax.annotation.Nullable; + /** * Manages chunkloading for mods. * @@ -105,6 +111,25 @@ public class ForgeChunkManager MOD_PROP_ORDER.add("maximumChunksPerTicket"); } + public static Iterator getPersistentChunksIterableFor(final World world, Iterator chunkIterator) + { + final ImmutableSetMultimap persistentChunksFor = getPersistentChunksFor(world); + final ImmutableSet.Builder builder = ImmutableSet.builder(); + world.theProfiler.startSection("forcedChunkLoading"); + builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function() { + @Nullable + @Override + public Chunk apply(@Nullable ChunkCoordIntPair input) + { + return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos); + } + })); + world.theProfiler.endStartSection("regularChunkLoading"); + builder.addAll(chunkIterator); + world.theProfiler.endSection(); + return builder.build().iterator(); + } + /** * All mods requiring chunkloading need to implement this to handle the * re-registration of chunk tickets at world loading time diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java index d3f5246806..d9f12cadb2 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java @@ -31,7 +31,7 @@ public class PlayerDropsEvent extends LivingDropsEvent { super(entity, source, drops, (source.getEntity() instanceof EntityPlayer) ? - EnchantmentHelper.getLootingModifier(((EntityPlayer)source.getEntity())) : 0, + EnchantmentHelper.func_185283_h(((EntityPlayer)source.getEntity())) : 0, recentlyHit); this.entityPlayer = entity;