2013-12-27 23:59:59 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
2014-02-16 05:33:13 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
import net.minecraft.client.gui.GuiTextField;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-02-16 05:33:13 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-01-05 09:49:08 +01:00
|
|
|
import net.minecraft.inventory.ICrafting;
|
2014-01-20 17:41:37 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.config.FuzzyMode;
|
2014-02-21 07:10:38 +01:00
|
|
|
import appeng.api.config.LevelType;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.config.RedstoneMode;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.config.SecurityPermissions;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.config.Settings;
|
2014-01-20 17:41:37 +01:00
|
|
|
import appeng.container.slot.SlotFakeTypeOnly;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
2014-02-16 05:33:13 +01:00
|
|
|
import appeng.core.AELog;
|
|
|
|
import appeng.core.sync.network.NetworkHandler;
|
|
|
|
import appeng.core.sync.packets.PacketProgressBar;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.parts.automation.PartLevelEmitter;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
public class ContainerLevelEmitter extends ContainerUpgradeable
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
PartLevelEmitter lvlEmitter;
|
2014-02-21 07:10:38 +01:00
|
|
|
long EmitterValue = -1;
|
2014-01-05 09:49:08 +01:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public GuiTextField textField;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void setTextField(GuiTextField level)
|
|
|
|
{
|
|
|
|
textField = level;
|
|
|
|
textField.setText( "" + EmitterValue );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
|
2014-01-05 09:49:08 +01:00
|
|
|
super( ip, te );
|
|
|
|
lvlEmitter = te;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-01-20 17:41:37 +01:00
|
|
|
public int availableUpgrades()
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean supportCapacity()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
public void setLevel(long l, EntityPlayer player)
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-02-21 07:10:38 +01:00
|
|
|
lvlEmitter.setReportingValue( l );
|
|
|
|
EmitterValue = l;
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
@Override
|
|
|
|
protected void setupConfig()
|
|
|
|
{
|
2014-02-21 07:10:38 +01:00
|
|
|
int x = 80 + 44;
|
2014-01-20 17:41:37 +01:00
|
|
|
int y = 40;
|
|
|
|
|
|
|
|
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
|
|
|
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() );
|
|
|
|
|
|
|
|
IInventory inv = myte.getInventoryByName( "config" );
|
|
|
|
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
|
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
public LevelType lvType;
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
2014-01-27 05:00:36 +01:00
|
|
|
verifyPermissions( SecurityPermissions.BUILD, false );
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
if ( this.lvType != this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE ) )
|
|
|
|
{
|
|
|
|
icrafting.sendProgressBarUpdate( this, 2, (int) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE ).ordinal() );
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
if ( this.EmitterValue != lvlEmitter.getReportingValue() )
|
|
|
|
{
|
2014-02-16 05:33:13 +01:00
|
|
|
try
|
|
|
|
{
|
2014-02-21 07:10:38 +01:00
|
|
|
NetworkHandler.instance.sendTo( new PacketProgressBar( 3, lvlEmitter.getReportingValue() ), (EntityPlayerMP) icrafting );
|
2014-02-16 05:33:13 +01:00
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
AELog.error( e );
|
|
|
|
}
|
|
|
|
// icrafting.sendProgressBarUpdate( this, 2, (int) lvlEmitter.getReportingValue() );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
this.EmitterValue = lvlEmitter.getReportingValue();
|
|
|
|
this.lvType = (LevelType) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE );
|
2014-01-05 09:49:08 +01:00
|
|
|
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
|
|
|
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER );
|
|
|
|
}
|
|
|
|
|
|
|
|
standardDetectAndSendChanges();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2014-01-05 09:49:08 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateProgressBar(int idx, int value)
|
|
|
|
{
|
|
|
|
super.updateProgressBar( idx, value );
|
|
|
|
|
|
|
|
if ( idx == 2 )
|
2014-02-21 07:10:38 +01:00
|
|
|
{
|
|
|
|
lvType = LevelType.values()[value];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateFullProgressBar(int idx, long value)
|
|
|
|
{
|
|
|
|
super.updateFullProgressBar( idx, value );
|
|
|
|
|
|
|
|
if ( idx == 3 )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
|
|
|
EmitterValue = value;
|
|
|
|
if ( textField != null )
|
|
|
|
textField.setText( "" + EmitterValue );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|