Update upstream, Map Events patch, gitignore stuff
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -19,3 +19,6 @@ gradle-app.setting
|
|||||||
# gradle/wrapper/gradle-wrapper.properties
|
# gradle/wrapper/gradle-wrapper.properties
|
||||||
/commit.sh
|
/commit.sh
|
||||||
/publish.sh
|
/publish.sh
|
||||||
|
/slice-api/
|
||||||
|
/slice-server/
|
||||||
|
/generated/
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
group=com.lokamc.slice
|
group=com.lokamc.slice
|
||||||
version=1.21.3-R0.1-SNAPSHOT
|
version=1.21.3-R0.1-SNAPSHOT
|
||||||
mcVersion=1.21.3
|
mcVersion=1.21.3
|
||||||
paperRef=ae80a251fc75abee4082981ac1ee59ccb2c9d96b
|
paperRef=c2294d7067959d264eb8ad275557f194a3e2656f
|
||||||
updatingMinecraft=false
|
updatingMinecraft=false
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
|
|||||||
114
patches/api/0017-Map-Events.patch
Normal file
114
patches/api/0017-Map-Events.patch
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cryptite <cryptite@gmail.com>
|
||||||
|
Date: Mon, 2 Dec 2024 11:52:34 -0600
|
||||||
|
Subject: [PATCH] Map Events
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/event/server/MapGetFreeIndexEvent.java b/src/main/java/io/papermc/paper/event/server/MapGetFreeIndexEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..25999adb10ed0f3514332d64f27ea118bfccbfb4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/event/server/MapGetFreeIndexEvent.java
|
||||||
|
@@ -0,0 +1,41 @@
|
||||||
|
+package io.papermc.paper.event.server;
|
||||||
|
+
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import org.bukkit.event.server.ServerEvent;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when we try to fetch a new index for a newly-created map.
|
||||||
|
+ */
|
||||||
|
+@NullMarked
|
||||||
|
+public class MapGetFreeIndexEvent extends ServerEvent {
|
||||||
|
+ public static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
+
|
||||||
|
+ private int index = -1;
|
||||||
|
+ @ApiStatus.Internal
|
||||||
|
+ public MapGetFreeIndexEvent() {
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getIndex() {
|
||||||
|
+ return index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setIndex(int index) {
|
||||||
|
+ this.index = index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public enum Cause {
|
||||||
|
+ COMMAND,
|
||||||
|
+ PLUGIN,
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/event/server/MapLoadEvent.java b/src/main/java/io/papermc/paper/event/server/MapLoadEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..0dfab37f18b797003b932a8a8b16943c1dd7677c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/event/server/MapLoadEvent.java
|
||||||
|
@@ -0,0 +1,55 @@
|
||||||
|
+package io.papermc.paper.event.server;
|
||||||
|
+
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import org.bukkit.event.server.ServerEvent;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jspecify.annotations.NullMarked;
|
||||||
|
+import org.jspecify.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+import java.io.ByteArrayInputStream;
|
||||||
|
+import java.io.ByteArrayOutputStream;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when we want to load a Map from disk
|
||||||
|
+ */
|
||||||
|
+@NullMarked
|
||||||
|
+public class MapLoadEvent extends ServerEvent {
|
||||||
|
+ public static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
+
|
||||||
|
+ private int id;
|
||||||
|
+ private ByteArrayInputStream buf;
|
||||||
|
+ @ApiStatus.Internal
|
||||||
|
+ public MapLoadEvent(int id) {
|
||||||
|
+ this.id = id;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getIndex() {
|
||||||
|
+ return id;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setIndex(int index) {
|
||||||
|
+ this.id = index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public @Nullable ByteArrayInputStream getBuf() {
|
||||||
|
+ return buf;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void setBuf(ByteArrayInputStream buf) {
|
||||||
|
+ this.buf = buf;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public enum Cause {
|
||||||
|
+ COMMAND,
|
||||||
|
+ PLUGIN,
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
52
patches/server/0026-Map-Events.patch
Normal file
52
patches/server/0026-Map-Events.patch
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Cryptite <cryptite@gmail.com>
|
||||||
|
Date: Mon, 2 Dec 2024 11:52:34 -0600
|
||||||
|
Subject: [PATCH] Map Events
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
index e256e5ff5c167c6cff5b9e985cdc80d5c9203708..5f0439860468283dcdcce17fefc22c5e088b8dc4 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -2119,6 +2119,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MapId getFreeMapId() {
|
||||||
|
+ // Slice start
|
||||||
|
+ io.papermc.paper.event.server.MapGetFreeIndexEvent event = new io.papermc.paper.event.server.MapGetFreeIndexEvent();
|
||||||
|
+ event.callEvent();
|
||||||
|
+ int newIndex = event.getIndex();
|
||||||
|
+ if (newIndex != -1) {
|
||||||
|
+ return new MapId(newIndex);
|
||||||
|
+ }
|
||||||
|
+ // Slice end
|
||||||
|
return ((MapIndex) this.getServer().overworld().getDataStorage().computeIfAbsent(MapIndex.factory(), "idcounts")).getFreeAuxValueForMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||||
|
index 4f256e61f858020f32e7a66664375ba05a57826b..04f989bb34bda3f71501156d727074fad0df3e7e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java
|
||||||
|
@@ -70,6 +70,22 @@ public class DimensionDataStorage implements AutoCloseable {
|
||||||
|
@Nullable
|
||||||
|
private <T extends SavedData> T readSavedData(BiFunction<CompoundTag, HolderLookup.Provider, T> readFunction, DataFixTypes dataFixTypes, String id) {
|
||||||
|
try {
|
||||||
|
+ // Slice start
|
||||||
|
+ if (id.startsWith("map_")) {
|
||||||
|
+ int mapId = Integer.parseInt(id.split("map_")[1]);
|
||||||
|
+ io.papermc.paper.event.server.MapLoadEvent event = new io.papermc.paper.event.server.MapLoadEvent(mapId);
|
||||||
|
+ event.callEvent();
|
||||||
|
+ ByteArrayInputStream buf = event.getBuf();
|
||||||
|
+ if (buf != null) {
|
||||||
|
+ try {
|
||||||
|
+ return readFunction.apply(NbtIo.readCompressed(buf, NbtAccounter.unlimitedHeap()), this.registries);
|
||||||
|
+ } catch (IOException e) {
|
||||||
|
+ LOGGER.error("Error loading saved data: {}", id, e);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Slice end
|
||||||
|
+
|
||||||
|
Path path = this.getDataFile(id);
|
||||||
|
if (Files.exists(path)) {
|
||||||
|
CompoundTag compoundTag = this.readTagFromDisk(id, dataFixTypes, SharedConstants.getCurrentVersion().getDataVersion().getVersion());
|
||||||
Reference in New Issue
Block a user