started working on GUI for filterable blocks
This commit is contained in:
parent
d3928cff1a
commit
aff4a8b6cd
4 changed files with 72 additions and 14 deletions
|
@ -25,6 +25,7 @@ public class CommonProxy implements IGuiHandler
|
||||||
public static final int GUI_ENCODER_CODE = 3;
|
public static final int GUI_ENCODER_CODE = 3;
|
||||||
public static final int GUI_ENCODER_HELP = 4;
|
public static final int GUI_ENCODER_HELP = 4;
|
||||||
public static final int GUI_PROCESSOR = 5;
|
public static final int GUI_PROCESSOR = 5;
|
||||||
|
public static final int GUI_MANIPULATOR = 6;
|
||||||
|
|
||||||
public void preInit()
|
public void preInit()
|
||||||
{
|
{
|
||||||
|
@ -107,7 +108,9 @@ public class CommonProxy implements IGuiHandler
|
||||||
switch (ID)
|
switch (ID)
|
||||||
{
|
{
|
||||||
case GUI_IMPRINTER:
|
case GUI_IMPRINTER:
|
||||||
|
{
|
||||||
return new ContainerImprinter(player.inventory, (TileEntityImprinter) tileEntity);
|
return new ContainerImprinter(player.inventory, (TileEntityImprinter) tileEntity);
|
||||||
|
}
|
||||||
case GUI_ENCODER:
|
case GUI_ENCODER:
|
||||||
{
|
{
|
||||||
if (tileEntity != null && tileEntity instanceof TileEntityEncoder)
|
if (tileEntity != null && tileEntity instanceof TileEntityEncoder)
|
||||||
|
@ -119,6 +122,10 @@ public class CommonProxy implements IGuiHandler
|
||||||
{
|
{
|
||||||
return new ContainerProcessor(player.inventory, (TileEntityProcessor) tileEntity);
|
return new ContainerProcessor(player.inventory, (TileEntityProcessor) tileEntity);
|
||||||
}
|
}
|
||||||
|
case GUI_MANIPULATOR:
|
||||||
|
{
|
||||||
|
return new ContainerProcessor(player.inventory, (TileEntityProcessor) tileEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,15 @@ import dark.assembly.machine.TileEntityAssembly;
|
||||||
|
|
||||||
public abstract class TileEntityFilterable extends TileEntityAssembly implements IRotatable, IFilterable
|
public abstract class TileEntityFilterable extends TileEntityAssembly implements IRotatable, IFilterable
|
||||||
{
|
{
|
||||||
|
|
||||||
private ItemStack filterItem;
|
private ItemStack filterItem;
|
||||||
private boolean inverted;
|
private boolean inverted;
|
||||||
|
public static final int FILTER_SLOT = 0;
|
||||||
|
public static final int BATERY_DRAIN_SLOT = 1;
|
||||||
|
|
||||||
public TileEntityFilterable()
|
public TileEntityFilterable()
|
||||||
{
|
{
|
||||||
super(0f);
|
super(0f);
|
||||||
|
this.invSlots = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileEntityFilterable(float wattsPerTick, float maxEnergy)
|
public TileEntityFilterable(float wattsPerTick, float maxEnergy)
|
||||||
|
@ -100,13 +102,6 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
NBTTagCompound filter = new NBTTagCompound();
|
|
||||||
if (getFilter() != null)
|
|
||||||
{
|
|
||||||
getFilter().writeToNBT(filter);
|
|
||||||
}
|
|
||||||
nbt.setTag("filter", filter);
|
|
||||||
nbt.setBoolean("inverted", inverted);
|
nbt.setBoolean("inverted", inverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,10 +109,11 @@ public abstract class TileEntityFilterable extends TileEntityAssembly implements
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
if (nbt.hasKey("filter"))
|
||||||
|
{
|
||||||
|
this.getInventory().setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("filter")));
|
||||||
|
}
|
||||||
inverted = nbt.getBoolean("inverted");
|
inverted = nbt.getBoolean("inverted");
|
||||||
NBTTagCompound filter = nbt.getCompoundTag("filter");
|
|
||||||
this.filterItem = ItemStack.loadItemStackFromNBT(filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.world.World;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import dark.assembly.CommonProxy;
|
||||||
import dark.assembly.client.render.BlockRenderingHandler;
|
import dark.assembly.client.render.BlockRenderingHandler;
|
||||||
import dark.assembly.client.render.RenderManipulator;
|
import dark.assembly.client.render.RenderManipulator;
|
||||||
import dark.assembly.client.render.RenderRejector;
|
import dark.assembly.client.render.RenderRejector;
|
||||||
|
@ -21,13 +22,14 @@ import dark.core.registration.ModObjectRegistry.BlockBuildData;
|
||||||
|
|
||||||
/** A block that manipulates item movement between inventories.
|
/** A block that manipulates item movement between inventories.
|
||||||
*
|
*
|
||||||
* @author Calclavia */
|
* @author Calclavia, DarkGuardsman */
|
||||||
public class BlockManipulator extends BlockImprintable
|
public class BlockManipulator extends BlockImprintable
|
||||||
{
|
{
|
||||||
public BlockManipulator()
|
public BlockManipulator()
|
||||||
{
|
{
|
||||||
super(new BlockBuildData(BlockManipulator.class, "manipulator", UniversalElectricity.machine));
|
super(new BlockBuildData(BlockManipulator.class, "manipulator", UniversalElectricity.machine));
|
||||||
this.setBlockBounds(0, 0, 0, 1, 0.29f, 1);
|
this.setBlockBounds(0, 0, 0, 1, 0.29f, 1);
|
||||||
|
this.guiID = CommonProxy.GUI_MANIPULATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
53
src/dark/assembly/machine/ContainerFilter.java
Normal file
53
src/dark/assembly/machine/ContainerFilter.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue