diff --git a/block/crafting/BlockMolecularAssembler.java b/block/crafting/BlockMolecularAssembler.java index 3b855ac21..a2c8e9f94 100644 --- a/block/crafting/BlockMolecularAssembler.java +++ b/block/crafting/BlockMolecularAssembler.java @@ -3,12 +3,17 @@ package appeng.block.crafting; import java.util.EnumSet; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import appeng.block.AEBaseBlock; import appeng.client.render.BaseBlockRender; import appeng.client.render.blocks.RenderQuartzGlass; import appeng.core.features.AEFeature; +import appeng.core.sync.GuiBridge; import appeng.tile.crafting.TileMolecularAssembler; +import appeng.util.Platform; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -36,4 +41,15 @@ public class BlockMolecularAssembler extends AEBaseBlock return super.shouldSideBeRendered( w, x, y, z, side ); } + @Override + public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ) + { + TileMolecularAssembler tg = getTileEntity( w, x, y, z ); + if ( tg != null && !p.isSneaking() ) + { + Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC ); + return true; + } + return false; + } } diff --git a/client/gui/implementations/GuiMAC.java b/client/gui/implementations/GuiMAC.java new file mode 100644 index 000000000..fa923bab9 --- /dev/null +++ b/client/gui/implementations/GuiMAC.java @@ -0,0 +1,32 @@ +package appeng.client.gui.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import appeng.client.gui.AEBaseGui; +import appeng.container.implementations.ContainerMAC; +import appeng.core.localization.GuiText; +import appeng.tile.crafting.TileMolecularAssembler; + +public class GuiMAC extends AEBaseGui +{ + + public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) { + super( new ContainerMAC( inventoryPlayer, te ) ); + this.ySize = 197; + this.xSize = 211; + } + + @Override + public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) + { + bindTexture( "guis/mac.png" ); + this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); + } + + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) + { + fontRendererObj.drawString( getGuiDisplayName( GuiText.MolecularAssembler.getLocal() ), 8, 6, 4210752 ); + fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); + } + +} diff --git a/container/implementations/ContainerMAC.java b/container/implementations/ContainerMAC.java new file mode 100644 index 000000000..1139ac90b --- /dev/null +++ b/container/implementations/ContainerMAC.java @@ -0,0 +1,91 @@ +package appeng.container.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import appeng.api.config.RedstoneMode; +import appeng.api.config.SecurityPermissions; +import appeng.api.config.Settings; +import appeng.container.slot.SlotRestrictedInput; +import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; +import appeng.tile.crafting.TileMolecularAssembler; +import appeng.util.Platform; + +public class ContainerMAC extends ContainerUpgradeable +{ + + public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te) { + super( ip, te ); + } + + @Override + protected int getHeight() + { + return 197; + } + + @Override + protected boolean supportCapacity() + { + return false; + } + + @Override + protected void setupConfig() + { + int offx = 29; + int offy = 30; + + IInventory cells = myte.getInventoryByName( "mac" ); + + for (int y = 0; y < 3; y++) + for (int x = 0; x < 3; x++) + addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, cells, x + y * 2, offx + x * 18, offy + y * 18 ) ); + + offx = 126; + offy = 16; + + addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, cells, 10, offx, offy ) ); + addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, cells, 9, offx, offy + 32 ) ); + + offx = 122; + offy = 17; + + IInventory upgrades = myte.getInventoryByName( "upgrades" ); + addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() ); + addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() ); + addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() ); + addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() ); + addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4 )).setNotDraggable() ); + } + + @Override + public void detectAndSendChanges() + { + verifyPermissions( SecurityPermissions.BUILD, false ); + + if ( Platform.isServer() ) + { + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting) this.crafters.get( i ); + + if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) ) + { + icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ).ordinal() ); + } + } + + this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ); + } + + standardDetectAndSendChanges(); + } + + @Override + public void updateProgressBar(int idx, int value) + { + super.updateProgressBar( idx, value ); + } + +} diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 584079447..ce4b2af12 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -28,7 +28,7 @@ public enum GuiText StoredPower, MaxPower, RequiredPower, Efficiency, CopyMode, CopyModeDesc, PatternTerminal, - CraftingPattern, ProcessingPattern, Crafts, Creates, And, With; + CraftingPattern, ProcessingPattern, Crafts, Creates, And, With, MolecularAssembler; String root; diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index ea4555452..0722a540b 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -39,6 +39,7 @@ import appeng.container.implementations.ContainerIOPort; import appeng.container.implementations.ContainerInscriber; import appeng.container.implementations.ContainerInterface; import appeng.container.implementations.ContainerLevelEmitter; +import appeng.container.implementations.ContainerMAC; import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.implementations.ContainerMEPortableCell; import appeng.container.implementations.ContainerNetworkStatus; @@ -65,6 +66,7 @@ import appeng.parts.misc.PartStorageBus; import appeng.parts.reporting.PartCraftingTerminal; import appeng.parts.reporting.PartPatternTerminal; import appeng.server.AccessType; +import appeng.tile.crafting.TileMolecularAssembler; import appeng.tile.grindstone.TileGrinder; import appeng.tile.misc.TileCellWorkbench; import appeng.tile.misc.TileCondenser; @@ -139,7 +141,9 @@ public enum GuiBridge implements IGuiHandler GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, false, null), - GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, false, null); + GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, false, null), + + GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, false, null); private Class Tile; private Class Gui; diff --git a/tile/crafting/TileMolecularAssembler.java b/tile/crafting/TileMolecularAssembler.java index 753688287..171d815d2 100644 --- a/tile/crafting/TileMolecularAssembler.java +++ b/tile/crafting/TileMolecularAssembler.java @@ -5,22 +5,44 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; +import appeng.api.AEApi; +import appeng.api.config.RedstoneMode; +import appeng.api.config.Settings; +import appeng.api.config.Upgrades; +import appeng.api.implementations.IUpgradeableHost; import appeng.api.util.AECableType; import appeng.api.util.DimensionalCoord; +import appeng.api.util.IConfigManager; +import appeng.parts.automation.UpgradeInventory; import appeng.tile.events.AETileEventHandler; import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkInvTile; import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; +import appeng.util.ConfigManager; +import appeng.util.IConfigManagerHost; -public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEngInventory, ISidedInventory +public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEngInventory, ISidedInventory, IUpgradeableHost, IConfigManagerHost { - final int[] sides = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + static final int[] sides = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + static final ItemStack is = AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ); - boolean hasPattern = false; - AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 + 2 ); + private AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 + 2 ); + private IConfigManager settings = new ConfigManager( this ); + private UpgradeInventory upgrades = new UpgradeInventory( is, this, getUpgradeSlots() ); + + @Override + public int getInstalledUpgrades(Upgrades u) + { + return upgrades.getInstalledUpgrades( u ); + } + + protected int getUpgradeSlots() + { + return 5; + } private class TileMolecularAssemblerHandler extends AETileEventHandler { @@ -32,18 +54,23 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn @Override public void writeToNBT(NBTTagCompound data) { - + upgrades.writeToNBT( data, "upgrades" ); + inv.writeToNBT( data, "inv" ); + settings.writeToNBT( data ); } @Override public void readFromNBT(NBTTagCompound data) { - + upgrades.readFromNBT( data, "upgrades" ); + inv.readFromNBT( data, "inv" ); + settings.readFromNBT( data ); } }; public TileMolecularAssembler() { + settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); addNewHandler( new TileMolecularAssemblerHandler() ); } @@ -53,7 +80,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn if ( i >= 9 ) return false; - if ( hasPattern ) + if ( hasPattern() ) { } @@ -61,6 +88,11 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn return false; } + private boolean hasPattern() + { + return false; + } + @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { @@ -97,4 +129,28 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn return new DimensionalCoord( this ); } + @Override + public IConfigManager getConfigManager() + { + return settings; + } + + @Override + public IInventory getInventoryByName(String name) + { + if ( name.equals( "upgrades" ) ) + return upgrades; + + if ( name.equals( "mac" ) ) + return inv; + + return null; + } + + @Override + public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) + { + + } + }