Crafting Amount Gui Mostly Done, missing "Next Button"
This commit is contained in:
parent
26dcae3f9b
commit
bc55956d56
10 changed files with 423 additions and 59 deletions
|
@ -273,8 +273,10 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 )
|
||||
action = InventoryAction.CRAFT_ITEM;
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
|
@ -285,9 +287,8 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
if ( stack != null && stack.isCraftable() )
|
||||
{
|
||||
action = InventoryAction.CRAFT_ITEM;
|
||||
}
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
else if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
IAEItemStack slotItem = ((SlotME) slot).getAEStack();
|
||||
|
|
219
client/gui/implementations/GuiCraftAmount.java
Normal file
219
client/gui/implementations/GuiCraftAmount.java
Normal file
|
@ -0,0 +1,219 @@
|
|||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTextField amountToCraft;
|
||||
GuiTabButton originalGuiBtn;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftAmount( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+1" ) );
|
||||
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+10" ) );
|
||||
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+100" ) );
|
||||
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+1000" ) );
|
||||
|
||||
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-1" ) );
|
||||
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-10" ) );
|
||||
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-100" ) );
|
||||
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-1000" ) );
|
||||
|
||||
ItemStack myIcon = null;
|
||||
Object target = ((AEBaseContainer) inventorySlots).getTarget();
|
||||
|
||||
if ( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if ( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if ( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if ( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if ( OriginalGui != null )
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
|
||||
amountToCraft = new GuiTextField( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT );
|
||||
amountToCraft.setEnableBackgroundDrawing( false );
|
||||
amountToCraft.setMaxStringLength( 16 );
|
||||
amountToCraft.setTextColor( 0xFFFFFF );
|
||||
amountToCraft.setVisible( true );
|
||||
amountToCraft.setFocused( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == plus1 )
|
||||
addQty( 1 );
|
||||
if ( btn == plus10 )
|
||||
addQty( 10 );
|
||||
if ( btn == plus100 )
|
||||
addQty( 100 );
|
||||
if ( btn == plus1000 )
|
||||
addQty( 1000 );
|
||||
if ( btn == minus1 )
|
||||
addQty( -1 );
|
||||
if ( btn == minus10 )
|
||||
addQty( -10 );
|
||||
if ( btn == minus100 )
|
||||
addQty( -100 );
|
||||
if ( btn == minus1000 )
|
||||
addQty( -1000 );
|
||||
}
|
||||
|
||||
private void addQty(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
|
||||
amountToCraft.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.CraftQty", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
|
||||
&& amountToCraft.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/priority.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
amountToCraft.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/priority.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.Crafts.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
|
@ -66,6 +67,7 @@ public abstract class AEBaseContainer extends Container
|
|||
final InventoryPlayer invPlayer;
|
||||
final TileEntity tileEntity;
|
||||
final IPart part;
|
||||
final IGuiItemObject obj;
|
||||
|
||||
final protected BaseActionSource mySrc;
|
||||
public boolean isContainerValid = true;
|
||||
|
@ -190,12 +192,7 @@ public abstract class AEBaseContainer extends Container
|
|||
|
||||
protected boolean hasAccess(SecurityPermissions perm, boolean requirePower)
|
||||
{
|
||||
IActionHost host = null;
|
||||
|
||||
if ( tileEntity instanceof IActionHost )
|
||||
host = (IActionHost) tileEntity;
|
||||
if ( part instanceof IActionHost )
|
||||
host = (IActionHost) part;
|
||||
IActionHost host = getActionHost();
|
||||
|
||||
if ( host != null )
|
||||
{
|
||||
|
@ -243,13 +240,46 @@ public abstract class AEBaseContainer extends Container
|
|||
}
|
||||
|
||||
public AEBaseContainer(InventoryPlayer ip, TileEntity myTile, IPart myPart) {
|
||||
this( ip, myTile, myPart, null );
|
||||
}
|
||||
|
||||
public AEBaseContainer(InventoryPlayer ip, TileEntity myTile, IPart myPart, IGuiItemObject gio) {
|
||||
invPlayer = ip;
|
||||
tileEntity = myTile;
|
||||
part = myPart;
|
||||
mySrc = new PlayerSource( ip.player, (IActionHost) (myTile instanceof IActionHost ? myTile : (myPart instanceof IActionHost ? myPart : null)) );
|
||||
obj = gio;
|
||||
mySrc = new PlayerSource( ip.player, getActionHost() );
|
||||
prepareSync();
|
||||
}
|
||||
|
||||
public AEBaseContainer(InventoryPlayer ip, Object anchor) {
|
||||
invPlayer = ip;
|
||||
tileEntity = anchor instanceof TileEntity ? (TileEntity) anchor : null;
|
||||
part = anchor instanceof IPart ? (IPart) anchor : null;
|
||||
obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null;
|
||||
|
||||
if ( tileEntity == null && part == null && obj == null )
|
||||
throw new RuntimeException( "Must have a valid anchor" );
|
||||
|
||||
mySrc = new PlayerSource( ip.player, getActionHost() );
|
||||
|
||||
prepareSync();
|
||||
}
|
||||
|
||||
private IActionHost getActionHost()
|
||||
{
|
||||
if ( obj instanceof IActionHost )
|
||||
return (IActionHost) obj;
|
||||
|
||||
if ( tileEntity instanceof IActionHost )
|
||||
return (IActionHost) tileEntity;
|
||||
|
||||
if ( part instanceof IActionHost )
|
||||
return (IActionHost) part;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canDragIntoSlot(Slot s)
|
||||
{
|
||||
return ((AppEngSlot) s).isDraggable;
|
||||
|
|
35
container/implementations/ContainerCraftAmount.java
Normal file
35
container/implementations/ContainerCraftAmount.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotInaccessable;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public class ContainerCraftAmount extends AEBaseContainer
|
||||
{
|
||||
|
||||
ITerminalHost priHost;
|
||||
IAEItemStack stack;
|
||||
|
||||
public Slot craftingItem;
|
||||
|
||||
public ContainerCraftAmount(InventoryPlayer ip, ITerminalHost te) {
|
||||
super( ip, te );
|
||||
priHost = te;
|
||||
|
||||
craftingItem = new SlotInaccessable( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
|
||||
addSlotToContainer( craftingItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package appeng.core.sync;
|
||||
|
||||
import static appeng.core.sync.GuiHostType.ITEM;
|
||||
import static appeng.core.sync.GuiHostType.ITEM_OR_WORLD;
|
||||
import static appeng.core.sync.GuiHostType.WORLD;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -31,6 +35,7 @@ import appeng.container.ContainerOpenContext;
|
|||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
|
@ -88,67 +93,69 @@ public enum GuiBridge implements IGuiHandler
|
|||
{
|
||||
GUI_Handler(),
|
||||
|
||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, false, null),
|
||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, WORLD, null),
|
||||
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, false, SecurityPermissions.BUILD),
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, false, null),
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, WORLD, null),
|
||||
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, false, SecurityPermissions.BUILD),
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, false, SecurityPermissions.BUILD),
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, false, null),
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, WORLD, null),
|
||||
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true, null),
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, ITEM, null),
|
||||
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, true, null),
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, ITEM, null),
|
||||
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true, null),
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, ITEM, null),
|
||||
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true, null),
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, ITEM, null),
|
||||
|
||||
GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, true, null),
|
||||
GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, ITEM, null),
|
||||
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, false, SecurityPermissions.BUILD),
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, false, null),
|
||||
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, WORLD, null),
|
||||
|
||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, false, null),
|
||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, WORLD, null),
|
||||
|
||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, false, SecurityPermissions.BUILD),
|
||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, false, SecurityPermissions.BUILD),
|
||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, false, SecurityPermissions.BUILD),
|
||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, false, SecurityPermissions.BUILD),
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FPLANE(ContainerFormationPlane.class, PartFormationPlane.class, false, SecurityPermissions.BUILD),
|
||||
GUI_FPLANE(ContainerFormationPlane.class, PartFormationPlane.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, false, SecurityPermissions.BUILD),
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, false, SecurityPermissions.SECURITY),
|
||||
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, WORLD, SecurityPermissions.SECURITY),
|
||||
|
||||
GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, false, SecurityPermissions.CRAFT),
|
||||
GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, false, SecurityPermissions.CRAFT),
|
||||
GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false, SecurityPermissions.BUILD),
|
||||
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SPATIALIOPORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, false, SecurityPermissions.BUILD),
|
||||
GUI_SPATIALIOPORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, false, null),
|
||||
GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, WORLD, null),
|
||||
|
||||
GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, false, null),
|
||||
GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, WORLD, null),
|
||||
|
||||
GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, false, null);
|
||||
GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, WORLD, null),
|
||||
|
||||
GUI_CRAFTING_AMOUNT(ContainerCraftAmount.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT);
|
||||
|
||||
private Class Tile;
|
||||
private Class Gui;
|
||||
private Class Container;
|
||||
private boolean isItem;
|
||||
private GuiHostType type;
|
||||
private SecurityPermissions requiredPermission;
|
||||
|
||||
private GuiBridge() {
|
||||
|
@ -182,10 +189,10 @@ public enum GuiBridge implements IGuiHandler
|
|||
getGui();
|
||||
}
|
||||
|
||||
private GuiBridge(Class _Container, Class _Tile, boolean isItem, SecurityPermissions requiredPermission) {
|
||||
private GuiBridge(Class _Container, Class _Tile, GuiHostType type, SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
Container = _Container;
|
||||
this.isItem = isItem;
|
||||
this.type = type;
|
||||
Tile = _Tile;
|
||||
getGui();
|
||||
}
|
||||
|
@ -288,14 +295,15 @@ public enum GuiBridge implements IGuiHandler
|
|||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||
GuiBridge ID = values()[ID_ORDINAL >> 3];
|
||||
|
||||
if ( ID.isItem() )
|
||||
if ( ID.type.isItem() )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||
if ( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side );
|
||||
}
|
||||
else
|
||||
|
||||
if ( ID.type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if ( TE instanceof IPartHost )
|
||||
|
@ -332,25 +340,21 @@ public enum GuiBridge implements IGuiHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean isItem()
|
||||
{
|
||||
return isItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||
GuiBridge ID = values()[ID_ORDINAL >> 3];
|
||||
|
||||
if ( ID.isItem() )
|
||||
if ( ID.type.isItem() )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||
if ( ID.CorrectTileOrPart( myItem ) )
|
||||
return ID.ConstructGui( player.inventory, side, myItem );
|
||||
}
|
||||
else
|
||||
|
||||
if ( ID.type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
|
||||
|
@ -377,7 +381,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
|
||||
if ( Platform.hasPermissions( x, y, z, player, AccessType.BLOCK_ACCESS ) )
|
||||
{
|
||||
if ( isItem() )
|
||||
if ( type.isItem() )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||
|
@ -389,7 +393,8 @@ public enum GuiBridge implements IGuiHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ( type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if ( TE instanceof IPartHost )
|
||||
|
@ -441,4 +446,9 @@ public enum GuiBridge implements IGuiHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
public GuiHostType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
16
core/sync/GuiHostType.java
Normal file
16
core/sync/GuiHostType.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package appeng.core.sync;
|
||||
|
||||
public enum GuiHostType
|
||||
{
|
||||
ITEM_OR_WORLD, ITEM, WORLD;
|
||||
|
||||
public boolean isItem()
|
||||
{
|
||||
return this != WORLD;
|
||||
}
|
||||
|
||||
public boolean isTile()
|
||||
{
|
||||
return this != ITEM;
|
||||
}
|
||||
}
|
|
@ -7,10 +7,14 @@ import java.io.IOException;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
|
@ -41,9 +45,29 @@ public class PacketInventoryAction extends AppEngPacket
|
|||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
if ( action == InventoryAction.AUTOCRAFT )
|
||||
{
|
||||
ContainerOpenContext context = aebc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.w.getTileEntity( context.x, context.y, context.z );
|
||||
Platform.openGUI( sender, te, aebc.openContext.side, GuiBridge.GUI_CRAFTING_AMOUNT );
|
||||
|
||||
if ( sender.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
if ( aebc.getTargetStack() != null )
|
||||
cca.craftingItem.putStack( aebc.getTargetStack().getItemStack() );
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aebc.doAction( sender, action, slot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
|
|
|
@ -9,5 +9,5 @@ public enum InventoryAction
|
|||
CRAFT_STACK, CRAFT_ITEM, CRAFT_SHIFT,
|
||||
|
||||
// extra...
|
||||
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN
|
||||
MOVE_REGION, PICKUP_SINGLE, UPDATE_HAND, ROLLUP, ROLLDOWN, AUTOCRAFT
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import appeng.api.networking.IGridHost;
|
|||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IMachineSet;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
|
@ -23,11 +24,12 @@ import appeng.api.storage.StorageChannel;
|
|||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class WirelessTerminalGuiObject implements IPortableCell
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost
|
||||
{
|
||||
|
||||
IWirelessTermHandler wth;
|
||||
|
@ -276,4 +278,31 @@ public class WirelessTerminalGuiObject implements IPortableCell
|
|||
return wth.getConfigManager( effectiveItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
{
|
||||
return this.getActionableNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
{
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
rangeCheck();
|
||||
if ( myWap != null )
|
||||
return myWap.getActionableNode();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ public class Platform
|
|||
z = tile.zCoord;
|
||||
}
|
||||
|
||||
if ( type.isItem() || 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 )
|
||||
p.openGui( AppEng.instance, type.ordinal() << 3, p.getEntityWorld(), x, y, z );
|
||||
|
|
Loading…
Reference in a new issue