geforkt von Mirrors/Paper
Fixes #95 - Vanilla bug with Villages
Dieser Commit ist enthalten in:
Ursprung
57aa8b7451
Commit
ea051e14d1
@ -1,4 +1,4 @@
|
||||
From 7c9c5611ad40131650fb248b824e5119349431fb Mon Sep 17 00:00:00 2001
|
||||
From 636e967ef66ae6a0c30fdb012b1db6252fe22aee Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 21:09:10 -0600
|
||||
Subject: [PATCH] mc-dev imports
|
||||
@ -5325,6 +5325,278 @@ index 0000000..1a20dbf
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/PersistentVillage.java b/src/main/java/net/minecraft/server/PersistentVillage.java
|
||||
new file mode 100644
|
||||
index 0000000..107f582
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/PersistentVillage.java
|
||||
@@ -0,0 +1,266 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class PersistentVillage extends PersistentBase {
|
||||
+
|
||||
+ private World world;
|
||||
+ private final List<BlockPosition> c = Lists.newArrayList();
|
||||
+ private final List<VillageDoor> d = Lists.newArrayList();
|
||||
+ private final List<Village> villages = Lists.newArrayList();
|
||||
+ private int time;
|
||||
+
|
||||
+ public PersistentVillage(String s) {
|
||||
+ super(s);
|
||||
+ }
|
||||
+
|
||||
+ public PersistentVillage(World world) {
|
||||
+ super(a(world.worldProvider));
|
||||
+ this.world = world;
|
||||
+ this.c();
|
||||
+ }
|
||||
+
|
||||
+ public void a(World world) {
|
||||
+ this.world = world;
|
||||
+ Iterator iterator = this.villages.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Village village = (Village) iterator.next();
|
||||
+
|
||||
+ village.a(world);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public void a(BlockPosition blockposition) {
|
||||
+ if (this.c.size() <= 64) {
|
||||
+ if (!this.e(blockposition)) {
|
||||
+ this.c.add(blockposition);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void tick() {
|
||||
+ ++this.time;
|
||||
+ Iterator iterator = this.villages.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Village village = (Village) iterator.next();
|
||||
+
|
||||
+ village.a(this.time);
|
||||
+ }
|
||||
+
|
||||
+ this.e();
|
||||
+ this.f();
|
||||
+ this.g();
|
||||
+ if (this.time % 400 == 0) {
|
||||
+ this.c();
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ private void e() {
|
||||
+ Iterator iterator = this.villages.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Village village = (Village) iterator.next();
|
||||
+
|
||||
+ if (village.g()) {
|
||||
+ iterator.remove();
|
||||
+ this.c();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public List<Village> getVillages() {
|
||||
+ return this.villages;
|
||||
+ }
|
||||
+
|
||||
+ public Village getClosestVillage(BlockPosition blockposition, int i) {
|
||||
+ Village village = null;
|
||||
+ double d0 = 3.4028234663852886E38D;
|
||||
+ Iterator iterator = this.villages.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Village village1 = (Village) iterator.next();
|
||||
+ double d1 = village1.a().k(blockposition);
|
||||
+
|
||||
+ if (d1 < d0) {
|
||||
+ float f = (float) (i + village1.b());
|
||||
+
|
||||
+ if (d1 <= (double) (f * f)) {
|
||||
+ village = village1;
|
||||
+ d0 = d1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return village;
|
||||
+ }
|
||||
+
|
||||
+ private void f() {
|
||||
+ if (!this.c.isEmpty()) {
|
||||
+ this.b((BlockPosition) this.c.remove(0));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void g() {
|
||||
+ for (int i = 0; i < this.d.size(); ++i) {
|
||||
+ VillageDoor villagedoor = (VillageDoor) this.d.get(i);
|
||||
+ Village village = this.getClosestVillage(villagedoor.d(), 32);
|
||||
+
|
||||
+ if (village == null) {
|
||||
+ village = new Village(this.world);
|
||||
+ this.villages.add(village);
|
||||
+ this.c();
|
||||
+ }
|
||||
+
|
||||
+ village.a(villagedoor);
|
||||
+ }
|
||||
+
|
||||
+ this.d.clear();
|
||||
+ }
|
||||
+
|
||||
+ private void b(BlockPosition blockposition) {
|
||||
+ byte b0 = 16;
|
||||
+ byte b1 = 4;
|
||||
+ byte b2 = 16;
|
||||
+
|
||||
+ for (int i = -b0; i < b0; ++i) {
|
||||
+ for (int j = -b1; j < b1; ++j) {
|
||||
+ for (int k = -b2; k < b2; ++k) {
|
||||
+ BlockPosition blockposition1 = blockposition.a(i, j, k);
|
||||
+
|
||||
+ if (this.f(blockposition1)) {
|
||||
+ VillageDoor villagedoor = this.c(blockposition1);
|
||||
+
|
||||
+ if (villagedoor == null) {
|
||||
+ this.d(blockposition1);
|
||||
+ } else {
|
||||
+ villagedoor.a(this.time);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ private VillageDoor c(BlockPosition blockposition) {
|
||||
+ Iterator iterator = this.d.iterator();
|
||||
+
|
||||
+ VillageDoor villagedoor;
|
||||
+
|
||||
+ do {
|
||||
+ if (!iterator.hasNext()) {
|
||||
+ iterator = this.villages.iterator();
|
||||
+
|
||||
+ VillageDoor villagedoor1;
|
||||
+
|
||||
+ do {
|
||||
+ if (!iterator.hasNext()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ Village village = (Village) iterator.next();
|
||||
+
|
||||
+ villagedoor1 = village.e(blockposition);
|
||||
+ } while (villagedoor1 == null);
|
||||
+
|
||||
+ return villagedoor1;
|
||||
+ }
|
||||
+
|
||||
+ villagedoor = (VillageDoor) iterator.next();
|
||||
+ } while (villagedoor.d().getX() != blockposition.getX() || villagedoor.d().getZ() != blockposition.getZ() || Math.abs(villagedoor.d().getY() - blockposition.getY()) > 1);
|
||||
+
|
||||
+ return villagedoor;
|
||||
+ }
|
||||
+
|
||||
+ private void d(BlockPosition blockposition) {
|
||||
+ EnumDirection enumdirection = BlockDoor.f(this.world, blockposition);
|
||||
+ EnumDirection enumdirection1 = enumdirection.opposite();
|
||||
+ int i = this.a(blockposition, enumdirection, 5);
|
||||
+ int j = this.a(blockposition, enumdirection1, i + 1);
|
||||
+
|
||||
+ if (i != j) {
|
||||
+ this.d.add(new VillageDoor(blockposition, i < j ? enumdirection : enumdirection1, this.time));
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ private int a(BlockPosition blockposition, EnumDirection enumdirection, int i) {
|
||||
+ int j = 0;
|
||||
+
|
||||
+ for (int k = 1; k <= 5; ++k) {
|
||||
+ if (this.world.h(blockposition.shift(enumdirection, k))) {
|
||||
+ ++j;
|
||||
+ if (j >= i) {
|
||||
+ return j;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return j;
|
||||
+ }
|
||||
+
|
||||
+ private boolean e(BlockPosition blockposition) {
|
||||
+ Iterator iterator = this.c.iterator();
|
||||
+
|
||||
+ BlockPosition blockposition1;
|
||||
+
|
||||
+ do {
|
||||
+ if (!iterator.hasNext()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ blockposition1 = (BlockPosition) iterator.next();
|
||||
+ } while (!blockposition1.equals(blockposition));
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private boolean f(BlockPosition blockposition) {
|
||||
+ IBlockData iblockdata = this.world.getType(blockposition);
|
||||
+ Block block = iblockdata.getBlock();
|
||||
+
|
||||
+ return block instanceof BlockDoor ? iblockdata.getMaterial() == Material.WOOD : false;
|
||||
+ }
|
||||
+
|
||||
+ public void a(NBTTagCompound nbttagcompound) {
|
||||
+ this.time = nbttagcompound.getInt("Tick");
|
||||
+ NBTTagList nbttaglist = nbttagcompound.getList("Villages", 10);
|
||||
+
|
||||
+ for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
+ NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
|
||||
+ Village village = new Village();
|
||||
+
|
||||
+ village.a(nbttagcompound1);
|
||||
+ this.villages.add(village);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public void b(NBTTagCompound nbttagcompound) {
|
||||
+ nbttagcompound.setInt("Tick", this.time);
|
||||
+ NBTTagList nbttaglist = new NBTTagList();
|
||||
+ Iterator iterator = this.villages.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Village village = (Village) iterator.next();
|
||||
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
+
|
||||
+ village.b(nbttagcompound1);
|
||||
+ nbttaglist.add(nbttagcompound1);
|
||||
+ }
|
||||
+
|
||||
+ nbttagcompound.set("Villages", nbttaglist);
|
||||
+ }
|
||||
+
|
||||
+ public static String a(WorldProvider worldprovider) {
|
||||
+ return "villages" + worldprovider.getDimensionManager().c();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
new file mode 100644
|
||||
index 0000000..e454622
|
||||
@ -5564,5 +5836,5 @@ index 0000000..2286c9e
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.7.3
|
||||
2.7.4
|
||||
|
||||
|
36
Spigot-Server-Patches/0096-Pass-world-to-Village-creation.patch
Normale Datei
36
Spigot-Server-Patches/0096-Pass-world-to-Village-creation.patch
Normale Datei
@ -0,0 +1,36 @@
|
||||
From 1937f16e1e4eb1172c75ee7b08e3e176e86e33a2 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 19 Mar 2016 15:16:54 -0400
|
||||
Subject: [PATCH] Pass world to Village creation
|
||||
|
||||
fixes NPE bug #95
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PersistentVillage.java b/src/main/java/net/minecraft/server/PersistentVillage.java
|
||||
index 107f582..140b14b 100644
|
||||
--- a/src/main/java/net/minecraft/server/PersistentVillage.java
|
||||
+++ b/src/main/java/net/minecraft/server/PersistentVillage.java
|
||||
@@ -236,7 +236,7 @@ public class PersistentVillage extends PersistentBase {
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
|
||||
- Village village = new Village();
|
||||
+ Village village = new Village(world); // Paper
|
||||
|
||||
village.a(nbttagcompound1);
|
||||
this.villages.add(village);
|
||||
diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java
|
||||
index 932eeb7..9b59dcb 100644
|
||||
--- a/src/main/java/net/minecraft/server/Village.java
|
||||
+++ b/src/main/java/net/minecraft/server/Village.java
|
||||
@@ -22,7 +22,7 @@ public class Village {
|
||||
private List<Village.Aggressor> k;
|
||||
private int l;
|
||||
|
||||
- public Village() {
|
||||
+ private Village() { // Paper - Nothing should call this - world needs to be set.
|
||||
this.c = BlockPosition.ZERO;
|
||||
this.d = BlockPosition.ZERO;
|
||||
this.j = new TreeMap();
|
||||
--
|
||||
2.7.4
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren