diff --git a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java index 52143946..f2c39e6d 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java @@ -5,6 +5,7 @@ import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiProgressBar; import appeng.client.gui.widgets.GuiProgressBar.Direction; import appeng.container.implementations.ContainerInscriber; +import appeng.container.implementations.ContainerUpgradeable; import appeng.core.localization.GuiText; import appeng.tile.misc.TileInscriber; @@ -18,6 +19,7 @@ public class GuiInscriber extends AEBaseGui super( new ContainerInscriber( inventoryPlayer, te ) ); cvc = (ContainerInscriber) inventorySlots; this.ySize = 176; + this.xSize = hasToolbox() ? 246 : 211; } @Override @@ -25,7 +27,7 @@ public class GuiInscriber extends AEBaseGui { super.initGui(); - pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 179, 39, 6, 18, Direction.VERTICAL ); + pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 135, 177, 6, 18, Direction.VERTICAL ); this.buttonList.add( pb ); } @@ -35,7 +37,13 @@ public class GuiInscriber extends AEBaseGui bindTexture( "guis/inscriber.png" ); pb.xPosition = 135 + guiLeft; pb.yPosition = 39 + guiTop; - this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); + + this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize ); + + if ( drawUpgrades() ) + this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + cvc.availableUpgrades() * 18 ); + if ( hasToolbox() ) + this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, ySize - 90, 68, 68 ); } @Override @@ -49,4 +57,14 @@ public class GuiInscriber extends AEBaseGui fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); } + protected boolean drawUpgrades() + { + return true; + } + + protected boolean hasToolbox() + { + return ((ContainerUpgradeable) inventorySlots).hasToolbox(); + } + } diff --git a/src/main/java/appeng/container/implementations/ContainerInscriber.java b/src/main/java/appeng/container/implementations/ContainerInscriber.java index 08fbec55..afd6958d 100644 --- a/src/main/java/appeng/container/implementations/ContainerInscriber.java +++ b/src/main/java/appeng/container/implementations/ContainerInscriber.java @@ -4,7 +4,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import appeng.api.AEApi; -import appeng.container.AEBaseContainer; import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotRestrictedInput; @@ -13,38 +12,67 @@ import appeng.recipes.handlers.Inscribe.InscriberRecipe; import appeng.tile.misc.TileInscriber; import appeng.util.Platform; -public class ContainerInscriber extends AEBaseContainer +public class ContainerInscriber extends ContainerUpgradeable { - TileInscriber myte; + TileInscriber ti; Slot top; Slot middle; Slot bottom; - @GuiSync(0) + @GuiSync(2) public int maxProcessingTime = -1; - @GuiSync(1) + @GuiSync(3) public int processingTime = -1; - public ContainerInscriber(InventoryPlayer ip, TileInscriber te) { - super( ip, te, null ); - myte = te; + public ContainerInscriber(InventoryPlayer ip, TileInscriber te) + { + super( ip, te ); + ti = te; - addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 0, 45, 16, invPlayer ) ); - addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 1, 45, 62, invPlayer ) ); - addSlotToContainer( middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, myte, 2, 63, 39, invPlayer ) ); + addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 0, 45, 16, invPlayer ) ); + addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 1, 45, 62, invPlayer ) ); + addSlotToContainer( middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, ti, 2, 63, 39, invPlayer ) ); - addSlotToContainer( new SlotOutput( myte, 3, 113, 40, -1 ) ); + addSlotToContainer( new SlotOutput( ti, 3, 113, 40, -1 ) ); - bindPlayerInventory( ip, 0, 176 - /* height of playerinventory */82 ); + bindPlayerInventory( ip, 0, getHeight() - /* height of playerinventory */82 ); + + } + + @Override + protected int getHeight() + { + return 176; + } + + @Override + public int availableUpgrades() + { + return 3; + } + + @Override + protected boolean supportCapacity() + { + return false; + } + + @Override + /** + * Overridden super.setupConfig to prevent setting up the fake slots + */ + protected void setupConfig() + { + setupUpgrades(); } public boolean isValidForSlot(Slot s, ItemStack is) { - ItemStack PlateA = myte.getStackInSlot( 0 ); - ItemStack PlateB = myte.getStackInSlot( 1 ); + ItemStack PlateA = ti.getStackInSlot( 0 ); + ItemStack PlateB = ti.getStackInSlot( 1 ); if ( s == middle ) { @@ -120,12 +148,12 @@ public class ContainerInscriber extends AEBaseContainer @Override public void detectAndSendChanges() { - super.detectAndSendChanges(); + standardDetectAndSendChanges(); if ( Platform.isServer() ) { - this.maxProcessingTime = myte.maxProcessingTime; - this.processingTime = myte.processingTime; + this.maxProcessingTime = ti.maxProcessingTime; + this.processingTime = ti.processingTime; } } } diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 2a8a449f..9aadddc4 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -660,6 +660,9 @@ public class Registration // Molecular Assembler Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ), 5 ); + // Inscriber + Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockInscriber.stack( 1 ), 3 ); + AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() ); if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) ) diff --git a/src/main/java/appeng/tile/misc/TileInscriber.java b/src/main/java/appeng/tile/misc/TileInscriber.java index 2af259bc..041098e9 100644 --- a/src/main/java/appeng/tile/misc/TileInscriber.java +++ b/src/main/java/appeng/tile/misc/TileInscriber.java @@ -12,6 +12,8 @@ import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; +import appeng.api.config.Upgrades; +import appeng.api.implementations.IUpgradeableHost; import appeng.api.networking.IGridNode; import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.energy.IEnergySource; @@ -19,8 +21,10 @@ import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; import appeng.api.util.AECableType; +import appeng.api.util.IConfigManager; import appeng.core.settings.TickRates; import appeng.me.GridAccessException; +import appeng.parts.automation.UpgradeInventory; import appeng.recipes.handlers.Inscribe; import appeng.recipes.handlers.Inscribe.InscriberRecipe; import appeng.tile.TileEvent; @@ -28,12 +32,14 @@ import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkPowerTile; import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.InvOperation; +import appeng.util.ConfigManager; +import appeng.util.IConfigManagerHost; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.WrapperInventoryRange; import appeng.util.item.AEItemStack; -public class TileInscriber extends AENetworkPowerTile implements IGridTickable +public class TileInscriber extends AENetworkPowerTile implements IGridTickable, IUpgradeableHost, IConfigManagerHost { final int top[] = new int[] { 0 }; @@ -51,6 +57,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable public long clientStart; + static final ItemStack inscriberStack = AEApi.instance().blocks().blockInscriber.stack( 1 ); + private IConfigManager settings = new ConfigManager( this ); + private UpgradeInventory upgrades = new UpgradeInventory( inscriberStack, this, getUpgradeSlots() ); + @Override public AECableType getCableConnectionType(ForgeDirection dir) { @@ -61,12 +71,16 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable public void writeToNBT_TileInscriber(NBTTagCompound data) { inv.writeToNBT( data, "inscriberInv" ); + upgrades.writeToNBT( data, "upgrades" ); + settings.writeToNBT( data ); } @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBT_TileInscriber(NBTTagCompound data) { inv.readFromNBT( data, "inscriberInv" ); + upgrades.readFromNBT( data, "upgrades" ); + settings.readFromNBT( data ); } @TileEvent(TileEventType.NETWORK_READ) @@ -122,7 +136,8 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable return true; } - public TileInscriber() { + public TileInscriber() + { gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); internalMaxPower = 1500; gridProxy.setIdlePowerUsage( 0 ); @@ -314,6 +329,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable { if ( smash ) { + finalStep++; if ( finalStep == 8 ) { @@ -354,22 +370,26 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable eg = gridProxy.getEnergy(); IEnergySource src = this; - double powerReq = extractAEPower( 10, Actionable.SIMULATE, PowerMultiplier.CONFIG ); + // Base 1, increase by 1 for each card + int speedFactor = 1 + upgrades.getInstalledUpgrades( Upgrades.SPEED ); + int powerConsumption = 10 * speedFactor; + double powerThreshold = powerConsumption - 0.01; + double powerReq = extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG ); - if ( powerReq <= 9.99 ) + if ( powerReq <= powerThreshold ) { src = eg; - powerReq = eg.extractAEPower( 10, Actionable.SIMULATE, PowerMultiplier.CONFIG ); + powerReq = eg.extractAEPower( powerConsumption, Actionable.SIMULATE, PowerMultiplier.CONFIG ); } - if ( powerReq > 9.99 ) + if ( powerReq > powerThreshold ) { - src.extractAEPower( 10, Actionable.MODULATE, PowerMultiplier.CONFIG ); + src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG ); if ( processingTime == 0 ) - processingTime++; + processingTime = processingTime + speedFactor; else - processingTime += TicksSinceLastCall; + processingTime += TicksSinceLastCall * speedFactor; } } catch (GridAccessException e) @@ -397,4 +417,38 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable return hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP; } + + @Override + public IConfigManager getConfigManager() + { + return settings; + } + + @Override + public IInventory getInventoryByName(String name) + { + if ( name.equals( "inv" ) ) + return inv; + + if ( name.equals( "upgrades" ) ) + return upgrades; + + return null; + } + + @Override + public int getInstalledUpgrades(Upgrades u) + { + return upgrades.getInstalledUpgrades( u ); + } + + protected int getUpgradeSlots() + { + return 3; + } + + @Override + public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) + { + } } diff --git a/src/main/resources/assets/appliedenergistics2/textures/guis/inscriber.png b/src/main/resources/assets/appliedenergistics2/textures/guis/inscriber.png index cbce6169..67c88610 100644 Binary files a/src/main/resources/assets/appliedenergistics2/textures/guis/inscriber.png and b/src/main/resources/assets/appliedenergistics2/textures/guis/inscriber.png differ