Add Upgrade Features to Interface, and add Buttons to Interface and Export Bus o alter crafting behavior.

This commit is contained in:
AlgorithmX2 2014-07-04 20:59:50 -05:00
parent 14187dc799
commit fa542c7d15
10 changed files with 176 additions and 37 deletions

View file

@ -1,29 +1,69 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui;
import org.lwjgl.input.Mouse;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.implementations.ContainerInterface;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.IInterfaceHost;
public class GuiInterface extends AEBaseGui
public class GuiInterface extends GuiUpgradeable
{
GuiImgButton BlockMode;
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super( new ContainerInterface( inventoryPlayer, te ) );
this.ySize = 211;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
protected void actionPerformed(GuiButton btn)
{
bindTexture( "guis/interface.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
super.actionPerformed( btn );
boolean backwards = Mouse.isButtonDown( 1 );
try
{
if ( btn == BlockMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( BlockMode.getSetting(), backwards ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
@Override
protected void addButtons()
{
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
buttonList.add( BlockMode );
}
protected String getBackground()
{
return "guis/interface.png";
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
if ( BlockMode != null )
BlockMode.set( ((ContainerInterface) cvb).bMode );
fontRendererObj.drawString( getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
@ -32,5 +72,4 @@ public class GuiInterface extends AEBaseGui
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}

View file

@ -11,6 +11,7 @@ import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.implementations.IUpgradeableHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
@ -29,6 +30,7 @@ public class GuiUpgradeable extends AEBaseGui
GuiImgButton redstoneMode;
GuiImgButton fuzzyMode;
GuiImgButton craftMode;
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
this( new ContainerUpgradeable( inventoryPlayer, te ) );
@ -54,7 +56,9 @@ public class GuiUpgradeable extends AEBaseGui
{
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
craftMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
buttonList.add( craftMode );
buttonList.add( redstoneMode );
buttonList.add( fuzzyMode );
}
@ -71,6 +75,9 @@ public class GuiUpgradeable extends AEBaseGui
if ( btn == redstoneMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( redstoneMode.getSetting(), backwards ) );
if ( btn == craftMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftMode.getSetting(), backwards ) );
if ( btn == fuzzyMode )
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
@ -115,6 +122,8 @@ public class GuiUpgradeable extends AEBaseGui
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
if ( fuzzyMode != null )
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
if ( craftMode != null )
craftMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
}
@Override
@ -128,6 +137,9 @@ public class GuiUpgradeable extends AEBaseGui
if ( fuzzyMode != null )
fuzzyMode.set( cvb.fzMode );
if ( craftMode != null )
craftMode.set( cvb.cMode );
}
protected GuiText getName()

View file

@ -148,11 +148,6 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
// registerApp( 66, Settings.SORT_BY, SortOrder.PRIORITY,
// "AppEng.GuiITooltip.SortBy",
// "AppEng.GuiITooltip.PriorityCellOrder" );
// registerApp( 68, Settings.SORT_BY, SortOrder.MOD,
// ButtonToolTips.SortBy, ButtonToolTips.ItemID );
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
@ -175,14 +170,11 @@ public class GuiImgButton extends GuiButton implements ITooltip
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
registerApp( 16 * 8 + 0, Settings.TRASH_CATCH, YesNo.YES, ButtonToolTips.TrashController, ButtonToolTips.Disabled );
registerApp( 16 * 8 + 1, Settings.TRASH_CATCH, YesNo.NO, ButtonToolTips.TrashController, ButtonToolTips.Enable );
registerApp( 16 * 1 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
registerApp( 16 * 1 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
registerApp( 19, Settings.CRAFT, YesNo.YES, ButtonToolTips.InterfaceCraftingMode, ButtonToolTips.Craft );
registerApp( 17, Settings.CRAFT, YesNo.NO, ButtonToolTips.InterfaceCraftingMode, ButtonToolTips.DontCraft );
registerApp( 16 * 1 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
registerApp( 16 * 1 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
}
}

View file

@ -2,7 +2,10 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SecurityPermissions;
import appeng.container.AEBaseContainer;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotNormal;
import appeng.container.slot.SlotRestrictedInput;
@ -10,25 +13,50 @@ import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
public class ContainerInterface extends AEBaseContainer
public class ContainerInterface extends ContainerUpgradeable
{
DualityInterface myte;
DualityInterface myDuality;
@GuiSync(3)
public YesNo bMode = YesNo.NO;
public ContainerInterface(InventoryPlayer ip, IInterfaceHost te) {
super( ip, te.getInterfaceDuality().getTile(), te.getInterfaceDuality().getPart() );
myte = te.getInterfaceDuality();
super( ip, te.getInterfaceDuality().getHost() );
myDuality = te.getInterfaceDuality();
for (int x = 0; x < 9; x++)
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, myte.getPatterns(), x, 8 + 18 * x, 90 + 7 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7 ) );
for (int x = 0; x < 8; x++)
addSlotToContainer( new SlotFake( myte.getConfig(), x, 17 + 18 * x, 35 ) );
addSlotToContainer( new SlotFake( myDuality.getConfig(), x, 17 + 18 * x, 35 ) );
for (int x = 0; x < 8; x++)
addSlotToContainer( new SlotNormal( myte.getStorage(), x, 17 + 18 * x, 35 + 18 ) );
addSlotToContainer( new SlotNormal( myDuality.getStorage(), x, 17 + 18 * x, 35 + 18 ) );
bindPlayerInventory( ip, 0, 211 - /* height of playerinventory */82 );
}
@Override
protected int getHeight()
{
return 211;
}
@Override
protected void setupConfig()
{
setupUpgrades();
}
protected void loadSettingsFromHost(IConfigManager cm)
{
this.bMode = (YesNo) cm.getSetting( Settings.BLOCK );
}
public int availableUpgrades()
{
return 1;
}
@Override

View file

@ -10,8 +10,10 @@ import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.parts.IPart;
import appeng.api.util.IConfigManager;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
@ -84,11 +86,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
bindPlayerInventory( ip, 0, getHeight() - /* height of playerinventory */82 );
}
protected void setupConfig()
protected void setupUpgrades()
{
int x = 80;
int y = 40;
IInventory upgrades = myte.getInventoryByName( "upgrades" );
if ( availableUpgrades() > 0 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
@ -98,6 +97,13 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
if ( availableUpgrades() > 3 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() );
}
protected void setupConfig()
{
int x = 80;
int y = 40;
setupUpgrades();
IInventory inv = myte.getInventoryByName( "config" );
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
@ -137,6 +143,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
@GuiSync(1)
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
@GuiSync(2)
public YesNo cMode = YesNo.NO;
public void checkToolbox()
{
if ( hasToolbox() )
@ -165,8 +174,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
if ( Platform.isServer() )
{
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
IConfigManager cm = this.myte.getConfigManager();
loadSettingsFromHost( cm );
}
checkToolbox();
@ -184,6 +193,13 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
standardDetectAndSendChanges();
}
protected void loadSettingsFromHost(IConfigManager cm)
{
this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE );
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
}
protected void standardDetectAndSendChanges()
{
super.detectAndSendChanges();

View file

@ -30,11 +30,11 @@ public enum ButtonToolTips
MoveWhenEmpty, MoveWhenWorkIsDone, MoveWhenFull, Disabled, Enable,
Blocking, NonBlocking, Craft, DontCraft,
Blocking, NonBlocking,
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small,
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc;
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither, Craft;
String root;

View file

@ -15,7 +15,11 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.tiles.ICraftingMachine;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.networking.GridFlags;
@ -46,6 +50,7 @@ import appeng.me.helpers.AENetworkProxy;
import appeng.me.storage.MEMonitorIInventory;
import appeng.me.storage.MEMonitorPassthu;
import appeng.me.storage.NullInventory;
import appeng.parts.automation.UpgradeInventory;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
@ -59,7 +64,7 @@ import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.WrapperInvSlot;
public class DualityInterface implements IGridTickable, ISegmentedInventory, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory,
IConfigureableObject, IConfigManagerHost, ICraftingProvider
IConfigureableObject, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
{
final int sides[] = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
@ -74,6 +79,16 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
List<ICraftingPatternDetails> craftingList = null;
List<ItemStack> waitingToSend = null;
private UpgradeInventory upgrades;
@Override
public int getInstalledUpgrades(Upgrades u)
{
if ( upgrades == null )
return 0;
return upgrades.getInstalledUpgrades( u );
}
public boolean hasItemsToSend()
{
return waitingToSend != null && !waitingToSend.isEmpty();
@ -167,6 +182,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
gridProxy = prox;
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
upgrades = new UpgradeInventory( gridProxy.getMachineRepresentation(), this, 1 );
cm.registerSetting( Settings.BLOCK, YesNo.NO );
iHost = ih;
mySrc = fluids.changeSource = items.changeSource = new MachineSource( iHost );
}
@ -595,6 +613,9 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
if ( name.equals( "config" ) )
return config;
if ( name.equals( "upgrades" ) )
return upgrades;
return null;
}
@ -603,6 +624,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
return storage;
}
@Override
public TileEntity getTile()
{
return (TileEntity) (iHost instanceof TileEntity ? iHost : null);
@ -620,6 +642,12 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{
if ( getInstalledUpgrades( Upgrades.CRAFTING ) == 0 )
cancelCrafting();
}
private void cancelCrafting()
{
// TODO Auto-generated method stub
@ -683,7 +711,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
private boolean isBlocking()
{
return true;
return cm.getSetting( Settings.BLOCK ) == YesNo.YES;
}
@Override
@ -802,8 +830,17 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
TileEntity te = iHost.getTileEntity();
if ( te != null && te.getWorldObj() != null )
{
te.getWorldObj().notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.air );
// te.getWorldObj().notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.air );
}
}
public IUpgradeableHost getHost()
{
if ( getPart() instanceof IUpgradeableHost )
return (IUpgradeableHost) getPart();
if ( getTile() instanceof IUpgradeableHost )
return (IUpgradeableHost) getTile();
return null;
}
}

View file

@ -4,10 +4,11 @@ import java.util.EnumSet;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.crafting.ICraftingProvider;
import appeng.api.networking.security.IActionHost;
public interface IInterfaceHost extends IActionHost, ICraftingProvider
public interface IInterfaceHost extends IActionHost, ICraftingProvider, IUpgradeableHost
{
DualityInterface getInterfaceDuality();

View file

@ -14,6 +14,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
import appeng.api.networking.IGridNode;
@ -354,4 +355,10 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISeg
return duality.isBusy();
}
@Override
public int getInstalledUpgrades(Upgrades u)
{
return duality.getInstalledUpgrades( u );
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
import appeng.api.networking.IGridNode;
@ -255,4 +256,10 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
return duality.isBusy();
}
@Override
public int getInstalledUpgrades(Upgrades u)
{
return duality.getInstalledUpgrades( u );
}
}