3
0

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

View File

@ -0,0 +1,104 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/CraftingManager.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/CraftingManager.java
@@ -13,10 +13,17 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class CraftingManager
{
private static final CraftingManager instance = new CraftingManager();
- private List recipes = new ArrayList();
+ // CraftBukkit start
+ /** A list of all the recipes added */
+ public List recipes = new ArrayList(); // private -> public
+ public IRecipe lastRecipe;
+ public org.bukkit.inventory.InventoryView lastCraftView;
+ // CraftBukkit end
private static final String __OBFID = "CL_00000090";
public static final CraftingManager getInstance()
@@ -24,7 +31,8 @@
return instance;
}
- private CraftingManager()
+ // CraftBukkit - private -> public
+ public CraftingManager()
{
(new RecipesTools()).addRecipes(this);
(new RecipesWeapons()).addRecipes(this);
@@ -152,6 +160,23 @@
this.addShapelessRecipe(new ItemStack(Items.fire_charge, 3), new Object[] {Items.gunpowder, Items.blaze_powder, new ItemStack(Items.coal, 1, 1)});
this.addRecipe(new ItemStack(Blocks.daylight_detector), new Object[] {"GGG", "QQQ", "WWW", 'G', Blocks.glass, 'Q', Items.quartz, 'W', Blocks.wooden_slab});
this.addRecipe(new ItemStack(Blocks.hopper), new Object[] {"I I", "ICI", " I ", 'I', Items.iron_ingot, 'C', Blocks.chest});
+ /*Collections.sort(this.recipes, new Comparator() // CraftBukkit - moved below
+ {
+ private static final String __OBFID = "CL_00000091";
+ public int compare(IRecipe par1IRecipe, IRecipe par2IRecipe)
+ {
+ return par1IRecipe instanceof ShapelessRecipes && par2IRecipe instanceof ShapedRecipes ? 1 : (par2IRecipe instanceof ShapelessRecipes && par1IRecipe instanceof ShapedRecipes ? -1 : (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize() ? -1 : (par2IRecipe.getRecipeSize() > par1IRecipe.getRecipeSize() ? 1 : 0)));
+ }
+ public int compare(Object par1Obj, Object par2Obj)
+ {
+ return this.compare((IRecipe)par1Obj, (IRecipe)par2Obj);
+ }
+ });*/
+ this.sort(); // CraftBukkit - call new sort method
+ }
+
+ public void sort()
+ {
Collections.sort(this.recipes, new Comparator()
{
private static final String __OBFID = "CL_00000091";
@@ -312,7 +337,22 @@
i1 = 0;
}
- return new ItemStack(itemstack.getItem(), 1, i1);
+ // Cauldron start - vanilla compatibility
+ if (p_82787_1_.resultInventory == null)
+ {
+ return new ItemStack(itemstack.getItem(), 1, i1);
+ }
+ // Cauldron end
+ // CraftBukkit start - Construct a dummy repair recipe
+ ItemStack result = new ItemStack(itemstack.getItem(), 1, i1);
+ List<ItemStack> ingredients = new ArrayList<ItemStack>();
+ ingredients.add(itemstack.copy());
+ ingredients.add(itemstack1.copy());
+ ShapelessRecipes recipe = new ShapelessRecipes(result.copy(), ingredients);
+ p_82787_1_.currentRecipe = recipe;
+ result = CraftEventFactory.callPreCraftEvent(p_82787_1_, result, lastCraftView, true);
+ return result;
+ // CraftBukkit end
}
else
{
@@ -320,12 +360,23 @@
{
IRecipe irecipe = (IRecipe)this.recipes.get(j);
- if (irecipe.matches(p_82787_1_, p_82787_2_))
+ if (irecipe.matches(p_82787_1_, p_82787_2_) && p_82787_1_.resultInventory != null) // Cauldron - add null check for vanilla compatibility
{
+ // CraftBukkit start - INVENTORY_PRE_CRAFT event
+ p_82787_1_.currentRecipe = irecipe;
+ ItemStack result = irecipe.getCraftingResult(p_82787_1_);
+ return CraftEventFactory.callPreCraftEvent(p_82787_1_, result, lastCraftView, false);
+ // CraftBukkit end
+ }
+ // Cauldron start - vanilla
+ else if (irecipe.matches(p_82787_1_, p_82787_2_))
+ {
return irecipe.getCraftingResult(p_82787_1_);
}
+ // Cauldron end
}
+ p_82787_1_.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
return null;
}
}

