@@ -30,7 +30,7 @@ public class GuiMEPortableCell extends GuiMEMonitorable
|
|||||||
|
|
||||||
public GuiMEPortableCell( InventoryPlayer inventoryPlayer, IPortableCell te )
|
public GuiMEPortableCell( InventoryPlayer inventoryPlayer, IPortableCell te )
|
||||||
{
|
{
|
||||||
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
|
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, te ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int defaultGetMaxRows()
|
int defaultGetMaxRows()
|
||||||
|
|||||||
@@ -25,20 +25,33 @@ import net.minecraft.item.ItemStack;
|
|||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
|
import appeng.container.interfaces.IInventorySlotAware;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class ContainerMEPortableCell extends ContainerMEMonitorable
|
public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||||
{
|
{
|
||||||
|
|
||||||
final IPortableCell civ;
|
public double powerMultiplier = 0.5;
|
||||||
double powerMultiplier = 0.5;
|
|
||||||
int ticks = 0;
|
private final IPortableCell civ;
|
||||||
|
private int ticks = 0;
|
||||||
|
private final int slot;
|
||||||
|
|
||||||
public ContainerMEPortableCell( InventoryPlayer ip, IPortableCell monitorable )
|
public ContainerMEPortableCell( InventoryPlayer ip, IPortableCell monitorable )
|
||||||
{
|
{
|
||||||
super( ip, monitorable, false );
|
super( ip, monitorable, false );
|
||||||
this.lockPlayerInventorySlot( ip.currentItem );
|
if( monitorable instanceof IInventorySlotAware )
|
||||||
|
{
|
||||||
|
int slotIndex = ( (IInventorySlotAware) monitorable ).getInventorySlot();
|
||||||
|
this.lockPlayerInventorySlot( slotIndex );
|
||||||
|
this.slot = slotIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.slot = -1;
|
||||||
|
this.lockPlayerInventorySlot( ip.currentItem );
|
||||||
|
}
|
||||||
this.civ = monitorable;
|
this.civ = monitorable;
|
||||||
this.bindPlayerInventory( ip, 0, 0 );
|
this.bindPlayerInventory( ip, 0, 0 );
|
||||||
}
|
}
|
||||||
@@ -46,7 +59,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
|||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
ItemStack currentItem = this.getPlayerInv().getCurrentItem();
|
ItemStack currentItem = slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot( slot );
|
||||||
|
|
||||||
if( this.civ != null )
|
if( this.civ != null )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Applied Energistics 2.
|
||||||
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package appeng.container.interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any item providing a GUI and depending on an exact inventory slot.
|
||||||
|
*
|
||||||
|
* This interface is likely a volatile one until a general GUI refactoring occurred.
|
||||||
|
* Use it with care and expect changes.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IInventorySlotAware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This is needed to select the correct slot index.
|
||||||
|
*
|
||||||
|
* @return the inventory index of this portable cell.
|
||||||
|
*/
|
||||||
|
int getInventorySlot();
|
||||||
|
}
|
||||||
@@ -250,15 +250,21 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||||
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
||||||
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
||||||
|
if( ID.type.isItem() )
|
||||||
if( ID.type.isItem() && stem )
|
|
||||||
{
|
{
|
||||||
ItemStack it = player.inventory.getCurrentItem();
|
ItemStack it = null;
|
||||||
|
if( stem )
|
||||||
|
{
|
||||||
|
it = player.inventory.getCurrentItem();
|
||||||
|
}
|
||||||
|
else if( x >= 0 && x < player.inventory.mainInventory.length )
|
||||||
|
{
|
||||||
|
it = player.inventory.getStackInSlot( x );
|
||||||
|
}
|
||||||
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||||
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ID.type.isTile() )
|
if( ID.type.isTile() )
|
||||||
{
|
{
|
||||||
TileEntity TE = w.getTileEntity( x, y, z );
|
TileEntity TE = w.getTileEntity( x, y, z );
|
||||||
@@ -275,7 +281,6 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ContainerNull();
|
return new ContainerNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,19 +416,24 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||||
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
||||||
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
||||||
|
if( ID.type.isItem() )
|
||||||
if( ID.type.isItem() && stem )
|
|
||||||
{
|
{
|
||||||
ItemStack it = player.inventory.getCurrentItem();
|
ItemStack it = null;
|
||||||
|
if( stem )
|
||||||
|
{
|
||||||
|
it = player.inventory.getCurrentItem();
|
||||||
|
}
|
||||||
|
else if( x >= 0 && x < player.inventory.mainInventory.length )
|
||||||
|
{
|
||||||
|
it = player.inventory.getStackInSlot( x );
|
||||||
|
}
|
||||||
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||||
if( ID.CorrectTileOrPart( myItem ) )
|
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||||
return ID.ConstructGui( player.inventory, side, myItem );
|
return ID.ConstructGui( player.inventory, side, myItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ID.type.isTile() )
|
if( ID.type.isTile() )
|
||||||
{
|
{
|
||||||
TileEntity TE = w.getTileEntity( x, y, z );
|
TileEntity TE = w.getTileEntity( x, y, z );
|
||||||
|
|
||||||
if( TE instanceof IPartHost )
|
if( TE instanceof IPartHost )
|
||||||
{
|
{
|
||||||
( (IPartHost) TE ).getPart( side );
|
( (IPartHost) TE ).getPart( side );
|
||||||
@@ -437,7 +447,6 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
return ID.ConstructGui( player.inventory, side, TE );
|
return ID.ConstructGui( player.inventory, side, TE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GuiNull( new ContainerNull() );
|
return new GuiNull( new ContainerNull() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,11 @@ import appeng.api.storage.data.IItemList;
|
|||||||
import appeng.api.util.AECableType;
|
import appeng.api.util.AECableType;
|
||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
|
import appeng.container.interfaces.IInventorySlotAware;
|
||||||
import appeng.tile.networking.TileWireless;
|
import appeng.tile.networking.TileWireless;
|
||||||
|
|
||||||
|
|
||||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost
|
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware
|
||||||
{
|
{
|
||||||
|
|
||||||
public final ItemStack effectiveItem;
|
public final ItemStack effectiveItem;
|
||||||
@@ -64,6 +65,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost
|
|||||||
IWirelessAccessPoint myWap;
|
IWirelessAccessPoint myWap;
|
||||||
double sqRange = Double.MAX_VALUE;
|
double sqRange = Double.MAX_VALUE;
|
||||||
double myRange = Double.MAX_VALUE;
|
double myRange = Double.MAX_VALUE;
|
||||||
|
private final int inventorySlot;
|
||||||
|
|
||||||
public WirelessTerminalGuiObject( IWirelessTermHandler wh, ItemStack is, EntityPlayer ep, World w, int x, int y, int z )
|
public WirelessTerminalGuiObject( IWirelessTermHandler wh, ItemStack is, EntityPlayer ep, World w, int x, int y, int z )
|
||||||
{
|
{
|
||||||
@@ -71,6 +73,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost
|
|||||||
this.effectiveItem = is;
|
this.effectiveItem = is;
|
||||||
this.myPlayer = ep;
|
this.myPlayer = ep;
|
||||||
this.wth = wh;
|
this.wth = wh;
|
||||||
|
this.inventorySlot = x;
|
||||||
|
|
||||||
ILocatable obj = null;
|
ILocatable obj = null;
|
||||||
|
|
||||||
@@ -332,4 +335,11 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventorySlot()
|
||||||
|
{
|
||||||
|
return inventorySlot;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,23 +35,32 @@ import appeng.api.storage.MEMonitorHandler;
|
|||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
|
import appeng.container.interfaces.IInventorySlotAware;
|
||||||
import appeng.me.storage.CellInventory;
|
import appeng.me.storage.CellInventory;
|
||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import appeng.util.IConfigManagerHost;
|
import appeng.util.IConfigManagerHost;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell
|
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell, IInventorySlotAware
|
||||||
{
|
{
|
||||||
|
|
||||||
private final ItemStack target;
|
private final ItemStack target;
|
||||||
private final IAEItemPowerStorage ips;
|
private final IAEItemPowerStorage ips;
|
||||||
|
private final int inventorySlot;
|
||||||
|
|
||||||
public PortableCellViewer( ItemStack is )
|
public PortableCellViewer( ItemStack is, int slot )
|
||||||
{
|
{
|
||||||
super( CellInventory.getCell( is, null ) );
|
super( CellInventory.getCell( is, null ) );
|
||||||
this.ips = (IAEItemPowerStorage) is.getItem();
|
this.ips = (IAEItemPowerStorage) is.getItem();
|
||||||
this.target = is;
|
this.target = is;
|
||||||
|
this.inventorySlot = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventorySlot()
|
||||||
|
{
|
||||||
|
return inventorySlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -186,6 +186,6 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
|||||||
@Override
|
@Override
|
||||||
public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
|
public IGuiItemObject getGuiObject( ItemStack is, World w, int x, int y, int z )
|
||||||
{
|
{
|
||||||
return new PortableCellViewer( is );
|
return new PortableCellViewer( is, x );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,8 +334,10 @@ public class Platform
|
|||||||
|
|
||||||
if( ( type.getType().isItem() && tile == null ) || type.hasPermissions( tile, x, y, z, side, p ) )
|
if( ( type.getType().isItem() && tile == null ) || type.hasPermissions( tile, x, y, z, side, p ) )
|
||||||
{
|
{
|
||||||
if( tile == null || type.getType() == GuiHostType.ITEM )
|
if( tile != null && type.getType() == GuiHostType.ITEM )
|
||||||
p.openGui( AppEng.instance, type.ordinal() << 4 | ( 1 << 3 ), p.getEntityWorld(), x, y, z );
|
p.openGui( AppEng.instance, type.ordinal() << 4 | (1 << 3) , p.getEntityWorld(), x, y, z );
|
||||||
|
else if ( tile == null && type.getType() == GuiHostType.ITEM )
|
||||||
|
p.openGui( AppEng.instance, type.ordinal() << 4 | (0 << 3), p.getEntityWorld(), p.inventory.currentItem, 0, 0 );
|
||||||
else
|
else
|
||||||
p.openGui( AppEng.instance, type.ordinal() << 4 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
|
p.openGui( AppEng.instance, type.ordinal() << 4 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user