2013-12-27 23:59:59 +01:00
|
|
|
package appeng.container.slot;
|
|
|
|
|
2014-01-01 09:57:16 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-07-19 21:33:28 +02:00
|
|
|
import appeng.container.AEBaseContainer;
|
2014-01-31 02:23:12 +01:00
|
|
|
import appeng.tile.inventory.AppEngInternalInventory;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class AppEngSlot extends Slot
|
|
|
|
{
|
|
|
|
|
|
|
|
public enum hasCalculatedValidness
|
|
|
|
{
|
|
|
|
NotAvailable, Valid, Invalid
|
|
|
|
};
|
|
|
|
|
2014-01-01 09:57:16 +01:00
|
|
|
public boolean isDraggable = true;
|
2013-12-30 06:52:00 +01:00
|
|
|
public boolean isPlayerSide = false;
|
2014-07-19 21:33:28 +02:00
|
|
|
public AEBaseContainer myContainer = null;
|
2013-12-30 06:52:00 +01:00
|
|
|
|
2014-01-01 09:57:16 +01:00
|
|
|
public Slot setNotDraggable()
|
|
|
|
{
|
|
|
|
isDraggable = false;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-12-30 06:52:00 +01:00
|
|
|
public Slot setPlayerSide()
|
|
|
|
{
|
|
|
|
isPlayerSide = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
public int IIcon = -1;
|
2013-12-27 23:59:59 +01:00
|
|
|
public hasCalculatedValidness isValid;
|
|
|
|
public int defX, defY;
|
|
|
|
|
2014-01-01 09:57:16 +01:00
|
|
|
@Override
|
|
|
|
public boolean func_111238_b()
|
|
|
|
{
|
|
|
|
return isEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEnabled()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public String getTooltip()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSlotChanged()
|
|
|
|
{
|
2014-01-31 02:23:12 +01:00
|
|
|
if ( inventory instanceof AppEngInternalInventory )
|
2014-02-09 02:34:52 +01:00
|
|
|
((AppEngInternalInventory) inventory).markDirty( getSlotIndex() );
|
2014-01-31 02:23:12 +01:00
|
|
|
else
|
|
|
|
super.onSlotChanged();
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
isValid = hasCalculatedValidness.NotAvailable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AppEngSlot(IInventory inv, int idx, int x, int y) {
|
|
|
|
super( inv, idx, x, y );
|
|
|
|
defX = x;
|
|
|
|
defY = y;
|
|
|
|
isValid = hasCalculatedValidness.NotAvailable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isDisplay = false;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getStack()
|
|
|
|
{
|
2014-01-01 09:57:16 +01:00
|
|
|
if ( !isEnabled() )
|
|
|
|
return null;
|
|
|
|
|
2014-01-20 17:41:37 +01:00
|
|
|
if ( inventory.getSizeInventory() <= getSlotIndex() )
|
|
|
|
return null;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isDisplay )
|
|
|
|
{
|
|
|
|
isDisplay = false;
|
|
|
|
return getDisplayStack();
|
|
|
|
}
|
|
|
|
return super.getStack();
|
|
|
|
}
|
|
|
|
|
2014-01-01 09:57:16 +01:00
|
|
|
@Override
|
|
|
|
public void putStack(ItemStack par1ItemStack)
|
|
|
|
{
|
|
|
|
if ( isEnabled() )
|
2014-07-19 21:33:28 +02:00
|
|
|
{
|
2014-01-01 09:57:16 +01:00
|
|
|
super.putStack( par1ItemStack );
|
2014-07-19 21:33:28 +02:00
|
|
|
|
|
|
|
if ( myContainer != null )
|
|
|
|
myContainer.onSlotChange( this );
|
|
|
|
}
|
2014-01-01 09:57:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void clearStack()
|
|
|
|
{
|
|
|
|
super.putStack( null );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
|
|
|
{
|
|
|
|
if ( isEnabled() )
|
|
|
|
return super.canTakeStack( par1EntityPlayer );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItemValid(ItemStack par1ItemStack)
|
|
|
|
{
|
|
|
|
if ( isEnabled() )
|
|
|
|
return super.isItemValid( par1ItemStack );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public ItemStack getDisplayStack()
|
|
|
|
{
|
|
|
|
return super.getStack();
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getOpacityOfIcon()
|
|
|
|
{
|
|
|
|
return 0.4f;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean renderIconWithItem()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getIcon()
|
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
return IIcon;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2013-12-30 06:52:00 +01:00
|
|
|
public boolean isPlayerSide()
|
|
|
|
{
|
|
|
|
return isPlayerSide;
|
|
|
|
}
|
|
|
|
|
2014-07-19 21:33:28 +02:00
|
|
|
public boolean shouldDisplay()
|
|
|
|
{
|
|
|
|
return isEnabled();
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|