Skip to content

Commit

Permalink
change patches instead of creating new
Browse files Browse the repository at this point in the history
  • Loading branch information
ham1255 committed Aug 29, 2022
1 parent 780bbe7 commit 29973df
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 129 deletions.
40 changes: 24 additions & 16 deletions patches/server/0057-Add-chunk-syncing.patch
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ index 83736cca003bf96271153700a89fcee3c43a63ff..c145a3e278ded8e32b1541f4f042102d
+ }
}
diff --git a/src/main/java/puregero/multipaper/MultiPaper.java b/src/main/java/puregero/multipaper/MultiPaper.java
index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..23cb905d1e680aa3f064df88fe46194b2b6fd013 100644
index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..482bdf1e056490aff298ad1766b3ef4690f23a64 100644
--- a/src/main/java/puregero/multipaper/MultiPaper.java
+++ b/src/main/java/puregero/multipaper/MultiPaper.java
@@ -1,29 +1,60 @@
Expand Down Expand Up @@ -1071,7 +1071,7 @@ index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..23cb905d1e680aa3f064df88fe46194b
}

public static void sendTickTime(long time, double tps) {
@@ -157,4 +207,232 @@ public class MultiPaper {
@@ -157,4 +207,234 @@ public class MultiPaper {
public static boolean isExternalPlayer(org.bukkit.entity.Entity bukkitEntity) {
return isExternalPlayer(((CraftEntity) bukkitEntity).getHandle());
}
Expand Down Expand Up @@ -1249,9 +1249,9 @@ index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..23cb905d1e680aa3f064df88fe46194b
+ }
+
+ public static ChunkAccess getChunkAccess(String world, int cx, int cz) {
+ ServerLevel level = ((CraftWorld) Bukkit.getWorld(world)).getHandle();
+ ChunkAccess chunkAccess = level.getChunkIfLoaded(cx, cz);
+ CraftWorld bukkitWorld = ((CraftWorld) Bukkit.getWorld(world));
+
+ ChunkAccess chunkAccess = bukkitWorld != null ? bukkitWorld.getHandle().getChunkIfLoaded(cx, cz) : null;
+ if (chunkAccess == null) {
+ ChunkHolder holder = getChunkHolder(world, cx, cz);
+ if (holder != null) {
Expand Down Expand Up @@ -1279,11 +1279,13 @@ index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..23cb905d1e680aa3f064df88fe46194b
+ }
+
+ public static ChunkHolder getChunkHolder(String world, int x, int z) {
+ return getChunkHolder(((CraftWorld) Bukkit.getWorld(world)).getHandle(), x, z);
+ CraftWorld craftWorld = ((CraftWorld) Bukkit.getWorld(world));
+ return craftWorld != null ? getChunkHolder(craftWorld.getHandle(), x, z) : null;
+ }
+
+ public static ChunkHolder getChunkHolder(UUID world, int x, int z) {
+ return getChunkHolder(((CraftWorld) Bukkit.getWorld(world)).getHandle(), x, z);
+ CraftWorld craftWorld = ((CraftWorld) Bukkit.getWorld(world));
+ return craftWorld != null ? getChunkHolder(craftWorld.getHandle(), x, z) : null;
+ }
+
+ public static ChunkHolder getChunkHolder(ServerLevel level, int x, int z) {
Expand All @@ -1306,10 +1308,10 @@ index 136a7bb726afef1ee199b066eec8ebecf7ef13b1..23cb905d1e680aa3f064df88fe46194b
}
diff --git a/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java b/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..382257ce8b3f2b5361ce8a8e05e514ad5561c0b1
index 0000000000000000000000000000000000000000..b8e417385cdd141a25de7c91ff70d0cc7f8f5fba
--- /dev/null
+++ b/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java
@@ -0,0 +1,258 @@
@@ -0,0 +1,261 @@
+package puregero.multipaper;
+
+import ca.spottedleaf.starlight.common.light.SWMRNibbleArray;
Expand Down Expand Up @@ -1391,7 +1393,7 @@ index 0000000000000000000000000000000000000000..382257ce8b3f2b5361ce8a8e05e514ad
+ // Wait a bit as the block entity may get changed multiple times in 1 tick
+ MultiPaper.runSync(() -> {
+ for (BlockEntity blockEntity : blockEntitiesToBroadcast) {
+ if (blockEntity != null) {
+ if (blockEntity != null && blockEntity.getLevel() != null) {
+ MultiPaperChunkHandler.onBlockUpdate(MultiPaper.getChunkHolder(blockEntity.getLevel().getWorld().getName(), blockEntity.getBlockPos()), ClientboundBlockEntityDataPacket.create(blockEntity, BlockEntity::saveWithFullMetadata));
+ }
+ }
Expand Down Expand Up @@ -1429,8 +1431,11 @@ index 0000000000000000000000000000000000000000..382257ce8b3f2b5361ce8a8e05e514ad
+ holder = null;
+ blockUpdateChunk = null;
+ ChunkAccess tempChunk = null;
+ ServerLevel level = ((CraftWorld) Bukkit.getWorld(world)).getHandle();
+ if (packet instanceof ClientboundBlockUpdatePacket update) {
+ CraftWorld bukkitWorld = ((CraftWorld) Bukkit.getWorld(world));
+ ServerLevel level = bukkitWorld != null ? bukkitWorld.getHandle() : null;
+ if (level == null) {
+ return;
+ } else if (packet instanceof ClientboundBlockUpdatePacket update) {
+ holder = MultiPaper.getChunkHolder(world, update.getPos());
+ } else if (packet instanceof ClientboundSectionBlocksUpdatePacket update) {
+ update.runUpdates((pos, state) -> {
Expand Down Expand Up @@ -2021,10 +2026,10 @@ index 0000000000000000000000000000000000000000..0bf0efa705158b1df1b073cf23669fb0
+}
diff --git a/src/main/java/puregero/multipaper/externalserverprotocol/SendChunkPacket.java b/src/main/java/puregero/multipaper/externalserverprotocol/SendChunkPacket.java
new file mode 100644
index 0000000000000000000000000000000000000000..7156c215aea68a45f97c2d0d1c7e2354c4639fc3
index 0000000000000000000000000000000000000000..ede543cb62ff52a2650856e8ef552df6cec710bc
--- /dev/null
+++ b/src/main/java/puregero/multipaper/externalserverprotocol/SendChunkPacket.java
@@ -0,0 +1,103 @@
@@ -0,0 +1,106 @@
+package puregero.multipaper.externalserverprotocol;
+
+import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -2106,9 +2111,12 @@ index 0000000000000000000000000000000000000000..7156c215aea68a45f97c2d0d1c7e2354
+ }
+
+ CompoundTag tag = MultiPaper.nbtFromBytes(data);
+ ServerLevel level = ((CraftWorld) Bukkit.getWorld(world)).getHandle();
+ ChunkHolder holder = MultiPaper.getChunkHolder(world, cx, cz);
+ if (holder == null) {
+ CraftWorld craftWorld = ((CraftWorld) Bukkit.getWorld(world));
+ ServerLevel level = craftWorld != null ? craftWorld.getHandle() : null;
+ ChunkHolder holder = level != null ? MultiPaper.getChunkHolder(world, cx, cz) : null;
+ if (level == null) {
+ LOGGER.warn("Received chunk data " + world + "," + cx + "," + cz + " but we don't have world loaded.");
+ } else if (holder == null) {
+ LOGGER.warn("Received chunk data " + world + "," + cx + "," + cz + " but no chunk is loaded here");
+ } else if (holder.getAvailableChunkNow() instanceof LevelChunk) {
+// LOGGER.warn("Received chunk data " + world + "," + cx + "," + cz + " but it is a level chunk (" + holder.getChunkHolderStatus() + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ index 88c74eb1e24c3874baa5c49b0f66295b5830ba9f..247426f85c876d8d487e5a4c199d6bf7
this.removeBlockEntity(blockposition);
}
diff --git a/src/main/java/puregero/multipaper/MultiPaper.java b/src/main/java/puregero/multipaper/MultiPaper.java
index 39e192b169732eaed6d0f9a4f51d8a90bfc5586d..6f6d38ddd93a93d5ce883460c9bea719ad2626f9 100644
index 80d5f643aee93e6a32506e48f945e2ed93c01ed2..9f1fb218803f14dafd0c7b961667b3849c55e809 100644
--- a/src/main/java/puregero/multipaper/MultiPaper.java
+++ b/src/main/java/puregero/multipaper/MultiPaper.java
@@ -151,6 +151,8 @@ public class MultiPaper {
Expand Down Expand Up @@ -257,7 +257,7 @@ index 0000000000000000000000000000000000000000..73d9c7d88cbf170d3b8d224b8bac5c92
+
+}
diff --git a/src/main/java/puregero/multipaper/externalserverprotocol/SendTickListPacket.java b/src/main/java/puregero/multipaper/externalserverprotocol/SendTickListPacket.java
index 95a3823f5d13c29628adfc73a185d43cac573e15..5fc9bca35b0f385bd629606cde5872225117bba5 100644
index 95a3823f5d13c29628adfc73a185d43cac573e15..5024e2996aece59f812ece288d4d8a2480f64e3d 100644
--- a/src/main/java/puregero/multipaper/externalserverprotocol/SendTickListPacket.java
+++ b/src/main/java/puregero/multipaper/externalserverprotocol/SendTickListPacket.java
@@ -6,9 +6,11 @@ import net.minecraft.nbt.Tag;
Expand All @@ -272,12 +272,16 @@ index 95a3823f5d13c29628adfc73a185d43cac573e15..5fc9bca35b0f385bd629606cde587222
import net.minecraft.world.ticks.LevelChunkTicks;
import net.minecraft.world.ticks.ProtoChunkTicks;
import org.apache.logging.log4j.LogManager;
@@ -72,7 +74,23 @@ public class SendTickListPacket extends ExternalServerPacket {
@@ -70,9 +72,26 @@ public class SendTickListPacket extends ExternalServerPacket {
@Override
public void handle(ExternalServerConnection connection) {
MultiPaper.runSync(() -> {
ServerLevel level = ((CraftWorld) Bukkit.getWorld(world)).getHandle();
- ServerLevel level = ((CraftWorld) Bukkit.getWorld(world)).getHandle();
+ CraftWorld bukkitWorld = ((CraftWorld) Bukkit.getWorld(world));
+ ServerLevel level = bukkitWorld != null ? bukkitWorld.getHandle() : null;
ChunkAccess chunk = MultiPaper.getChunkAccess(world, cx, cz);
- if (chunk instanceof LevelChunk levelChunk) {
+ if (level.getChunkIfLoaded(cx, cz) != null) {
+ if (level != null && level.getChunkIfLoaded(cx, cz) != null) {
+ long now = level.getLevelData().getGameTime();
+
+ LevelChunkTicks<Block> blockTicks = LevelChunkTicks.load(tag.getList("block_ticks", Tag.TAG_COMPOUND), s -> Registry.BLOCK.getOptional(ResourceLocation.tryParse(s)), chunk.getPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Send server port to the master server


diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 44943119193ff66ee26124e08a8a73f82dff459e..ad84c33104520d1d3242d6657447bb519a0a2977 100644
index 1f77ea047bb67e3d2f8d81f0d3df1382aa01d972..9499bfed901d6a6877a62cae3ae5ce43d7127105 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -263,6 +263,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
Expand All @@ -17,10 +17,10 @@ index 44943119193ff66ee26124e08a8a73f82dff459e..ad84c33104520d1d3242d6657447bb51
// Paper end

diff --git a/src/main/java/puregero/multipaper/MultiPaper.java b/src/main/java/puregero/multipaper/MultiPaper.java
index 420092b3eb62688c269a814e564b8f8fe07153ca..84c7d0cf0ca67bb6a6a9adec83cc59f13d594539 100644
index df142a1b200fa4ddeedf6fd7b74e94f0bf56f861..0d39f6047dc353f8f567317750c19f8ef5e6b866 100644
--- a/src/main/java/puregero/multipaper/MultiPaper.java
+++ b/src/main/java/puregero/multipaper/MultiPaper.java
@@ -590,4 +590,8 @@ public class MultiPaper {
@@ -592,4 +592,8 @@ public class MultiPaper {
public static void chunkChangedStatus(ServerLevel level, ChunkPos pos, ChunkStatus status) {
getConnection().send(new ChunkChangedStatusMessage(level.getWorld().getName(), pos.x, pos.z, Registry.CHUNK_STATUS.getKey(status).toString()));
}
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0178-Sync-game-events.patch
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ index e45f54534bbf054eaf0008546ff459d4c11ddd50..f2af1a52a4a36846f9db623ba8ad47c9

public static record ReceivingEvent(GameEvent gameEvent, float distance, Vec3 pos, @Nullable UUID uuid, @Nullable UUID projectileOwnerUuid, @Nullable Entity entity) {
diff --git a/src/main/java/puregero/multipaper/MultiPaper.java b/src/main/java/puregero/multipaper/MultiPaper.java
index a517ca77b3f8dc915c2ad1e1074037a9a67a2738..0428f7d8702c8f1e837a9a95d31dc501374880bf 100644
index e3e17b1953067ccc66d7f9cc50d6cf41781ec405..df163434fc5245d893d23ac375bc5f27d1315d4f 100644
--- a/src/main/java/puregero/multipaper/MultiPaper.java
+++ b/src/main/java/puregero/multipaper/MultiPaper.java
@@ -102,6 +102,8 @@ public class MultiPaper {
Expand All @@ -184,10 +184,10 @@ index a517ca77b3f8dc915c2ad1e1074037a9a67a2738..0428f7d8702c8f1e837a9a95d31dc501

player.syncExperience();
diff --git a/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java b/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java
index 382257ce8b3f2b5361ce8a8e05e514ad5561c0b1..5b4e31e9576d0549e9dacdeef7a53d012b00c86c 100644
index b8e417385cdd141a25de7c91ff70d0cc7f8f5fba..53b29b38c607c89d20b289a628503b337f768696 100644
--- a/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java
+++ b/src/main/java/puregero/multipaper/MultiPaperChunkHandler.java
@@ -167,7 +167,9 @@ public class MultiPaperChunkHandler {
@@ -170,7 +170,9 @@ public class MultiPaperChunkHandler {
} else if (packet instanceof ClientboundBlockEntityDataPacket update) {
BlockEntity existingBlockEntity = blockUpdateChunk.getBlockEntity(update.getPos());
if (existingBlockEntity != null && existingBlockEntity.minecraftKey.toString().equals(update.getTag().getString("id"))) {
Expand Down
102 changes: 0 additions & 102 deletions patches/server/0181-check-whatever-Bukkit-getWorld-is-null.patch

This file was deleted.

0 comments on commit 29973df

Please sign in to comment.