Started adding the programmer for the arm (it and disks need textures!)

This commit is contained in:
Brian Ricketts 2012-12-30 15:43:13 -06:00
parent 0ec1fd449d
commit 433b06ea55
11 changed files with 531 additions and 0 deletions

View file

@ -8,6 +8,7 @@ assemblyline.gui.crafting=Crafting
tile.crate.name=Crate
tile.conveyorBelt.name=Conveyor Belt
tile.imprinter.name=Imprinter
tile.programmer.name=Programmer
tile.engineerTable.name=Engineer's Table
tile.detector.name=Detector
tile.armbot.name=Armbot
@ -16,4 +17,5 @@ tile.rejector.name=Rejector
# Items
item.imprint.name=Imprint
item.disk.name=Disk
item.blueprint.name=Blueprint

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View file

@ -7,6 +7,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.gui.GuiImprinter;
import assemblyline.client.gui.GuiProgrammer;
import assemblyline.client.render.BlockRenderingHandler;
import assemblyline.client.render.RenderConveyorBelt;
import assemblyline.client.render.RenderCrate;
@ -54,6 +55,8 @@ public class ClientProxy extends CommonProxy
{
case GUI_STAMPER:
return new GuiImprinter(player.inventory, world, new Vector3(x, y, z));
case GUI_PROGRAMMER:
return new GuiProgrammer(player.inventory, world, new Vector3(x, y, z));
}
return null;

View file

