geforkt von Mirrors/Paper
Clean up forced chunk loading patch
Dieser Commit ist enthalten in:
Ursprung
d37d0f83c4
Commit
5030643f4e
@ -1,129 +1,153 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
|
From: Byteflux <byte@byteflux.net>
|
||||||
Date: Thu, 28 May 2015 22:01:25 -0500
|
Date: Tue, 30 Jun 2015 20:45:24 -0700
|
||||||
Subject: [PATCH] Force load chunks for specific entities that fly through
|
Subject: [PATCH] Force load chunks for specific entities that fly through
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||||
|
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queueUnload(int i, int j) {
|
||||||
|
+ // PaperSpigot start - Don't unload chunk if it contains an entity that loads chunks
|
||||||
|
+ Chunk chunk = chunks.get(LongHash.toLong(i, j));
|
||||||
|
+ if (chunk != null) {
|
||||||
|
+ for (List<Entity> entities : chunk.entitySlices) {
|
||||||
|
+ for (Entity entity : entities) {
|
||||||
|
+ if (entity.loadChunks) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // PaperSpigot end
|
||||||
|
if (this.world.worldProvider.e()) {
|
||||||
|
if (!this.world.c(i, j)) {
|
||||||
|
// CraftBukkit start
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
|
||||||
|
public boolean valid; // CraftBukkit
|
||||||
|
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
|
||||||
|
public boolean inUnloadedChunk = false; // PaperSpigot - Remove entities in unloaded chunks
|
||||||
|
+ public boolean loadChunks = false; // PaperSpigot - Entities can load chunks they move through and keep them loaded
|
||||||
|
|
||||||
|
// Spigot start
|
||||||
|
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Entity implements ICommandListener {
|
||||||
|
return this.world.getCubes(this, axisalignedbb).isEmpty() && !this.world.containsLiquid(axisalignedbb);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * PaperSpigot - Load surrounding chunks the entity is moving through
|
||||||
|
+ */
|
||||||
|
+ public void loadChunks() {
|
||||||
|
+ for (int cx = (int) locX >> 4; cx <= (int) (locX + motX) >> 4; ++cx) {
|
||||||
|
+ for (int cz = (int) locZ >> 4; cz <= (int) (locZ + motZ) >> 4; ++cz) {
|
||||||
|
+ ((ChunkProviderServer) world.chunkProvider).getChunkAt(cx, cz);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public void move(double d0, double d1, double d2) {
|
||||||
|
org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
|
||||||
|
+ if (this.loadChunks) loadChunks(); // PaperSpigot - Load chunks
|
||||||
|
if (this.noclip) {
|
||||||
|
this.a(this.getBoundingBox().c(d0, d1, d2));
|
||||||
|
this.recalcPosition();
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
--- a/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
+++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java
|
||||||
@@ -0,0 +0,0 @@ public class EntityEnderPearl extends EntityProjectile {
|
@@ -0,0 +0,0 @@ public class EntityEnderPearl extends EntityProjectile {
|
||||||
|
|
||||||
|
public EntityEnderPearl(World world) {
|
||||||
|
super(world);
|
||||||
|
+ this.loadChunks = world.paperSpigotConfig.loadUnloadedEnderPearls; // PaperSpigot
|
||||||
}
|
}
|
||||||
|
|
||||||
public void t_() {
|
public EntityEnderPearl(World world, EntityLiving entityliving) {
|
||||||
- EntityLiving entityliving = this.getShooter();
|
super(world, entityliving);
|
||||||
+ // PaperSpigot start - Force load chunks for specific entities that fly through
|
this.c = entityliving;
|
||||||
+ if (world.paperSpigotConfig.loadUnloadedEnderPearls) {
|
+ this.loadChunks = world.paperSpigotConfig.loadUnloadedEnderPearls; // PaperSpigot
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
|
}
|
||||||
+ boolean before = chunkProvider.forceChunkLoad;
|
|
||||||
+ chunkProvider.forceChunkLoad = true;
|
|
||||||
+ for (int cx = (int) locX >> 4; cx <= (int) (locX + motX) >> 4; ++cx) {
|
|
||||||
+ for (int cz = (int) locZ >> 4; cz <= (int) (locZ + motZ) >> 4; ++cz) {
|
|
||||||
+ world.getChunkAt(cx, cz);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ chunkProvider.forceChunkLoad = before;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
+ EntityLiving entityliving = this.getShooter();
|
protected void a(MovingObjectPosition movingobjectposition) {
|
||||||
if (entityliving != null && entityliving instanceof EntityHuman && !entityliving.isAlive()) {
|
|
||||||
this.die();
|
|
||||||
} else {
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
||||||
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
||||||
if (block.getMaterial() == Material.AIR) {
|
public EntityFallingBlock(org.bukkit.Location loc, World world) {
|
||||||
this.die();
|
super(world);
|
||||||
} else {
|
sourceLoc = loc;
|
||||||
+ // PaperSpigot start - Force load chunks for specific entities that fly through
|
+ this.loadChunks = world.paperSpigotConfig.loadUnloadedFallingBlocks; // PaperSpigot
|
||||||
+ if (world.paperSpigotConfig.loadUnloadedFallingBlocks) {
|
}
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
|
|
||||||
+ boolean before = chunkProvider.forceChunkLoad;
|
public EntityFallingBlock(org.bukkit.Location loc, World world, double d0, double d1, double d2, IBlockData iblockdata) {
|
||||||
+ chunkProvider.forceChunkLoad = true;
|
@@ -0,0 +0,0 @@ public class EntityFallingBlock extends Entity {
|
||||||
+
|
this.lastX = d0;
|
||||||
+ for (int cx = (int) locX >> 4; cx <= (int) (locX + motX) >> 4; ++cx) {
|
this.lastY = d1;
|
||||||
+ for (int cz = (int) locZ >> 4; cz <= (int) (locZ + motZ) >> 4; ++cz) {
|
this.lastZ = d2;
|
||||||
+ world.getChunkAt(cx, cz);
|
+ this.loadChunks = world.paperSpigotConfig.loadUnloadedFallingBlocks; // PaperSpigot
|
||||||
+ }
|
}
|
||||||
+ }
|
|
||||||
+
|
protected boolean s_() {
|
||||||
+ chunkProvider.forceChunkLoad = before;
|
|
||||||
+ }
|
|
||||||
+ // PaperSpigot end
|
|
||||||
this.lastX = this.locX;
|
|
||||||
this.lastY = this.locY;
|
|
||||||
this.lastZ = this.locZ;
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
||||||
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
||||||
|
// PaperSpigot end
|
||||||
|
this.k = true;
|
||||||
|
this.setSize(0.98F, 0.98F);
|
||||||
|
+ this.loadChunks = world.paperSpigotConfig.loadUnloadedTNTEntities; // PaperSpigot
|
||||||
|
}
|
||||||
|
|
||||||
public void t_() {
|
public EntityTNTPrimed(org.bukkit.Location loc, World world, double d0, double d1, double d2, EntityLiving entityliving) {
|
||||||
if (world.spigotConfig.currentPrimedTnt++ > world.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
|
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
||||||
+ // PaperSpigot start - Force load chunks for specific entities that fly through
|
private void explode() {
|
||||||
|
// CraftBukkit start
|
||||||
|
// float f = 4.0F;
|
||||||
|
-
|
||||||
|
+ // PaperSpigot start - Force load chunks during TNT explosions
|
||||||
|
+ ChunkProviderServer chunkProviderServer = ((ChunkProviderServer) world.chunkProvider);
|
||||||
|
+ boolean forceChunkLoad = chunkProviderServer.forceChunkLoad;
|
||||||
+ if (world.paperSpigotConfig.loadUnloadedTNTEntities) {
|
+ if (world.paperSpigotConfig.loadUnloadedTNTEntities) {
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
|
+ chunkProviderServer.forceChunkLoad = true;
|
||||||
+ boolean before = chunkProvider.forceChunkLoad;
|
|
||||||
+ chunkProvider.forceChunkLoad = true;
|
|
||||||
+
|
|
||||||
+ for (int cx = (int) locX >> 4; cx <= (int) (locX + motX) >> 4; ++cx) {
|
|
||||||
+ for (int cz = (int) locZ >> 4; cz <= (int) (locZ + motZ) >> 4; ++cz) {
|
|
||||||
+ world.getChunkAt(cx, cz);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ chunkProvider.forceChunkLoad = before;
|
|
||||||
+ }
|
+ }
|
||||||
+ // PaperSpigot end
|
+ // PaperSpigot end
|
||||||
this.lastX = this.locX;
|
org.bukkit.craftbukkit.CraftServer server = this.world.getServer();
|
||||||
this.lastY = this.locY;
|
|
||||||
this.lastZ = this.locZ;
|
|
||||||
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
|
||||||
server.getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
|
||||||
- this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, event.getRadius(), event.getFire(), true);
|
@@ -0,0 +0,0 @@ public class EntityTNTPrimed extends Entity {
|
||||||
+ // PaperSpigot start - Force load chunks for specific entities that fly through
|
this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, event.getRadius(), event.getFire(), true);
|
||||||
+ if (world.paperSpigotConfig.loadUnloadedTNTEntities) {
|
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) world.chunkProvider;
|
|
||||||
+ boolean before = chunkProvider.forceChunkLoad;
|
|
||||||
+ chunkProvider.forceChunkLoad = true;
|
|
||||||
+
|
|
||||||
+ this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, event.getRadius(), event.getFire(), true);
|
|
||||||
+
|
|
||||||
+ chunkProvider.forceChunkLoad = before;
|
|
||||||
+ } else {
|
|
||||||
+ this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, event.getRadius(), event.getFire(), true);
|
|
||||||
+ }
|
|
||||||
+ // PaperSpigot end
|
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
+ // PaperSpigot start - Force load chunks during TNT explosions
|
||||||
|
+ if (world.paperSpigotConfig.loadUnloadedTNTEntities) {
|
||||||
|
+ chunkProviderServer.forceChunkLoad = forceChunkLoad;
|
||||||
|
+ }
|
||||||
|
+ // PaperSpigot end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void b(NBTTagCompound nbttagcompound) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/World.java
|
--- a/src/main/java/net/minecraft/server/World.java
|
||||||
+++ b/src/main/java/net/minecraft/server/World.java
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||||
if (this.isChunkLoaded(k, i1, true)) {
|
int i1 = MathHelper.floor(entity.locZ / 16.0D);
|
||||||
entity.ad = true;
|
|
||||||
this.getChunkAt(k, i1).a(entity);
|
if (!entity.ad || entity.ae != k || entity.af != l || entity.ag != i1) {
|
||||||
+ // PaperSpigot start - Force load chunks for specific entities that fly through
|
+ if (entity.loadChunks) entity.loadChunks(); // PaperSpigot - Force load chunks
|
||||||
+ } else if ((entity instanceof EntityEnderPearl && entity.world.paperSpigotConfig.loadUnloadedEnderPearls) ||
|
if (entity.ad && this.isChunkLoaded(entity.ae, entity.ag, true)) {
|
||||||
+ (entity instanceof EntityTNTPrimed && entity.world.paperSpigotConfig.loadUnloadedTNTEntities) ||
|
this.getChunkAt(entity.ae, entity.ag).a(entity, entity.af);
|
||||||
+ (entity instanceof EntityFallingBlock && entity.world.paperSpigotConfig.loadUnloadedFallingBlocks)) {
|
|
||||||
+ ChunkProviderServer chunkProvider = (ChunkProviderServer) this.chunkProvider;
|
|
||||||
+ boolean before = chunkProvider.forceChunkLoad;
|
|
||||||
+ chunkProvider.forceChunkLoad = true;
|
|
||||||
+ entity.ad = true;
|
|
||||||
+ this.getChunkAt(k, i1).a(entity);
|
|
||||||
+ chunkProvider.forceChunkLoad = before;
|
|
||||||
+ // PaperSpigot end
|
|
||||||
} else {
|
|
||||||
entity.ad = false;
|
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
|
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@ -148,23 +172,12 @@ diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.server.EntityComplexPart;
|
|
||||||
import net.minecraft.server.EntityCreature;
|
|
||||||
import net.minecraft.server.EntityEnderCrystal;
|
|
||||||
import net.minecraft.server.EntityEnderDragon;
|
|
||||||
+import net.minecraft.server.EntityEnderPearl; // PaperSpigot
|
|
||||||
import net.minecraft.server.EntityFallingBlock;
|
|
||||||
import net.minecraft.server.EntityFireball;
|
|
||||||
import net.minecraft.server.EntityFireworks;
|
|
||||||
@@ -0,0 +0,0 @@ public class ActivationRange
|
@@ -0,0 +0,0 @@ public class ActivationRange
|
||||||
{
|
{
|
||||||
SpigotTimings.checkIfActiveTimer.startTiming();
|
SpigotTimings.checkIfActiveTimer.startTiming();
|
||||||
// Never safe to skip fireworks or entities not yet added to chunk
|
// Never safe to skip fireworks or entities not yet added to chunk
|
||||||
- if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks ) {
|
- if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks ) {
|
||||||
+ // PaperSpigot - Changes for loading chunks for entities that fly through them
|
+ if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks || entity.loadChunks ) {
|
||||||
+ if ( !entity.isAddedToChunk() || entity instanceof EntityFireworks || entity instanceof EntityFallingBlock ||
|
|
||||||
+ ( entity instanceof EntityEnderPearl && entity.world.paperSpigotConfig.loadUnloadedEnderPearls ) ||
|
|
||||||
+ ( entity instanceof EntityTNTPrimed && entity.world.paperSpigotConfig.loadUnloadedTNTEntities ) ) {
|
|
||||||
SpigotTimings.checkIfActiveTimer.stopTiming();
|
SpigotTimings.checkIfActiveTimer.stopTiming();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren