SPIGOT-7940: Recipe book errors after reload

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2024-11-02 17:55:34 +11:00
parent d580602ebb
commit 82bd6be3e1
2 changed files with 20 additions and 9 deletions

View file

@ -421,13 +421,13 @@
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
}
+ }
+
+ cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(event.getKickMessage());
+ return null;
+ }
}
+ return entity;
}
@ -766,7 +766,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -932,13 +1236,20 @@
@@ -932,15 +1236,28 @@
}
public void reloadResources() {
@ -787,4 +787,12 @@
+ // CraftBukkit end
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
+ // CraftBukkit start
+ reloadRecipes();
+ }
+
+ public void reloadRecipes() {
+ // CraftBukkit end
CraftingManager craftingmanager = this.server.getRecipeManager();
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes());
Iterator iterator1 = this.players.iterator();

View file

@ -1,17 +1,18 @@
--- a/net/minecraft/world/item/crafting/CraftingManager.java
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
@@ -38,6 +38,10 @@
@@ -38,6 +38,11 @@
import net.minecraft.world.level.World;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.util.Collections;
+import net.minecraft.server.MinecraftServer;
+// CraftBukkit end
+
public class CraftingManager extends ResourceDataAbstract<RecipeMap> implements RecipeAccess {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -109,7 +113,23 @@
@@ -109,7 +114,25 @@
CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size());
}
@ -26,6 +27,8 @@
+ public void finalizeRecipeLoading() {
+ if (featureflagset != null) {
+ finalizeRecipeLoading(featureflagset);
+
+ MinecraftServer.getServer().getPlayerList().reloadRecipes();
+ }
+ }
+
@ -35,7 +38,7 @@
List<SelectableRecipe.a<RecipeStonecutting>> list = new ArrayList();
List<CraftingManager.b> list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> {
return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue());
@@ -128,7 +148,7 @@
@@ -128,7 +151,7 @@
RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe;
if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) {
@ -44,7 +47,7 @@
}
}
@@ -170,7 +190,10 @@
@@ -170,7 +193,10 @@
}
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world) {
@ -56,7 +59,7 @@
}
public Optional<RecipeHolder<?>> byKey(ResourceKey<IRecipe<?>> resourcekey) {
@@ -181,7 +204,7 @@
@@ -181,7 +207,7 @@
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, ResourceKey<IRecipe<?>> resourcekey) {
RecipeHolder<?> recipeholder = this.recipes.byKey(resourcekey);
@ -65,7 +68,7 @@
}
public Map<ResourceKey<RecipePropertySet>, RecipePropertySet> getSynchronizedItemProperties() {
@@ -229,6 +252,22 @@
@@ -229,6 +255,22 @@
return new RecipeHolder<>(resourcekey, irecipe);
}