From cdcae974e247e0c4f6e9ce38498c26fc7f0a510d Mon Sep 17 00:00:00 2001 From: yueh Date: Thu, 25 Sep 2014 22:30:19 +0200 Subject: [PATCH] Changed Inscriber to be upgradable with Cards Supports up to 3 cards Currently max 3 Acceleration Cards, each reducing the crafting time by 25% --- .../gui/implementations/GuiInscriber.java | 22 +++++- .../implementations/ContainerInscriber.java | 64 +++++++++++----- src/main/java/appeng/core/Registration.java | 3 + .../java/appeng/tile/misc/TileInscriber.java | 72 +++++++++++++++--- .../textures/guis/inscriber.png | Bin 3238 -> 2423 bytes 5 files changed, 132 insertions(+), 29 deletions(-) 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 cbce61695312ea74aaf85ee3430bf460962df308..67c88610f73d5b6e6e287c342f8daf49e326b56d 100644 GIT binary patch literal 2423 zcmeHIYfuwc6u!H#2#IKTnu>*#M-2)T#DXs%2@nX+7=lJ^A%LK~Le!vGR2G6IkOB%Q zsckiaH0Y?{gTiRQ1uCFeA45<;s5lrZph%|(30K5X=b)c2NkHH8baUhq=+uGW2 z0(~4GJMdrYK&N5rW!;A&;e|yI9R5EK5HY>TfjB=Sap1On04%wwd!hCjjR!GFmG}!J z5ormM12KE!fjA~nBykbNOK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