Moving the handling of progress to GuiProgressBar

Adds an interface providing data for GuiProgressBar
Changed all containers simulating progress to implement the interface
This commit is contained in:
yueh
2014-09-28 20:36:58 +02:00
parent 640d888d13
commit 21a7d815ae
10 changed files with 142 additions and 44 deletions
@@ -5,12 +5,13 @@ import appeng.api.config.CondenserOutput;
import appeng.api.config.Settings;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class ContainerCondenser extends AEBaseContainer
public class ContainerCondenser extends AEBaseContainer implements IProgressProvider
{
TileCondenser condenser;
@@ -52,4 +53,16 @@ public class ContainerCondenser extends AEBaseContainer
@GuiSync(2)
public CondenserOutput output = CondenserOutput.TRASH;
@Override
public int getCurrentProgress()
{
return (int) storedPower;
}
@Override
public int getMaxProgress()
{
return (int) requiredEnergy;
}
}
@@ -5,6 +5,7 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.recipes.handlers.Inscribe;
@@ -12,7 +13,7 @@ import appeng.recipes.handlers.Inscribe.InscriberRecipe;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class ContainerInscriber extends ContainerUpgradeable
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider
{
TileInscriber ti;
@@ -157,4 +158,16 @@ public class ContainerInscriber extends ContainerUpgradeable
this.processingTime = ti.processingTime;
}
}
@Override
public int getCurrentProgress()
{
return processingTime;
}
@Override
public int getMaxProgress()
{
return maxProcessingTime;
}
}
@@ -9,6 +9,7 @@ import appeng.api.config.SecurityPermissions;
import appeng.api.config.Settings;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotMACPattern;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
@@ -16,12 +17,14 @@ import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
public class ContainerMAC extends ContainerUpgradeable
public class ContainerMAC extends ContainerUpgradeable implements IProgressProvider
{
TileMolecularAssembler tma;
private static final int MAX_CRAFT_PROGRESS = 100;
public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te) {
public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te)
{
super( ip, te );
tma = te;
}
@@ -92,11 +95,16 @@ public class ContainerMAC extends ContainerUpgradeable
offY = 17;
IInventory upgrades = upgradeable.getInventoryByName( "upgrades" );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer )).setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer ))
.setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer ))
.setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer ))
.setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer ))
.setNotDraggable() );
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer ))
.setNotDraggable() );
}
@Override
@@ -114,4 +122,16 @@ public class ContainerMAC extends ContainerUpgradeable
standardDetectAndSendChanges();
}
@Override
public int getCurrentProgress()
{
return craftProgress;
}
@Override
public int getMaxProgress()
{
return MAX_CRAFT_PROGRESS;
}
}
@@ -3,14 +3,16 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
public class ContainerVibrationChamber extends AEBaseContainer
public class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider
{
TileVibrationChamber vibrationChamber;
private static final int MAX_BURN_TIME = 200;
public ContainerVibrationChamber(InventoryPlayer ip, TileVibrationChamber vibrationChamber) {
super( ip, vibrationChamber, null );
@@ -41,4 +43,16 @@ public class ContainerVibrationChamber extends AEBaseContainer
super.detectAndSendChanges();
}
@Override
public int getCurrentProgress()
{
return burnProgress > 0 ? burnSpeed : 0;
}
@Override
public int getMaxProgress()
{
return MAX_BURN_TIME;
}
}