Moved some reusable files to Dark-Lib
These files can be used by other mods that use Dark-Library so i have moved them. If needed i can share these files, or if i can i'll make the Dark-Library public for use.
This commit is contained in:
parent
bf878681b2
commit
e3be6af826
12 changed files with 35 additions and 249 deletions
|
@ -1,50 +0,0 @@
|
|||
package assemblyline.client.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Copied from GSM lib and modified for this mod only
|
||||
*
|
||||
* @author Rseifert
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Deprecated
|
||||
public class GuiButtonImage extends GuiButton
|
||||
{
|
||||
private int type = 0;
|
||||
|
||||
public GuiButtonImage(int par1, int par2, int par3, int type)
|
||||
{
|
||||
super(par1, par2, par3, 12, 12, "");
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
*/
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int width, int hight)
|
||||
{
|
||||
if (this.drawButton)
|
||||
{
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/assemblyline/textures/gui@.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
|
||||
int var5 = 106;
|
||||
int var6 = 0;
|
||||
if (var4)
|
||||
{
|
||||
var5 += this.height;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, var6, var5, this.width, this.height);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,9 +27,9 @@ public class RenderCrate extends TileEntitySpecialRenderer
|
|||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||
{
|
||||
Vector3 vec = new Vector3(x,y,z);
|
||||
double distance = vec.distanceTo(new Vector3(0,0,0));
|
||||
if (tileEntity instanceof TileEntityCrate && distance < 15)
|
||||
Vector3 vec = new Vector3(x, y, z);
|
||||
double distance = vec.distanceTo(new Vector3(0, 0, 0));
|
||||
if (tileEntity instanceof TileEntityCrate && distance < 35)
|
||||
{
|
||||
TileEntityCrate tileCrate = (TileEntityCrate) tileEntity;
|
||||
|
||||
|
@ -133,8 +133,6 @@ public class RenderCrate extends TileEntitySpecialRenderer
|
|||
GL11.glPolygonOffset(-10, -10);
|
||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
float displayX = 1 / 16;
|
||||
float displayY = 1 / 16;
|
||||
float displayWidth = 1 - (2 / 16);
|
||||
float displayHeight = 1 - (2 / 16);
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
|
|
@ -187,7 +187,7 @@ public class AssemblyLine
|
|||
|
||||
this.createStandardRecipes();
|
||||
this.createUERecipes();
|
||||
if (PowerSystems.isPowerSystemLoaded(PowerSystems.INDUSTRIALCRAFT))
|
||||
if (PowerSystems.isPowerSystemLoaded(PowerSystems.INDUSTRIALCRAFT, true))
|
||||
{
|
||||
createIC2Recipes();
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package assemblyline.common;
|
||||
|
||||
public class Pair<L, R>
|
||||
{
|
||||
private final L left;
|
||||
private final R right;
|
||||
|
||||
public Pair(L left, R right)
|
||||
{
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public L getKey()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
public R getValue()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return left.hashCode() ^ right.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o == null)
|
||||
return false;
|
||||
if (!(o instanceof Pair))
|
||||
return false;
|
||||
Pair pairo = (Pair) o;
|
||||
return this.left.equals(pairo.getKey()) && this.right.equals(pairo.getValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
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.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -30,11 +34,11 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
}
|
||||
|
||||
// Imprint Input for Imprinting
|
||||
this.addSlotToContainer(new SlotCustom(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
|
||||
this.addSlotToContainer(new SlotRestricted(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START, 68, 34, new ItemStack(AssemblyLine.itemImprint)));
|
||||
// Item to be imprinted
|
||||
this.addSlotToContainer(new WatchedSlot(this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 1, 92, 34, this));
|
||||
// Result of Crafting/Imprinting
|
||||
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||
this.addSlotToContainer(new SlotCraftingResult(this.tileEntity, this, this.tileEntity, TileEntityImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||
|
||||
// Imprinter Inventory
|
||||
for (int ii = 0; ii < 2; ii++)
|
||||
|
@ -133,12 +137,12 @@ public class ContainerImprinter extends Container implements ISlotWatcher
|
|||
slotObj.onPickupFromSlot(player, slotStack);
|
||||
}
|
||||
|
||||
this.slotContentsChanged();
|
||||
this.slotContentsChanged(slot);
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slotContentsChanged()
|
||||
public void slotContentsChanged(int slot)
|
||||
{
|
||||
this.tileEntity.onInventoryChanged();
|
||||
this.detectAndSendChanges();
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package assemblyline.common.imprinter;
|
||||
|
||||
public interface ISlotWatcher
|
||||
{
|
||||
public void slotContentsChanged();
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package assemblyline.common.imprinter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotCraftingResult extends WatchedSlot
|
||||
{
|
||||
private ContainerImprinter container;
|
||||
|
||||
public SlotCraftingResult(ContainerImprinter container, IInventory inventory, int par2, int par3, int par4)
|
||||
{
|
||||
super(inventory, par2, par3, par4, container);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
{
|
||||
this.container.tileEntity.onPickUpFromResult(entityPlayer, itemStack);
|
||||
super.onPickupFromSlot(entityPlayer, itemStack);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package assemblyline.common.imprinter;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotCustom extends Slot
|
||||
{
|
||||
private ItemStack itemStack;
|
||||
|
||||
public SlotCustom(IInventory par1iInventory, int par2, int par3, int par4, ItemStack itemStack)
|
||||
{
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.isItemEqual(this.itemStack);
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package assemblyline.common.imprinter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotImprintResult extends Slot
|
||||
{
|
||||
|
||||
public SlotImprintResult(IInventory par1iInventory, int par2, int par3, int par4)
|
||||
{
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
{
|
||||
super.onPickupFromSlot(par1EntityPlayer, par2ItemStack);
|
||||
|
||||
if (this.inventory.getStackInSlot(0) != null)
|
||||
{
|
||||
this.inventory.getStackInSlot(0).stackSize--;
|
||||
if (this.inventory.getStackInSlot(0).stackSize <= 0)
|
||||
{
|
||||
this.inventory.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if (this.inventory.getStackInSlot(1) != null) {
|
||||
* this.inventory.getStackInSlot(1).stackSize--; if
|
||||
* (this.inventory.getStackInSlot(1).stackSize <= 1) {
|
||||
* this.inventory.setInventorySlotContents(1, null); } }
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -39,14 +39,15 @@ import universalelectricity.prefab.tile.TileEntityAdvanced;
|
|||
import assemblyline.api.IArmbot;
|
||||
import assemblyline.api.IArmbotUseable;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.Pair;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import dark.library.helpers.Pair;
|
||||
import dark.library.inv.ISlotPickResult;
|
||||
|
||||
public class TileEntityImprinter extends TileEntityAdvanced implements net.minecraftforge.common.ISidedInventory, ISidedInventory, IArmbotUseable, IPacketReceiver
|
||||
public class TileEntityImprinter extends TileEntityAdvanced implements net.minecraftforge.common.ISidedInventory, ISidedInventory, IArmbotUseable, IPacketReceiver, ISlotPickResult
|
||||
{
|
||||
public static final int IMPRINTER_MATRIX_START = 9;
|
||||
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
|
||||
|
@ -361,7 +362,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
}
|
||||
}
|
||||
|
||||
public void onPickUpFromResult(EntityPlayer entityPlayer, ItemStack itemStack)
|
||||
public void onPickUpFromSlot(EntityPlayer entityPlayer, int s, ItemStack itemStack)
|
||||
{
|
||||
|
||||
if (itemStack != null)
|
||||
|
@ -507,7 +508,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
*/
|
||||
public Pair<ItemStack, ItemStack[]> getIdealRecipe(ItemStack outputItem)
|
||||
{
|
||||
//System.out.println("IdealRecipe: Finding " + outputItem.toString());
|
||||
// System.out.println("IdealRecipe: Finding " + outputItem.toString());
|
||||
for (Object object : CraftingManager.getInstance().getRecipeList())
|
||||
{
|
||||
if (object instanceof IRecipe)
|
||||
|
@ -516,12 +517,12 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
{
|
||||
if (this.areStacksEqual(outputItem, ((IRecipe) object).getRecipeOutput()))
|
||||
{
|
||||
//System.out.println("IdealRecipe: Output Match Found");
|
||||
// System.out.println("IdealRecipe: Output Match Found");
|
||||
if (object instanceof ShapedRecipes)
|
||||
{
|
||||
if (this.hasResource(((ShapedRecipes) object).recipeItems) != null)
|
||||
{
|
||||
//System.out.println("IdealRecipe: Shaped Recipe Found");
|
||||
// System.out.println("IdealRecipe: Shaped Recipe Found");
|
||||
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), ((ShapedRecipes) object).recipeItems);
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +530,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
{
|
||||
if (this.hasResource(((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1])) != null)
|
||||
{
|
||||
//System.out.println("IdealRecipe: Shapeless Recipe Found");
|
||||
// System.out.println("IdealRecipe: Shapeless Recipe Found");
|
||||
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), (ItemStack[]) ((ShapelessRecipes) object).recipeItems.toArray(new ItemStack[1]));
|
||||
}
|
||||
}
|
||||
|
@ -542,7 +543,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
|
||||
if (hasResources != null)
|
||||
{
|
||||
//System.out.println("IdealRecipe: ShapedOre Recipe Found");
|
||||
// System.out.println("IdealRecipe: ShapedOre Recipe Found");
|
||||
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +556,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
|
||||
if (hasResources != null)
|
||||
{
|
||||
//System.out.println("IdealRecipe: ShapelessOre Recipe Found");
|
||||
// System.out.println("IdealRecipe: ShapelessOre Recipe Found");
|
||||
return new Pair<ItemStack, ItemStack[]>(((IRecipe) object).getRecipeOutput().copy(), hasResources.toArray(new ItemStack[1]));
|
||||
}
|
||||
}
|
||||
|
@ -584,10 +585,10 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
this.writeToNBT(cloneData);
|
||||
dummyImprinter.readFromNBT(cloneData);
|
||||
|
||||
//System.out.println("ResourceChecker: Looking for items");
|
||||
// System.out.println("ResourceChecker: Looking for items");
|
||||
for (int i = 0; i < recipeItems.length; i++)
|
||||
{
|
||||
//System.out.println("ResourceChecker: Looking for " + recipeItems.toString());
|
||||
// System.out.println("ResourceChecker: Looking for " + recipeItems.toString());
|
||||
}
|
||||
/**
|
||||
* The actual amount of resource required. Each ItemStack will only have stacksize of 1.
|
||||
|
@ -649,13 +650,15 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("ResourceChecker: Item0" + w + " = null");
|
||||
// System.out.println("ResourceChecker: Item0" + w + " = null");
|
||||
itemMatch++;
|
||||
}
|
||||
}
|
||||
boolean resourcesFound = itemMatch >= actualResources.size();
|
||||
//System.out.println("ResourceChecker: Found " + actualResources.size() + " Items and " + itemMatch + " slot matches");
|
||||
//System.out.println("ResourceChecker: has all resources been found? /n A: " + resourcesFound);
|
||||
// System.out.println("ResourceChecker: Found " + actualResources.size() + " Items and "
|
||||
// + itemMatch + " slot matches");
|
||||
// System.out.println("ResourceChecker: has all resources been found? /n A: " +
|
||||
// resourcesFound);
|
||||
return resourcesFound ? actualResources : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -674,7 +677,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
{
|
||||
return true;
|
||||
}
|
||||
//System.out.println("ResourceChecker: Checking inv for item " + recipeItem.toString());
|
||||
// System.out.println("ResourceChecker: Checking inv for item " + recipeItem.toString());
|
||||
for (int i = 0; i < dummyImprinter.containingItems.length; i++)
|
||||
{
|
||||
ItemStack checkStack = dummyImprinter.containingItems[i];
|
||||
|
@ -687,7 +690,8 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
{
|
||||
// TODO Do NBT Checking
|
||||
dummyImprinter.decrStackSize(i + INVENTORY_START, 1);
|
||||
//System.out.println("ResourceChecker: Found matching item " + checkStack.toString());
|
||||
// System.out.println("ResourceChecker: Found matching item " +
|
||||
// checkStack.toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -840,7 +844,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements net.minec
|
|||
if (this.imprinterMatrix[2] != null)
|
||||
{
|
||||
armbot.grabItem(this.imprinterMatrix[2].copy());
|
||||
this.onPickUpFromResult(null, this.imprinterMatrix[2]);
|
||||
this.onPickUpFromSlot(null, 2, this.imprinterMatrix[2]);
|
||||
this.imprinterMatrix[2] = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package assemblyline.common.imprinter;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class WatchedSlot extends Slot
|
||||
{
|
||||
private ISlotWatcher slotWatcher;
|
||||
|
||||
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher)
|
||||
{
|
||||
super(inventory, id, xPosition, yPosition);
|
||||
this.slotWatcher = slotWatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if (this.slotWatcher != null)
|
||||
{
|
||||
this.slotWatcher.slotContentsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package assemblyline.common.machine.encoder;
|
||||
|
||||
import dark.library.inv.SlotRestricted;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.imprinter.SlotCustom;
|
||||
|
||||
public class ContainerEncoder extends Container
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ public class ContainerEncoder extends Container
|
|||
this.tileEntity = encoder;
|
||||
|
||||
// Disk
|
||||
this.addSlotToContainer(new SlotCustom(encoder, 0, 80, 24 + Y_OFFSET, new ItemStack(AssemblyLine.itemDisk)));
|
||||
this.addSlotToContainer(new SlotRestricted(encoder, 0, 80, 24 + Y_OFFSET, new ItemStack(AssemblyLine.itemDisk)));
|
||||
|
||||
int var3;
|
||||
|
||||
|
|
Loading…
Reference in a new issue