Level Emitter and Stack Watcher Implementation.

This commit is contained in:
AlgorithmX2
2014-01-05 02:49:08 -06:00
parent 09a8f82245
commit b8b37b5791
6 changed files with 663 additions and 55 deletions
+37 -15
View File
@@ -31,10 +31,14 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
myte = te;
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() );
if ( availableUpgrades() > 0 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() );
if ( availableUpgrades() > 1 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() );
if ( availableUpgrades() > 2 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() );
if ( availableUpgrades() > 3 )
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() );
if ( hasToolbox() )
{
@@ -49,19 +53,32 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
IInventory inv = myte.getInventoryByName( "config" );
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
if ( supportCapacity() )
{
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
}
bindPlayerInventory( ip, 0, 184 - /* height of playerinventory */82 );
}
protected int availableUpgrades()
{
return 4;
}
protected boolean supportCapacity()
{
return true;
}
public RedstoneMode rsMode = RedstoneMode.IGNORE;
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
@@ -74,9 +91,9 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_OUTPUT ) )
if ( this.rsMode != this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_OUTPUT ).ordinal() );
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED ).ordinal() );
}
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
@@ -86,7 +103,7 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
}
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_OUTPUT );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
for (Object o : inventorySlots)
@@ -99,6 +116,11 @@ public class ContainerBus extends AEBaseContainer implements IOptionalSlotHost
}
}
standardDetectAndSendChanges();
}
protected void standardDetectAndSendChanges()
{
super.detectAndSendChanges();
}
@@ -1,23 +1,102 @@
package appeng.container.implementations;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import net.minecraft.inventory.ICrafting;
import appeng.api.config.FuzzyMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.parts.automation.PartLevelEmitter;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerLevelEmitter extends AEBaseContainer
public class ContainerLevelEmitter extends ContainerBus
{
PartLevelEmitter myte;
PartLevelEmitter lvlEmitter;
@SideOnly(Side.CLIENT)
public GuiTextField textField;
@SideOnly(Side.CLIENT)
public void setTextField(GuiTextField level)
{
textField = level;
textField.setText( "" + EmitterValue );
}
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
super( ip, te.getHost().getTile(), te );
myte = te;
// addSlotToContainer( new SlotRestrictedInput(
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
super( ip, te );
lvlEmitter = te;
}
@Override
protected int availableUpgrades()
{
return 1;
}
@Override
protected boolean supportCapacity()
{
return false;
}
int EmitterValue = -1;
public void setLevel(int newValue, EntityPlayer player)
{
lvlEmitter.setReportingValue( newValue );
EmitterValue = newValue;
}
@Override
public void detectAndSendChanges()
{
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_EMITTER ) )
{
icrafting.sendProgressBarUpdate( this, 0, (int) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ).ordinal() );
}
if ( this.fzMode != this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ) )
{
icrafting.sendProgressBarUpdate( this, 1, (int) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE ).ordinal() );
}
if ( this.EmitterValue != lvlEmitter.getReportingValue() )
{
icrafting.sendProgressBarUpdate( this, 2, (int) lvlEmitter.getReportingValue() );
}
}
this.EmitterValue = (int) lvlEmitter.getReportingValue();
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER );
}
standardDetectAndSendChanges();
}
@Override
public void updateProgressBar(int idx, int value)
{
super.updateProgressBar( idx, value );
if ( idx == 2 )
{
EmitterValue = value;
if ( textField != null )
textField.setText( "" + EmitterValue );
}
}
}