2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/CraftingManager.java
|
|
|
|
+++ b/net/minecraft/server/CraftingManager.java
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -9,10 +9,16 @@
|
|
|
|
import java.util.Iterator;
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
|
|
|
+
|
|
|
|
public class CraftingManager {
|
|
|
|
|
|
|
|
private static final CraftingManager a = new CraftingManager();
|
2015-06-06 11:33:48 +02:00
|
|
|
public List<IRecipe> recipes = Lists.newArrayList();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public IRecipe lastRecipe;
|
|
|
|
+ public org.bukkit.inventory.InventoryView lastCraftView;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
public static CraftingManager getInstance() {
|
|
|
|
return CraftingManager.a;
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -179,7 +185,12 @@
|
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())});
|
2016-02-29 22:32:46 +01:00
|
|
|
this.registerShapedRecipe(new ItemStack(Blocks.END_ROD, 4), new Object[] { "/", "#", Character.valueOf('/'), Items.BLAZE_ROD, Character.valueOf('#'), Items.CHORUS_FRUIT_POPPED});
|
2016-06-09 03:43:49 +02:00
|
|
|
this.registerShapedRecipe(new ItemStack(Blocks.di, 1), new Object[] { "XXX", "XXX", "XXX", Character.valueOf('X'), new ItemStack(Items.DYE, 1, EnumColor.WHITE.getInvColorIndex())});
|
2015-02-26 23:41:06 +01:00
|
|
|
- Collections.sort(this.recipes, new Comparator() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ sort();
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +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)));
|
|
|
|
}
|
2016-06-09 03:43:49 +02:00
|
|
|
@@ -290,13 +301,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (!iterator.hasNext()) {
|
|
|
|
+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
|
2016-11-17 02:41:03 +01:00
|
|
|
return ItemStack.a;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
irecipe = (IRecipe) iterator.next();
|
2015-02-26 23:41:06 +01:00
|
|
|
} while (!irecipe.a(inventorycrafting, world));
|
|
|
|
|
2015-07-30 08:56:52 +02:00
|
|
|
- return irecipe.craftItem(inventorycrafting);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - INVENTORY_PRE_CRAFT event
|
|
|
|
+ inventorycrafting.currentRecipe = irecipe;
|
2015-07-30 08:56:52 +02:00
|
|
|
+ ItemStack result = irecipe.craftItem(inventorycrafting);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public NonNullList<ItemStack> b(InventoryCrafting inventorycrafting, World world) {
|