2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/ItemWorldMap.java
|
|
|
|
+++ b/net/minecraft/server/ItemWorldMap.java
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -5,6 +5,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import com.google.common.collect.Multisets;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.event.server.MapInitializeEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class ItemWorldMap extends ItemWorldMapBase {
|
|
|
|
|
|
|
|
protected ItemWorldMap() {
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -12,25 +17,32 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public WorldMap getSavedMap(ItemStack itemstack, World world) {
|
|
|
|
+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world
|
|
|
|
String s = "map_" + itemstack.getData();
|
|
|
|
- WorldMap worldmap = (WorldMap) world.a(WorldMap.class, s);
|
|
|
|
+ WorldMap worldmap = (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps
|
|
|
|
|
2015-02-26 23:41:06 +01:00
|
|
|
if (worldmap == null && !world.isClientSide) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- itemstack.setData(world.b("map"));
|
|
|
|
+ itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps
|
|
|
|
s = "map_" + itemstack.getData();
|
|
|
|
worldmap = new WorldMap(s);
|
|
|
|
worldmap.scale = 3;
|
2016-02-29 22:32:46 +01:00
|
|
|
worldmap.a((double) world.getWorldData().b(), (double) world.getWorldData().d(), worldmap.scale);
|
|
|
|
- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps
|
|
|
|
worldmap.c();
|
|
|
|
- world.a(s, (PersistentBase) worldmap);
|
|
|
|
+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - use primary world for maps
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
|
|
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
return worldmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(World world, Entity entity, WorldMap worldmap) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- if (world.worldProvider.getDimensionManager().getDimensionID() == worldmap.map && entity instanceof EntityHuman) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit - world.worldProvider -> ((WorldServer) world)
|
|
|
|
+ if (((WorldServer) world).dimension == worldmap.map && entity instanceof EntityHuman) {
|
|
|
|
int i = 1 << worldmap.scale;
|
|
|
|
int j = worldmap.centerX;
|
|
|
|
int k = worldmap.centerZ;
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -197,6 +209,7 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
protected static void a(ItemStack itemstack, World world, int i) {
|
|
|
|
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps
|
|
|
|
itemstack.setData(world.b("map"));
|
|
|
|
WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -206,11 +219,16 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
worldmap1.map = worldmap.map;
|
|
|
|
worldmap1.c();
|
|
|
|
world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
|
|
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static void b(ItemStack itemstack, World world) {
|
|
|
|
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world);
|
|
|
|
|
|
|
|
+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps
|
|
|
|
itemstack.setData(world.b("map"));
|
|
|
|
WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@@ -221,5 +239,9 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
worldmap1.map = worldmap.map;
|
|
|
|
worldmap1.c();
|
|
|
|
world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
|
|
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|