import net.minecraft.src.Container;
import net.minecraft.src.EntityPlayer;
+import net.minecraft.src.World;
+import chemicraft.ChemiCraft;
import chemicraft.tileentity.TileEntityDecompositionTable;
public class ContainerDecompositionTable extends Container {
+ private World worldObj;
+
+ private int posX;
+ private int posY;
+ private int posZ;
+
public ContainerDecompositionTable(EntityPlayer par1EntityPlayer, TileEntityDecompositionTable par2){
super();
+ this.worldObj = par2.worldObj;
+ this.posX = par2.xCoord;
+ this.posY = par2.yCoord;
+ this.posZ = par2.zCoord;
}
@Override
- public boolean canInteractWith(EntityPlayer var1) {
- return false;
+ public boolean canInteractWith(EntityPlayer par1EntityPlayer) {
+ return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.decompositionTableID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
}
}
public class ChemiCraftCraftingManager {
public ItemStack[] getDecompositionResults(IInventory par1IInventory){
- //Setting to Flag.
- /*
- * Commented by mozipi.
- ((InventoryDecomposition)par1IInventory).setFlag(false);
- */
-
- //variable of results.
- ItemStack[] results = null;
-
- //Just loop of amount of added recipe.
- for(int i1 = 0;i1 < ChemiCraftAPI.getInstance().getDecompositionMaterial().size();i1++){
- //Check of null of the Material Slot.
- if(par1IInventory.getStackInSlot(16) == null){ this.clearResults(par1IInventory, 16); return new ItemStack[16];}
- //Recipe the match?
- boolean match = true;
- //Reset the results.
- results = new ItemStack[ChemiCraftAPI.getInstance().getDecompositionResult().get(i1).length];
- //Recipe ID & Damage.
- //Material ID & Damage.
- int materialID = par1IInventory.getStackInSlot(16).itemID;
- int materialDamage = par1IInventory.getStackInSlot(16).getItemDamage();
- int recipeID = ChemiCraftAPI.getInstance().getDecompositionMaterial().get(i1).itemID;
- int recipeDamage = ChemiCraftAPI.getInstance().getDecompositionMaterial().get(i1).getItemDamage();
-
- //ID check.
- if(materialID != recipeID){ match = false;}
- //Damage check.
- if(materialDamage != recipeDamage){ match = false;}
-
- //if "match == true"
- if(match){
- //Just loop of recipe size of recipe index i1.
- for(int i = 0;i < ChemiCraftAPI.getInstance().getDecompositionResult().get(i1).length;i++){
- //Assignment to the results.
- results[i] = new ItemStack(
- ChemiCraftAPI.getInstance().getDecompositionResult().get(i1)[i].itemID,
- ChemiCraftAPI.getInstance().getDecompositionResult().get(i1)[i].stackSize,
- ChemiCraftAPI.getInstance().getDecompositionResult().get(i1)[i].getItemDamage()
- );
- }
- //return the results.
- return results;
- }
- }
- //return the null.
return null;
}
public ItemStack getChemicalCombinationResult(ArrayList<String> atomsList, ArrayList<Integer> atomsAmountList){
ChemiCraftAPI api = ChemiCraftAPI.getInstance();
recipeSize :
- for (int i = 0; i < api.getChemicalCombinationAtoms().size(); i++) {
- FormulaPart[] var1 = new FormulaPart[atomsList.size()];
- FormulaPart[] var2 = new FormulaPart[api.getChemicalCombinationAtoms().get(i).length];
- for (int j = 0; j < atomsList.size(); j++) {
- var1[j] = new FormulaPart(atomsList.get(j), atomsAmountList.get(j));
- }
- for (int j = 0; j < api.getChemicalCombinationAtoms().get(i).length; j++) {
- var2[j] = new FormulaPart(api.getChemicalCombinationAtoms().get(i)[j], api.getChemicalCombinationAmounts().get(i)[j]);
- }
- if (var1.length != var2.length) {
- continue recipeSize;
- }
- for (int j = 0; j < var1.length; j++) {
- if (!var1[j].equals(var2[j])) {
+ for (int i = 0; i < api.getChemicalCombinationAtoms().size(); i++) {
+ FormulaPart[] var1 = new FormulaPart[atomsList.size()];
+ FormulaPart[] var2 = new FormulaPart[api.getChemicalCombinationAtoms().get(i).length];
+ for (int j = 0; j < atomsList.size(); j++) {
+ var1[j] = new FormulaPart(atomsList.get(j), atomsAmountList.get(j));
+ }
+ for (int j = 0; j < api.getChemicalCombinationAtoms().get(i).length; j++) {
+ var2[j] = new FormulaPart(api.getChemicalCombinationAtoms().get(i)[j], api.getChemicalCombinationAmounts().get(i)[j]);
+ }
+ if (var1.length != var2.length) {
continue recipeSize;
}
+ for (int j = 0; j < var1.length; j++) {
+ if (!var1[j].equals(var2[j])) {
+ continue recipeSize;
+ }
+ }
+ return api.getChemicalCombinationResult().get(i);
}
- return api.getChemicalCombinationResult().get(i);
- }
return null;
}
import java.io.DataOutputStream;
+import chemicraft.inventory.InventoryDecompositionTableMaterial;
+import chemicraft.inventory.InventoryDecompositionTableResult;
+
import com.google.common.io.ByteArrayDataInput;
+import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
public class TileEntityDecompositionTable extends TileEntity {
+ private InventoryDecompositionTableMaterial invm = new InventoryDecompositionTableMaterial();
+ private InventoryDecompositionTableResult invr = new InventoryDecompositionTableResult();
+
+ @Override
+ public void readFromNBT(NBTTagCompound par1) {
+ super.readFromNBT(par1);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound par1) {
+ super.writeToNBT(par1);
+ }
+
public void readPacket(ByteArrayDataInput data) {
try {
} catch (Exception e) {
}
}
+ public InventoryDecompositionTableMaterial getInvMaterial() {
+ return this.invm;
+ }
+
+ public InventoryDecompositionTableResult getInvResult() {
+ return this.invr;
+ }
+
}