More work on the imprinter

This commit is contained in:
Henry Mao 2013-01-12 22:22:08 +08:00
parent 899aaa0c52
commit 09f519ede1
10 changed files with 52 additions and 38 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -52,7 +52,7 @@ public class GuiEncoder extends GuiContainer implements IInventoryWatcher
public GuiEncoder(InventoryPlayer playerInventory, TileEntityEncoder tileEntity) public GuiEncoder(InventoryPlayer playerInventory, TileEntityEncoder tileEntity)
{ {
super(new ContainerEncoder(playerInventory, tileEntity)); super(new ContainerEncoder(playerInventory, tileEntity));
this.ySize = 256; this.ySize = 237;
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
tileEntity.setWatcher(this); tileEntity.setWatcher(this);
} }
@ -89,7 +89,6 @@ public class GuiEncoder extends GuiContainer implements IInventoryWatcher
protected void actionPerformed(GuiButton button) protected void actionPerformed(GuiButton button)
{ {
// TODO: Add insert command to allow commands to be inserted between two existing commands. // TODO: Add insert command to allow commands to be inserted between two existing commands.
switch (button.id) switch (button.id)
{ {
case 0: // add case 0: // add

View file

@ -18,6 +18,7 @@ public class GuiImprinter extends GuiContainer
public GuiImprinter(InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity) public GuiImprinter(InventoryPlayer par1InventoryPlayer, TileEntityImprinter tileEntity)
{ {
super(new ContainerImprinter(par1InventoryPlayer, tileEntity)); super(new ContainerImprinter(par1InventoryPlayer, tileEntity));
this.ySize = 184;
} }
/** /**
@ -27,7 +28,7 @@ public class GuiImprinter extends GuiContainer
protected void drawGuiContainerForegroundLayer(int par1, int par2) protected void drawGuiContainerForegroundLayer(int par1, int par2)
{ {
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 4210752); this.fontRenderer.drawString(TranslationHelper.getLocal("tile.imprinter.name"), 68, 6, 4210752);
this.fontRenderer.drawString(TranslationHelper.getLocal("assemblyline.gui.crafting") + ":", 25, 55, 4210752); this.fontRenderer.drawString(TranslationHelper.getLocal("assemblyline.gui.crafting") + ":", 20, 54, 4210752);
} }
/** /**
@ -36,11 +37,11 @@ public class GuiImprinter extends GuiContainer
@Override @Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{ {
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_stamper.png"); int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_imprinter.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4); this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2; this.containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2; this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
} }
} }

View file

@ -1,8 +1,11 @@
package assemblyline.common.machine; package assemblyline.common.machine;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity; import universalelectricity.core.UniversalElectricity;
import assemblyline.client.render.BlockRenderingHandler; import assemblyline.client.render.BlockRenderingHandler;
@ -101,4 +104,10 @@ public class BlockManipulator extends BlockImprintable
{ {
return false; return false;
} }
@Override
public int damageDropped(int par1)
{
return 0;
}
} }

View file

@ -13,12 +13,13 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRedstoneReceptor; import universalelectricity.prefab.implement.IRedstoneReceptor;
import universalelectricity.prefab.implement.IRotatable;
import universalelectricity.prefab.network.PacketManager; import universalelectricity.prefab.network.PacketManager;
import assemblyline.api.IManipulator; import assemblyline.api.IManipulator;
import assemblyline.common.machine.imprinter.TileEntityFilterable; import assemblyline.common.machine.imprinter.TileEntityFilterable;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
public class TileEntityManipulator extends TileEntityFilterable implements IRedstoneReceptor, IManipulator public class TileEntityManipulator extends TileEntityFilterable implements IRotatable, IRedstoneReceptor, IManipulator
{ {
public boolean selfPulse = false; public boolean selfPulse = false;
@ -100,7 +101,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
outputDown.modifyPositionFromSide(ForgeDirection.DOWN); outputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 outputPosition = new Vector3(this); Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite()); outputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1); AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1);
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds); List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
@ -126,7 +127,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
if (remainingStack != null) if (remainingStack != null)
{ {
remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getBeltDirection().getOpposite()); remainingStack = this.tryPlaceInPosition(remainingStack, outputPosition, this.getDirection().getOpposite());
} }
if (remainingStack != null && remainingStack.stackSize > 0) if (remainingStack != null && remainingStack.stackSize > 0)
@ -154,10 +155,10 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
inputDown.modifyPositionFromSide(ForgeDirection.DOWN); inputDown.modifyPositionFromSide(ForgeDirection.DOWN);
Vector3 inputPosition = new Vector3(this); Vector3 inputPosition = new Vector3(this);
inputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite()); inputPosition.modifyPositionFromSide(this.getDirection().getOpposite());
Vector3 outputPosition = new Vector3(this); Vector3 outputPosition = new Vector3(this);
outputPosition.modifyPositionFromSide(this.getBeltDirection()); outputPosition.modifyPositionFromSide(this.getDirection());
ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN); ItemStack itemStack = this.tryGrabFromPosition(inputUp, ForgeDirection.DOWN);
@ -168,7 +169,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
if (itemStack == null) if (itemStack == null)
{ {
itemStack = this.tryGrabFromPosition(inputPosition, this.getBeltDirection().getOpposite()); itemStack = this.tryGrabFromPosition(inputPosition, this.getDirection().getOpposite());
} }
if (itemStack != null) if (itemStack != null)
@ -205,7 +206,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionZ = 0; entityItem.motionZ = 0;
entityItem.motionY /= 5; entityItem.motionY /= 5;
entityItem.delayBeforeCanPickup = 30; entityItem.delayBeforeCanPickup = 20;
worldObj.spawnEntityInWorld(entityItem); worldObj.spawnEntityInWorld(entityItem);
} }
@ -423,11 +424,6 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
return null; return null;
} }
public ForgeDirection getBeltDirection()
{
return ForgeDirection.getOrientation(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord));
}
@Override @Override
public void readFromNBT(NBTTagCompound nbt) public void readFromNBT(NBTTagCompound nbt)
{ {

View file

@ -10,7 +10,7 @@ import assemblyline.common.machine.imprinter.SlotCustom;
public class ContainerEncoder extends Container public class ContainerEncoder extends Container
{ {
public static final int Y_OFFSET = 9; public static final int Y_OFFSET = 0;
private ItemStack[] containingItems = new ItemStack[1]; private ItemStack[] containingItems = new ItemStack[1];
private InventoryPlayer inventoryPlayer; private InventoryPlayer inventoryPlayer;

View file

@ -29,29 +29,36 @@ public class ContainerImprinter extends Container implements ISlotWatcher
this.inventoryPlayer = inventoryPlayer; this.inventoryPlayer = inventoryPlayer;
// Paper Input // Paper Input
this.addSlotToContainer(new SlotCustom(this.tileEntity, 0, 42, 24, new ItemStack(AssemblyLine.itemImprint))); this.addSlotToContainer(new SlotCustom(this.tileEntity, 0, 33, 22, new ItemStack(AssemblyLine.itemImprint)));
// Item Stamp // Item Stamp
this.addSlotToContainer(new Slot(this.tileEntity, 1, 78, 24)); this.addSlotToContainer(new Slot(this.tileEntity, 1, 69, 22));
// Output Filter // Output Filter
this.addSlotToContainer(new SlotImprintResult(this.tileEntity, 2, 136, 24)); this.addSlotToContainer(new SlotImprintResult(this.tileEntity, 2, 127, 22));
// Crafting Slot // Crafting Slot
this.addSlotToContainer(new SlotCustom(this.tileEntity, 3, 78, 53, new ItemStack(AssemblyLine.itemImprint))); this.addSlotToContainer(new SlotCustom(this.tileEntity, 3, 69, 51, new ItemStack(AssemblyLine.itemImprint)));
// Crafting Output // Crafting Output
this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, 4, 136, 53)); this.addSlotToContainer(new SlotCraftingResult(this, this.tileEntity, 4, 127, 51));
// Imprinter Inventory
for (int i = 0; i < 9; i++)
{
this.addSlotToContainer(new WatchedSlot(this.tileEntity, i + TileEntityImprinter.START_INVENTORY, 8 + i * 18, 80, this));
}
// Player Inventory
int var3; int var3;
for (var3 = 0; var3 < 3; ++var3) for (var3 = 0; var3 < 3; ++var3)
{ {
for (int var4 = 0; var4 < 9; ++var4) for (int var4 = 0; var4 < 9; ++var4)
{ {
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18, this)); this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 102 + var3 * 18, this));
} }
} }
for (var3 = 0; var3 < 9; ++var3) for (var3 = 0; var3 < 9; ++var3)
{ {
this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var3, 8 + var3 * 18, 142, this)); this.addSlotToContainer(new WatchedSlot(inventoryPlayer, var3, 8 + var3 * 18, 160, this));
} }
} }
@ -81,19 +88,19 @@ public class ContainerImprinter extends Container implements ISlotWatcher
this.tileEntity.setInventorySlotContents(0, null); this.tileEntity.setInventorySlotContents(0, null);
} }
if (slot > 4) if (slot > this.tileEntity.getSizeInventory())
{ {
if (this.getSlot(0).isItemValid(slotStack)) if (this.getSlot(0).isItemValid(slotStack))
{ {
if (!this.mergeItemStack(slotStack, 0, 1, false)) { return null; } if (!this.mergeItemStack(slotStack, 0, 1, false)) { return null; }
} }
else if (!this.mergeItemStack(slotStack, 1, 2, false)) { return null; } else if (!this.mergeItemStack(slotStack, this.tileEntity.START_INVENTORY, this.tileEntity.getSizeInventory(), false)) { return null; }
} }
else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), 37, false)) { return null; } else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) { return null; }
if (slotStack.stackSize == 0) if (slotStack.stackSize == 0)
{ {
slotObj.putStack((ItemStack) null); slotObj.putStack(null);
} }
else else
{ {

View file

@ -22,12 +22,13 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInventory public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInventory
{ {
public static final int START_INVENTORY = 5;
public static final int INVENTORY_LENGTH = 9;
/** /**
* Imprinter slots. 10 extra slots for storing imprints. * Imprinter slots. 10 extra slots for storing imprints.
*/ */
private ItemStack[] containingItems = new ItemStack[5 + 10]; private ItemStack[] containingItems = new ItemStack[5 + INVENTORY_LENGTH];
public static final int START_INVENTORY = 5;
@Override @Override
public boolean canUpdate() public boolean canUpdate()
@ -39,13 +40,14 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
public int getStartInventorySide(ForgeDirection side) public int getStartInventorySide(ForgeDirection side)
{ {
if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 3; } if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 3; }
return 4; return START_INVENTORY;
} }
@Override @Override
public int getSizeInventorySide(ForgeDirection side) public int getSizeInventorySide(ForgeDirection side)
{ {
return 1; if (side == ForgeDirection.UP || side == ForgeDirection.DOWN) { return 1; }
return INVENTORY_LENGTH;
} }
@Override @Override

View file

@ -5,7 +5,7 @@ import net.minecraft.inventory.Slot;
public class WatchedSlot extends Slot public class WatchedSlot extends Slot
{ {
ISlotWatcher slotWatcher; private ISlotWatcher slotWatcher;
public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher) public WatchedSlot(IInventory inventory, int id, int xPosition, int yPosition, ISlotWatcher slotWatcher)
{ {
@ -16,9 +16,9 @@ public class WatchedSlot extends Slot
@Override @Override
public void onSlotChanged() public void onSlotChanged()
{ {
if (slotWatcher != null) if (this.slotWatcher != null)
{ {
slotWatcher.slotContentsChanged(); this.slotWatcher.slotContentsChanged();
} }
} }