[ci skip] Cleanup events (#10202)
This commit is contained in:
@@ -30,20 +30,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ if (this.isValidRecipeIndex(id)) {
|
||||
+ io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((Player) player.getBukkitEntity(), (org.bukkit.inventory.StonecutterInventory) getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) this.getRecipes().get(id).toBukkitRecipe());
|
||||
+ if (!event.callEvent()) {
|
||||
+ ((Player) player.getBukkitEntity()).updateInventory();
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ return false;
|
||||
+ }
|
||||
+ int newRecipeIndex;
|
||||
+ if (!this.getRecipes().get(recipeIndex).id().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { // If the recipe did NOT stay the same
|
||||
+ for (newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) {
|
||||
+ if (this.getRecipes().get(newRecipeIndex).id().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) {
|
||||
+
|
||||
+ net.minecraft.resources.ResourceLocation key = org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey());
|
||||
+ if (!this.getRecipes().get(recipeIndex).id().equals(key)) { // If the recipe did NOT stay the same
|
||||
+ for (int newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) {
|
||||
+ if (this.getRecipes().get(newRecipeIndex).id().equals(key)) {
|
||||
+ recipeIndex = newRecipeIndex;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ ((Player) player.getBukkitEntity()).updateInventory();
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it
|
||||
+ // Paper end - Add PlayerStonecutterRecipeSelectEvent
|
||||
this.setupResultSlot();
|
||||
|
||||
Reference in New Issue
Block a user