Critical Fixes - Also Trying to get OreDict Support for Woodchopper
This commit is contained in:
parent
42e12d41e5
commit
31ad60f322
4 changed files with 48 additions and 94 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package com.oitsjustjose.criss_cross.Recipes;
|
||||
|
||||
import com.oitsjustjose.criss_cross.Items.ItemManager;
|
||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
|
||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
|
||||
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,98 +1,50 @@
|
|||
package com.oitsjustjose.criss_cross.Recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
|
||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
|
||||
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class WoodchipperRecipes
|
||||
{
|
||||
public static void initRecipes()
|
||||
{
|
||||
ArrayList<ItemStack> logs = OreDictionary.getOres("logWood");
|
||||
ArrayList<ItemStack> planks = OreDictionary.getOres("plankWood");
|
||||
|
||||
String logName;
|
||||
String plankName;
|
||||
|
||||
//Iterates through the inputItems String array
|
||||
for(int i = 0; i < ConfigHandler.woodchipperLogs.length; i++)
|
||||
for(int i = 0; i < logs.size(); i++)
|
||||
{
|
||||
//Done in a try loop just in case there's an issue with reading a value in.
|
||||
try
|
||||
logName = logs.get(i).getDisplayName();
|
||||
logName = logName.replace("Wood", "");
|
||||
logName = logName.trim();
|
||||
System.out.println(logName);
|
||||
|
||||
for(int j = 0; j < planks.size(); j++)
|
||||
{
|
||||
//Splits the modid:item / modid:item:metadata string at the ':' and makes a
|
||||
//new Array of strings, each element containing the newly separated parts.
|
||||
String[] logs = ConfigHandler.woodchipperLogs[i].split(":");
|
||||
String[] planks = ConfigHandler.woodchipperPlanks[i].split(":");
|
||||
|
||||
|
||||
ItemStack log = GameRegistry.findItemStack(logs[0], logs[1], 1);
|
||||
ItemStack plank = GameRegistry.findItemStack(planks[0], planks[1], 1);
|
||||
|
||||
boolean flag = (log != null) && (plank != null);
|
||||
|
||||
if(!flag)
|
||||
plankName = planks.get(j).getDisplayName();
|
||||
plankName = plankName.replace("Wood", "");
|
||||
plankName = plankName.replace("Planks", "");
|
||||
plankName = plankName.trim();
|
||||
System.out.println(plankName);
|
||||
if(plankName.contains(logName))
|
||||
{
|
||||
if(log == null)
|
||||
System.out.println("[CrissCross] Item " + ConfigHandler.woodchipperLogs[i] + " could not be added to the Woodchipper's recipe list. Please confirm you have the name and formatting correct.");
|
||||
if(plank == null)
|
||||
System.out.println("[CrissCross] Item " + ConfigHandler.woodchipperPlanks[i] + " could not be added to the Woodchipper's recipe list. Please confirm you have the name and formatting correct.");
|
||||
TileEntityWoodchipper.addRecipe(new ItemStack(logs.get(i).getItem(), 1, logs.get(i).getItemDamage()),
|
||||
new ItemStack(planks.get(j).getItem(), 1, planks.get(j).getItemDamage()));
|
||||
System.out.println("plankName.contains(logName) evaluated to True");
|
||||
break;
|
||||
}
|
||||
|
||||
//Checks the read in string as modid:item
|
||||
if(flag)
|
||||
{
|
||||
if(logs.length == 2)
|
||||
{
|
||||
if(planks.length == 2)
|
||||
{
|
||||
TileEntityWoodchipper.addRecipe(log, plank);
|
||||
}
|
||||
else if(planks.length == 3)
|
||||
{
|
||||
TileEntityWoodchipper.addRecipe(log, new ItemStack(plank.getItem(), 1, Integer.parseInt(planks[2])));
|
||||
}
|
||||
}
|
||||
else if(logs.length == 3)
|
||||
{
|
||||
if(planks.length == 2)
|
||||
{
|
||||
TileEntityWoodchipper.addRecipe(new ItemStack(log.getItem(), 1, Integer.parseInt(logs[2])), plank);
|
||||
}
|
||||
else if(planks.length == 3)
|
||||
{
|
||||
TileEntityWoodchipper.addRecipe(new ItemStack(log.getItem(), 1, Integer.parseInt(logs[2])), new ItemStack(plank.getItem(), 1, Integer.parseInt(planks[2])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Gotta catch em all
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void initFuels()
|
||||
{
|
||||
for(int i = 0; i < ConfigHandler.woodchipperFuels.length; i++)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.oitsjustjose.criss_cross.TileEntity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.criss_cross.Blocks.BlockCropomator;
|
||||
import com.oitsjustjose.criss_cross.Blocks.BlockElectroextractor;
|
||||
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
@ -242,7 +242,7 @@ public class TileEntityElectroextractor extends TileEntity implements ISidedInve
|
|||
if (flag != this.fuelTime > 0)
|
||||
{
|
||||
flag1 = true;
|
||||
BlockCropomator.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
BlockElectroextractor.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,22 +260,23 @@ public class TileEntityElectroextractor extends TileEntity implements ISidedInve
|
|||
}
|
||||
else
|
||||
{
|
||||
int posInArList = 0;
|
||||
ItemStack output = null;
|
||||
for(int i = 0; i < inputItems.size(); i++)
|
||||
{
|
||||
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
|
||||
{
|
||||
posInArList = i;
|
||||
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).getItemDamage());
|
||||
|
||||
if(output == null)
|
||||
return false;
|
||||
|
||||
if(this.ItemStacks[2] == null)
|
||||
return true;
|
||||
if(!this.ItemStacks[2].isItemEqual(itemstack))
|
||||
if(!this.ItemStacks[2].isItemEqual(output))
|
||||
return false;
|
||||
int result = ItemStacks[2].stackSize + itemstack.stackSize;
|
||||
int result = ItemStacks[2].stackSize + output.stackSize;
|
||||
|
||||
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
|
||||
}
|
||||
|
|
@ -347,16 +348,17 @@ public class TileEntityElectroextractor extends TileEntity implements ISidedInve
|
|||
{
|
||||
if (this.canProcess())
|
||||
{
|
||||
int posInArList = 0;
|
||||
ItemStack output = null;
|
||||
for(int i = 0; i < inputItems.size(); i++)
|
||||
{
|
||||
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
|
||||
{
|
||||
posInArList = i;
|
||||
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack output = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).getItemDamage());
|
||||
if(output == null)
|
||||
return;
|
||||
|
||||
if (this.ItemStacks[2] == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.oitsjustjose.criss_cross.TileEntity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.criss_cross.Blocks.BlockCropomator;
|
||||
import com.oitsjustjose.criss_cross.Blocks.BlockWoodchipper;
|
||||
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
|
@ -15,7 +15,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityWoodchipper extends TileEntity implements ISidedInventory
|
||||
{
|
||||
|
|
@ -242,7 +241,7 @@ public class TileEntityWoodchipper extends TileEntity implements ISidedInventory
|
|||
if (flag != this.fuelTime > 0)
|
||||
{
|
||||
flag1 = true;
|
||||
BlockCropomator.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
BlockWoodchipper.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,22 +259,23 @@ public class TileEntityWoodchipper extends TileEntity implements ISidedInventory
|
|||
}
|
||||
else
|
||||
{
|
||||
int posInArList = 0;
|
||||
ItemStack output = null;
|
||||
for(int i = 0; i < inputItems.size(); i++)
|
||||
{
|
||||
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
|
||||
{
|
||||
posInArList = i;
|
||||
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).getItemDamage());
|
||||
|
||||
if(output == null)
|
||||
return false;
|
||||
|
||||
if(this.ItemStacks[2] == null)
|
||||
return true;
|
||||
if(!this.ItemStacks[2].isItemEqual(itemstack))
|
||||
if(!this.ItemStacks[2].isItemEqual(output))
|
||||
return false;
|
||||
int result = ItemStacks[2].stackSize + itemstack.stackSize;
|
||||
int result = ItemStacks[2].stackSize + output.stackSize;
|
||||
|
||||
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
|
||||
}
|
||||
|
|
@ -345,18 +345,19 @@ public class TileEntityWoodchipper extends TileEntity implements ISidedInventory
|
|||
|
||||
public void processItem()
|
||||
{
|
||||
if (this.canProcess())
|
||||
if (this.canProcess())
|
||||
{
|
||||
int posInArList = 0;
|
||||
ItemStack output = null;
|
||||
for(int i = 0; i < inputItems.size(); i++)
|
||||
{
|
||||
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
|
||||
{
|
||||
posInArList = i;
|
||||
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack output = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).getItemDamage());
|
||||
if(output == null)
|
||||
return;
|
||||
|
||||
if (this.ItemStacks[2] == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue