cleanup
This commit is contained in:
parent
a6506b67bf
commit
92d096a8a5
5 changed files with 55 additions and 53 deletions
|
@ -6,15 +6,16 @@ import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.modstats.ModstatInfo;
|
|
||||||
import org.modstats.Modstats;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||||
|
|
||||||
|
import org.modstats.ModstatInfo;
|
||||||
|
import org.modstats.Modstats;
|
||||||
|
|
||||||
import universalelectricity.prefab.TranslationHelper;
|
import universalelectricity.prefab.TranslationHelper;
|
||||||
import universalelectricity.prefab.multiblock.BlockMulti;
|
import universalelectricity.prefab.multiblock.BlockMulti;
|
||||||
import universalelectricity.prefab.network.PacketManager;
|
import universalelectricity.prefab.network.PacketManager;
|
||||||
|
|
|
@ -383,4 +383,32 @@ public class AutoCraftingManager
|
||||||
}
|
}
|
||||||
return this.decrStackSize(stack, amount);
|
return this.decrStackSize(stack, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to automatically remove selected items from crafting inv
|
||||||
|
*
|
||||||
|
* @param requiredItems - items that are to be removed
|
||||||
|
*/
|
||||||
|
public void consumeItems(final ItemStack... requiredItems)
|
||||||
|
{
|
||||||
|
for (ItemStack searchStack : requiredItems)
|
||||||
|
{
|
||||||
|
if (searchStack != null)
|
||||||
|
{
|
||||||
|
int[] invSlots = ((IAutoCrafter) this.craftingEntity).getCraftingInv();
|
||||||
|
for (int i = 0; i < invSlots.length; i++)
|
||||||
|
{
|
||||||
|
ItemStack checkStack = this.craftingInv.getStackInSlot(invSlots[i]);
|
||||||
|
if (checkStack != null)
|
||||||
|
{
|
||||||
|
if (this.areStacksEqual(searchStack, checkStack))
|
||||||
|
{
|
||||||
|
this.craftingInv.setInventorySlotContents(invSlots[i], this.consumeItem(searchStack, 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package assemblyline.common.imprinter;
|
package assemblyline.common.imprinter;
|
||||||
|
|
||||||
import dark.library.inv.ISlotWatcher;
|
|
||||||
import dark.library.inv.SlotCraftingResult;
|
|
||||||
import dark.library.inv.SlotRestricted;
|
|
||||||
import dark.library.inv.WatchedSlot;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
|
import dark.library.inv.ISlotWatcher;
|
||||||
|
import dark.library.inv.SlotCraftingResult;
|
||||||
|
import dark.library.inv.SlotRestricted;
|
||||||
|
import dark.library.inv.WatchedSlot;
|
||||||
|
|
||||||
public class ContainerImprinter extends Container implements ISlotWatcher
|
public class ContainerImprinter extends Container implements ISlotWatcher
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@ package assemblyline.common.imprinter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
@ -18,8 +17,6 @@ import net.minecraft.network.packet.Packet250CustomPayload;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityChest;
|
import net.minecraft.tileentity.TileEntityChest;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
import universalelectricity.core.vector.VectorHelper;
|
import universalelectricity.core.vector.VectorHelper;
|
||||||
import universalelectricity.prefab.TranslationHelper;
|
import universalelectricity.prefab.TranslationHelper;
|
||||||
|
@ -33,7 +30,6 @@ import assemblyline.common.AssemblyLine;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import dark.library.helpers.Pair;
|
import dark.library.helpers.Pair;
|
||||||
import dark.library.inv.ISlotPickResult;
|
import dark.library.inv.ISlotPickResult;
|
||||||
|
|
||||||
|
@ -42,7 +38,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
public static final int IMPRINTER_MATRIX_START = 9;
|
public static final int IMPRINTER_MATRIX_START = 9;
|
||||||
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
|
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
|
||||||
|
|
||||||
private AutoCraftingManager craftingManager;
|
private AutoCraftingManager craftManager;
|
||||||
/**
|
/**
|
||||||
* 9 slots for crafting, 1 slot for an imprint, 1 slot for an item
|
* 9 slots for crafting, 1 slot for an imprint, 1 slot for an item
|
||||||
*/
|
*/
|
||||||
|
@ -90,6 +86,18 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the AutoCraftingManager that does all the crafting results
|
||||||
|
*/
|
||||||
|
public AutoCraftingManager getCraftingManager()
|
||||||
|
{
|
||||||
|
if (craftManager == null)
|
||||||
|
{
|
||||||
|
craftManager = new AutoCraftingManager(this);
|
||||||
|
}
|
||||||
|
return craftManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
{
|
{
|
||||||
|
@ -254,10 +262,6 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
{
|
{
|
||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
if (craftingManager == null)
|
|
||||||
{
|
|
||||||
craftingManager = new AutoCraftingManager(this);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Makes the stamping recipe for filters
|
* Makes the stamping recipe for filters
|
||||||
*/
|
*/
|
||||||
|
@ -311,7 +315,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
{
|
{
|
||||||
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
||||||
|
|
||||||
if (matrixOutput != null && this.craftingManager.getIdealRecipe(matrixOutput) != null)
|
if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null)
|
||||||
{
|
{
|
||||||
this.imprinterMatrix[craftingOutputSlot] = matrixOutput;
|
this.imprinterMatrix[craftingOutputSlot] = matrixOutput;
|
||||||
didCraft = true;
|
didCraft = true;
|
||||||
|
@ -331,7 +335,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
{
|
{
|
||||||
// System.out.println("Imprint: Geting recipe for " +
|
// System.out.println("Imprint: Geting recipe for " +
|
||||||
// outputStack.toString());
|
// outputStack.toString());
|
||||||
Pair<ItemStack, ItemStack[]> idealRecipe = this.craftingManager.getIdealRecipe(outputStack);
|
Pair<ItemStack, ItemStack[]> idealRecipe = this.getCraftingManager().getIdealRecipe(outputStack);
|
||||||
|
|
||||||
if (idealRecipe != null)
|
if (idealRecipe != null)
|
||||||
{
|
{
|
||||||
|
@ -363,51 +367,20 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
||||||
{
|
{
|
||||||
if (itemStack != null)
|
if (itemStack != null)
|
||||||
{
|
{
|
||||||
if (craftingManager == null)
|
|
||||||
{
|
|
||||||
craftingManager = new AutoCraftingManager(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println("PickResult:" + worldObj.isRemote + " managing item " + itemStack.toString());
|
|
||||||
|
|
||||||
if (this.isImprinting)
|
if (this.isImprinting)
|
||||||
{
|
{
|
||||||
this.imprinterMatrix[0] = null;
|
this.imprinterMatrix[0] = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pair<ItemStack, ItemStack[]> idealRecipeItem = this.craftingManager.getIdealRecipe(itemStack);
|
Pair<ItemStack, ItemStack[]> idealRecipeItem = this.getCraftingManager().getIdealRecipe(itemStack);
|
||||||
/**
|
|
||||||
* Based on the ideal recipe, consume all the items required to make such recipe.
|
|
||||||
*/
|
|
||||||
if (idealRecipeItem != null)
|
if (idealRecipeItem != null)
|
||||||
{
|
{
|
||||||
//System.out.println("PickResult: ideal recipe ");
|
|
||||||
ItemStack[] requiredItems = idealRecipeItem.getValue().clone();
|
ItemStack[] requiredItems = idealRecipeItem.getValue().clone();
|
||||||
|
|
||||||
if (requiredItems != null)
|
if (requiredItems != null)
|
||||||
{
|
{
|
||||||
//System.out.println("PickResult: valid resources ");
|
this.getCraftingManager().consumeItems(requiredItems);
|
||||||
for (ItemStack searchStack : requiredItems)
|
|
||||||
{
|
|
||||||
if (searchStack != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < this.invSlots.length; i++)
|
|
||||||
{
|
|
||||||
ItemStack checkStack = this.getStackInSlot(this.invSlots[i]);
|
|
||||||
|
|
||||||
if (checkStack != null)
|
|
||||||
{
|
|
||||||
if (craftingManager.areStacksEqual(searchStack, checkStack))
|
|
||||||
{
|
|
||||||
this.setInventorySlotContents(this.invSlots[i], this.craftingManager.consumeItem(searchStack, 1));
|
|
||||||
//System.out.println("Consumed Item From Inv: " + checkStack.toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package assemblyline.common.machine.encoder;
|
package assemblyline.common.machine.encoder;
|
||||||
|
|
||||||
import dark.library.inv.SlotRestricted;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import assemblyline.common.AssemblyLine;
|
import assemblyline.common.AssemblyLine;
|
||||||
|
import dark.library.inv.SlotRestricted;
|
||||||
|
|
||||||
public class ContainerEncoder extends Container
|
public class ContainerEncoder extends Container
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue