Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/ItemWorldMap.patch

91 Zeilen
4.6 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemWorldMap.java
+++ b/net/minecraft/server/ItemWorldMap.java
2018-07-15 02:00:00 +02:00
@@ -6,6 +6,11 @@
2018-12-25 22:00:00 +01:00
import com.google.common.collect.Multisets;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.server.MapInitializeEvent;
+// CraftBukkit end
+
public class ItemWorldMap extends ItemWorldMapBase {
2018-07-15 02:00:00 +02:00
public ItemWorldMap(Item.Info item_info) {
@@ -15,7 +20,7 @@
2018-10-22 21:00:00 +02:00
public static ItemStack createFilledMapView(World world, int i, int j, byte b0, boolean flag, boolean flag1) {
2018-07-15 02:00:00 +02:00
ItemStack itemstack = new ItemStack(Items.FILLED_MAP);
2018-08-26 04:00:00 +02:00
- a(itemstack, world, i, j, b0, flag, flag1, world.worldProvider.getDimensionManager());
2018-07-15 02:00:00 +02:00
+ a(itemstack, world, i, j, b0, flag, flag1, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps
return itemstack;
}
2018-07-15 02:00:00 +02:00
@@ -24,7 +29,7 @@
WorldMap worldmap = a((GeneratorAccess) world, "map_" + e(itemstack));
2016-11-17 02:41:03 +01:00
2018-07-15 02:00:00 +02:00
if (worldmap == null && !world.isClientSide) {
2018-08-26 04:00:00 +02:00
- worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, world.worldProvider.getDimensionManager());
2018-07-15 02:00:00 +02:00
+ worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps
}
return worldmap;
@@ -33,26 +38,42 @@
2018-07-15 02:00:00 +02:00
public static int e(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
2016-11-17 02:41:03 +01:00
}
2018-08-26 04:00:00 +02:00
private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, DimensionManager dimensionmanager) {
- int l = world.a(DimensionManager.OVERWORLD, "map");
+ World worldMain = world.getServer().getServer().getWorldServer(DimensionManager.OVERWORLD); // CraftBukkit - store reference to primary world
+ int l = worldMain.a(DimensionManager.OVERWORLD, "map"); // CraftBukkit - use primary world for maps
WorldMap worldmap = new WorldMap("map_" + l);
2018-08-26 04:00:00 +02:00
worldmap.a(i, j, k, flag, flag1, dimensionmanager);
- world.a(DimensionManager.OVERWORLD, worldmap.getId(), (PersistentBase) worldmap);
+ worldMain.a(DimensionManager.OVERWORLD, worldmap.getId(), (PersistentBase) worldmap); // CraftBukkit - use primary world for maps
itemstack.getOrCreateTag().setInt("map", l);
2015-02-26 23:41:06 +01:00
+
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
return worldmap;
}
@Nullable
public static WorldMap a(GeneratorAccess generatoraccess, String s) {
2018-08-26 04:00:00 +02:00
- return (WorldMap) generatoraccess.a(DimensionManager.OVERWORLD, WorldMap::new, s);
+ // CraftBukkit start - use primary world for maps and call event
2018-08-26 04:00:00 +02:00
+ WorldMap worldmap = (WorldMap) MinecraftServer.getServer().getWorldServer(DimensionManager.OVERWORLD).a(DimensionManager.OVERWORLD, (id) -> {
+ // We only get here when the data file exists, but is not a valid map
+ WorldMap newMap = new WorldMap(id);
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ return newMap;
+ }, s);
2018-07-15 02:00:00 +02:00
+ return worldmap;
+ // CraftBukkit end
}
public void a(World world, Entity entity, WorldMap worldmap) {
2018-08-26 04:00:00 +02:00
- if (world.worldProvider.getDimensionManager() == worldmap.map && entity instanceof EntityHuman) {
+ // 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;
@@ -199,7 +220,8 @@
2018-07-15 02:00:00 +02:00
WorldMap worldmap = getSavedMap(itemstack, world);
2016-02-29 22:32:46 +01:00
2018-07-15 02:00:00 +02:00
if (worldmap != null) {
2018-08-26 04:00:00 +02:00
- if (world.worldProvider.getDimensionManager() == worldmap.map) {
2018-07-15 02:00:00 +02:00
+ // CraftBukkit - world.worldProvider -> ((WorldServer) world)
+ if (((WorldServer) world).dimension == worldmap.map) {
int i = 1 << worldmap.scale;
int j = worldmap.centerX;
int k = worldmap.centerZ;