Applied-Energistics-2-tiler.../container/slot/AppEngSlot.java

155 lines
2.5 KiB
Java
Raw Normal View History

package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import appeng.container.AEBaseContainer;
import appeng.tile.inventory.AppEngInternalInventory;
public class AppEngSlot extends Slot
{
public enum hasCalculatedValidness
{
NotAvailable, Valid, Invalid
};
public boolean isDraggable = true;
2013-12-30 06:52:00 +01:00
public boolean isPlayerSide = false;
public AEBaseContainer myContainer = null;
2013-12-30 06:52:00 +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;
public hasCalculatedValidness isValid;
public int defX, defY;
@Override
public boolean func_111238_b()
{
return isEnabled();
}
public boolean isEnabled()
{
return true;
}
public String getTooltip()
{
return null;
}
@Override
public void onSlotChanged()
{
if ( inventory instanceof AppEngInternalInventory )
2014-02-09 02:34:52 +01:00
((AppEngInternalInventory) inventory).markDirty( getSlotIndex() );
else
super.onSlotChanged();
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()
{
if ( !isEnabled() )
return null;
2014-01-20 17:41:37 +01:00
if ( inventory.getSizeInventory() <= getSlotIndex() )
return null;
if ( isDisplay )
{
isDisplay = false;
return getDisplayStack();
}
return super.getStack();
}
@Override
public void putStack(ItemStack par1ItemStack)
{
if ( isEnabled() )
{
super.putStack( par1ItemStack );
if ( myContainer != null )
myContainer.onSlotChange( this );
}
}
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;
}
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-30 06:52:00 +01:00
public boolean isPlayerSide()
{
return isPlayerSide;
}
public boolean shouldDisplay()
{
return isEnabled();
}
}