2014-01-27 05:00:36 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiTextField;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import appeng.api.config.SecurityPermissions;
|
|
|
|
import appeng.api.parts.IPart;
|
|
|
|
import appeng.container.AEBaseContainer;
|
2014-05-07 07:22:42 +02:00
|
|
|
import appeng.container.guisync.GuiSync;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.helpers.IPriorityHost;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
public class ContainerPriority extends AEBaseContainer
|
|
|
|
{
|
|
|
|
|
|
|
|
IPriorityHost priHost;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public GuiTextField textField;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void setTextField(GuiTextField level)
|
|
|
|
{
|
|
|
|
textField = level;
|
|
|
|
textField.setText( "" + PriorityValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
public ContainerPriority(InventoryPlayer ip, IPriorityHost te) {
|
|
|
|
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
|
|
|
|
priHost = te;
|
|
|
|
}
|
|
|
|
|
2014-05-07 07:22:42 +02:00
|
|
|
@GuiSync(2)
|
|
|
|
long PriorityValue = -1;
|
2014-01-27 05:00:36 +01:00
|
|
|
|
|
|
|
public void setPriority(int newValue, EntityPlayer player)
|
|
|
|
{
|
|
|
|
priHost.setPriority( newValue );
|
|
|
|
PriorityValue = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
|
|
|
verifyPermissions( SecurityPermissions.BUILD, false );
|
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
2014-05-07 07:22:42 +02:00
|
|
|
this.PriorityValue = priHost.getPriority();
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-05-07 07:22:42 +02:00
|
|
|
public void onUpdate(String field, Object oldValue, Object newValue)
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
2014-05-07 07:22:42 +02:00
|
|
|
if ( field.equals( "PriorityValue" ) )
|
2014-01-27 05:00:36 +01:00
|
|
|
{
|
|
|
|
if ( textField != null )
|
|
|
|
textField.setText( "" + PriorityValue );
|
|
|
|
}
|
|
|
|
|
2014-05-07 07:22:42 +02:00
|
|
|
super.onUpdate( field, oldValue, newValue );
|
|
|
|
}
|
2014-01-27 05:00:36 +01:00
|
|
|
}
|