pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,177 +29,169 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot {
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot
|
||||
{
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IItemHandler craftMatrix;
|
||||
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IItemHandler craftMatrix;
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final PlayerEntity thePlayer;
|
||||
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final PlayerEntity thePlayer;
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to
|
||||
* ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory,
|
||||
final IItemHandler par3IInventory, final int par4, final int par5, final int par6) {
|
||||
super(par3IInventory, par4, par5, par6);
|
||||
this.thePlayer = par1PlayerEntity;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
|
||||
public AppEngCraftingSlot( final PlayerEntity par1PlayerEntity, final IItemHandler par2IInventory, final IItemHandler par3IInventory, final int par4, final int par5, final int par6 )
|
||||
{
|
||||
super( par3IInventory, par4, par5, par6 );
|
||||
this.thePlayer = par1PlayerEntity;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the
|
||||
* armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood. Typically increases an internal count then calls
|
||||
* onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack, final int par2) {
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting(par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
|
||||
* internal count then calls onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack, final int par2 )
|
||||
{
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting( par1ItemStack );
|
||||
}
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(final ItemStack par1ItemStack) {
|
||||
par1ItemStack.onCrafting(this.thePlayer.world, this.thePlayer, this.amountCrafted);
|
||||
this.amountCrafted = 0;
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting( final ItemStack par1ItemStack )
|
||||
{
|
||||
par1ItemStack.onCrafting( this.thePlayer.world, this.thePlayer, this.amountCrafted );
|
||||
this.amountCrafted = 0;
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE )
|
||||
// )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.BREAD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.CAKE )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool)
|
||||
// par1ItemStack.getItem()
|
||||
// ).getToolMaterial() != Item.ToolMaterial.WOOD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE
|
||||
// ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BOOKCASE, 1 );
|
||||
// }
|
||||
}
|
||||
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.CRAFTING_TABLE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_WORK_BENCH, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.FURNACE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_FURNACE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_HOE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.BREAD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.MAKE_BREAD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Items.CAKE )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BAKE_CAKE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemTool) par1ItemStack.getItem()
|
||||
// ).getToolMaterial() != Item.ToolMaterial.WOOD )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_BETTER_PICKAXE, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BUILD_SWORD, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.ENCHANTING_TABLE ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.ENCHANTMENTS, 1 );
|
||||
// }
|
||||
//
|
||||
// if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.BOOKSHELF ) )
|
||||
// {
|
||||
// this.thePlayer.addStat( AchievementList.BOOKCASE, 1 );
|
||||
// }
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity playerIn, final ItemStack stack) {
|
||||
BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, new WrapperInvItemHandler(this.craftMatrix));
|
||||
this.onCrafting(stack);
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
|
||||
final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3);
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity playerIn, final ItemStack stack )
|
||||
{
|
||||
BasicEventHooks.firePlayerCraftingEvent( playerIn, stack, new WrapperInvItemHandler( this.craftMatrix ) );
|
||||
this.onCrafting( stack );
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( playerIn );
|
||||
final CraftingInventory ic = new CraftingInventory( this.getContainer(), 3, 3 );
|
||||
for (int x = 0; x < this.craftMatrix.getSlots(); x++) {
|
||||
ic.setInventorySlotContents(x, this.craftMatrix.getStackInSlot(x));
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.craftMatrix.getSlots(); x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
|
||||
}
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems(ic, playerIn.world);
|
||||
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems( ic, playerIn.world );
|
||||
ItemHandlerUtil.copy(ic, this.craftMatrix, false);
|
||||
|
||||
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
|
||||
|
||||
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( null );
|
||||
for (int i = 0; i < aitemstack.size(); ++i) {
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i);
|
||||
final ItemStack itemstack2 = aitemstack.get(i);
|
||||
|
||||
for( int i = 0; i < aitemstack.size(); ++i )
|
||||
{
|
||||
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i );
|
||||
final ItemStack itemstack2 = aitemstack.get( i );
|
||||
if (!itemstack1.isEmpty()) {
|
||||
this.craftMatrix.extractItem(i, 1, false);
|
||||
}
|
||||
|
||||
if( !itemstack1.isEmpty() )
|
||||
{
|
||||
this.craftMatrix.extractItem( i, 1, false );
|
||||
}
|
||||
if (!itemstack2.isEmpty()) {
|
||||
if (this.craftMatrix.getStackInSlot(i).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2);
|
||||
} else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
|
||||
this.thePlayer.dropItem(itemstack2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !itemstack2.isEmpty() )
|
||||
{
|
||||
if( this.craftMatrix.getStackInSlot( i ).isEmpty() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.craftMatrix, i, itemstack2 );
|
||||
}
|
||||
else if( !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
|
||||
{
|
||||
this.thePlayer.dropItem( itemstack2, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the
|
||||
* second int arg. Returns the new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
if (this.getHasStack()) {
|
||||
this.amountCrafted += Math.min(par1, this.getStack().getCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
|
||||
* stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
this.amountCrafted += Math.min( par1, this.getStack().getCount() );
|
||||
}
|
||||
return super.decrStackSize(par1);
|
||||
}
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems( CraftingInventory ic, World world )
|
||||
{
|
||||
// FIXME return CraftingManager.getRemainingItems( ic, world );
|
||||
return null;
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
// FIXME return CraftingManager.getRemainingItems( ic, world );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -33,257 +32,211 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
|
||||
public class AppEngSlot extends Slot {
|
||||
private static IInventory emptyInventory = new Inventory(0);
|
||||
private final IItemHandler itemHandler;
|
||||
private final int index;
|
||||
|
||||
public class AppEngSlot extends Slot
|
||||
{
|
||||
private static IInventory emptyInventory = new Inventory(0);
|
||||
private final IItemHandler itemHandler;
|
||||
private final int index;
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private AEBaseContainer myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private AEBaseContainer myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private hasCalculatedValidness isValid;
|
||||
private boolean isDisplay = false;
|
||||
public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(emptyInventory, idx, x, y);
|
||||
this.itemHandler = inv;
|
||||
this.index = idx;
|
||||
|
||||
public AppEngSlot( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( emptyInventory, idx, x, y );
|
||||
this.itemHandler = inv;
|
||||
this.index = idx;
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
}
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setNotDraggable()
|
||||
{
|
||||
this.setDraggable( false );
|
||||
return this;
|
||||
}
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setPlayerSide()
|
||||
{
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getTooltip()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public void clearStack() {
|
||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
public void clearStack()
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, ItemStack.EMPTY );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(@Nonnull final ItemStack par1ItemStack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return this.itemHandler.isItemValid(this.index, par1ItemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( @Nonnull final ItemStack par1ItemStack )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
return this.itemHandler.isItemValid( this.index, par1ItemStack );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.itemHandler.getSlots() <= this.getSlotIndex()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( this.itemHandler.getSlots() <= this.getSlotIndex() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
|
||||
if( this.isDisplay() )
|
||||
{
|
||||
this.setDisplay( false );
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return this.itemHandler.getStackInSlot(this.index);
|
||||
}
|
||||
|
||||
return this.itemHandler.getStackInSlot( this.index );
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack stack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, stack);
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack stack )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack );
|
||||
if (this.getContainer() != null) {
|
||||
this.getContainer().onSlotChange(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getContainer() != null )
|
||||
{
|
||||
this.getContainer().onSlotChange( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
public IItemHandler getItemHandler() {
|
||||
return this.itemHandler;
|
||||
}
|
||||
|
||||
public IItemHandler getItemHandler()
|
||||
{
|
||||
return this.itemHandler;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
this.setIsValid( hasCalculatedValidness.NotAvailable );
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return this.itemHandler.getSlotLimit(this.index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return this.itemHandler.getSlotLimit( this.index );
|
||||
}
|
||||
@Override
|
||||
public int getItemStackLimit(@Nonnull ItemStack stack) {
|
||||
return Math.min(this.getSlotStackLimit(), stack.getMaxStackSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit( @Nonnull ItemStack stack )
|
||||
{
|
||||
return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() );
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return !this.itemHandler.extractItem(this.index, 1, true).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
return !this.itemHandler.extractItem( this.index, 1, true ).isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize(int amount) {
|
||||
return this.itemHandler.extractItem(this.index, amount, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack decrStackSize( int amount )
|
||||
{
|
||||
return this.itemHandler.extractItem( this.index, amount, false );
|
||||
}
|
||||
@Override
|
||||
public boolean isSameInventory(Slot other) {
|
||||
return other instanceof AppEngSlot && ((AppEngSlot) other).itemHandler == this.itemHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameInventory( Slot other )
|
||||
{
|
||||
return other instanceof AppEngSlot && ( (AppEngSlot) other ).itemHandler == this.itemHandler;
|
||||
}
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean isEnabled() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public ItemStack getDisplayStack() {
|
||||
return this.itemHandler.getStackInSlot(this.index);
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
return this.itemHandler.getStackInSlot( this.index );
|
||||
}
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
return 0.4f;
|
||||
}
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
|
||||
public int getIcon()
|
||||
{
|
||||
return this.getIIcon();
|
||||
}
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
public boolean shouldDisplay() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
public boolean shouldDisplay()
|
||||
{
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return this.defX;
|
||||
}
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
return this.defY;
|
||||
}
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
|
||||
private int getIIcon()
|
||||
{
|
||||
return this.IIcon;
|
||||
}
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
|
||||
public void setIIcon( final int iIcon )
|
||||
{
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
|
||||
private boolean isDisplay()
|
||||
{
|
||||
return this.isDisplay;
|
||||
}
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
|
||||
public void setDisplay( final boolean isDisplay )
|
||||
{
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
|
||||
public boolean isDraggable()
|
||||
{
|
||||
return this.isDraggable;
|
||||
}
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
|
||||
private void setDraggable( final boolean isDraggable )
|
||||
{
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
|
||||
void setPlayerSide( final boolean isPlayerSide )
|
||||
{
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
public hasCalculatedValidness getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public hasCalculatedValidness getIsValid()
|
||||
{
|
||||
return this.isValid;
|
||||
}
|
||||
public void setIsValid(final hasCalculatedValidness isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public void setIsValid( final hasCalculatedValidness isValid )
|
||||
{
|
||||
this.isValid = isValid;
|
||||
}
|
||||
protected AEBaseContainer getContainer() {
|
||||
return this.myContainer;
|
||||
}
|
||||
|
||||
protected AEBaseContainer getContainer()
|
||||
{
|
||||
return this.myContainer;
|
||||
}
|
||||
public void setContainer(final AEBaseContainer myContainer) {
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
|
||||
public void setContainer( final AEBaseContainer myContainer )
|
||||
{
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
|
||||
public enum hasCalculatedValidness
|
||||
{
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
public enum hasCalculatedValidness {
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,17 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 2/05/2018
|
||||
* @since rv6 2/05/2018
|
||||
*/
|
||||
public interface IOptionalSlot
|
||||
{
|
||||
default boolean isRenderDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public interface IOptionalSlot {
|
||||
default boolean isRenderDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int getSourceX();
|
||||
int getSourceX();
|
||||
|
||||
int getSourceY();
|
||||
int getSourceY();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
public interface IOptionalSlotHost {
|
||||
|
||||
public interface IOptionalSlotHost
|
||||
{
|
||||
|
||||
boolean isSlotEnabled( int idx );
|
||||
boolean isSlotEnabled(int idx);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -26,72 +25,60 @@ import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
// FIXME seems unused
|
||||
public class NullSlot extends Slot
|
||||
{
|
||||
public class NullSlot extends Slot {
|
||||
|
||||
public NullSlot()
|
||||
{
|
||||
super( null, 0, 0, 0 );
|
||||
}
|
||||
public NullSlot() {
|
||||
super(null, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange( final ItemStack par1ItemStack, final ItemStack par2ItemStack )
|
||||
{
|
||||
@Override
|
||||
public void onSlotChange(final ItemStack par1ItemStack, final ItemStack par2ItemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack )
|
||||
{
|
||||
return par2ItemStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) {
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getSlotIndex() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,77 +18,65 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotFake extends SlotFake implements IOptionalSlot {
|
||||
|
||||
public class OptionalSlotFake extends SlotFake implements IOptionalSlot
|
||||
{
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
public OptionalSlotFake(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, idx, x + offX * 18, y + offY * 18);
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
public OptionalSlotFake( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, idx, x + offX * 18, y + offY * 18 );
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
if( !this.getDisplayStack().isEmpty() )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
@Override
|
||||
public boolean isRenderDisabled() {
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderDisabled()
|
||||
{
|
||||
return this.renderDisabled;
|
||||
}
|
||||
public void setRenderDisabled(final boolean renderDisabled) {
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
|
||||
public void setRenderDisabled( final boolean renderDisabled )
|
||||
{
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.srcY;
|
||||
}
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.srcY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,27 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake {
|
||||
|
||||
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
|
||||
{
|
||||
public OptionalSlotFakeTypeOnly(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx,
|
||||
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
public OptionalSlotFakeTypeOnly( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
if( is.getCount() > 1 )
|
||||
{
|
||||
is.setCount( 1 );
|
||||
}
|
||||
else if( is.getCount() < -1 )
|
||||
{
|
||||
is.setCount( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,43 +18,36 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot {
|
||||
|
||||
public class OptionalSlotNormal extends AppEngSlot implements IOptionalSlot
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public OptionalSlotNormal(final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot,
|
||||
final int xPos, final int yPos, final int groupNum) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
public OptionalSlotNormal( final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot, final int xPos, final int yPos, final int groupNum )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.yPos;
|
||||
}
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.yPos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,32 +18,27 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class OptionalSlotRestrictedInput extends SlotRestrictedInput {
|
||||
|
||||
public class OptionalSlotRestrictedInput extends SlotRestrictedInput
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public OptionalSlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host,
|
||||
final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) {
|
||||
super(valid, i, slotIndex, x, y, invPlayer);
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public OptionalSlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host, final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer )
|
||||
{
|
||||
super( valid, i, slotIndex, x, y, invPlayer );
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -26,44 +25,38 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot {
|
||||
private final AEBaseContainer c;
|
||||
private final IInventory wrappedInventory;
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot
|
||||
{
|
||||
private final AEBaseContainer c;
|
||||
private final IInventory wrappedInventory;
|
||||
public SlotCraftingMatrix(final AEBaseContainer c, final IItemHandler par1iInventory, final int par2,
|
||||
final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.c = c;
|
||||
this.wrappedInventory = new WrapperInvItemHandler(par1iInventory);
|
||||
}
|
||||
|
||||
public SlotCraftingMatrix( final AEBaseContainer c, final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.c = c;
|
||||
this.wrappedInventory = new WrapperInvItemHandler( par1iInventory );
|
||||
}
|
||||
@Override
|
||||
public void clearStack() {
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStack()
|
||||
{
|
||||
super.clearStack();
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
}
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {
|
||||
super.putStack(par1ItemStack);
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
}
|
||||
@Override
|
||||
public boolean isPlayerSide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
final ItemStack is = super.decrStackSize( par1 );
|
||||
this.c.onCraftMatrixChanged( this.wrappedInventory );
|
||||
return is;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
final ItemStack is = super.decrStackSize(par1);
|
||||
this.c.onCraftMatrixChanged(this.wrappedInventory);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -56,277 +55,239 @@ import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
|
||||
public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
{
|
||||
private final IItemHandler craftInv;
|
||||
private final IItemHandler pattern;
|
||||
|
||||
private final IItemHandler craftInv;
|
||||
private final IItemHandler pattern;
|
||||
private final IActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
|
||||
private final IActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
public SlotCraftingTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix,
|
||||
final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp) {
|
||||
super(player, cMatrix, output, 0, x, y);
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
this.container = ccp;
|
||||
}
|
||||
|
||||
public SlotCraftingTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
|
||||
{
|
||||
super( player, cMatrix, output, 0, x, y );
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
this.container = ccp;
|
||||
}
|
||||
public IItemHandler getCraftingMatrix() {
|
||||
return this.craftInv;
|
||||
}
|
||||
|
||||
public IItemHandler getCraftingMatrix()
|
||||
{
|
||||
return this.craftInv;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity p, final ItemStack is) {
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity p, final ItemStack is )
|
||||
{
|
||||
return is;
|
||||
}
|
||||
public void doClick(final InventoryAction action, final PlayerEntity who) {
|
||||
if (this.getStack().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void doClick( final InventoryAction action, final PlayerEntity who )
|
||||
{
|
||||
if( this.getStack().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
final int howManyPerCraft = this.getStack().getCount();
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
final int howManyPerCraft = this.getStack().getCount();
|
||||
int maxTimesToCraft = 0;
|
||||
InventoryAdaptor ia = null;
|
||||
if (action == InventoryAction.CRAFT_SHIFT) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor(who);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft);
|
||||
} else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorItemHandler(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor( who );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else if( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft);
|
||||
|
||||
maxTimesToCraft = this.capCraftingAttempts( maxTimesToCraft );
|
||||
if (ia == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ia == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
final ItemStack rs = this.getStack().copy();
|
||||
if (rs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack rs = this.getStack().copy();
|
||||
if( rs.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int x = 0; x < maxTimesToCraft; x++) {
|
||||
if (ia.simulateAdd(rs).isEmpty()) {
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all));
|
||||
if (!extra.isEmpty()) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add(extra);
|
||||
Platform.spawnDrops(who.world,
|
||||
new BlockPos((int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ()), drops);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( int x = 0; x < maxTimesToCraft; x++ )
|
||||
{
|
||||
if( ia.simulateAdd( rs ).isEmpty() )
|
||||
{
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add( extra );
|
||||
Platform.spawnDrops( who.world, new BlockPos( (int) who.getPosX(), (int) who.getPosY(), (int) who.getPosZ() ), drops );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected IRecipe<CraftingInventory> findRecipe(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected IRecipe<CraftingInventory> findRecipe( CraftingInventory ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).orElse(null);
|
||||
}
|
||||
|
||||
return world.getRecipeManager().getRecipe( IRecipeType.CRAFTING, ic, world ).orElse(null);
|
||||
}
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems( CraftingInventory ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe().getRemainingItems(ic);
|
||||
}
|
||||
}
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe().getRemainingItems( ic );
|
||||
}
|
||||
}
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world).map(r -> r.getRemainingItems(ic))
|
||||
.orElse(NonNullList.create());
|
||||
}
|
||||
|
||||
return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, ic, world)
|
||||
.map(r -> r.getRemainingItems(ic))
|
||||
.orElse(NonNullList.create());
|
||||
}
|
||||
private int capCraftingAttempts(final int maxTimesToCraft) {
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
private int capCraftingAttempts( final int maxTimesToCraft )
|
||||
{
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
private ItemStack craftItem(final PlayerEntity p, final ItemStack request, final IMEMonitor<IAEItemStack> inv,
|
||||
final IItemList all) {
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
private ItemStack craftItem( final PlayerEntity p, final ItemStack request, final IMEMonitor<IAEItemStack> inv, final IItemList all )
|
||||
{
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) {
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
|
||||
// Safeguard for empty slots in the inventory for now
|
||||
Arrays.fill(set, ItemStack.EMPTY);
|
||||
|
||||
if( !is.isEmpty() && ItemStack.areItemsEqual( request, is ) )
|
||||
{
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
|
||||
// Safeguard for empty slots in the inventory for now
|
||||
Arrays.fill( set, ItemStack.EMPTY );
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x));
|
||||
}
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final CraftingInventory ic = new CraftingInventory( new ContainerNull(), 3, 3 );
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, this.getPattern().getStackInSlot( x ) );
|
||||
}
|
||||
final IRecipe<CraftingInventory> r = this.findRecipe(ic, p.world);
|
||||
|
||||
final IRecipe<CraftingInventory> r = this.findRecipe( ic, p.world );
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
if (target.isDamageable() && target.isRepairable(request)) {
|
||||
boolean isBad = false;
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
final ItemStack pis = ic.getStackInSlot(x);
|
||||
if (pis.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (pis.getItem() != target) {
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if (!isBad) {
|
||||
super.onTake(p, is);
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
final Item target = request.getItem();
|
||||
if( target.isDamageable() && target.isRepairable(request) )
|
||||
{
|
||||
boolean isBad = false;
|
||||
for( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack pis = ic.getStackInSlot( x );
|
||||
if( pis.isEmpty() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( pis.getItem() != target )
|
||||
{
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if( !isBad )
|
||||
{
|
||||
super.onTake( p, is );
|
||||
// actually necessary to cleanup this case...
|
||||
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
is = r.getCraftingResult(ic);
|
||||
|
||||
is = r.getCraftingResult( ic );
|
||||
if (inv != null) {
|
||||
for (int x = 0; x < this.getPattern().getSlots(); x++) {
|
||||
if (!this.getPattern().getStackInSlot(x).isEmpty()) {
|
||||
set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic,
|
||||
this.getPattern().getStackInSlot(x), x, all, Actionable.MODULATE,
|
||||
ItemViewCell.createFilter(this.container.getViewCells()));
|
||||
ic.setInventorySlotContents(x, set[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( inv != null )
|
||||
{
|
||||
for( int x = 0; x < this.getPattern().getSlots(); x++ )
|
||||
{
|
||||
if( !this.getPattern().getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.world, r, is, ic, this.getPattern().getStackInSlot( x ),
|
||||
x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) );
|
||||
ic.setInventorySlotContents( x, set[x] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.preCraft(p, inv, set, is)) {
|
||||
this.makeItem(p, is);
|
||||
|
||||
if( this.preCraft( p, inv, set, is ) )
|
||||
{
|
||||
this.makeItem( p, is );
|
||||
this.postCraft(p, inv, set, is);
|
||||
}
|
||||
|
||||
this.postCraft( p, inv, set, is );
|
||||
}
|
||||
p.openContainer.onCraftMatrixChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
|
||||
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
|
||||
return is;
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
private boolean preCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean preCraft( final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
private void makeItem(final PlayerEntity p, final ItemStack is) {
|
||||
super.onTake(p, is);
|
||||
}
|
||||
|
||||
private void makeItem( final PlayerEntity p, final ItemStack is )
|
||||
{
|
||||
super.onTake( p, is );
|
||||
}
|
||||
private void postCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
|
||||
private void postCraft( final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set, final ItemStack result )
|
||||
{
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
// set new items onto the crafting table...
|
||||
for (int x = 0; x < this.craftInv.getSlots(); x++) {
|
||||
if (this.craftInv.getStackInSlot(x).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]);
|
||||
} else if (!set[x].isEmpty()) {
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems(AEItemStack.fromItemStack(set[x]), Actionable.MODULATE,
|
||||
this.mySrc);
|
||||
if (fail != null) {
|
||||
drops.add(fail.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// set new items onto the crafting table...
|
||||
for( int x = 0; x < this.craftInv.getSlots(); x++ )
|
||||
{
|
||||
if( this.craftInv.getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.craftInv, x, set[x] );
|
||||
}
|
||||
else if( !set[x].isEmpty() )
|
||||
{
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems( AEItemStack.fromItemStack( set[x] ), Actionable.MODULATE, this.mySrc );
|
||||
if( fail != null )
|
||||
{
|
||||
drops.add( fail.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (drops.size() > 0) {
|
||||
Platform.spawnDrops(p.world, new BlockPos((int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ()), drops);
|
||||
}
|
||||
}
|
||||
|
||||
if( drops.size() > 0 )
|
||||
{
|
||||
Platform.spawnDrops( p.world, new BlockPos( (int) p.getPosX(), (int) p.getPosY(), (int) p.getPosZ() ), drops );
|
||||
}
|
||||
}
|
||||
|
||||
IItemHandler getPattern()
|
||||
{
|
||||
return this.pattern;
|
||||
}
|
||||
IItemHandler getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,29 +18,23 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotDisabled extends AppEngSlot {
|
||||
|
||||
public class SlotDisabled extends AppEngSlot
|
||||
{
|
||||
public SlotDisabled(final IItemHandler par1iInventory, final int slotIndex, final int x, final int y) {
|
||||
super(par1iInventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
public SlotDisabled( final IItemHandler par1iInventory, final int slotIndex, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, slotIndex, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,52 +18,42 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFake extends AppEngSlot {
|
||||
|
||||
public class SlotFake extends AppEngSlot
|
||||
{
|
||||
public SlotFake(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFake( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public ItemStack onTake(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) {
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTake( final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack )
|
||||
{
|
||||
return par2ItemStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,37 +18,29 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeBlacklist extends SlotFakeTypeOnly {
|
||||
|
||||
public class SlotFakeBlacklist extends SlotFakeTypeOnly
|
||||
{
|
||||
public SlotFakeBlacklist(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFakeBlacklist( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
return 0.8f;
|
||||
}
|
||||
@Override
|
||||
public boolean renderIconWithItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIcon()
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
return this.getStack().getCount() > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int getIcon() {
|
||||
if (this.getHasStack()) {
|
||||
return this.getStack().getCount() > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake {
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake
|
||||
{
|
||||
|
||||
public SlotFakeCraftingMatrix( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
public SlotFakeCraftingMatrix(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,26 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotFakeTypeOnly extends SlotFake {
|
||||
|
||||
public class SlotFakeTypeOnly extends SlotFake
|
||||
{
|
||||
public SlotFakeTypeOnly(final IItemHandler inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
public SlotFakeTypeOnly( final IItemHandler inv, final int idx, final int x, final int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
@Override
|
||||
public void putStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is = is.copy();
|
||||
if( is.getCount() > 1 )
|
||||
{
|
||||
is.setCount( 1 );
|
||||
}
|
||||
else if( is.getCount() < -1 )
|
||||
{
|
||||
is.setCount( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
super.putStack(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,52 +18,42 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot {
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot
|
||||
{
|
||||
private ItemStack dspStack = ItemStack.EMPTY;
|
||||
|
||||
private ItemStack dspStack = ItemStack.EMPTY;
|
||||
public SlotInaccessible(final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
|
||||
public SlotInaccessible( final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
this.dspStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
super.onSlotChanged();
|
||||
this.dspStack = ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( this.dspStack.isEmpty() )
|
||||
{
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if( !dsp.isEmpty() )
|
||||
{
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (this.dspStack.isEmpty()) {
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if (!dsp.isEmpty()) {
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotInaccessibleHD extends SlotInaccessible {
|
||||
|
||||
public class SlotInaccessibleHD extends SlotInaccessible
|
||||
{
|
||||
|
||||
public SlotInaccessibleHD( final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
public SlotInaccessibleHD(final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
|
||||
public class SlotMACPattern extends AppEngSlot {
|
||||
|
||||
public class SlotMACPattern extends AppEngSlot
|
||||
{
|
||||
private final ContainerMAC mac;
|
||||
|
||||
private final ContainerMAC mac;
|
||||
public SlotMACPattern(final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public SlotMACPattern( final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return this.mac.isValidItemForSlot( this.getSlotIndex(), i );
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return this.mac.isValidItemForSlot(this.getSlotIndex(), i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotNormal extends AppEngSlot {
|
||||
|
||||
public class SlotNormal extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotNormal( final IItemHandler inv, final int slot, final int xPos, final int yPos )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
}
|
||||
public SlotNormal(final IItemHandler inv, final int slot, final int xPos, final int yPos) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,18 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotOutput extends AppEngSlot {
|
||||
|
||||
public class SlotOutput extends AppEngSlot
|
||||
{
|
||||
public SlotOutput(final IItemHandler a, final int b, final int c, final int d, final int i) {
|
||||
super(a, b, c, d);
|
||||
this.setIIcon(i);
|
||||
}
|
||||
|
||||
public SlotOutput( final IItemHandler a, final int b, final int c, final int d, final int i )
|
||||
{
|
||||
super( a, b, c, d );
|
||||
this.setIIcon( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,27 +18,22 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotPatternOutputs extends OptionalSlotFake {
|
||||
|
||||
public class SlotPatternOutputs extends OptionalSlotFake
|
||||
{
|
||||
public SlotPatternOutputs(final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
public SlotPatternOutputs( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay()
|
||||
{
|
||||
return super.isSlotEnabled();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldDisplay() {
|
||||
return super.isSlotEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -34,49 +33,44 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
|
||||
public class SlotPatternTerm extends SlotCraftingTerm {
|
||||
|
||||
public class SlotPatternTerm extends SlotCraftingTerm
|
||||
{
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
public SlotPatternTerm(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix,
|
||||
final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber,
|
||||
final IContainerCraftingPacket c) {
|
||||
super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c);
|
||||
|
||||
public SlotPatternTerm( final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
|
||||
{
|
||||
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
public AppEngPacket getRequest(final boolean shift) {
|
||||
return new PacketPatternSlot(this.getPattern(),
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
|
||||
shift);
|
||||
}
|
||||
|
||||
public AppEngPacket getRequest( final boolean shift )
|
||||
{
|
||||
return new PacketPatternSlot( this
|
||||
.getPattern(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( this.getStack() ), shift );
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
if( !this.getDisplayStack().isEmpty() )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,12 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot {
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotPlayerHotBar( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
public SlotPlayerHotBar(final IItemHandler par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||
|
||||
public class SlotPlayerInv extends AppEngSlot
|
||||
{
|
||||
public class SlotPlayerInv extends AppEngSlot {
|
||||
|
||||
public SlotPlayerInv( final IItemHandler par1iInventory, final int idx, final int x, final int y )
|
||||
{
|
||||
super( par1iInventory, idx, x, y );
|
||||
public SlotPlayerInv(final IItemHandler par1iInventory, final int idx, final int x, final int y) {
|
||||
super(par1iInventory, idx, x, y);
|
||||
|
||||
this.setPlayerSide( true );
|
||||
}
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,11 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.recipes.handlers.GrinderRecipes;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -43,281 +39,243 @@ import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.recipes.handlers.GrinderRecipes;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class SlotRestrictedInput extends AppEngSlot
|
||||
{
|
||||
public class SlotRestrictedInput extends AppEngSlot {
|
||||
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
private boolean allowEdit = true;
|
||||
private int stackLimit = -1;
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
private boolean allowEdit = true;
|
||||
private int stackLimit = -1;
|
||||
|
||||
public SlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x, final int y, final PlayerInventory p )
|
||||
{
|
||||
super( i, slotIndex, x, y );
|
||||
this.which = valid;
|
||||
this.setIIcon( valid.IIcon );
|
||||
this.p = p;
|
||||
}
|
||||
public SlotRestrictedInput(final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x,
|
||||
final int y, final PlayerInventory p) {
|
||||
super(i, slotIndex, x, y);
|
||||
this.which = valid;
|
||||
this.setIIcon(valid.IIcon);
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
if( this.stackLimit != -1 )
|
||||
{
|
||||
return this.stackLimit;
|
||||
}
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
if (this.stackLimit != -1) {
|
||||
return this.stackLimit;
|
||||
}
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
|
||||
public boolean isValid( final ItemStack is, final World theWorld )
|
||||
{
|
||||
if( this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT )
|
||||
{
|
||||
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ( (ICraftingPatternItem) is.getItem() ).getPatternForItem( is,
|
||||
theWorld ) : null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isValid(final ItemStack is, final World theWorld) {
|
||||
if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) {
|
||||
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem
|
||||
? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld)
|
||||
: null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Slot setStackLimit(final int i )
|
||||
{
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
public Slot setStackLimit(final int i) {
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack i )
|
||||
{
|
||||
if( !this.getContainer().isValidForSlot( this, i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack i) {
|
||||
if (!this.getContainer().isValidForSlot(this, i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (i.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( i.getItem() == Items.AIR )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (i.getItem() == Items.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !super.isItemValid( i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!super.isItemValid(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !this.isAllowEdit() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!this.isAllowEdit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
switch( this.which )
|
||||
{
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
final ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.world );
|
||||
if( de != null )
|
||||
{
|
||||
return de.isCraftable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN:
|
||||
{
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ?
|
||||
// ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
return false;// pattern != null;
|
||||
}
|
||||
case BLANK_PATTERN:
|
||||
return materials.blankPattern().isSameAs( i );
|
||||
switch (this.which) {
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world);
|
||||
if (de != null) {
|
||||
return de.isCraftable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN: {
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem
|
||||
// ?
|
||||
// ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
return false;// pattern != null;
|
||||
}
|
||||
case BLANK_PATTERN:
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case PATTERN:
|
||||
case PATTERN:
|
||||
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return materials.blankPattern().isSameAs( i );
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case INSCRIBER_PLATE:
|
||||
if( materials.namePress().isSameAs( i ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
case INSCRIBER_PLATE:
|
||||
if (materials.namePress().isSameAs(i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
||||
|
||||
case INSCRIBER_INPUT:
|
||||
return true;/*
|
||||
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return
|
||||
* true;
|
||||
* return false;
|
||||
*/
|
||||
case INSCRIBER_INPUT:
|
||||
return true;/*
|
||||
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i )
|
||||
* ) return true; return false;
|
||||
*/
|
||||
|
||||
case METAL_INGOTS:
|
||||
case METAL_INGOTS:
|
||||
|
||||
return isMetalIngot( i );
|
||||
return isMetalIngot(i);
|
||||
|
||||
case VIEW_CELL:
|
||||
return items.viewCell().isSameAs( i );
|
||||
case ORE:
|
||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
||||
case FUEL:
|
||||
return ForgeHooks.getBurnTime( i ) > 0;
|
||||
case POWERED_TOOL:
|
||||
return Platform.isChargeable( i );
|
||||
case QE_SINGULARITY:
|
||||
return materials.qESingularity().isSameAs( i );
|
||||
case VIEW_CELL:
|
||||
return items.viewCell().isSameAs(i);
|
||||
case ORE:
|
||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
||||
case FUEL:
|
||||
return ForgeHooks.getBurnTime(i) > 0;
|
||||
case POWERED_TOOL:
|
||||
return Platform.isChargeable(i);
|
||||
case QE_SINGULARITY:
|
||||
return materials.qESingularity().isSameAs(i);
|
||||
|
||||
case RANGE_BOOSTER:
|
||||
return materials.wirelessBooster().isSameAs( i );
|
||||
case RANGE_BOOSTER:
|
||||
return materials.wirelessBooster().isSameAs(i);
|
||||
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell && ( (ISpatialStorageCell) i.getItem() ).isSpatialStorage( i );
|
||||
case STORAGE_CELLS:
|
||||
return AEApi.instance().registries().cell().isCellHandled( i );
|
||||
case WORKBENCH_CELL:
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ( (ICellWorkbenchItem) i.getItem() ).isEditable( i );
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i );
|
||||
case TRASH:
|
||||
if( AEApi.instance().registries().cell().isCellHandled( i ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell
|
||||
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
|
||||
case STORAGE_CELLS:
|
||||
return AEApi.instance().registries().cell().isCellHandled(i);
|
||||
case WORKBENCH_CELL:
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i);
|
||||
case TRASH:
|
||||
if (AEApi.instance().registries().cell().isCellHandled(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) );
|
||||
case ENCODABLE_ITEM:
|
||||
return i.getItem() instanceof INetworkEncodable || AEApi.instance().registries().wireless().isWirelessTerminal( i );
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ( (IUpgradeModule) i.getItem() ).getType( i ) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return !(i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i));
|
||||
case ENCODABLE_ITEM:
|
||||
return i.getItem() instanceof INetworkEncodable
|
||||
|| AEApi.instance().registries().wireless().isWirelessTerminal(i);
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final PlayerEntity par1PlayerEntity )
|
||||
{
|
||||
return this.isAllowEdit();
|
||||
}
|
||||
@Override
|
||||
public boolean canTakeStack(final PlayerEntity par1PlayerEntity) {
|
||||
return this.isAllowEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) )
|
||||
{
|
||||
final ItemStack is = super.getStack();
|
||||
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern)
|
||||
{
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput( is );
|
||||
if( !out.isEmpty() )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (Platform.isClient() && (this.which == PlacableItemType.ENCODED_PATTERN)) {
|
||||
final ItemStack is = super.getStack();
|
||||
if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) {
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
if (!out.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public static boolean isMetalIngot( final ItemStack i )
|
||||
{
|
||||
if( Platform.itemComparisons().isSameItem( i, new ItemStack( Items.IRON_INGOT ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public static boolean isMetalIngot(final ItemStack i) {
|
||||
if (Platform.itemComparisons().isSameItem(i, new ItemStack(Items.IRON_INGOT))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for( final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } )
|
||||
{
|
||||
// FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) )
|
||||
// FIXME {
|
||||
// FIXME return true;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
for (final String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass",
|
||||
"Nickel", "Aluminium" }) {
|
||||
// FIXME for( final ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.itemComparisons().isSameItem( i, ingot ) )
|
||||
// FIXME {
|
||||
// FIXME return true;
|
||||
// FIXME }
|
||||
// FIXME }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAllowEdit()
|
||||
{
|
||||
return this.allowEdit;
|
||||
}
|
||||
private boolean isAllowEdit() {
|
||||
return this.allowEdit;
|
||||
}
|
||||
|
||||
public void setAllowEdit( final boolean allowEdit )
|
||||
{
|
||||
this.allowEdit = allowEdit;
|
||||
}
|
||||
public void setAllowEdit(final boolean allowEdit) {
|
||||
this.allowEdit = allowEdit;
|
||||
}
|
||||
|
||||
public enum PlacableItemType
|
||||
{
|
||||
STORAGE_CELLS( 15 ),
|
||||
ORE( 16 + 15 ),
|
||||
STORAGE_COMPONENT( 3 * 16 + 15 ),
|
||||
public enum PlacableItemType {
|
||||
STORAGE_CELLS(15), ORE(16 + 15), STORAGE_COMPONENT(3 * 16 + 15),
|
||||
|
||||
ENCODABLE_ITEM( 4 * 16 + 15 ),
|
||||
TRASH( 5 * 16 + 15 ),
|
||||
VALID_ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ),
|
||||
ENCODED_PATTERN_W_OUTPUT( 7 * 16 + 15 ),
|
||||
ENCODABLE_ITEM(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
|
||||
ENCODED_CRAFTING_PATTERN( 7 * 16 + 15 ),
|
||||
ENCODED_PATTERN( 7 * 16 + 15 ),
|
||||
PATTERN( 8 * 16 + 15 ),
|
||||
BLANK_PATTERN( 8 * 16 + 15 ),
|
||||
POWERED_TOOL( 9 * 16 + 15 ),
|
||||
ENCODED_CRAFTING_PATTERN(7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), PATTERN(8 * 16 + 15),
|
||||
BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15),
|
||||
|
||||
RANGE_BOOSTER( 6 * 16 + 15 ),
|
||||
QE_SINGULARITY( 10 * 16 + 15 ),
|
||||
SPATIAL_STORAGE_CELLS( 11 * 16 + 15 ),
|
||||
RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARITY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15),
|
||||
|
||||
FUEL( 12 * 16 + 15 ),
|
||||
UPGRADES( 13 * 16 + 15 ),
|
||||
WORKBENCH_CELL( 15 ),
|
||||
BIOMETRIC_CARD( 14 * 16 + 15 ),
|
||||
VIEW_CELL( 4 * 16 + 14 ),
|
||||
FUEL(12 * 16 + 15), UPGRADES(13 * 16 + 15), WORKBENCH_CELL(15), BIOMETRIC_CARD(14 * 16 + 15),
|
||||
VIEW_CELL(4 * 16 + 14),
|
||||
|
||||
INSCRIBER_PLATE( 2 * 16 + 14 ),
|
||||
INSCRIBER_INPUT( 3 * 16 + 14 ),
|
||||
METAL_INGOTS( 3 * 16 + 14 );
|
||||
INSCRIBER_PLATE(2 * 16 + 14), INSCRIBER_INPUT(3 * 16 + 14), METAL_INGOTS(3 * 16 + 14);
|
||||
|
||||
public final int IIcon;
|
||||
public final int IIcon;
|
||||
|
||||
PlacableItemType( final int o )
|
||||
{
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
PlacableItemType(final int o) {
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user