mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@5e73c55 [ci skip] Add more identifying patch comments PaperMC/Paper@3e20d3a [ci skip] Add more identifying patch comments PaperMC/Paper@f61ebdc Fix issue with kick event causes being passed improperly PaperMC/Paper@106c67a [ci skip] Add more identifying patch comments PaperMC/Paper@cc693ce [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@eeb6afc [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@1c956ab [ci skip] Add more identifying patch comments, merge related patches PaperMC/Paper@42e88a8 [ci skip] Add more identifying patch comments PaperMC/Paper@8e41ef4 Add visual blockdata api for primed tnt (#10146) PaperMC/Paper@68c3297 [ci skip] Add more identifying patch comments PaperMC/Paper@4a98986 Add back Reduce allocation of Vec3D by entity tracker patch (#10179) PaperMC/Paper@b48d737 Async world data IO saving (#10171) PaperMC/Paper@8d94596 [ci skip] Add more identifying patch comments PaperMC/Paper@f7dd304 [ci skip] Add more identifying patch comments PaperMC/Paper@98e6d20 [ci skip] Add more identifying patch comments PaperMC/Paper@e9e0bc1 [ci skip] Add more identifying patch comments PaperMC/Paper@d9df6bc [ci skip] Add more patch identifying comments, cleanup PaperMC/Paper@27cabc1 [ci skip] Add more patch identifying comments Pufferfish Changes: pufferfish-gg/Pufferfish@8e208d3 Fix Async World Saving attribution
81 lines
4.6 KiB
Diff
81 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MelnCat <melncatuwu@gmail.com>
|
|
Date: Sat, 24 Sep 2022 09:56:28 -0700
|
|
Subject: [PATCH] Add item packet serialize event
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
index b863249ff7e13cf4939c8961601f0564c62fd661..bdcfd80f937c34956911373905d66424bbff8e1d 100644
|
|
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
@@ -95,6 +95,8 @@ public class FriendlyByteBuf extends ByteBuf {
|
|
private static final int MAX_PUBLIC_KEY_LENGTH = 512;
|
|
private static final Gson GSON = new Gson();
|
|
|
|
+ public static boolean hasItemSerializeEvent = false; // Purpur
|
|
+
|
|
public FriendlyByteBuf(ByteBuf parent) {
|
|
this.source = parent;
|
|
}
|
|
@@ -640,6 +642,17 @@ public class FriendlyByteBuf extends ByteBuf {
|
|
this.writeBoolean(false);
|
|
} else {
|
|
this.writeBoolean(true);
|
|
+ // Purpur start
|
|
+ if (hasItemSerializeEvent) {
|
|
+ var event = new org.purpurmc.purpur.event.packet.NetworkItemSerializeEvent(stack.asBukkitCopy());
|
|
+ event.callEvent();
|
|
+ ItemStack newStack = ItemStack.fromBukkitCopy(event.getItemStack());
|
|
+ if (org.purpurmc.purpur.PurpurConfig.fixNetworkSerializedItemsInCreative && !ItemStack.matches(stack, newStack)) {
|
|
+ stack.save(newStack.getOrCreateTagElement("Purpur.OriginalItem"));
|
|
+ }
|
|
+ stack = newStack;
|
|
+ }
|
|
+ // Purpur end
|
|
Item item = stack.getItem();
|
|
|
|
this.writeId(BuiltInRegistries.ITEM, item);
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index c6403274658ccaa2ed27e586cc35d13c760f2040..16b5f59dd3658bb9fc5be629aa4e1bc0ce356243 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1719,6 +1719,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
//MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper // Purpur
|
|
|
|
this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked
|
|
+ net.minecraft.network.FriendlyByteBuf.hasItemSerializeEvent = org.purpurmc.purpur.event.packet.NetworkItemSerializeEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
|
|
Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down
|
|
while (iterator.hasNext()) {
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index dc2c43794841af062b325a90fd5f68f581b99317..d7ff08767fe6b14f18386651666c42903a52ec1c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3377,6 +3377,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
}
|
|
}
|
|
+ // Purpur start
|
|
+ if (org.purpurmc.purpur.PurpurConfig.fixNetworkSerializedItemsInCreative) {
|
|
+ var tag = itemstack.getTagElement("Purpur.OriginalItem");
|
|
+ if (tag != null) itemstack = ItemStack.of(tag);
|
|
+ }
|
|
+ // Purpur end
|
|
|
|
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;
|
|
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
index 128eab7246bf263e302cbeb5e4c359a41dd2cd3f..be7b302257447d5593efe9b512d036b293f340b5 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
@@ -563,4 +563,9 @@ public class PurpurConfig {
|
|
}
|
|
});
|
|
}
|
|
+
|
|
+ public static boolean fixNetworkSerializedItemsInCreative = false;
|
|
+ private static void fixNetworkSerializedCreativeItems() {
|
|
+ fixNetworkSerializedItemsInCreative = getBoolean("settings.fix-network-serialized-items-in-creative", fixNetworkSerializedItemsInCreative);
|
|
+ }
|
|
}
|