New Repo
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.kitsu.medievalcraft.Main;
|
||||
import com.kitsu.medievalcraft.item.ModItems;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public class CraftingHandle {
|
||||
|
||||
public static int craftflag;
|
||||
//ItemStack j;
|
||||
//ItemStack R;
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemCrafting(PlayerEvent.ItemCraftedEvent event) {
|
||||
|
||||
for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { // Checks all the slots
|
||||
|
||||
if (event.craftMatrix.getStackInSlot(i) != null) { // If there is an item
|
||||
//ItemStack a = event.craftMatrix.getStackInSlot(i);
|
||||
ItemStack j = event.craftMatrix.getStackInSlot(i); // Gets the item
|
||||
//ItemStack L = event.craftMatrix.getStackInSlot(i - 1);
|
||||
//ItemStack R = event.craftMatrix.getStackInSlot(i+3);
|
||||
|
||||
//FORGE HAMMER
|
||||
if (j.getItem() != null && j.getItem() == ModItems.forgeHammer) {
|
||||
|
||||
ItemStack k = new ItemStack(ModItems.forgeHammer, 2, (j.getItemDamage() + 1));
|
||||
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
event.player.worldObj.playSoundAtEntity(event.player, "random.anvil_use", 0.8F, 1.0F );
|
||||
|
||||
//IRONSAW
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironSaw) {
|
||||
ItemStack k = new ItemStack(ModItems.ironSaw, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.player.worldObj.playSoundAtEntity(event.player, Main.MODID + ":sawwood", 0.1F, 2.0F);
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
//FLINTSAW
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.flintSaw) {
|
||||
ItemStack k = new ItemStack(ModItems.flintSaw, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.player.worldObj.playSoundAtEntity(event.player, Main.MODID + ":sawwood", 0.1F, 3.0F);
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//WORKBLADE
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.workBlade) {
|
||||
ItemStack k = new ItemStack(ModItems.workBlade, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON AXE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironAxeForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironAxeForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON BATTLE AXE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironBattleAxeForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironBattleAxeForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON DAGGER FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironDaggerForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironDaggerForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON HALBERD FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironHandleForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironHandleForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON HOE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironHoeForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironHoeForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON LONGSWORD FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironLongswordForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironLongswordForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON MACE HEAD FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironMaceHeadForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironMaceHeadForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON PICKAXE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironPickaxeForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironPickaxeForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON RING FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironRingForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironRingForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON SAWBLADE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironSawBladeForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironSawBladeForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON SHARP TIP FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironSharpTipForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironSharpTipForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON SHORT SWORD FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironShortSwordForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironShortSwordForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON SPADE FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironSpadForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironSpadForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//IRON SPEAR TIP FORM
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.ironSpearTipForm) {
|
||||
ItemStack k = new ItemStack(ModItems.ironSpearTipForm, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
|
||||
//LEATHER SHEARS
|
||||
} if (j.getItem() != null && j.getItem() == ModItems.leatherShears) {
|
||||
ItemStack k = new ItemStack(ModItems.leatherShears, 2, (j.getItemDamage() + 1));
|
||||
if (k.getItemDamage() >= k.getMaxDamage()) {
|
||||
k.stackSize--;
|
||||
}
|
||||
event.craftMatrix.setInventorySlotContents(i, k);
|
||||
event.player.worldObj.playSoundAtEntity(event.player, "mob.sheep.shear", 0.8F, 1.0F );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.kitsu.medievalcraft.item.ModItems;
|
||||
|
||||
public class ForgeAnvilCrafting {
|
||||
|
||||
public static final Hashtable<Integer, Item> itemToCheck = new Hashtable <Integer, Item>(){{
|
||||
|
||||
put(0, ModItems.ironPickaxeForm);
|
||||
put(1, ModItems.ironSpadForm);
|
||||
put(2, ModItems.ironHoeForm);
|
||||
put(3, ModItems.ironAxeForm);
|
||||
put(4, ModItems.ironLongswordForm);
|
||||
put(5, ModItems.ironShortSwordForm);
|
||||
put(6, ModItems.ironDaggerForm);
|
||||
put(7, ModItems.ironSpearTipForm);
|
||||
put(8, ModItems.ironMaceHeadForm);
|
||||
put(9, ModItems.ironBattleAxeForm);
|
||||
put(10, ModItems.ironSawBladeForm);
|
||||
put(11, ModItems.ironSharpTipForm);
|
||||
put(12, ModItems.ironRingForm);
|
||||
put(13, ModItems.ironHandleForm);
|
||||
|
||||
}};
|
||||
|
||||
public static final Hashtable<Integer, Item> itemToCheckClay = new Hashtable <Integer, Item>(){{
|
||||
|
||||
put(0, ModItems.cookedpickaxeClayForm);
|
||||
put(1, ModItems.cookedspadeHeadClayForm);
|
||||
put(2, ModItems.cookedhoeHeadClayForm);
|
||||
put(3, ModItems.cookedaxeHeadClayForm);
|
||||
put(4, ModItems.cookedlongswordClayForm);
|
||||
put(5, ModItems.cookedshortswordClayForm);
|
||||
put(6, ModItems.cookeddaggerClayForm);
|
||||
put(7, ModItems.cookedspeartipClayForm);
|
||||
put(8, ModItems.cookedmaceheadClayForm);
|
||||
put(9, ModItems.cookedbattleaxeClayForm);
|
||||
put(10, ModItems.cookedsawbladeClayForm);
|
||||
put(11, ModItems.cookedsharptipClayForm);
|
||||
put(12, ModItems.cookedringClayForm);
|
||||
|
||||
}};
|
||||
|
||||
public static final Hashtable<Integer, ItemStack> itemToGive = new Hashtable <Integer, ItemStack>(){{
|
||||
|
||||
put(0, new ItemStack (ModItems.ironpickaxeHead, 1, 0));
|
||||
put(1, new ItemStack (ModItems.ironspadeHead, 1, 0));
|
||||
put(2, new ItemStack (ModItems.ironhoeHead, 1, 0));
|
||||
put(3, new ItemStack (ModItems.ironaxeHead, 1, 0));
|
||||
put(4, new ItemStack (ModItems.ironlongswordBlade, 1, 0));
|
||||
put(5, new ItemStack (ModItems.ironshortswordBlade,2,0));
|
||||
put(6, new ItemStack (ModItems.irondaggerBlade, 3,0));
|
||||
put(7, new ItemStack (ModItems.ironspearTip, 1, 0));
|
||||
put(8, new ItemStack (ModItems.ironmaceHead, 1, 0));
|
||||
|
||||
put(9, new ItemStack (ModItems.ironbattleaxeHead, 1, 0));
|
||||
put(10, new ItemStack (ModItems.ironsawBlade, 1, 0));
|
||||
put(11, new ItemStack (ModItems.ironsharpTip,9,0));
|
||||
put(12, new ItemStack (ModItems.ironRing,9,0));
|
||||
put(13, new ItemStack (ModItems.ironweaponHandle, 2, 0));
|
||||
|
||||
}};
|
||||
|
||||
public static final Hashtable<Integer, String> toolToRepair = new Hashtable <Integer, String>(){{
|
||||
|
||||
put(0, "Forged Iron Pickaxe");
|
||||
put(1, "Forged Shovel");
|
||||
put(2, "Forged Lumber Axe");
|
||||
put(3, "Leather Shears");
|
||||
put(4, "Iron Saw");
|
||||
put(5, "Iron Shield");
|
||||
put(6, "Heavy Mace");
|
||||
put(7, "Longsword");
|
||||
put(8, "Forge Hammer");
|
||||
put(9, "Crafting Blade");
|
||||
put(10, "Gladius");
|
||||
|
||||
}};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.kitsu.medievalcraft.item.ModItems;
|
||||
|
||||
public class FormTableCraftManager {
|
||||
|
||||
private static final FormTableCraftManager instance = new FormTableCraftManager();
|
||||
private List recipes = new ArrayList();
|
||||
//private static final String __OBFID = "CL_00000090";
|
||||
|
||||
public static final FormTableCraftManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private FormTableCraftManager () {
|
||||
|
||||
recipes = new ArrayList();
|
||||
////////RECIPES////////////////////////////////////////////////////////
|
||||
//EXAMPLE RECIPE
|
||||
//this.addRecipe(new ItemStack(ModItems.longSword, 1), new Object[]{"S", "S", "S", "S", "S", 'S', Items.stick});
|
||||
//this.addRecipe(new ItemStack(ModItems.xxx, 1), new Object[]{"", "", "", "", "", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.pickaxeClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", " c ", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.spadeHeadClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "c c", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.hoeHeadClayForm, 1), new Object[]{ "ccccc", "c c", "c ccc", "ccccc", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.axeHeadClayForm, 1), new Object[]{ "ccccc", "c ccc", " c", "c ccc", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.longswordClayForm, 1), new Object[]{ "cccc ", "ccc c", "cc cc", "c ccc", " cccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.shortswordClayForm, 1), new Object[]{"cc cc", "cc cc", "cc cc", "c c", "cc cc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.daggerClayForm, 1), new Object[]{ "ccccc", "cc cc", "cc cc", "cc cc", "ccccc", 'c', Items.clay_ball});
|
||||
//this.addRecipe(new ItemStack(ModItems.halberdClayForm, 1), new Object[]{ "ccccc", "c ccc", " ", " cc", "c ccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.speartipClayForm, 1), new Object[]{ "ccccc", "cc cc", "cc cc", "c c", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.maceheadClayForm, 1), new Object[]{ "cc cc", "c c", " ", "c c", "cc cc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.sharptipClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "ccccc", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.battleaxeClayForm, 1), new Object[]{ "c c c", " ", " ", " ", "c c c", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.ringClayForm, 1), new Object[]{ "ccccc", "cc cc", "c c", "cc cc", "ccccc", 'c', Items.clay_ball});
|
||||
//this.addRecipe(new ItemStack(ModItems.plateClayForm, 1), new Object[]{ "ccccc", "c c", "c c", "c c", "ccccc", 'c', Items.clay_ball});
|
||||
this.addRecipe(new ItemStack(ModItems.sawbladeClayForm, 1), new Object[]{ "ccccc", "ccccc", " ", "c ", "ccccc", 'c', Items.clay_ball});
|
||||
|
||||
Collections.sort(this.recipes, new FormTableRecipeSorter(this));
|
||||
}
|
||||
|
||||
public FormTableShapedRecipes addRecipe(ItemStack p_92103_1_, Object ... p_92103_2_)
|
||||
{
|
||||
String s = "";
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
|
||||
if (p_92103_2_[i] instanceof String[])
|
||||
{
|
||||
@SuppressWarnings("cast")
|
||||
String[] astring = (String[])((String[])p_92103_2_[i++]);
|
||||
|
||||
for (int l = 0; l < astring.length; ++l)
|
||||
{
|
||||
String s1 = astring[l];
|
||||
++k;
|
||||
j = s1.length();
|
||||
s = s + s1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (p_92103_2_[i] instanceof String)
|
||||
{
|
||||
String s2 = (String)p_92103_2_[i++];
|
||||
++k;
|
||||
j = s2.length();
|
||||
s = s + s2;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap hashmap;
|
||||
|
||||
for (hashmap = new HashMap(); i < p_92103_2_.length; i += 2)
|
||||
{
|
||||
Character character = (Character)p_92103_2_[i];
|
||||
ItemStack itemstack1 = null;
|
||||
|
||||
if (p_92103_2_[i + 1] instanceof Item)
|
||||
{
|
||||
itemstack1 = new ItemStack((Item)p_92103_2_[i + 1]);
|
||||
}
|
||||
else if (p_92103_2_[i + 1] instanceof Block)
|
||||
{
|
||||
itemstack1 = new ItemStack((Block)p_92103_2_[i + 1], 1, 32767);
|
||||
}
|
||||
else if (p_92103_2_[i + 1] instanceof ItemStack)
|
||||
{
|
||||
itemstack1 = (ItemStack)p_92103_2_[i + 1];
|
||||
}
|
||||
|
||||
hashmap.put(character, itemstack1);
|
||||
}
|
||||
|
||||
ItemStack[] aitemstack = new ItemStack[j * k];
|
||||
|
||||
for (int i1 = 0; i1 < j * k; ++i1)
|
||||
{
|
||||
char c0 = s.charAt(i1);
|
||||
|
||||
if (hashmap.containsKey(Character.valueOf(c0)))
|
||||
{
|
||||
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
aitemstack[i1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
FormTableShapedRecipes shapedrecipes = new FormTableShapedRecipes(j, k, aitemstack, p_92103_1_);
|
||||
this.recipes.add(shapedrecipes);
|
||||
return shapedrecipes;
|
||||
}
|
||||
|
||||
public void addShapelessRecipe(ItemStack p_77596_1_, Object ... p_77596_2_)
|
||||
{
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Object[] aobject = p_77596_2_;
|
||||
int i = p_77596_2_.length;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
Object object1 = aobject[j];
|
||||
|
||||
if (object1 instanceof ItemStack)
|
||||
{
|
||||
arraylist.add(((ItemStack)object1).copy());
|
||||
}
|
||||
else if (object1 instanceof Item)
|
||||
{
|
||||
arraylist.add(new ItemStack((Item)object1));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(object1 instanceof Block))
|
||||
{
|
||||
throw new RuntimeException("Invalid shapeless recipy!");
|
||||
}
|
||||
|
||||
arraylist.add(new ItemStack((Block)object1));
|
||||
}
|
||||
}
|
||||
|
||||
this.recipes.add(new ShapelessRecipes(p_77596_1_, arraylist));
|
||||
}
|
||||
|
||||
|
||||
public ItemStack findMatchingRecipe(InventoryCrafting p_82787_1_, World p_82787_2_)
|
||||
{
|
||||
int i = 0;
|
||||
ItemStack itemstack = null;
|
||||
ItemStack itemstack1 = null;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < p_82787_1_.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack2 = p_82787_1_.getStackInSlot(j);
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
itemstack = itemstack2;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
itemstack1 = itemstack2;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable())
|
||||
{
|
||||
Item item = itemstack.getItem();
|
||||
int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay();
|
||||
int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay();
|
||||
int l = j1 + k + item.getMaxDamage() * 5 / 100;
|
||||
int i1 = item.getMaxDamage() - l;
|
||||
|
||||
if (i1 < 0)
|
||||
{
|
||||
i1 = 0;
|
||||
}
|
||||
|
||||
return new ItemStack(itemstack.getItem(), 1, i1);
|
||||
}
|
||||
for (j = 0; j < this.recipes.size(); ++j)
|
||||
{
|
||||
IRecipe irecipe = (IRecipe)this.recipes.get(j);
|
||||
|
||||
if (irecipe.matches(p_82787_1_, p_82787_2_))
|
||||
{
|
||||
return irecipe.getCraftingResult(p_82787_1_);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the List<> of all recipes
|
||||
*/
|
||||
public List getRecipeList()
|
||||
{
|
||||
return this.recipes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public class FormTableRecipeSorter implements Comparator {
|
||||
|
||||
final FormTableCraftManager formTable;
|
||||
|
||||
public FormTableRecipeSorter(FormTableCraftManager ftcraftmanage) {
|
||||
this.formTable = ftcraftmanage;
|
||||
}
|
||||
|
||||
public int compareRecipes(IRecipe irecipe1, IRecipe irecipe2) {
|
||||
return irecipe1 instanceof FormTableShapelessRecipes && irecipe2 instanceof FormTableShapedRecipes ? 1 : (irecipe2 instanceof FormTableShapelessRecipes && irecipe1 instanceof FormTableShapedRecipes ? -1 : (irecipe2.getRecipeSize() > irecipe1.getRecipeSize() ? -1 : (irecipe2.getRecipeSize() > irecipe1.getRecipeSize() ? 1 : 0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return this.compareRecipes((IRecipe)o1, (IRecipe)o2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FormTableShapedRecipes implements IRecipe
|
||||
{
|
||||
/** How many horizontal slots this recipe is wide. */
|
||||
public final int recipeWidth;
|
||||
/** How many vertical slots this recipe uses. */
|
||||
public final int recipeHeight;
|
||||
/** Is a array of ItemStack that composes the recipe. */
|
||||
public final ItemStack[] recipeItems;
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private ItemStack recipeOutput;
|
||||
private boolean field_92101_f;
|
||||
//private static final String __OBFID = "CL_00000093";
|
||||
|
||||
public FormTableShapedRecipes(int p_i1917_1_, int p_i1917_2_, ItemStack[] p_i1917_3_, ItemStack p_i1917_4_)
|
||||
{
|
||||
this.recipeWidth = p_i1917_1_;
|
||||
this.recipeHeight = p_i1917_2_;
|
||||
this.recipeItems = p_i1917_3_;
|
||||
this.recipeOutput = p_i1917_4_;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
|
||||
{
|
||||
for (int i = 0; i <= 5 - this.recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 5 - this.recipeHeight; ++j)
|
||||
{
|
||||
if (this.checkMatch(p_77569_1_, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.checkMatch(p_77569_1_, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
private boolean checkMatch(InventoryCrafting p_77573_1_, int p_77573_2_, int p_77573_3_, boolean p_77573_4_)
|
||||
{
|
||||
for (int k = 0; k < 5; ++k)
|
||||
{
|
||||
for (int l = 0; l < 5; ++l)
|
||||
{
|
||||
int i1 = k - p_77573_2_;
|
||||
int j1 = l - p_77573_3_;
|
||||
ItemStack itemstack = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < this.recipeWidth && j1 < this.recipeHeight)
|
||||
{
|
||||
if (p_77573_4_)
|
||||
{
|
||||
itemstack = this.recipeItems[this.recipeWidth - i1 - 1 + j1 * this.recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = this.recipeItems[i1 + j1 * this.recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = p_77573_1_.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (itemstack1 != null || itemstack != null)
|
||||
{
|
||||
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItem() != itemstack1.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
|
||||
{
|
||||
ItemStack itemstack = this.getRecipeOutput().copy();
|
||||
|
||||
if (this.field_92101_f)
|
||||
{
|
||||
for (int i = 0; i < p_77572_1_.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack1 = p_77572_1_.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((NBTTagCompound)itemstack1.stackTagCompound.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeWidth * this.recipeHeight;
|
||||
}
|
||||
|
||||
public FormTableShapedRecipes func_92100_c()
|
||||
{
|
||||
this.field_92101_f = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FormTableShapelessRecipes implements IRecipe{
|
||||
|
||||
/** Is the ItemStack that you get when craft the recipe. */
|
||||
private final ItemStack recipeOutput;
|
||||
/** Is a List of ItemStack that composes the recipe. */
|
||||
public final List recipeItems;
|
||||
//private static final String __OBFID = "CL_00000094";
|
||||
|
||||
public FormTableShapelessRecipes(ItemStack p_i1918_1_, List p_i1918_2_)
|
||||
{
|
||||
this.recipeOutput = p_i1918_1_;
|
||||
this.recipeItems = p_i1918_2_;
|
||||
}
|
||||
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return this.recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_)
|
||||
{
|
||||
ArrayList arraylist = new ArrayList(this.recipeItems);
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
for (int j = 0; j < 5; ++j)
|
||||
{
|
||||
ItemStack itemstack = p_77569_1_.getStackInRowAndColumn(j, i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
|
||||
if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == 32767 || itemstack.getItemDamage() == itemstack1.getItemDamage()))
|
||||
{
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
|
||||
{
|
||||
return this.recipeOutput.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return this.recipeItems.size();
|
||||
}
|
||||
}
|
||||
1893
src/main/java/com/kitsu/medievalcraft/crafting/ModCrafting.java
Normal file
1893
src/main/java/com/kitsu/medievalcraft/crafting/ModCrafting.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
package com.kitsu.medievalcraft.crafting;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import com.kitsu.medievalcraft.block.ModBlocks;
|
||||
|
||||
public class TestForgeCrafting {
|
||||
|
||||
public static final Hashtable<Integer, Block> blockToCheck = new Hashtable <Integer, Block>(){{
|
||||
|
||||
/*put(0, ModBlocks.myIronIngot);
|
||||
put(1, ModBlocks.filledCrucibleIron);
|
||||
put(2, ModBlocks.emptySoftCrucible);
|
||||
put(3, ModBlocks.ironPlate);
|
||||
put(4, ModBlocks.filledCrucibleIronIngot);
|
||||
put(5, ModBlocks.filledCrucibleDamascus);
|
||||
put(6, ModBlocks.damascusIngot);
|
||||
put(7, ModBlocks.filledLapisCrucible);
|
||||
put(8, ModBlocks.lapisIngot);
|
||||
put(9, ModBlocks.redstoneIngot);
|
||||
put(10, ModBlocks.filledRedstoneCrucible);*/
|
||||
|
||||
}};
|
||||
|
||||
public static final Hashtable<Integer, Integer> cookTable= new Hashtable <Integer, Integer>(){{
|
||||
|
||||
/*put(0, 300);
|
||||
put(1, 1000);
|
||||
put(2, 200);
|
||||
put(3, 250);
|
||||
put(4, 750);
|
||||
put(5, 1200);
|
||||
put(6, 400);
|
||||
put(7, 900);
|
||||
put(8, 400);
|
||||
put(9, 400);
|
||||
put(10, 900);*/
|
||||
}};
|
||||
|
||||
public static final Hashtable<Integer, Block> blockToCook = new Hashtable <Integer, Block>(){{
|
||||
|
||||
/*put(0, ModBlocks.hotIronBlock);
|
||||
put(1, ModBlocks.hotCrucibleIron);
|
||||
put(2, ModBlocks.emptyCookedCrucible);
|
||||
put(3, ModBlocks.hotIronPlate);
|
||||
put(4, ModBlocks.hotCrucibleIron);
|
||||
put(5, ModBlocks.hotCrucibleDamascus);
|
||||
put(6, ModBlocks.hotDamascusIngot);
|
||||
put(7, ModBlocks.hotLapisCrucible);
|
||||
put(8, ModBlocks.hotLapisIngot);
|
||||
put(9, ModBlocks.hotRedstoneIngot);
|
||||
put(10, ModBlocks.hotRedstoneCrucible);*/
|
||||
|
||||
}};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user