Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
89 Zeilen
4.2 KiB
Diff
89 Zeilen
4.2 KiB
Diff
--- a/net/minecraft/server/ItemWorldMap.java
|
|
+++ b/net/minecraft/server/ItemWorldMap.java
|
|
@@ -6,6 +6,11 @@
|
|
import java.util.function.Function;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// 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) {
|
|
@@ -15,7 +20,7 @@
|
|
public static ItemStack a(World world, int i, int j, byte b0, boolean flag, boolean flag1) {
|
|
ItemStack itemstack = new ItemStack(Items.FILLED_MAP);
|
|
|
|
- a(itemstack, world, i, j, b0, flag, flag1, world.worldProvider.getDimensionManager().getDimensionID());
|
|
+ a(itemstack, world, i, j, b0, flag, flag1, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps
|
|
return itemstack;
|
|
}
|
|
|
|
@@ -24,7 +29,7 @@
|
|
WorldMap worldmap = a((GeneratorAccess) world, "map_" + e(itemstack));
|
|
|
|
if (worldmap == null && !world.isClientSide) {
|
|
- worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, world.worldProvider.getDimensionManager().getDimensionID());
|
|
+ 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,40 @@
|
|
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
|
|
}
|
|
|
|
private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, int l) {
|
|
- int i1 = world.b("map");
|
|
+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world
|
|
+ int i1 = worldMain.b("map"); // CraftBukkit - use primary world for maps
|
|
WorldMap worldmap = new WorldMap("map_" + i1);
|
|
|
|
worldmap.a(i, j, k, flag, flag1, l);
|
|
- world.a(worldmap.getId(), (PersistentBase) worldmap);
|
|
+ worldMain.a(worldmap.getId(), (PersistentBase) worldmap); // CraftBukkit - use primary world for maps
|
|
itemstack.getOrCreateTag().setInt("map", i1);
|
|
+
|
|
+ // 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) {
|
|
- return (WorldMap) generatoraccess.a(WorldMap::new, s);
|
|
+ // CraftBukkit start
|
|
+ WorldMap worldmap = (WorldMap) MinecraftServer.getServer().worlds.get(0).a(WorldMap::new, s); // CraftBukkit - use primary world for maps
|
|
+ if (worldmap != null) {
|
|
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
|
|
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
|
+ }
|
|
+ return worldmap;
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
public void a(World world, Entity entity, WorldMap worldmap) {
|
|
- if (world.worldProvider.getDimensionManager().getDimensionID() == 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 +218,8 @@
|
|
WorldMap worldmap = getSavedMap(itemstack, world);
|
|
|
|
if (worldmap != null) {
|
|
- if (world.worldProvider.getDimensionManager().getDimensionID() == worldmap.map) {
|
|
+ // CraftBukkit - world.worldProvider -> ((WorldServer) world)
|
|
+ if (((WorldServer) world).dimension == worldmap.map) {
|
|
int i = 1 << worldmap.scale;
|
|
int j = worldmap.centerX;
|
|
int k = worldmap.centerZ;
|