mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
124 lines
5.1 KiB
Diff
124 lines
5.1 KiB
Diff
--- a/net/minecraft/server/WorldMap.java
|
|
+++ b/net/minecraft/server/WorldMap.java
|
|
@@ -7,6 +7,14 @@
|
|
import java.util.Map;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import java.util.UUID;
|
|
+
|
|
+import org.bukkit.craftbukkit.CraftServer;
|
|
+import org.bukkit.craftbukkit.CraftWorld;
|
|
+import org.bukkit.craftbukkit.map.CraftMapView;
|
|
+// CraftBukkit end
|
|
+
|
|
public class WorldMap extends PersistentBase {
|
|
|
|
public int centerX;
|
|
@@ -20,8 +28,18 @@
|
|
private final Map<EntityHuman, WorldMap.WorldMapHumanTracker> k = Maps.newHashMap();
|
|
public Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
|
|
|
|
+ // CraftBukkit start
|
|
+ public final CraftMapView mapView;
|
|
+ private CraftServer server;
|
|
+ private UUID uniqueId = null;
|
|
+ // CraftBukkit end
|
|
+
|
|
public WorldMap(String s) {
|
|
super(s);
|
|
+ // CraftBukkit start
|
|
+ mapView = new CraftMapView(this);
|
|
+ server = (CraftServer) org.bukkit.Bukkit.getServer();
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
public void a(double d0, double d1, int i) {
|
|
@@ -34,7 +52,30 @@
|
|
}
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
|
- this.map = nbttagcompound.getByte("dimension");
|
|
+ // CraftBukkit start
|
|
+ byte dimension = nbttagcompound.getByte("dimension");
|
|
+
|
|
+ if (dimension >= 10) {
|
|
+ long least = nbttagcompound.getLong("UUIDLeast");
|
|
+ long most = nbttagcompound.getLong("UUIDMost");
|
|
+
|
|
+ if (least != 0L && most != 0L) {
|
|
+ this.uniqueId = new UUID(most, least);
|
|
+
|
|
+ CraftWorld world = (CraftWorld) server.getWorld(this.uniqueId);
|
|
+ // Check if the stored world details are correct.
|
|
+ if (world == null) {
|
|
+ /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached.
|
|
+ This is to prevent them being corrupted with the wrong map data. */
|
|
+ dimension = 127;
|
|
+ } else {
|
|
+ dimension = (byte) world.getHandle().dimension;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ this.map = dimension;
|
|
+ // CraftBukkit end
|
|
this.centerX = nbttagcompound.getInt("xCenter");
|
|
this.centerZ = nbttagcompound.getInt("zCenter");
|
|
this.scale = nbttagcompound.getByte("scale");
|
|
@@ -76,6 +117,25 @@
|
|
}
|
|
|
|
public NBTTagCompound b(NBTTagCompound nbttagcompound) {
|
|
+ // CraftBukkit start
|
|
+ if (this.map >= 10) {
|
|
+ if (this.uniqueId == null) {
|
|
+ for (org.bukkit.World world : server.getWorlds()) {
|
|
+ CraftWorld cWorld = (CraftWorld) world;
|
|
+ if (cWorld.getHandle().dimension == this.map) {
|
|
+ this.uniqueId = cWorld.getUID();
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ /* Perform a second check to see if a matching world was found, this is a necessary
|
|
+ change incase Maps are forcefully unlinked from a World and lack a UID.*/
|
|
+ if (this.uniqueId != null) {
|
|
+ nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
|
|
+ nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
nbttagcompound.setByte("dimension", this.map);
|
|
nbttagcompound.setInt("xCenter", this.centerX);
|
|
nbttagcompound.setInt("zCenter", this.centerZ);
|
|
@@ -265,12 +325,26 @@
|
|
|
|
@Nullable
|
|
public Packet<?> a(ItemStack itemstack) {
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()); // CraftBukkit
|
|
+
|
|
+ java.util.Collection<MapIcon> icons = new java.util.ArrayList<MapIcon>();
|
|
+
|
|
+ for ( org.bukkit.map.MapCursor cursor : render.cursors) {
|
|
+
|
|
+ if (cursor.isVisible()) {
|
|
+ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection()));
|
|
+ }
|
|
+ }
|
|
+
|
|
if (this.d) {
|
|
this.d = false;
|
|
- return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
|
|
+ // PAIL: this.e
|
|
+ return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
|
|
} else {
|
|
- return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null;
|
|
+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null;
|
|
}
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
public void a(int i, int j) {
|