aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0088-Pass-world-to-Village-creation.patch
blob: 6b23bec08b5434c24de77317d32668842f5a6537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 4d271a1256717859ffd1692a3bbc5481644b0f8e 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 a285639..22ee682 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 e674cf9..2624abf 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();
@@ -391,7 +391,7 @@ public class Village {
             NBTTagCompound nbttagcompound2 = nbttaglist1.get(j);
 
             if (nbttagcompound2.hasKey("UUID")) {
-                UserCache usercache = this.a.getMinecraftServer().getUserCache();
+                UserCache usercache = MinecraftServer.getServer().getUserCache(); // Paper - Bandaid for world being null
                 GameProfile gameprofile = usercache.a(UUID.fromString(nbttagcompound2.getString("UUID")));
 
                 if (gameprofile != null) {
-- 
2.8.2