started working on GUI for filterable blocks

This commit is contained in:
DarkGuardsman 2013-11-19 17:38:28 -05:00
parent d3928cff1a
commit aff4a8b6cd
4 changed files with 72 additions and 14 deletions

View file

@ -25,6 +25,7 @@ public class CommonProxy implements IGuiHandler
public static final int GUI_ENCODER_CODE = 3;
public static final int GUI_ENCODER_HELP = 4;
public static final int GUI_PROCESSOR = 5;
public static final int GUI_MANIPULATOR = 6;
public void preInit()
{
@ -107,7 +108,9 @@ public class CommonProxy implements IGuiHandler
switch (ID)
{
case GUI_IMPRINTER:
{
return new ContainerImprinter(player.inventory, (TileEntityImprinter) tileEntity);
}
case GUI_ENCODER:
{
if (tileEntity != null && tileEntity instanceof TileEntityEncoder)
@ -119,6 +122,10 @@ public class CommonProxy implements IGuiHandler
{
return new ContainerProcessor(player.inventory, (TileEntityProcessor) tileEntity);
}
case GUI_MANIPULATOR:
{
return new ContainerProcessor(player.inventory, (TileEntityProcessor) tileEntity);
}
}
}

View file

@ -12,13 +12,15 @@ import dark.assembly.machine.TileEntityAssembly;
public abstract class TileEntityFilterable extends TileEntityAssembly implements IRotatable, IFilterable
{
private ItemStack filterItem;
private boolean inverted;
public static final int FILTER_SLOT = 0;
public static final int BATERY_DRAIN_SLOT = 1;
public TileEntityFilterable()
{
super(0f);
this.invSlots = 2;
}
public TileEntityFilterable(float wattsPerTick, float maxEnergy)
@ -100,13 +102,6 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
NBTTagCompound filter = new NBTTagCompound();
if (getFilter() != null)
{
getFilter().writeToNBT(filter);
}
nbt.setTag("filter", filter);
nbt.setBoolean("inverted", inverted);
}
@ -114,10 +109,11 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
if (nbt.hasKey("filter"))
{
this.getInventory().setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("filter")));
}
inverted = nbt.getBoolean("inverted");
NBTTagCompound filter = nbt.getCompoundTag("filter");
this.filterItem = ItemStack.loadItemStackFromNBT(filter);
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dark.assembly.CommonProxy;
import dark.assembly.client.render.BlockRenderingHandler;
import dark.assembly.client.render.RenderManipulator;
import dark.assembly.client.render.RenderRejector;
@ -20,14 +21,15 @@ import dark.assembly.imprinter.prefab.BlockImprintable;
import dark.core.registration.ModObjectRegistry.BlockBuildData;
/** A block that manipulates item movement between inventories.
*
* @author Calclavia */
*
* @author Calclavia, DarkGuardsman */
public class BlockManipulator extends BlockImprintable
{
public BlockManipulator()
{
super(new BlockBuildData(BlockManipulator.class, "manipulator", UniversalElectricity.machine));
this.setBlockBounds(0, 0, 0, 1, 0.29f, 1);
this.guiID = CommonProxy.GUI_MANIPULATOR;
}
@Override
@ -84,7 +86,7 @@ public class BlockManipulator extends BlockImprintable
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void getClientTileEntityRenderers(List<Pair<Class<? extends TileEntity>, TileEntitySpecialRenderer>> list)

View file

@ -0,0 +1,53 @@
package dark.assembly.machine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import dark.assembly.imprinter.prefab.TileEntityFilterable;
public class ContainerFilter extends Container
{
private TileEntityFilterable tileEntity;
public ContainerFilter(InventoryPlayer playerInv, TileEntityFilterable tile)
{
this.tileEntity = tile;
this.addSlotToContainer(new Slot(tile, TileEntityFilterable.FILTER_SLOT, 37, 25));
this.addSlotToContainer(new Slot(tile, TileEntityFilterable.BATERY_DRAIN_SLOT, 144, 43));
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
}
}
@Override
public void addCraftingToCrafters(ICrafting par1ICrafting)
{
super.addCraftingToCrafters(par1ICrafting);
}
@Override
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
return null;
}
}