@ -0,0 +1,46 @@
package assemblyline.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.programmer.ContainerProgrammer;
public class GuiProgrammer extends GuiContainer
{
private int containerWidth;
private int containerHeight;
public GuiProgrammer(InventoryPlayer par1InventoryPlayer, World worldObj, Vector3 position)
{
super(new ContainerProgrammer(par1InventoryPlayer, worldObj, position));
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRenderer.drawString(TranslationHelper.getLocal("tile.programmer.name"), 68, 6, 4210752);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "gui_programmer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
containerWidth = (this.width - this.xSize) / 2;
containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -22,6 +22,8 @@ import assemblyline.common.machine.detector.BlockDetector;
import assemblyline.common.machine.imprinter.BlockImprinter;
import assemblyline.common.machine.imprinter.ItemImprinter;
import assemblyline.common.machine.machine.BlockRejector;
import assemblyline.common.machine.programmer.BlockProgrammer;
import assemblyline.common.machine.programmer.ItemDisk;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
@ -67,11 +69,13 @@ public class AssemblyLine
public static Block blockEncoder;
public static Block blockCrate;
public static Block blockImprinter;
public static Block blockProgrammer;
public static Block blockDetector;
public static Block blockRejector;
public static final int ITEM_ID_PREFIX = 3030;
public static Item itemImprint;
public static Item itemDisk;
@PreInit
public void preInit(FMLPreInitializationEvent event)
@ -87,8 +91,10 @@ public class AssemblyLine
blockImprinter = new BlockImprinter(CONFIGURATION.getBlock("Imprinter", BLOCK_ID_PREFIX + 4).getInt(), 0);
blockDetector = new BlockDetector(CONFIGURATION.getBlock("Detector", BLOCK_ID_PREFIX + 5).getInt(), 1);
blockRejector = new BlockRejector(CONFIGURATION.getBlock("Rejector", BLOCK_ID_PREFIX + 6).getInt());
blockProgrammer = new BlockProgrammer(CONFIGURATION.getBlock("Programmer", BLOCK_ID_PREFIX + 7).getInt(), 0);
itemImprint = new ItemImprinter(CONFIGURATION.getBlock("Imprint", ITEM_ID_PREFIX).getInt());
itemDisk = new ItemDisk(CONFIGURATION.getBlock("Disk", ITEM_ID_PREFIX + 1).getInt());
CONFIGURATION.save();
NetworkRegistry.instance().registerGuiHandler(this, this.proxy);
@ -97,6 +103,7 @@ public class AssemblyLine
GameRegistry.registerBlock(blockManipulator, "Manipulator");
// GameRegistry.registerBlock(blockEncoder, "Encoder");
GameRegistry.registerBlock(blockImprinter, "Imprinter");
GameRegistry.registerBlock(blockProgrammer, "Programmer");
GameRegistry.registerBlock(blockDetector, "Detector");
GameRegistry.registerBlock(blockRejector, "Rejector");

View file

@ -10,6 +10,7 @@ import assemblyline.common.machine.TileEntityRejector;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import assemblyline.common.machine.detector.TileEntityDetector;
import assemblyline.common.machine.imprinter.ContainerImprinter;
import assemblyline.common.machine.programmer.ContainerProgrammer;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
@ -17,6 +18,7 @@ public class CommonProxy implements IGuiHandler
{
public static final int GUI_STAMPER = 1;
public static final int GUI_ARCHITECHT_TABLE = 2;
public static final int GUI_PROGRAMMER = 3;
public void preInit()
{
@ -41,6 +43,8 @@ public class CommonProxy implements IGuiHandler
{
case GUI_STAMPER:
return new ContainerImprinter(player.inventory, world, new Vector3(x, y, z));
case GUI_PROGRAMMER:
return new ContainerProgrammer(player.inventory, world, new Vector3(x, y, z));
}
return null;

View file

@ -0,0 +1,54 @@
package assemblyline.common.machine.programmer;
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 BlockProgrammer extends BlockMachine
{
public BlockProgrammer(int id, int texture)
{
super(id, Material.wood);
this.blockIndexInTexture = 4;
this.setBlockName("programmer");
this.setCreativeTab(UETab.INSTANCE);
this.setTextureFile(AssemblyLine.BLOCK_TEXTURE_PATH);
}
/**
* Returns the block texture based on the side being looked at. Args: side
*/
public int getBlockTextureFromSide(int side)
{
if (side == 0)
{
return this.blockIndexInTexture;
}
else if (side == 1) { return this.blockIndexInTexture + 1;
}
return this.blockIndexInTexture + 2;
}
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
{
if (!world.isRemote)
{
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_PROGRAMMER, world, x, y, z);
}
return true;
}
}

View file

@ -0,0 +1,262 @@
package assemblyline.common.machine.programmer;
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.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ContainerProgrammer extends Container implements IInventory
{
private ItemStack[] containingItems = new ItemStack[3];
private World worldObj;
private Vector3 position;
private InventoryPlayer inventoryPlayer;
public ContainerProgrammer(InventoryPlayer inventoryPlayer, World worldObj, Vector3 position)
{
this.worldObj = worldObj;
this.position = position;
this.inventoryPlayer = inventoryPlayer;
// Paper Input
this.addSlotToContainer(new SlotDisk(this, 0, 42, 24));
// Item Stamp
this.addSlotToContainer(new Slot(this, 1, 78, 24));
// Output Filter
this.addSlotToContainer(new SlotDiskResult(this, 2, 136, 24));
int var3;
for (var3 = 0; var3 < 3; ++var3)
{
for (int var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
}
}
for (var3 = 0; var3 < 9; ++var3)
{
this.addSlotToContainer(new Slot(inventoryPlayer, var3, 8 + var3 * 18, 142));
}
}
@Override
public void updateCraftingResults()
{
super.updateCraftingResults();
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return this.isUseableByPlayer(player);
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack copyStack = null;
Slot slotObj = (Slot) this.inventorySlots.get(slot);
if (slotObj != null && slotObj.getHasStack())
{
ItemStack slotStack = slotObj.getStack();
copyStack = slotStack.copy();
if (slot == 2)
{
setInventorySlotContents(0, null); // Prevents disk from being duplicated
}
if (slot > 2)
{
if (this.getSlot(0).isItemValid(slotStack))
{
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.containingItems.length, 37, false)) { return null; }
if (slotStack.stackSize == 0)
{
slotObj.putStack((ItemStack) null);
}
else
{
slotObj.onSlotChanged();
}
if (slotStack.stackSize == copyStack.stackSize) { return null; }
slotObj.onPickupFromSlot(player, slotStack);
}
onInventoryChanged();
return copyStack;
}
@Override
public int getSizeInventory()
{
return this.containingItems.length;
}
@Override
public ItemStack getStackInSlot(int slot)
{
return this.containingItems[slot];
}
/**
* 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 slot, int amount)
{
if (this.containingItems[slot] != null)
{
ItemStack var3 = this.containingItems[slot];
this.containingItems[slot] = 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 slot)
{
if (this.containingItems[slot] != null && slot != 2)
{
ItemStack var2 = this.containingItems[slot];
this.containingItems[slot] = 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)
{
if (par1 < this.containingItems.length)
{
this.containingItems[par1] = par2ItemStack;
}
}
@Override
public String getInvName()
{
return "Programmer";
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public void onInventoryChanged()
{
/**
* Makes the stamping recipe for disks
*/
boolean didStamp = false;
if (this.getStackInSlot(0) != null && this.getStackInSlot(1) != null)
{
if (this.getStackInSlot(0).getItem() instanceof ItemDisk)
{
ItemStack outputStack = this.getStackInSlot(0).copy();
outputStack.stackSize = 1;
ArrayList<String> commands = ItemDisk.getCommands(outputStack);
boolean filteringItemExists = false;
for (String command : commands)
{
// remove commands
}
if (!filteringItemExists)
{
// add commands
}
ItemDisk.setCommands(outputStack, commands);
this.setInventorySlotContents(2, outputStack);
didStamp = true;
}
}
if (!didStamp)
{
this.setInventorySlotContents(2, null);
}
}
@Override
public boolean isUseableByPlayer(EntityPlayer player)
{
return true;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
@Override
public void onCraftGuiClosed(EntityPlayer player)
{
super.onCraftGuiClosed(player);
if (!this.worldObj.isRemote)
{
for (int slot = 0; slot < this.getSizeInventory(); ++slot)
{
ItemStack itemStack = this.getStackInSlotOnClosing(slot);
if (itemStack != null && slot != 4)
{
player.dropPlayerItem(itemStack);
}
}
}
}
}

View file

@ -0,0 +1,90 @@
package assemblyline.common.machine.programmer;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import universalelectricity.prefab.UETab;
import assemblyline.common.AssemblyLine;
public class ItemDisk extends Item
{
public ItemDisk(int id)
{
super(id);
this.setItemName("disk");
this.setIconIndex(1);
this.setCreativeTab(UETab.INSTANCE);
this.setHasSubtypes(true);
this.setTextureFile(AssemblyLine.ITEM_TEXTURE_PATH);
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4)
{
List<String> commands = getCommands(itemStack);
if (commands.size() > 0)
{
for (String command : commands)
{
list.add(command);
}
}
else
{
list.add("No commands");
}
}
/**
* Saves the list of items to filter out inside.
*/
public static void setCommands(ItemStack itemStack, ArrayList<String> commands)
{
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagList nbt = new NBTTagList();
for (int i = 0; i < commands.size(); ++i)
{
if (commands.get(i) != null)
{
NBTTagCompound newCompound = new NBTTagCompound();
newCompound.setString("command", commands.get(i));
nbt.appendTag(newCompound);
}
}
itemStack.getTagCompound().setTag("Commands", nbt);
}
public static ArrayList<String> getCommands(ItemStack itemStack)
{
ArrayList<String> commands = new ArrayList<String>();
if (itemStack.getTagCompound() == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound nbt = itemStack.getTagCompound();
NBTTagList tagList = nbt.getTagList("Commands");
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound curTag = (NBTTagCompound) tagList.tagAt(i);
String cmd = curTag.getString("command");
commands.add(cmd);
}
return commands;
}
}

View file

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

View file

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