Made stamp work, changed detector to a block

This commit is contained in:
Henry Mao 2012-12-27 17:28:28 +08:00
parent d4781ab3b0
commit e88d2d9ee3
17 changed files with 306 additions and 90 deletions

View file

@ -1 +1 @@
31
32

View file

@ -27,3 +27,4 @@ Minecraft 1.4.5
@ AssemblyLine_v0.1.8.29.jar AssemblyLine_v0.1.8.29_api.zip
* AssemblyLine_v0.1.8.30.jar AssemblyLine_v0.1.8.30_api.zip
@ AssemblyLine_v0.1.8.31.jar AssemblyLine_v0.1.8.31_api.zip
@ AssemblyLine_v0.1.9.32.jar AssemblyLine_v0.1.9.32_api.zip

View file

@ -4,7 +4,7 @@
# Blocks
tile.crate.name=Crate
tile.conveyorBelt.name=Conveyor Belt
tile.stamper.name=Filter Stamper
tile.stamper.name=Stamper
tile.engineerTable.name=Engineer's Table
tile.detector.name=Detector
tile.armbot.name=Armbot

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
resources/minecraft.jar.tmp Normal file

Binary file not shown.

View file

@ -5,8 +5,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.gui.GuiDetector;
import assemblyline.client.gui.GuiRejector;
import assemblyline.client.gui.GuiStamper;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.client.render.RenderConveyorBelt;
import assemblyline.client.render.RenderCrate;
@ -41,7 +43,6 @@ public class ClientProxy extends CommonProxy
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDetector.class, new RenderDetector());
}
@Override
@ -49,17 +50,14 @@ public class ClientProxy extends CommonProxy
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
switch (ID)
{
switch (ID)
{
case GUI_REJECTOR:
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_DETECTOR:
return new GuiDetector(player.inventory, ((TileEntityDetector) tileEntity));
}
case GUI_REJECTOR:
return new GuiRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new GuiStamper(player.inventory, world, new Vector3(x, y, z));
case GUI_DETECTOR:
return new GuiDetector(player.inventory, ((TileEntityDetector) tileEntity));
}
return null;

View file

