3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/CraftingManager.patch

62 Zeilen
3.0 KiB
Diff

2015-02-26 23:41:06 +01:00
--- /home/matt/mc-dev-private//net/minecraft/server/CraftingManager.java 2015-02-26 22:40:22.431608141 +0000
+++ src/main/java/net/minecraft/server/CraftingManager.java 2015-02-26 22:40:22.435608141 +0000
@@ -9,16 +9,22 @@
import java.util.Iterator;
import java.util.List;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class CraftingManager {
private static final CraftingManager a = new CraftingManager();
2015-02-26 23:41:06 +01:00
- private final List<IRecipe> recipes = Lists.newArrayList();
+ public List<IRecipe> recipes = Lists.newArrayList(); // CraftBukkit - public, removed final
+ // CraftBukkit start
+ public IRecipe lastRecipe;
+ public org.bukkit.inventory.InventoryView lastCraftView;
+ // CraftBukkit end
public static CraftingManager getInstance() {
return CraftingManager.a;
2015-02-26 23:41:06 +01:00
}
- private CraftingManager() {
+ public CraftingManager() { // CraftBukkit - public
(new RecipesTools()).a(this);
(new RecipesWeapons()).a(this);
(new RecipeIngots()).a(this);
@@ -167,7 +173,12 @@
this.registerShapedRecipe(new ItemStack(Blocks.DAYLIGHT_DETECTOR), new Object[] { "GGG", "QQQ", "WWW", Character.valueOf('G'), Blocks.GLASS, Character.valueOf('Q'), Items.QUARTZ, Character.valueOf('W'), Blocks.WOODEN_SLAB});
this.registerShapedRecipe(new ItemStack(Blocks.HOPPER), new Object[] { "I I", "ICI", " I ", Character.valueOf('I'), Items.IRON_INGOT, Character.valueOf('C'), Blocks.CHEST});
2015-02-26 23:41:06 +01:00
this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, BlockDoubleStepAbstract.EnumStoneSlabVariant.STONE.a())});
- Collections.sort(this.recipes, new Comparator() {
+ sort();
+ }
2015-02-26 23:41:06 +01:00
+
+ // CraftBukkit start
+ public void sort() {
2015-02-26 23:41:06 +01:00
+ Collections.sort(this.recipes, new Comparator() {
public int a(IRecipe irecipe, IRecipe irecipe1) {
return irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes ? 1 : (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes ? -1 : (irecipe1.a() < irecipe.a() ? -1 : (irecipe1.a() > irecipe.a() ? 1 : 0)));
}
@@ -274,13 +285,18 @@
do {
if (!iterator.hasNext()) {
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
return null;
}
irecipe = (IRecipe) iterator.next();
2015-02-26 23:41:06 +01:00
} while (!irecipe.a(inventorycrafting, world));
- return irecipe.a(inventorycrafting);
+ // CraftBukkit start - INVENTORY_PRE_CRAFT event
+ inventorycrafting.currentRecipe = irecipe;
+ ItemStack result = irecipe.a(inventorycrafting);
+ return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false);
+ // CraftBukkit end
}
public ItemStack[] b(InventoryCrafting inventorycrafting, World world) {