You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+ createUUIDBackedDimensionKeyCodec().forGetter(MapItemSavedData::packUUIDBackedDimension), // Paper - store target world by uuid in addition to dimension
+ private final org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper - Use Vanilla map renderer when possible
16
17
public final List<MapItemSavedData.HoldingPlayer> carriedBy = Lists.newArrayList();
17
18
public final Map<Player, MapItemSavedData.HoldingPlayer> carriedByPlayers = Maps.newHashMap();
18
19
private final Map<String, MapBanner> bannerMarkers = Maps.newHashMap();
19
-
@@ -68,6 +69,13 @@ public class MapItemSavedData extends SavedData {
20
+
@@ -81,6 +_,13 @@
20
21
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
21
22
private int trackedDecorationCount;
22
23
@@ -27,120 +28,66 @@ index 3bfdc4df0db8944db6c671f53499cf07f3a3e7be..3c1c89aade5ff092b880ba1bf1de83f5
27
28
+ public MapId id;
28
29
+ // CraftBukkit end
29
30
+
30
-
public static SavedData.Factory<MapItemSavedData> factory() {
31
-
return new SavedData.Factory<>(() -> {
31
+
public static SavedDataType<MapItemSavedData> type(MapId mapId) {
32
+
return new SavedDataType<>(mapId.key(), () -> {
32
33
throw new IllegalStateException("Should never create an empty map saved data");
33
-
@@ -82,6 +90,11 @@ public class MapItemSavedData extends SavedData {
34
+
@@ -95,7 +_,29 @@
34
35
this.trackingPosition = trackingPosition;
35
36
this.unlimitedTracking = unlimitedTracking;
36
37
this.locked = locked;
38
+
- }
37
39
+ // CraftBukkit start
38
40
+ this.mapView = new org.bukkit.craftbukkit.map.CraftMapView(this);
@@ -521,7 +594,7 @@ public class MapItemSavedData extends SavedData {
107
+
this.setDirty();
108
+
@@ -497,7 +_,7 @@
162
109
this.player = player;
163
110
}
164
111
@@ -167,7 +114,7 @@ index 3bfdc4df0db8944db6c671f53499cf07f3a3e7be..3c1c89aade5ff092b880ba1bf1de83f5
167
114
int i = this.minDirtyX;
168
115
int i1 = this.minDirtyY;
169
116
int i2 = this.maxDirtyX + 1 - this.minDirtyX;
170
-
@@ -530,7 +603,7 @@ public class MapItemSavedData extends SavedData {
117
+
@@ -506,7 +_,7 @@
171
118
172
119
for (int i4 = 0; i4 < i2; i4++) {
173
120
for (int i5 = 0; i5 < i3; i5++) {
@@ -176,7 +123,7 @@ index 3bfdc4df0db8944db6c671f53499cf07f3a3e7be..3c1c89aade5ff092b880ba1bf1de83f5
176
123
}
177
124
}
178
125
179
-
@@ -540,17 +613,38 @@ public class MapItemSavedData extends SavedData {
126
+
@@ -516,17 +_,38 @@
180
127
@Nullable
181
128
Packet<?> nextUpdatePacket(MapId mapId) {
182
129
MapItemSavedData.MapPatch mapPatch;
@@ -218,7 +165,7 @@ index 3bfdc4df0db8944db6c671f53499cf07f3a3e7be..3c1c89aade5ff092b880ba1bf1de83f5
218
165
} else {
219
166
collection = null;
220
167
}
221
-
@@ -578,6 +672,23 @@ public class MapItemSavedData extends SavedData {
168
+
@@ -554,6 +_,23 @@
222
169
private void markDecorationsDirty() {
223
170
this.dirtyDecorations = true;
224
171
}
@@ -242,3 +189,75 @@ index 3bfdc4df0db8944db6c671f53499cf07f3a3e7be..3c1c89aade5ff092b880ba1bf1de83f5
242
189
}
243
190
244
191
record MapDecorationLocation(Holder<MapDecorationType> type, byte x, byte y, byte rot) {
192
+
@@ -598,4 +_,71 @@
193
+
}
194
+
}
195
+
}
196
+
+
197
+
+ // Paper start - store target world by uuid in addition to dimension
198
+
+ record UUIDAndError(java.util.UUID uuid, String faultyDimension) {
199
+
+
200
+
+ }
201
+
+ record UUIDBackedDimension(@Nullable ResourceKey<Level> resourceKey, @Nullable UUIDAndError uuid) {
202
+
+ public UUIDBackedDimension(final @org.jetbrains.annotations.NotNull ResourceKey<Level> resourceKey) {
203
+
+ this(resourceKey, null);
204
+
+ }
205
+
+ public UUIDBackedDimension {
206
+
+ com.google.common.base.Preconditions.checkArgument(resourceKey != null || uuid != null, "Created uuid backed dimension with null level and uuid. This is a bug");
207
+
+ }
208
+
+
209
+
+ public @org.jetbrains.annotations.NotNull ResourceKey<Level> resolveOrThrow() {
210
+
+ if (resourceKey != null) return resourceKey;
211
+
+
212
+
+ final org.bukkit.World worldByUUID = org.bukkit.Bukkit.getWorld(uuid.uuid());
213
+
+ if (worldByUUID != null) return ((org.bukkit.craftbukkit.CraftWorld) worldByUUID).getHandle().dimension();
214
+
+
215
+
+ throw new IllegalArgumentException("Invalid dimension " + uuid.faultyDimension() + " and unknown world uuid " + uuid.uuid);
+ public <T> com.mojang.serialization.DataResult<UUIDBackedDimension> decode(final com.mojang.serialization.DynamicOps<T> ops,
233
+
+ final com.mojang.serialization.MapLike<T> input) {
234
+
+ final com.mojang.serialization.DataResult<UUIDBackedDimension> foundDimension = Level.RESOURCE_KEY_CODEC.decode(ops, input.get("dimension"))
235
+
+ .map(Pair::getFirst)
236
+
+ .map(UUIDBackedDimension::new); // Do not pack uuid when reading as the level itself might reference an unloaded world. UUID lookup would be faulty + should be re-generated when written.
237
+
+ if (foundDimension.isSuccess()) return foundDimension;
238
+
+
239
+
+ // Fallback attempt at parsing the uuid
240
+
+ final com.mojang.serialization.DataResult<UUIDBackedDimension> fromUUID = Codec.LONG.decode(ops, input.get("UUIDMost")).map(Pair::getFirst).apply2(
0 commit comments