@ -27,7 +27,7 @@ public class GuiStamper extends GuiContainer
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.stamper.name"), 55, 6, 4210752);
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.stamper.name"), 68, 6, 4210752);
}
/**
@ -36,7 +36,7 @@ public class GuiStamper extends GuiContainer
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_empty.png");
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_stamper.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;

View file

@ -88,7 +88,7 @@ public class AssemblyLine
blockEngineerTable = new BlockEngineerTable(CONFIGURATION.getBlock("Architect's Table", BLOCK_ID_PREFIX + 2).getInt());
blockCrate = new BlockCrate(CONFIGURATION.getBlock("Crate", BLOCK_ID_PREFIX + 3).getInt(), 0);
blockStamper = new BlockStamper(CONFIGURATION.getBlock("Stamper", BLOCK_ID_PREFIX + 4).getInt(), 0);
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt());
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt(), 1);
itemFilter = new ItemFilter(CONFIGURATION.getBlock("Filter", ITEM_ID_PREFIX).getInt());
CONFIGURATION.save();
@ -135,6 +135,15 @@ public class AssemblyLine
LanguageRegistry.addName(new ItemStack(blockMulti, 1, type.metadata), type.name);
}
// Filter
GameRegistry.addRecipe(new ShapedOreRecipe(itemFilter, new Object[] { "R", "P", "I", 'P', Item.paper, 'R', Item.redstone, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
// Stamper
GameRegistry.addRecipe(new ShapedOreRecipe(blockStamper, new Object[] { "SIS", "SPS", "WWW", 'S', "ingotSteel", 'W', Block.wood, 'P', Block.pistonStickyBase, 'I', new ItemStack(Item.dyePowder, 1, 0) }));
// Detector
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));
// Crate
GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "SPS", "P P", "SPS", 'P', "plateSteel", 'S', Item.stick }));

View file

@ -41,18 +41,15 @@ public class CommonProxy implements IGuiHandler
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
switch (ID)
{
switch (ID)
{
case GUI_REJECTOR:
return new ContainerRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new ContainerStamper(player.inventory, world, new Vector3(x, y, z));
case GUI_DETECTOR:
return new ContainerDetector(player.inventory, ((TileEntityDetector) tileEntity));
case GUI_REJECTOR:
return new ContainerRejector(player.inventory, ((TileEntityRejector) tileEntity));
case GUI_STAMPER:
return new ContainerStamper(player.inventory, world, new Vector3(x, y, z));
case GUI_DETECTOR:
return new ContainerDetector(player.inventory, ((TileEntityDetector) tileEntity));
}
}
return null;

View file

@ -27,10 +27,41 @@ public class BlockDetector extends BlockMachine
{
private Random random = new Random();
public BlockDetector(int blockID)
public BlockDetector(int blockID, int texture)
{
super("detector", blockID, UniversalElectricity.machine, UETab.INSTANCE);
this.setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.75f, 0.75f);
this.blockIndexInTexture = texture;
}
@Override
public int getBlockTexture(IBlockAccess iBlockAccess, int x, int y, int z, int side)
{
TileEntity tileEntity = iBlockAccess.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEntityDetector)
{
if (side == ForgeDirection.DOWN.ordinal())
{
if (((TileEntityDetector) tileEntity).isInverted())
{
return this.blockIndexInTexture + 2;
}
else
{
return this.blockIndexInTexture + 1;
}
}
}
return this.blockIndexInTexture;
}
@Override
public int getBlockTextureFromSideAndMetadata(int side, int metadata)
{
if (side == ForgeDirection.DOWN.ordinal()) { return this.blockIndexInTexture + 1; }
return this.blockIndexInTexture;
}
@Override
@ -66,14 +97,6 @@ public class BlockDetector extends BlockMachine
return true;
}
/*
* @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entity)
* { if (entity instanceof EntityPlayer) { world.notifyBlocksOfNeighborChange(x + 1, y, z,
* blockID); world.notifyBlocksOfNeighborChange(x - 1, y, z, blockID);
* world.notifyBlocksOfNeighborChange(x, y, z + 1, blockID);
* world.notifyBlocksOfNeighborChange(x, y, z - 1, blockID); } }
*/
@Override
public void breakBlock(World world, int x, int y, int z, int int1, int int2)
{
@ -129,42 +152,19 @@ public class BlockDetector extends BlockMachine
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1iBlockAccess, int par2, int par3, int par4)
{
setBlockBounds(0.25f, 0.25f, 0.25f, 0.75f, 0.75f, 0.75f);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side)
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.BLOCK_RENDER_ID;
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
onEntityCollidedWithBlock(world, x, y, z, entity);
}
/*
* @Override public boolean renderAsNormalBlock() { return false; }
*
* @SideOnly(Side.CLIENT)
*
* @Override public int getRenderType() { return BlockRenderingHandler.BLOCK_RENDER_ID; }
*/
@Override
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int direction)

View file

@ -4,9 +4,12 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import assemblyline.common.AssemblyLine;
import assemblyline.common.CommonProxy;
public class BlockStamper extends Block
public class BlockStamper extends BlockMachine
{
public BlockStamper(int id, int texture)
{
@ -27,17 +30,16 @@ public class BlockStamper extends Block
/**
* Called upon block activation (right click on the block.)
*/
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
{
if (par1World.isRemote)
if (!world.isRemote)
{
return true;
}
else
{
par5EntityPlayer.displayGUIWorkbench(par2, par3, par4);
return true;
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_STAMPER, world, x, y, z);
}
return true;
}
}

View file

