Improve Village Door code to not break village mechanics

This commit is contained in:
Aikar 2018-10-11 21:42:13 -04:00
parent a16ef75bfd
commit ee7933e43e
No known key found for this signature in database
GPG Key ID: 401ADFC9891FAAFE
2 changed files with 71 additions and 16 deletions

View File

@ -1,4 +1,4 @@
From 2fd84bb4152e70a21453a5deb49b2938207764b8 Mon Sep 17 00:00:00 2001 From 303049b123b3adb9aea02f550750a9afc8a45887 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 00:32:22 -0400 Date: Tue, 5 Jun 2018 00:32:22 -0400
Subject: [PATCH] Configurable Villages loading chunks for door checks Subject: [PATCH] Configurable Villages loading chunks for door checks
@ -45,19 +45,49 @@ index d14a9e3a3e..0be1bf0d99 100644
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java
index bda67faefe..0414f003a5 100644 index bda67faefe..5b56ae1818 100644
--- a/src/main/java/net/minecraft/server/Village.java --- a/src/main/java/net/minecraft/server/Village.java
+++ b/src/main/java/net/minecraft/server/Village.java +++ b/src/main/java/net/minecraft/server/Village.java
@@ -297,7 +297,7 @@ public class Village { @@ -11,10 +11,10 @@ import javax.annotation.Nullable;
villagedoor.a();
public class Village {
- private World a;
+ private World a; private World getWorld() { return a; } // Paper - OBFHELPER
private final List<VillageDoor> b = Lists.newArrayList();
private BlockPosition c;
- private BlockPosition d;
+ private BlockPosition d;private BlockPosition getCenter() { return d; } // Paper - OBFHELPER
private int e;
private int f;
private int g;
@@ -44,6 +44,12 @@ public class Village {
} }
- if (!this.g(villagedoor.d()) || Math.abs(this.g - villagedoor.h()) > 1200) { public void a(int i) {
+ if ((!this.g(villagedoor.d()) || Math.abs(this.g - villagedoor.h()) > 1200) && this.a.isLoaded(villagedoor.d())) { // Paper - don't expire doors unless the chunk is loaded, use same param as the first conditional and the one below checks + // Paper - don't tick village if chunk isn't loaded
this.c = this.c.b(villagedoor.d()); + Chunk chunk = getWorld().getChunkIfLoaded(getCenter());
flag = true; + if (chunk == null || !chunk.areNeighborsLoaded(1)) {
villagedoor.a(true); + return;
@@ -312,7 +312,9 @@ public class Village { + }
+ // Paper end
this.g = i;
this.m();
this.l();
@@ -292,6 +298,12 @@ public class Village {
while (iterator.hasNext()) {
VillageDoor villagedoor = (VillageDoor) iterator.next();
+ // Paper start - don't remove doors from unloaded chunks
+ if (!getWorld().isLoaded(villagedoor.getPosition())) {
+ villagedoor.setLastSeen(villagedoor.getLastSeen());
+ continue;
+ }
+ // Paper end
if (flag1) {
villagedoor.a();
@@ -312,7 +324,9 @@ public class Village {
} }
private boolean g(BlockPosition blockposition) { private boolean g(BlockPosition blockposition) {
@ -68,6 +98,31 @@ index bda67faefe..0414f003a5 100644
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
return block instanceof BlockDoor ? iblockdata.getMaterial() == Material.WOOD : false; return block instanceof BlockDoor ? iblockdata.getMaterial() == Material.WOOD : false;
-- diff --git a/src/main/java/net/minecraft/server/VillageDoor.java b/src/main/java/net/minecraft/server/VillageDoor.java
2.19.0 index 62771547f6..74ac3c1ba6 100644
--- a/src/main/java/net/minecraft/server/VillageDoor.java
+++ b/src/main/java/net/minecraft/server/VillageDoor.java
@@ -59,6 +59,7 @@ public class VillageDoor {
return this.f;
}
+ public BlockPosition getPosition() { return d(); } // Paper - OBFHELPER
public BlockPosition d() {
return this.a;
}
@@ -75,10 +76,12 @@ public class VillageDoor {
return this.c.getAdjacentZ() * 2;
}
+ public int getLastSeen() { return h(); } // Paper - OBFHELPER
public int h() {
return this.d;
}
+ public void setLastSeen(int i) { a(i); } // Paper - OBFHELPER
public void a(int i) {
this.d = i;
}
--
2.19.1

View File

@ -1,4 +1,4 @@
From 55a1e8faecf44ded04ae4ba2089134bcf7b4ee46 Mon Sep 17 00:00:00 2001 From 91b4f51a74524843e76a6531ca4279cef4fbe489 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Thu, 30 Aug 2018 20:56:26 -0400 Date: Thu, 30 Aug 2018 20:56:26 -0400
Subject: [PATCH] Don't double add golems to world Subject: [PATCH] Don't double add golems to world
@ -6,10 +6,10 @@ Subject: [PATCH] Don't double add golems to world
spawnCreature adds to world now spawnCreature adds to world now
diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java
index 0414f003a5..d92ef03661 100644 index 5b56ae1818..afb79bb641 100644
--- a/src/main/java/net/minecraft/server/Village.java --- a/src/main/java/net/minecraft/server/Village.java
+++ b/src/main/java/net/minecraft/server/Village.java +++ b/src/main/java/net/minecraft/server/Village.java
@@ -77,7 +77,7 @@ public class Village { @@ -83,7 +83,7 @@ public class Village {
if (entityirongolem != null) { if (entityirongolem != null) {
if (entityirongolem.a((GeneratorAccess) this.a, false) && entityirongolem.a((IWorldReader) this.a)) { if (entityirongolem.a((GeneratorAccess) this.a, false) && entityirongolem.a((IWorldReader) this.a)) {
@ -19,5 +19,5 @@ index 0414f003a5..d92ef03661 100644
} }
-- --
2.19.0 2.19.1