View File

@ -0,0 +1,62 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java
@@ -14,8 +14,9 @@
public class FurnaceRecipes
{
private static final FurnaceRecipes smeltingBase = new FurnaceRecipes();
- private Map smeltingList = new HashMap();
+ public Map smeltingList = new HashMap(); // CraftBukkit - private -> public
private Map experienceList = new HashMap();
+ public Map customRecipes = new HashMap(); // CraftBukkit
private static final String __OBFID = "CL_00000085";
public static FurnaceRecipes smelting()
@@ -23,7 +24,7 @@
return smeltingBase;
}
- private FurnaceRecipes()
+ public FurnaceRecipes() // CraftBukkit - private -> public
{
this.func_151393_a(Blocks.iron_ore, new ItemStack(Items.iron_ingot), 0.7F);
this.func_151393_a(Blocks.gold_ore, new ItemStack(Items.gold_ingot), 1.0F);
@@ -76,16 +77,37 @@
this.experienceList.put(p_151394_2_, Float.valueOf(p_151394_3_));
}
+ // CraftBukkit start
+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1)
+ {
+ this.customRecipes.put(itemstack, itemstack1);
+ }
+ // CraftBukkit end
+
public ItemStack getSmeltingResult(ItemStack p_151395_1_)
{
- Iterator iterator = this.smeltingList.entrySet().iterator();
+ // CraftBukkit start
+ boolean vanilla = false;
+ Iterator iterator = this.customRecipes.entrySet().iterator();
+ // CraftBukkit end
Entry entry;
do
{
if (!iterator.hasNext())
{
- return null;
+ // CraftBukkit start
+ if (!vanilla)
+ {
+ iterator = this.smeltingList.entrySet().iterator();
+ vanilla = true;
+ }
+ else
+ {
+ return null;
+ }
+
+ // CraftBukkit end
}
entry = (Entry)iterator.next();

View File

@ -0,0 +1,9 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/IRecipe.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/IRecipe.java
@@ -13,4 +13,6 @@
int getRecipeSize();
ItemStack getRecipeOutput();
+
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
}

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/RecipeBookCloning.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/RecipeBookCloning.java
@@ -6,10 +6,17 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
-public class RecipeBookCloning implements IRecipe
+public class RecipeBookCloning extends ShapelessRecipes implements IRecipe // CraftBukkit - added extends
{
private static final String __OBFID = "CL_00000081";
+ // CraftBukkit start - Delegate to new parent class
+ public RecipeBookCloning()
+ {
+ super(new ItemStack(Items.written_book, 0, -1), java.util.Arrays.asList(new ItemStack(Items.writable_book, 0, 0)));
+ }
+ // CraftBukkit end
+
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
int i = 0;

View File

@ -0,0 +1,22 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/RecipeFireworks.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/RecipeFireworks.java
@@ -9,11 +9,18 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
-public class RecipeFireworks implements IRecipe
+public class RecipeFireworks extends ShapelessRecipes implements IRecipe // CraftBukkit - added extends
{
private ItemStack field_92102_a;
private static final String __OBFID = "CL_00000083";
+ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeFireworks()
+ {
+ super(new ItemStack(Items.fireworks, 0, 0), java.util.Arrays.asList(new ItemStack(Items.gunpowder, 0, 5)));
+ }
+ // CraftBukkit end
+
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
this.field_92102_a = null;

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/RecipesArmorDyes.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/RecipesArmorDyes.java
@@ -9,10 +9,17 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-public class RecipesArmorDyes implements IRecipe
+public class RecipesArmorDyes extends ShapelessRecipes implements IRecipe // CraftBukkit - added extends
{
private static final String __OBFID = "CL_00000079";
+ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipesArmorDyes()
+ {
+ super(new ItemStack(Items.leather_helmet, 0, 0), java.util.Arrays.asList(new ItemStack(Items.dye, 0, 5)));
+ }
+ // CraftBukkit end
+
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
ItemStack itemstack = null;

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/RecipesMapCloning.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/RecipesMapCloning.java
@@ -5,10 +5,17 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-public class RecipesMapCloning implements IRecipe
+public class RecipesMapCloning extends ShapelessRecipes implements IRecipe // CraftBukkit - added extends
{
private static final String __OBFID = "CL_00000087";
+ // CraftBukkit start - Delegate to new parent class
+ public RecipesMapCloning()
+ {
+ super(new ItemStack(Items.filled_map, 0, -1), java.util.Arrays.asList(new ItemStack(Items.map, 0, 0)));
+ }
+ // CraftBukkit end
+
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
{
int i = 0;

View File

@ -0,0 +1,92 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/ShapedRecipes.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/ShapedRecipes.java
@@ -5,6 +5,11 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
+// CraftBukkit end
+
public class ShapedRecipes implements IRecipe
{
public final int recipeWidth;
@@ -22,6 +27,77 @@
this.recipeOutput = p_i1917_4_;
}
+ // CraftBukkit start
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe()
+ {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.recipeOutput);
+ CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
+
+ switch (this.recipeHeight)
+ {
+ case 1:
+ switch (this.recipeWidth)
+ {
+ case 1:
+ recipe.shape("a");
+ break;
+ case 2:
+ recipe.shape("ab");
+ break;
+ case 3:
+ recipe.shape("abc");
+ break;
+ }
+
+ break;
+ case 2:
+ switch (this.recipeWidth)
+ {
+ case 1:
+ recipe.shape("a", "b");
+ break;
+ case 2:
+ recipe.shape("ab", "cd");
+ break;
+ case 3:
+ recipe.shape("abc", "def");
+ break;
+ }
+
+ break;
+ case 3:
+ switch (this.recipeWidth)
+ {
+ case 1:
+ recipe.shape("a", "b", "c");
+ break;
+ case 2:
+ recipe.shape("ab", "cd", "ef");
+ break;
+ case 3:
+ recipe.shape("abc", "def", "ghi");
+ break;
+ }
+
+ break;
+ }
+
+ char c = 'a';
+
+ for (ItemStack stack : this.recipeItems)
+ {
+ if (stack != null)
+ {
+ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getItemDamage());
+ }
+
+ c++;
+ }
+
+ return recipe;
+ }
+ // CraftBukkit end
+
public ItemStack getRecipeOutput()
{
return this.recipeOutput;

View File

@ -0,0 +1,40 @@
--- ../src-base/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java
+++ ../src-work/minecraft/net/minecraft/item/crafting/ShapelessRecipes.java
@@ -7,6 +7,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
+// CraftBukkit end
+
public class ShapelessRecipes implements IRecipe
{
private final ItemStack recipeOutput;
@@ -19,6 +24,25 @@
this.recipeItems = p_i1918_2_;
}
+ // CraftBukkit start
+ @SuppressWarnings("unchecked")
+ public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe()
+ {
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.recipeOutput);
+ CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
+
+ for (ItemStack stack : (List<ItemStack>) this.recipeItems)
+ {
+ if (stack != null)
+ {
+ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), stack.getItemDamage());
+ }
+ }
+
+ return recipe;
+ }
+ // CraftBukkit end
+
public ItemStack getRecipeOutput()
{
return this.recipeOutput;