3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0844-API-for-updating-recipes-on-clients.patch
Jake Potrebic c6aa61ee18
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11561)
Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b9df8e9f SPIGOT-7933: Improve custom Minecart max speed
fc496179 Fix InstrumentTest
7c0ec598 PR-1075: Make Art an interface
c389f5a4 PR-1074: Make Sound an interface

CraftBukkit Changes:
df1efc0bb SPIGOT-7945: `Bukkit#dispatchCommand` throws `UnsupportedOperationException`
285df6e85 SPIGOT-7933: Improve custom Minecart max speed
a0f3d4e50 SPIGOT-7940: Recipe book errors after reload
9e0618ec2 SPIGOT-7937: Cannot spawn minecart during world generation with minecart_improvements enabled
1eb4d28da SPIGOT-7941: Fix resistance over 4 amplify causing issues in damage
52b99158a PR-1504: Make Art an interface
e18ae35f1 PR-1502: Make Sound an interface

Spigot Changes:
e65d67a7 SPIGOT-7934: Item entities start "bouncing" under certain conditions
2024-11-04 18:42:38 +01:00

114 Zeilen
4.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 21 Aug 2021 17:25:38 -0700
Subject: [PATCH] API for updating recipes on clients
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 3a6e918e9db6397b6f1cff531041655298ce087d..efc12d629b71ba1da664d9ecfd4575bee9b45dc3 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1448,6 +1448,13 @@ public abstract class PlayerList {
}
public void reloadResources() {
+ // Paper start - API for updating recipes on clients
+ this.reloadAdvancementData();
+ this.reloadTagData();
+ this.reloadRecipes();
+ }
+ public void reloadAdvancementData() {
+ // Paper end - API for updating recipes on clients
// CraftBukkit start
/*Iterator iterator = this.advancements.values().iterator();
@@ -1463,9 +1470,13 @@ public abstract class PlayerList {
}
// CraftBukkit end
+ // Paper start - API for updating recipes on clients
+ }
+ public void reloadTagData() {
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
// CraftBukkit start
- this.reloadRecipes();
+ // this.reloadRecipes(); // Paper - do not reload recipes just because tag data was reloaded
+ // Paper end - API for updating recipes on clients
}
public void reloadRecipes() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 87bc228c121077815bdad7942df1c9576edac21b..a618258fde1226588ea447522ba4177aa9cf9016 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1178,6 +1178,18 @@ public final class CraftServer implements Server {
ReloadCommand.reload(this.console);
}
+ // Paper start - API for updating recipes on clients
+ @Override
+ public void updateResources() {
+ this.playerList.reloadResources();
+ }
+
+ @Override
+ public void updateRecipes() {
+ this.playerList.reloadRecipes();
+ }
+ // Paper end - API for updating recipes on clients
+
private void loadIcon() {
this.icon = new CraftIconCache(null);
try {
@@ -1557,6 +1569,13 @@ public final class CraftServer implements Server {
@Override
public boolean addRecipe(Recipe recipe) {
+ // Paper start - API for updating recipes on clients
+ return this.addRecipe(recipe, false);
+ }
+
+ @Override
+ public boolean addRecipe(Recipe recipe, boolean resendRecipes) {
+ // Paper end - API for updating recipes on clients
CraftRecipe toAdd;
if (recipe instanceof CraftRecipe) {
toAdd = (CraftRecipe) recipe;
@@ -1588,6 +1607,11 @@ public final class CraftServer implements Server {
}
}
toAdd.addToCraftingManager();
+ // Paper start - API for updating recipes on clients
+ if (true || resendRecipes) { // Always needs to be resent now... TODO
+ this.playerList.reloadRecipes();
+ }
+ // Paper end - API for updating recipes on clients
return true;
}
@@ -1768,9 +1792,23 @@ public final class CraftServer implements Server {
@Override
public boolean removeRecipe(NamespacedKey recipeKey) {
+ // Paper start - API for updating recipes on clients
+ return this.removeRecipe(recipeKey, false);
+ }
+
+ @Override
+ public boolean removeRecipe(NamespacedKey recipeKey, boolean resendRecipes) {
+ // Paper end - API for updating recipes on clients
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
- return this.getServer().getRecipeManager().removeRecipe(CraftRecipe.toMinecraft(recipeKey));
+ // Paper start - resend recipes on successful removal
+ final ResourceKey<net.minecraft.world.item.crafting.Recipe<?>> minecraftKey = CraftRecipe.toMinecraft(recipeKey);
+ final boolean removed = this.getServer().getRecipeManager().removeRecipe(minecraftKey);
+ if (removed/* && resendRecipes*/) { // TODO Always need to resend them rn - deprecate this method?
+ this.playerList.reloadRecipes();
+ }
+ return removed;
+ // Paper end - resend recipes on successful removal
}
@Override