Merge pull request #2 from yueh/feature-upgradeable-inscriber
Changed Inscriber to be upgradable with Cards Closes #126
This commit is contained in:
commit
0b87595f9d
5 changed files with 132 additions and 29 deletions
|
@ -5,6 +5,7 @@ import appeng.client.gui.AEBaseGui;
|
||||||
import appeng.client.gui.widgets.GuiProgressBar;
|
import appeng.client.gui.widgets.GuiProgressBar;
|
||||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||||
import appeng.container.implementations.ContainerInscriber;
|
import appeng.container.implementations.ContainerInscriber;
|
||||||
|
import appeng.container.implementations.ContainerUpgradeable;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.tile.misc.TileInscriber;
|
import appeng.tile.misc.TileInscriber;
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ public class GuiInscriber extends AEBaseGui
|
||||||
super( new ContainerInscriber( inventoryPlayer, te ) );
|
super( new ContainerInscriber( inventoryPlayer, te ) );
|
||||||
cvc = (ContainerInscriber) inventorySlots;
|
cvc = (ContainerInscriber) inventorySlots;
|
||||||
this.ySize = 176;
|
this.ySize = 176;
|
||||||
|
this.xSize = hasToolbox() ? 246 : 211;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +27,7 @@ public class GuiInscriber extends AEBaseGui
|
||||||
{
|
{
|
||||||
super.initGui();
|
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 );
|
this.buttonList.add( pb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +37,13 @@ public class GuiInscriber extends AEBaseGui
|
||||||
bindTexture( "guis/inscriber.png" );
|
bindTexture( "guis/inscriber.png" );
|
||||||
pb.xPosition = 135 + guiLeft;
|
pb.xPosition = 135 + guiLeft;
|
||||||
pb.yPosition = 39 + guiTop;
|
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
|
@Override
|
||||||
|
@ -49,4 +57,14 @@ public class GuiInscriber extends AEBaseGui
|
||||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean drawUpgrades()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean hasToolbox()
|
||||||
|
{
|
||||||
|
return ((ContainerUpgradeable) inventorySlots).hasToolbox();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.container.AEBaseContainer;
|
|
||||||
import appeng.container.guisync.GuiSync;
|
import appeng.container.guisync.GuiSync;
|
||||||
import appeng.container.slot.SlotOutput;
|
import appeng.container.slot.SlotOutput;
|
||||||
import appeng.container.slot.SlotRestrictedInput;
|
import appeng.container.slot.SlotRestrictedInput;
|
||||||
|
@ -13,38 +12,67 @@ import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||||
import appeng.tile.misc.TileInscriber;
|
import appeng.tile.misc.TileInscriber;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
public class ContainerInscriber extends AEBaseContainer
|
public class ContainerInscriber extends ContainerUpgradeable
|
||||||
{
|
{
|
||||||
|
|
||||||
TileInscriber myte;
|
TileInscriber ti;
|
||||||
|
|
||||||
Slot top;
|
Slot top;
|
||||||
Slot middle;
|
Slot middle;
|
||||||
Slot bottom;
|
Slot bottom;
|
||||||
|
|
||||||
@GuiSync(0)
|
@GuiSync(2)
|
||||||
public int maxProcessingTime = -1;
|
public int maxProcessingTime = -1;
|
||||||
|
|
||||||
@GuiSync(1)
|
@GuiSync(3)
|
||||||
public int processingTime = -1;
|
public int processingTime = -1;
|
||||||
|
|
||||||
public ContainerInscriber(InventoryPlayer ip, TileInscriber te) {
|
public ContainerInscriber(InventoryPlayer ip, TileInscriber te)
|
||||||
super( ip, te, null );
|
{
|
||||||
myte = te;
|
super( ip, te );
|
||||||
|
ti = te;
|
||||||
|
|
||||||
addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 0, 45, 16, invPlayer ) );
|
addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 0, 45, 16, invPlayer ) );
|
||||||
addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 1, 45, 62, invPlayer ) );
|
addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 1, 45, 62, invPlayer ) );
|
||||||
addSlotToContainer( middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, myte, 2, 63, 39, 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)
|
public boolean isValidForSlot(Slot s, ItemStack is)
|
||||||
{
|
{
|
||||||
ItemStack PlateA = myte.getStackInSlot( 0 );
|
ItemStack PlateA = ti.getStackInSlot( 0 );
|
||||||
ItemStack PlateB = myte.getStackInSlot( 1 );
|
ItemStack PlateB = ti.getStackInSlot( 1 );
|
||||||
|
|
||||||
if ( s == middle )
|
if ( s == middle )
|
||||||
{
|
{
|
||||||
|
@ -120,12 +148,12 @@ public class ContainerInscriber extends AEBaseContainer
|
||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
super.detectAndSendChanges();
|
standardDetectAndSendChanges();
|
||||||
|
|
||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
this.maxProcessingTime = myte.maxProcessingTime;
|
this.maxProcessingTime = ti.maxProcessingTime;
|
||||||
this.processingTime = myte.processingTime;
|
this.processingTime = ti.processingTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,6 +660,9 @@ public class Registration
|
||||||
// Molecular Assembler
|
// Molecular Assembler
|
||||||
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ), 5 );
|
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() );
|
AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||||
|
|
||||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||||
|
|
|
@ -12,6 +12,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
|
import appeng.api.config.Upgrades;
|
||||||
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.energy.IEnergyGrid;
|
import appeng.api.networking.energy.IEnergyGrid;
|
||||||
import appeng.api.networking.energy.IEnergySource;
|
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.TickRateModulation;
|
||||||
import appeng.api.networking.ticking.TickingRequest;
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
import appeng.api.util.AECableType;
|
import appeng.api.util.AECableType;
|
||||||
|
import appeng.api.util.IConfigManager;
|
||||||
import appeng.core.settings.TickRates;
|
import appeng.core.settings.TickRates;
|
||||||
import appeng.me.GridAccessException;
|
import appeng.me.GridAccessException;
|
||||||
|
import appeng.parts.automation.UpgradeInventory;
|
||||||
import appeng.recipes.handlers.Inscribe;
|
import appeng.recipes.handlers.Inscribe;
|
||||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||||
import appeng.tile.TileEvent;
|
import appeng.tile.TileEvent;
|
||||||
|
@ -28,12 +32,14 @@ import appeng.tile.events.TileEventType;
|
||||||
import appeng.tile.grid.AENetworkPowerTile;
|
import appeng.tile.grid.AENetworkPowerTile;
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.tile.inventory.InvOperation;
|
import appeng.tile.inventory.InvOperation;
|
||||||
|
import appeng.util.ConfigManager;
|
||||||
|
import appeng.util.IConfigManagerHost;
|
||||||
import appeng.util.InventoryAdaptor;
|
import appeng.util.InventoryAdaptor;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.inv.WrapperInventoryRange;
|
import appeng.util.inv.WrapperInventoryRange;
|
||||||
import appeng.util.item.AEItemStack;
|
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 };
|
final int top[] = new int[] { 0 };
|
||||||
|
@ -51,6 +57,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
|
|
||||||
public long clientStart;
|
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
|
@Override
|
||||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||||
{
|
{
|
||||||
|
@ -61,12 +71,16 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
public void writeToNBT_TileInscriber(NBTTagCompound data)
|
public void writeToNBT_TileInscriber(NBTTagCompound data)
|
||||||
{
|
{
|
||||||
inv.writeToNBT( data, "inscriberInv" );
|
inv.writeToNBT( data, "inscriberInv" );
|
||||||
|
upgrades.writeToNBT( data, "upgrades" );
|
||||||
|
settings.writeToNBT( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||||
public void readFromNBT_TileInscriber(NBTTagCompound data)
|
public void readFromNBT_TileInscriber(NBTTagCompound data)
|
||||||
{
|
{
|
||||||
inv.readFromNBT( data, "inscriberInv" );
|
inv.readFromNBT( data, "inscriberInv" );
|
||||||
|
upgrades.readFromNBT( data, "upgrades" );
|
||||||
|
settings.readFromNBT( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
@TileEvent(TileEventType.NETWORK_READ)
|
@TileEvent(TileEventType.NETWORK_READ)
|
||||||
|
@ -122,7 +136,8 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TileInscriber() {
|
public TileInscriber()
|
||||||
|
{
|
||||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||||
internalMaxPower = 1500;
|
internalMaxPower = 1500;
|
||||||
gridProxy.setIdlePowerUsage( 0 );
|
gridProxy.setIdlePowerUsage( 0 );
|
||||||
|
@ -314,6 +329,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
{
|
{
|
||||||
if ( smash )
|
if ( smash )
|
||||||
{
|
{
|
||||||
|
|
||||||
finalStep++;
|
finalStep++;
|
||||||
if ( finalStep == 8 )
|
if ( finalStep == 8 )
|
||||||
{
|
{
|
||||||
|
@ -354,22 +370,26 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
eg = gridProxy.getEnergy();
|
eg = gridProxy.getEnergy();
|
||||||
IEnergySource src = this;
|
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;
|
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 )
|
if ( processingTime == 0 )
|
||||||
processingTime++;
|
processingTime = processingTime + speedFactor;
|
||||||
else
|
else
|
||||||
processingTime += TicksSinceLastCall;
|
processingTime += TicksSinceLastCall * speedFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (GridAccessException e)
|
catch (GridAccessException e)
|
||||||
|
@ -397,4 +417,38 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||||
|
|
||||||
return hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP;
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in a new issue