mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 15:03:07 +00:00
#2752 Finish standardizing Container code
This commit is contained in:
1 parent
4bfc477d1c
commit
b1e852a99a
16 files changed
+180
-278
No files matched your search
@@ -99,7 +99,7 @@ import crazypants.enderio.machine.obelisk.attractor.TileAttractor;
|
||||
import crazypants.enderio.machine.obelisk.aversion.AversionObeliskRenderer;
|
||||
import crazypants.enderio.machine.obelisk.aversion.TileAversionObelisk;
|
||||
import crazypants.enderio.machine.obelisk.weather.TileWeatherObelisk;
|
||||
import crazypants.enderio.machine.obelisk.xp.TileExperienceOblisk;
|
||||
import crazypants.enderio.machine.obelisk.xp.TileExperienceObelisk;
|
||||
import crazypants.enderio.machine.painter.BlockPaintedFenceGate;
|
||||
import crazypants.enderio.machine.painter.BlockPaintedFenceGateRenderer;
|
||||
import crazypants.enderio.machine.painter.BlockPaintedGlowstone;
|
||||
@@ -271,9 +271,9 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAversionObelisk.class, sgr);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockSpawnGuard), sgr);
|
||||
|
||||
ObeliskSpecialRenderer<TileExperienceOblisk> eor = new ObeliskSpecialRenderer<TileExperienceOblisk>(new ItemStack(EnderIO.itemXpTransfer),
|
||||
ObeliskSpecialRenderer<TileExperienceObelisk> eor = new ObeliskSpecialRenderer<TileExperienceObelisk>(new ItemStack(EnderIO.itemXpTransfer),
|
||||
defaultObeliskRenderer);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileExperienceOblisk.class, eor);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileExperienceObelisk.class, eor);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockExperianceOblisk), eor);
|
||||
|
||||
ObeliskSpecialRenderer<TileWeatherObelisk> twr = new ObeliskSpecialRenderer<TileWeatherObelisk>(new ItemStack(EnderIO.itemMaterial, 1,
|
||||
|
||||
@@ -6,13 +6,13 @@ import java.util.List;
|
||||
|
||||
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.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.enderio.core.common.ContainerEnder;
|
||||
import com.enderio.core.common.util.ItemUtil;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -22,7 +22,7 @@ import crazypants.enderio.conduit.item.IItemConduit;
|
||||
import crazypants.enderio.conduit.item.SpeedUpgrade;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class ExternalConnectionContainer extends Container {
|
||||
public class ExternalConnectionContainer extends ContainerEnder<InventoryUpgrades> {
|
||||
|
||||
private final IItemConduit itemConduit;
|
||||
|
||||
@@ -43,47 +43,30 @@ public class ExternalConnectionContainer extends Container {
|
||||
final List<FilterChangeListener> filterListeners = new ArrayList<FilterChangeListener>();
|
||||
|
||||
public ExternalConnectionContainer(InventoryPlayer playerInv, IConduitBundle bundle, ForgeDirection dir) {
|
||||
super(playerInv, new InventoryUpgrades(bundle.getConduit(IItemConduit.class), dir));
|
||||
this.itemConduit = bundle.getConduit(IItemConduit.class);
|
||||
slotLocations.addAll(playerSlotLocations.values());
|
||||
|
||||
int x;
|
||||
int y;
|
||||
|
||||
int topY = 113;
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
x = 23 + j * 18;
|
||||
y = topY + i * 18;
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
y = 171;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
x = 23 + i * 18;
|
||||
addSlotToContainer(new Slot(playerInv, i, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
}
|
||||
|
||||
itemConduit = bundle.getConduit(IItemConduit.class);
|
||||
if(itemConduit != null) {
|
||||
final InventoryUpgrades ui = new InventoryUpgrades(itemConduit, dir);
|
||||
|
||||
if (itemConduit != null) {
|
||||
x = 10;
|
||||
y = 47;
|
||||
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 3, x, y));
|
||||
slotOutputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 3, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 10;
|
||||
y = 47;
|
||||
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(ui, 2, x, y));
|
||||
slotInputFilterUpgrades = addSlotToContainer(new FilterSlot(getInv(), 2, x, y));
|
||||
slotLocations.add(new Point(x, y));
|
||||
|
||||
x = 28;
|
||||
y = 47;
|
||||
slotSpeedUpgrades = addSlotToContainer(new Slot(ui, 0, x, y) {
|
||||
y = 47;
|
||||
slotSpeedUpgrades = addSlotToContainer(new Slot(getInv(), 0, x, y) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return ui.isItemValidForSlot(0, par1ItemStack);
|
||||
return getInv().isItemValidForSlot(0, par1ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,10 +78,10 @@ public class ExternalConnectionContainer extends Container {
|
||||
|
||||
x = 10;
|
||||
y = 65;
|
||||
slotFunctionUpgrades = addSlotToContainer(new Slot(ui, 1, x, y) {
|
||||
slotFunctionUpgrades = addSlotToContainer(new Slot(getInv(), 1, x, y) {
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return ui.isItemValidForSlot(1, par1ItemStack);
|
||||
return getInv().isItemValidForSlot(1, par1ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,6 +92,11 @@ public class ExternalConnectionContainer extends Container {
|
||||
slotLocations.add(new Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getPlayerInventoryOffset() {
|
||||
return new Point(23, 113);
|
||||
}
|
||||
|
||||
public void addFilterListener(FilterChangeListener list) {
|
||||
filterListeners.add(list);
|
||||
@@ -164,11 +152,6 @@ public class ExternalConnectionContainer extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
|
||||
ItemStack st = par4EntityPlayer.inventory.getItemStack();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class ContainerNoInv extends Container {
|
||||
|
||||
private IInventory inv;
|
||||
|
||||
public ContainerNoInv(IInventory inv) {
|
||||
super();
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return inv.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,8 @@ package crazypants.enderio.machine.hypercube;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import crazypants.util.ArrayInventory;
|
||||
|
||||
import com.enderio.core.common.util.ArrayInventory;
|
||||
|
||||
public class ItemRecieveBuffer extends ArrayInventory implements ISidedInventory {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.ContainerNoInv;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public class BlockPowerMonitor extends AbstractMachineBlock<TilePowerMonitor> {
|
||||
@@ -32,14 +33,18 @@ public class BlockPowerMonitor extends AbstractMachineBlock<TilePowerMonitor> {
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerPowerMonitor();
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TilePowerMonitor) {
|
||||
return new ContainerNoInv((TilePowerMonitor) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TilePowerMonitor) {
|
||||
return new GuiPowerMonitor((TilePowerMonitor) te);
|
||||
return new GuiPowerMonitor(player.inventory, (TilePowerMonitor) te);
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package crazypants.enderio.machine.monitor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerPowerMonitor extends Container {
|
||||
|
||||
public ContainerPowerMonitor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.text.NumberFormat;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -18,6 +19,7 @@ import com.enderio.core.client.render.ColorUtil;
|
||||
import com.enderio.core.client.render.RenderUtil;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.machine.ContainerNoInv;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
@@ -33,7 +35,7 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
|
||||
private static final int MARGIN = 7;
|
||||
|
||||
private static final int WIDTH = 203;
|
||||
private static final int WIDTH = 210;
|
||||
private static final int HEIGHT = 146;
|
||||
|
||||
private static final int POWER_X = 185;
|
||||
@@ -66,8 +68,8 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
private String monHeading4;
|
||||
private String monHeading5;
|
||||
|
||||
public GuiPowerMonitor(final TilePowerMonitor te) {
|
||||
super(new ContainerPowerMonitor());
|
||||
public GuiPowerMonitor(InventoryPlayer playerInv, final TilePowerMonitor te) {
|
||||
super(new ContainerNoInv(te));
|
||||
this.te = te;
|
||||
xSize = WIDTH;
|
||||
ySize = HEIGHT;
|
||||
|
||||
@@ -2,8 +2,12 @@ package crazypants.enderio.machine.obelisk.xp;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.enderio.core.common.ContainerEnder;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -13,9 +17,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.ContainerNoInv;
|
||||
import crazypants.enderio.machine.monitor.GuiPowerMonitor;
|
||||
import crazypants.enderio.machine.monitor.TilePowerMonitor;
|
||||
import crazypants.enderio.machine.obelisk.BlockObeliskAbstract;
|
||||
|
||||
public class BlockExperienceObelisk extends BlockObeliskAbstract<TileExperienceOblisk> {
|
||||
public class BlockExperienceObelisk extends BlockObeliskAbstract<TileExperienceObelisk> {
|
||||
|
||||
public static BlockExperienceObelisk create() {
|
||||
BlockExperienceObelisk res = new BlockExperienceObelisk();
|
||||
@@ -24,7 +31,7 @@ public class BlockExperienceObelisk extends BlockObeliskAbstract<TileExperienceO
|
||||
}
|
||||
|
||||
private BlockExperienceObelisk() {
|
||||
super(ModObject.blockExperienceObelisk, TileExperienceOblisk.class);
|
||||
super(ModObject.blockExperienceObelisk, TileExperienceObelisk.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,14 +56,23 @@ public class BlockExperienceObelisk extends BlockObeliskAbstract<TileExperienceO
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerExperienceObelisk();
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te instanceof TileExperienceObelisk) {
|
||||
return new ContainerNoInv((IInventory) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GuiExperienceObelisk(player.inventory, (TileExperienceOblisk) world.getTileEntity(x, y, z));
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileExperienceObelisk) {
|
||||
return new GuiExperienceObelisk(player.inventory, (TileExperienceObelisk) te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_XP_OBELISK;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package crazypants.enderio.machine.obelisk.xp;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerExperienceObelisk extends Container {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,13 +12,14 @@ import com.enderio.core.client.render.RenderUtil;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.machine.ContainerNoInv;
|
||||
import crazypants.enderio.machine.gui.GuiMachineBase;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.ExperienceBarRenderer;
|
||||
import crazypants.enderio.xp.PacketDrainPlayerXP;
|
||||
import crazypants.enderio.xp.PacketGivePlayerXP;
|
||||
|
||||
public class GuiExperienceObelisk extends GuiMachineBase<TileExperienceOblisk> {
|
||||
public class GuiExperienceObelisk extends GuiMachineBase<TileExperienceObelisk> {
|
||||
|
||||
private IconButton p;
|
||||
private IconButton pp;
|
||||
@@ -28,8 +29,8 @@ public class GuiExperienceObelisk extends GuiMachineBase<TileExperienceOblisk> {
|
||||
private IconButton mm;
|
||||
private IconButton mmm;
|
||||
|
||||
public GuiExperienceObelisk(InventoryPlayer par1InventoryPlayer, TileExperienceOblisk te) {
|
||||
super(te, new ContainerExperienceObelisk());
|
||||
public GuiExperienceObelisk(InventoryPlayer playerInv, TileExperienceObelisk te) {
|
||||
super(te, new ContainerNoInv(te));
|
||||
ySize = 115;
|
||||
|
||||
int spacing = 5;
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ import crazypants.enderio.xp.IHaveExperience;
|
||||
import crazypants.enderio.xp.PacketExperianceContainer;
|
||||
import crazypants.enderio.xp.XpUtil;
|
||||
|
||||
public class TileExperienceOblisk extends AbstractMachineEntity implements IFluidHandler, IHaveExperience, ITankAccess {
|
||||
public class TileExperienceObelisk extends AbstractMachineEntity implements IFluidHandler, IHaveExperience, ITankAccess {
|
||||
|
||||
private ExperienceContainer xpCont = new ExperienceContainer(XpUtil.getExperienceForLevel(Config.xpObeliskMaxXpLevel));
|
||||
|
||||
public TileExperienceOblisk() {
|
||||
public TileExperienceObelisk() {
|
||||
super(new SlotDefinition(0, 0, 0));
|
||||
}
|
||||
|
||||
@@ -2,45 +2,35 @@ package crazypants.enderio.machine.vacuum;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerVacuumChest extends Container {
|
||||
import com.enderio.core.common.ContainerEnder;
|
||||
|
||||
final Slot filterSlot;
|
||||
Runnable filterChangedCB;
|
||||
public class ContainerVacuumChest extends ContainerEnder<TileVacuumChest> {
|
||||
|
||||
private Slot filterSlot;
|
||||
private Runnable filterChangedCB;
|
||||
|
||||
public ContainerVacuumChest(EntityPlayer player, InventoryPlayer inventory, final TileVacuumChest te) {
|
||||
super(inventory, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSlots(InventoryPlayer playerInv) {
|
||||
int x = 8;
|
||||
int y = 18;
|
||||
int index = -1;
|
||||
for (int i = 0; i < TileVacuumChest.ITEM_ROWS; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
addSlotToContainer(new Slot(te, ++index, x + j * 18, y + i * 18));
|
||||
addSlotToContainer(new Slot(getInv(), ++index, x + j * 18, y + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
y = 124;
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
addSlotToContainer(new Slot(inventory, j + i * 9 + 9, x + j * 18, y + i * 18));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new Slot(inventory, i, x + i * 18, y + 58));
|
||||
}
|
||||
|
||||
filterSlot = new FilterSlot(new InventoryFilterUpgrade(te));
|
||||
filterSlot = new FilterSlot(new InventoryFilterUpgrade(getInv()));
|
||||
addSlotToContainer(filterSlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
|
||||
ItemStack itemstack = null;
|
||||
|
||||
@@ -4,17 +4,16 @@ import java.awt.Point;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.enderio.core.client.gui.widget.TemplateSlot;
|
||||
import com.enderio.core.common.ContainerEnder;
|
||||
import com.enderio.core.common.util.ArrayInventory;
|
||||
|
||||
import crazypants.enderio.api.teleport.ITravelAccessable;
|
||||
import crazypants.enderio.teleport.ContainerTravelAccessable.PasswordInventory;
|
||||
import crazypants.util.ArrayInventory;
|
||||
|
||||
public class ContainerTravelAccessable extends ContainerEnder<PasswordInventory> {
|
||||
|
||||
|
||||
@@ -2,103 +2,102 @@ package crazypants.enderio.teleport;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.enderio.core.client.gui.widget.TemplateSlot;
|
||||
import com.enderio.core.common.ContainerEnder;
|
||||
import com.enderio.core.common.util.ArrayInventory;
|
||||
|
||||
import crazypants.util.ArrayInventory;
|
||||
import crazypants.enderio.teleport.ContainerTravelAuth.AuthInventory;
|
||||
|
||||
public class ContainerTravelAuth extends Container {
|
||||
public class ContainerTravelAuth extends ContainerEnder<AuthInventory> {
|
||||
|
||||
ItemStack[] enteredPassword = new ItemStack[5];
|
||||
static class AuthInventory extends ArrayInventory {
|
||||
private ContainerTravelAuth container;
|
||||
|
||||
private AuthInventory(ItemStack[] inv) {
|
||||
super(inv);
|
||||
}
|
||||
|
||||
private void setContainer(ContainerTravelAuth container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
container.dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if(i < 0 || i >= items.length) {
|
||||
return null;
|
||||
}
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int fromSlot, int amount) {
|
||||
ItemStack item = items[fromSlot];
|
||||
items[fromSlot] = null;
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
item.stackSize = 0;
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if(itemstack != null) {
|
||||
items[i] = itemstack.copy();
|
||||
items[i].stackSize = 0;
|
||||
} else {
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
|
||||
boolean dirty = false;
|
||||
|
||||
public ContainerTravelAuth(InventoryPlayer playerInv) {
|
||||
|
||||
ArrayInventory arrInv = new ArrayInventory(enteredPassword) {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if(i < 0 || i >= items.length) {
|
||||
return null;
|
||||
}
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int fromSlot, int amount) {
|
||||
ItemStack item = items[fromSlot];
|
||||
items[fromSlot] = null;
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
item.stackSize = 0;
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if(itemstack != null) {
|
||||
items[i] = itemstack.copy();
|
||||
items[i].stackSize = 0;
|
||||
} else {
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
int x = 44;
|
||||
int y = 28;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
addSlotToContainer(new TemplateSlot(arrInv, i, x, y));
|
||||
x += 18;
|
||||
}
|
||||
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 83 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 141));
|
||||
}
|
||||
|
||||
super(playerInv, new AuthInventory(new ItemStack[5]));
|
||||
getInv().setContainer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
protected void addSlots(InventoryPlayer playerInv) {
|
||||
int x = 44;
|
||||
int y = 28;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
addSlotToContainer(new TemplateSlot(getInv(), i, x, y));
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GuiTravelAuth extends GuiContainerBase {
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
ContainerTravelAuth poo = (ContainerTravelAuth) inventorySlots;
|
||||
if(ta.authoriseUser(player, poo.enteredPassword)) {
|
||||
if(ta.authoriseUser(player, poo.getInv().getInventory())) {
|
||||
TileEntity te = ((TileEntity) ta);
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageTileNBT(te));
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.enderio.core.common.util.Util;
|
||||
|
||||
public class ArrayInventory implements IInventory {
|
||||
|
||||
protected ItemStack[] items;
|
||||
|
||||
public ArrayInventory(ItemStack... items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public ArrayInventory(int size) {
|
||||
items = new ItemStack[size];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return items[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
return Util.decrStackSize(this, slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
items[slot] = stack;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "ArrayInventory";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user