@ -1,16 +1,19 @@
package assemblyline.common.machine.filter;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
public class ContainerStamper extends Container
public class ContainerStamper extends Container implements IInventory
{
private ItemStack[] containingItems = new ItemStack[3];
private World worldObj;
private Vector3 position;
@ -20,11 +23,11 @@ public class ContainerStamper extends Container
this.position = position;
// Paper Input
this.addSlotToContainer(new Slot(par1InventoryPlayer, 0, 33, 34));
this.addSlotToContainer(new SlotFilter(this, 0, 30, 35));
// Item Stamp
this.addSlotToContainer(new Slot(par1InventoryPlayer, 1, 33 + 18, 34));
this.addSlotToContainer(new Slot(this, 1, 66, 35));
// Output Filter
this.addSlotToContainer(new Slot(par1InventoryPlayer, 2, 33 + 36, 34));
this.addSlotToContainer(new SlotFilterResult(this, 2, 124, 35));
int var3;
@ -46,13 +49,39 @@ public class ContainerStamper extends Container
public void updateCraftingResults()
{
super.updateCraftingResults();
System.out.println("WORK");
if (this.getStackInSlot(0) != null && this.getStackInSlot(1) != null)
{
if (this.getStackInSlot(0).getItem() instanceof ItemFilter)
{
ItemStack outputStack = this.getStackInSlot(0).copy();
outputStack.stackSize = 1;
ArrayList<ItemStack> filters = ItemFilter.getFilters(outputStack);
for (ItemStack filteredStack : filters)
{
if (filteredStack.isItemEqual(this.getStackInSlot(1)))
{
this.setInventorySlotContents(2, null);
return;
}
}
filters.add(this.getStackInSlot(1));
ItemFilter.setFilters(outputStack, filters);
this.setInventorySlotContents(2, outputStack);
return;
}
}
this.setInventorySlotContents(2, null);
}
@Override
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
public boolean canInteractWith(EntityPlayer player)
{
return true;
return this.isUseableByPlayer(player);
}
/**
@ -69,13 +98,13 @@ public class ContainerStamper extends Container
ItemStack itemStack2 = itemStack.getStack();
itemStack3 = itemStack2.copy();
if (par1 != 0)
if (par1 > 2)
{
if (itemStack2.itemID == Item.coal.shiftedIndex)
if (this.getSlot(0).isItemValid(itemStack2))
{
if (!this.mergeItemStack(itemStack2, 0, 1, false)) { return null; }
}
else if (par1 >= 30 && par1 < 37 && !this.mergeItemStack(itemStack2, 3, 30, false)) { return null; }
else if (!this.mergeItemStack(itemStack2, 1, 2, false)) { return null; }
}
else if (!this.mergeItemStack(itemStack2, 3, 37, false)) { return null; }
@ -95,4 +124,117 @@ public class ContainerStamper extends Container
return itemStack3;
}
@Override
public int getSizeInventory()
{
return this.containingItems.length;
}
@Override
public ItemStack getStackInSlot(int par1)
{
return this.containingItems[par1];
}
/**
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and
* returns them in a new stack.
*/
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
return null;
}
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as
* an EntityItem - like when you close a workbench GUI.
*/
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null && par1 != 2)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor
* sections).
*/
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
}
@Override
public String getInvName()
{
return "Stamper";
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public void onInventoryChanged()
{
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
{
return true;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
@Override
public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
{
super.onCraftGuiClosed(par1EntityPlayer);
if (!this.worldObj.isRemote)
{
for (int i = 0; i < this.getSizeInventory(); ++i)
{
ItemStack itemStack = this.getStackInSlotOnClosing(i);
if (itemStack != null)
{
par1EntityPlayer.dropPlayerItem(itemStack);
}
}
}
}
}

View file

@ -32,7 +32,7 @@ public class ItemFilter extends Item
for (ItemStack filterItem : filterItems)
{
list.add(filterItem.getItemName());
list.add(filterItem.getDisplayName());
}
}
else
@ -44,7 +44,7 @@ public class ItemFilter extends Item
/**
* Saves the list of items to filter out inside.
*/
public static void setFilters(ItemStack itemStack, List<ItemStack> filterStacks)
public static void setFilters(ItemStack itemStack, ArrayList<ItemStack> filterStacks)
{
if (itemStack.getTagCompound() == null)
{
@ -67,9 +67,9 @@ public class ItemFilter extends Item
itemStack.getTagCompound().setTag("Items", nbt);
}
public static List<ItemStack> getFilters(ItemStack itemStack)
public static ArrayList<ItemStack> getFilters(ItemStack itemStack)
{
List<ItemStack> filterStacks = new ArrayList<ItemStack>();
ArrayList<ItemStack> filterStacks = new ArrayList<ItemStack>();
if (itemStack.getTagCompound() == null)
{

View file

@ -0,0 +1,22 @@
package assemblyline.common.machine.filter;
import assemblyline.common.AssemblyLine;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class SlotFilter extends Slot
{
public SlotFilter(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack itemStack)
{
return itemStack.itemID == AssemblyLine.itemFilter.shiftedIndex;
}
}

View file

@ -0,0 +1,45 @@
package assemblyline.common.machine.filter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotFilterResult extends Slot
{
public SlotFilterResult(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);
}
}*/
}
}