PaperMC/paper-server/nms-patches/net/minecraft/world/item/ItemWorldMap.patch

36 lines
1.4 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/item/ItemWorldMap.java
+++ b/net/minecraft/world/item/ItemWorldMap.java
@@ -30,6 +30,11 @@
import net.minecraft.world.level.material.MaterialMapColor;
import net.minecraft.world.level.saveddata.maps.WorldMap;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.server.MapInitializeEvent;
+// CraftBukkit end
+
public class ItemWorldMap extends ItemWorldMapBase {
public ItemWorldMap(Item.Info item_info) {
2021-03-15 23:00:00 +01:00
@@ -62,7 +67,7 @@
public static int d(ItemStack itemstack) {
NBTTagCompound nbttagcompound = itemstack.getTag();
- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0;
+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
}
private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
2021-03-15 23:00:00 +01:00
@@ -72,6 +77,11 @@
worldmap.a(i, j, k, flag, flag1, resourcekey);
world.a(worldmap);
itemstack.getOrCreateTag().setInt("map", l);
+
+ // CraftBukkit start
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
return worldmap;
}