mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Finish world, chunkloading should work again?
This commit is contained in:
1 parent
c11732fc40
commit
aa24916736
5 files changed
+40
-11
No files matched your search
@@ -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<Chunk> getPersistentChunkIterable(Iterator<Chunk> chunkIterator)
|
||||
+ {
|
||||
+ return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksIterableFor(this, chunkIterator);
|
||||
+ }
|
||||
+ /**
|
||||
+ * Readded as it was removed, very useful helper function
|
||||
+ *
|
||||
|
||||
@@ -80,6 +80,15 @@
|
||||
}
|
||||
|
||||
public boolean areAllPlayersAsleep()
|
||||
@@ -368,7 +380,7 @@
|
||||
boolean flag1 = this.isThundering();
|
||||
this.theProfiler.startSection("pollingChunks");
|
||||
|
||||
- for (Iterator<Chunk> iterator = this.thePlayerManager.func_187300_b(); iterator.hasNext(); this.theProfiler.endSection())
|
||||
+ for (Iterator<Chunk> 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");
|
||||
|
||||
@@ -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
|
||||
@@ -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<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
final ImmutableSetMultimap<ChunkCoordIntPair, Ticket> persistentChunksFor = getPersistentChunksFor(world);
|
||||
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
|
||||
world.theProfiler.startSection("forcedChunkLoading");
|
||||
builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function<ChunkCoordIntPair, Chunk>() {
|
||||
@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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user