summaryrefslogtreecommitdiffstats
path: root/nms-patches/ItemMapEmpty.patch
blob: 6edb2d9b1d853bfda6942a706cbe1a8b0256d3bf (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
--- a/net/minecraft/server/ItemMapEmpty.java
+++ b/net/minecraft/server/ItemMapEmpty.java
@@ -7,16 +7,20 @@
     }
 
     public InteractionResultWrapper<ItemStack> a(ItemStack itemstack, World world, EntityHuman entityhuman, EnumHand enumhand) {
-        ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, world.b("map"));
+        World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world
+        ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps
         String s = "map_" + itemstack1.getData();
         WorldMap worldmap = new WorldMap(s);
 
-        world.a(s, (PersistentBase) worldmap);
+        worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit
         worldmap.scale = 0;
         worldmap.a(entityhuman.locX, entityhuman.locZ, worldmap.scale);
         worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID();
         worldmap.track = true;
         worldmap.c();
+
+        org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit
+
         --itemstack.count;
         if (itemstack.count <= 0) {
             return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack1);