Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -33,13 +34,18 @@ import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot
|
||||
{
|
||||
|
||||
/** The craft matrix inventory linked to this result slot. */
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IInventory craftMatrix;
|
||||
|
||||
/** The player that is using the GUI where this slot resides. */
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final EntityPlayer thePlayer;
|
||||
|
||||
/**
|
||||
@@ -47,7 +53,8 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
public AppEngCraftingSlot(EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3IInventory, int par4, int par5, int par6) {
|
||||
public AppEngCraftingSlot( EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3IInventory, int par4, int par5, int par6 )
|
||||
{
|
||||
super( par3IInventory, par4, par5, par6 );
|
||||
this.thePlayer = par1EntityPlayer;
|
||||
this.craftMatrix = par2IInventory;
|
||||
@@ -57,32 +64,17 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
public boolean isItemValid( ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(int par1)
|
||||
{
|
||||
if ( this.getHasStack() )
|
||||
{
|
||||
this.amountCrafted += Math.min( par1, this.getStack().stackSize );
|
||||
}
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(ItemStack par1ItemStack, int par2)
|
||||
protected void onCrafting( ItemStack par1ItemStack, int par2 )
|
||||
{
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafting( par1ItemStack );
|
||||
@@ -92,90 +84,89 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(ItemStack par1ItemStack)
|
||||
protected void onCrafting( ItemStack par1ItemStack )
|
||||
{
|
||||
par1ItemStack.onCrafting( this.thePlayer.worldObj, this.thePlayer, this.amountCrafted );
|
||||
this.amountCrafted = 0;
|
||||
|
||||
if ( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.crafting_table ) )
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.crafting_table ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildWorkBench, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
if( par1ItemStack.getItem() instanceof ItemPickaxe )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildPickaxe, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.furnace ) )
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.furnace ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildFurnace, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
if( par1ItemStack.getItem() instanceof ItemHoe )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildHoe, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() == Items.bread )
|
||||
if( par1ItemStack.getItem() == Items.bread )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.makeBread, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() == Items.cake )
|
||||
if( par1ItemStack.getItem() == Items.cake )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.bakeCake, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() instanceof ItemPickaxe && ((ItemPickaxe) par1ItemStack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD )
|
||||
if( par1ItemStack.getItem() instanceof ItemPickaxe && ( (ItemPickaxe) par1ItemStack.getItem() ).func_150913_i() != Item.ToolMaterial.WOOD )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildBetterPickaxe, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() instanceof ItemSword )
|
||||
if( par1ItemStack.getItem() instanceof ItemSword )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.buildSword, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.enchanting_table ) )
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.enchanting_table ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.enchantments, 1 );
|
||||
}
|
||||
|
||||
if ( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.bookshelf ) )
|
||||
if( par1ItemStack.getItem() == Item.getItemFromBlock( Blocks.bookshelf ) )
|
||||
{
|
||||
this.thePlayer.addStat( AchievementList.bookcase, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
public void onPickupFromSlot( EntityPlayer par1EntityPlayer, ItemStack par2ItemStack )
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( par1EntityPlayer, par2ItemStack, this.craftMatrix );
|
||||
this.onCrafting( par2ItemStack );
|
||||
|
||||
for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i)
|
||||
for( int i = 0; i < this.craftMatrix.getSizeInventory(); ++i )
|
||||
{
|
||||
ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i );
|
||||
|
||||
if ( itemstack1 != null )
|
||||
if( itemstack1 != null )
|
||||
{
|
||||
this.craftMatrix.decrStackSize( i, 1 );
|
||||
|
||||
if ( itemstack1.getItem().hasContainerItem( itemstack1 ) )
|
||||
if( itemstack1.getItem().hasContainerItem( itemstack1 ) )
|
||||
{
|
||||
ItemStack itemstack2 = itemstack1.getItem().getContainerItem( itemstack1 );
|
||||
|
||||
if ( itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage() )
|
||||
if( itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage() )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( this.thePlayer, itemstack2 ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !itemstack1.getItem().doesContainerItemLeaveCraftingGrid( itemstack1 )
|
||||
|| !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
|
||||
if( !itemstack1.getItem().doesContainerItemLeaveCraftingGrid( itemstack1 ) || !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
|
||||
{
|
||||
if ( this.craftMatrix.getStackInSlot( i ) == null )
|
||||
if( this.craftMatrix.getStackInSlot( i ) == null )
|
||||
{
|
||||
this.craftMatrix.setInventorySlotContents( i, itemstack2 );
|
||||
}
|
||||
@@ -188,4 +179,19 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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( int par1 )
|
||||
{
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
this.amountCrafted += Math.min( par1, this.getStack().stackSize );
|
||||
}
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -26,17 +27,26 @@ 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 final int defX;
|
||||
public final int defY;
|
||||
public boolean isDraggable = true;
|
||||
public boolean isPlayerSide = false;
|
||||
public AEBaseContainer myContainer = null;
|
||||
public int IIcon = -1;
|
||||
public hasCalculatedValidness isValid;
|
||||
public boolean isDisplay = false;
|
||||
|
||||
public AppEngSlot( IInventory inv, int idx, int x, int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.isValid = hasCalculatedValidness.NotAvailable;
|
||||
}
|
||||
|
||||
public Slot setNotDraggable()
|
||||
{
|
||||
@@ -50,95 +60,76 @@ public class AppEngSlot extends Slot
|
||||
return this;
|
||||
}
|
||||
|
||||
public int IIcon = -1;
|
||||
public hasCalculatedValidness isValid;
|
||||
public final int defX;
|
||||
public final int defY;
|
||||
|
||||
@Override
|
||||
public boolean func_111238_b()
|
||||
{
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getTooltip()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if ( this.inventory instanceof AppEngInternalInventory )
|
||||
((AppEngInternalInventory) this.inventory).markDirty( this.getSlotIndex() );
|
||||
else
|
||||
super.onSlotChanged();
|
||||
|
||||
this.isValid = hasCalculatedValidness.NotAvailable;
|
||||
}
|
||||
|
||||
public AppEngSlot(IInventory inv, int idx, int x, int y) {
|
||||
super( inv, idx, x, y );
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.isValid = hasCalculatedValidness.NotAvailable;
|
||||
}
|
||||
|
||||
public boolean isDisplay = false;
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if ( !this.isEnabled() )
|
||||
return null;
|
||||
|
||||
if ( this.inventory.getSizeInventory() <= this.getSlotIndex() )
|
||||
return null;
|
||||
|
||||
if ( this.isDisplay )
|
||||
{
|
||||
this.isDisplay = false;
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack)
|
||||
{
|
||||
if ( this.isEnabled() )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
|
||||
if ( this.myContainer != null )
|
||||
this.myContainer.onSlotChange( this );
|
||||
}
|
||||
}
|
||||
|
||||
public void clearStack()
|
||||
{
|
||||
super.putStack( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public boolean isItemValid( ItemStack par1ItemStack )
|
||||
{
|
||||
if ( this.isEnabled() )
|
||||
if( this.isEnabled() )
|
||||
return super.isItemValid( par1ItemStack );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isEnabled() )
|
||||
return null;
|
||||
|
||||
if( this.inventory.getSizeInventory() <= this.getSlotIndex() )
|
||||
return null;
|
||||
|
||||
if( this.isDisplay )
|
||||
{
|
||||
this.isDisplay = false;
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack par1ItemStack )
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
|
||||
if( this.myContainer != null )
|
||||
this.myContainer.onSlotChange( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
if( this.inventory instanceof AppEngInternalInventory )
|
||||
( (AppEngInternalInventory) this.inventory ).markDirty( this.getSlotIndex() );
|
||||
else
|
||||
super.onSlotChanged();
|
||||
|
||||
this.isValid = hasCalculatedValidness.NotAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
if( this.isEnabled() )
|
||||
return super.canTakeStack( par1EntityPlayer );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
public boolean func_111238_b()
|
||||
{
|
||||
if ( this.isEnabled() )
|
||||
return super.isItemValid( par1ItemStack );
|
||||
return false;
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack()
|
||||
@@ -146,6 +137,11 @@ public class AppEngSlot extends Slot
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon()
|
||||
{
|
||||
return 0.4f;
|
||||
@@ -171,4 +167,8 @@ public class AppEngSlot extends Slot
|
||||
return this.isEnabled();
|
||||
}
|
||||
|
||||
public enum hasCalculatedValidness
|
||||
{
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
public interface IOptionalSlotHost
|
||||
{
|
||||
|
||||
boolean isSlotEnabled(int idx);
|
||||
|
||||
boolean isSlotEnabled( int idx );
|
||||
}
|
||||
|
||||
@@ -18,32 +18,35 @@
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public class NullSlot extends Slot
|
||||
{
|
||||
|
||||
public NullSlot() {
|
||||
public NullSlot()
|
||||
{
|
||||
super( null, 0, 0, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
public void onSlotChange( ItemStack par1ItemStack, ItemStack par2ItemStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
public void onPickupFromSlot( EntityPlayer par1EntityPlayer, ItemStack par2ItemStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
public boolean isItemValid( ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -55,7 +58,7 @@ public class NullSlot extends Slot
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack)
|
||||
public void putStack( ItemStack par1ItemStack )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -73,19 +76,19 @@ public class NullSlot extends Slot
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1)
|
||||
public ItemStack decrStackSize( int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory(IInventory par1IInventory, int par2)
|
||||
public boolean isSlotInInventory( IInventory par1IInventory, int par2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,22 +18,23 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class OptionalSlotFake extends SlotFake
|
||||
{
|
||||
|
||||
public final int srcX;
|
||||
public final int srcY;
|
||||
final int invSlot;
|
||||
final int groupNum;
|
||||
final IOptionalSlotHost host;
|
||||
|
||||
public boolean renderDisabled = true;
|
||||
|
||||
public final int srcX;
|
||||
public final int srcY;
|
||||
|
||||
public OptionalSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
|
||||
public OptionalSlotFake( IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum )
|
||||
{
|
||||
super( inv, idx, x + offX * 18, y + offY * 18 );
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
@@ -45,9 +46,9 @@ public class OptionalSlotFake extends SlotFake
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if ( !this.isEnabled() )
|
||||
if( !this.isEnabled() )
|
||||
{
|
||||
if ( this.getDisplayStack() != null )
|
||||
if( this.getDisplayStack() != null )
|
||||
this.clearStack();
|
||||
}
|
||||
|
||||
@@ -57,7 +58,7 @@ public class OptionalSlotFake extends SlotFake
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if ( this.host == null )
|
||||
if( this.host == null )
|
||||
return false;
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
@@ -67,5 +68,4 @@ public class OptionalSlotFake extends SlotFake
|
||||
{
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,28 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
|
||||
{
|
||||
|
||||
public OptionalSlotFakeTypeOnly(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
|
||||
public OptionalSlotFakeTypeOnly( IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack is)
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
is = is.copy();
|
||||
if ( is.stackSize > 1 )
|
||||
if( is.stackSize > 1 )
|
||||
is.stackSize = 1;
|
||||
else if ( is.stackSize < -1 )
|
||||
else if( is.stackSize < -1 )
|
||||
is.stackSize = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,18 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class OptionalSlotNormal extends AppEngSlot
|
||||
{
|
||||
|
||||
final int groupNum;
|
||||
final IOptionalSlotHost host;
|
||||
|
||||
public OptionalSlotNormal(IInventory inv, IOptionalSlotHost containerBus, int slot, int xPos, int yPos, int groupNum) {
|
||||
public OptionalSlotNormal( IInventory inv, IOptionalSlotHost containerBus, int slot, int xPos, int yPos, int groupNum )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
@@ -35,10 +38,9 @@ public class OptionalSlotNormal extends AppEngSlot
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if ( this.host == null )
|
||||
if( this.host == null )
|
||||
return false;
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,17 +18,19 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class OptionalSlotRestrictedInput extends SlotRestrictedInput
|
||||
{
|
||||
|
||||
final int groupNum;
|
||||
final IOptionalSlotHost host;
|
||||
|
||||
public OptionalSlotRestrictedInput(PlacableItemType valid, IInventory i, IOptionalSlotHost host, int slotIndex, int x, int y, int grpNum,
|
||||
InventoryPlayer invPlayer) {
|
||||
public OptionalSlotRestrictedInput( PlacableItemType valid, IInventory i, IOptionalSlotHost host, int slotIndex, int x, int y, int grpNum, InventoryPlayer invPlayer )
|
||||
{
|
||||
super( valid, i, slotIndex, x, y, invPlayer );
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
@@ -37,10 +39,9 @@ public class OptionalSlotRestrictedInput extends SlotRestrictedInput
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if ( this.host == null )
|
||||
if( this.host == null )
|
||||
return false;
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class QuartzKnifeOutput extends SlotOutput
|
||||
{
|
||||
|
||||
public QuartzKnifeOutput(IInventory a, int b, int c, int d, int i) {
|
||||
public QuartzKnifeOutput( IInventory a, int b, int c, int d, int i )
|
||||
{
|
||||
super( a, b, c, d, i );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,26 +18,23 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotCraftingMatrix extends AppEngSlot
|
||||
{
|
||||
|
||||
final Container c;
|
||||
|
||||
public SlotCraftingMatrix(Container c, IInventory par1iInventory, int par2, int par3, int par4) {
|
||||
public SlotCraftingMatrix( Container c, IInventory par1iInventory, int par2, int par3, int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStack()
|
||||
{
|
||||
@@ -46,18 +43,23 @@ public class SlotCraftingMatrix extends AppEngSlot
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1)
|
||||
{
|
||||
ItemStack is = super.decrStackSize( par1 );
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack par1ItemStack)
|
||||
public void putStack( ItemStack par1ItemStack )
|
||||
{
|
||||
super.putStack( par1ItemStack );
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( int par1 )
|
||||
{
|
||||
ItemStack is = super.decrStackSize( par1 );
|
||||
this.c.onCraftMatrixChanged( this.inventory );
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
@@ -58,8 +57,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
|
||||
public SlotCraftingTerm( EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
|
||||
IInventory secondMatrix, IInventory output, int x, int y, IContainerCraftingPacket ccp )
|
||||
public SlotCraftingTerm( EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix, IInventory secondMatrix, IInventory output, int x, int y, IContainerCraftingPacket ccp )
|
||||
{
|
||||
super( player, cMatrix, output, 0, x, y );
|
||||
this.energySrc = energySrc;
|
||||
@@ -83,11 +81,67 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot( EntityPlayer p, ItemStack is )
|
||||
{}
|
||||
|
||||
public void makeItem( EntityPlayer p, ItemStack is )
|
||||
{
|
||||
super.onPickupFromSlot( p, is );
|
||||
}
|
||||
|
||||
public void doClick( InventoryAction action, EntityPlayer who )
|
||||
{
|
||||
if( this.getStack() == null )
|
||||
return;
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
IMEMonitor<IAEItemStack> inv = this.storage.getItemInventory();
|
||||
int howManyPerCraft = this.getStack().stackSize;
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor( who, null );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else if( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorPlayerHand( who );
|
||||
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
|
||||
}
|
||||
else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorPlayerHand( who );
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
maxTimesToCraft = this.CapCraftingAttempts( maxTimesToCraft );
|
||||
|
||||
if( ia == null )
|
||||
return;
|
||||
|
||||
ItemStack rs = Platform.cloneItemStack( this.getStack() );
|
||||
if( rs == null )
|
||||
return;
|
||||
|
||||
for( int x = 0; x < maxTimesToCraft; x++ )
|
||||
{
|
||||
if( ia.simulateAdd( rs ) == null )
|
||||
{
|
||||
IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) );
|
||||
if( extra != null )
|
||||
{
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add( extra );
|
||||
Platform.spawnDrops( who.worldObj, (int) who.posX, (int) who.posY, (int) who.posZ, drops );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int CapCraftingAttempts( int maxTimesToCraft )
|
||||
{
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
public ItemStack craftItem( EntityPlayer p, ItemStack request, IMEMonitor<IAEItemStack> inv, IItemList all )
|
||||
@@ -95,34 +149,34 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
if ( is != null && Platform.isSameItem( request, is ) )
|
||||
if( is != null && Platform.isSameItem( request, is ) )
|
||||
{
|
||||
ItemStack[] set = new ItemStack[this.pattern.getSizeInventory()];
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
for ( int x = 0; x < 9; x++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
ic.setInventorySlotContents( x, this.pattern.getStackInSlot( x ) );
|
||||
|
||||
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
|
||||
|
||||
if ( r == null )
|
||||
if( r == null )
|
||||
{
|
||||
Item target = request.getItem();
|
||||
if ( target.isDamageable() && target.isRepairable() )
|
||||
if( target.isDamageable() && target.isRepairable() )
|
||||
{
|
||||
boolean isBad = false;
|
||||
for ( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack pis = ic.getStackInSlot( x );
|
||||
if ( pis == null )
|
||||
if( pis == null )
|
||||
continue;
|
||||
if ( pis.getItem() != target )
|
||||
if( pis.getItem() != target )
|
||||
isBad = true;
|
||||
}
|
||||
if ( !isBad )
|
||||
if( !isBad )
|
||||
{
|
||||
super.onPickupFromSlot( p, is );
|
||||
// actually necessary to cleanup this case...
|
||||
@@ -135,21 +189,20 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
|
||||
is = r.getCraftingResult( ic );
|
||||
|
||||
if ( inv != null )
|
||||
if( inv != null )
|
||||
{
|
||||
for ( int x = 0; x < this.pattern.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.pattern.getSizeInventory(); x++ )
|
||||
{
|
||||
if ( this.pattern.getStackInSlot( x ) != null )
|
||||
if( this.pattern.getStackInSlot( x ) != null )
|
||||
{
|
||||
set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.worldObj, r, is, ic, this.pattern.getStackInSlot( x ), x, all,
|
||||
Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) );
|
||||
set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.worldObj, r, is, ic, this.pattern.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) );
|
||||
ic.setInventorySlotContents( x, set[x] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.preCraft( p, inv, set, is ) )
|
||||
if( this.preCraft( p, inv, set, is ) )
|
||||
{
|
||||
this.makeItem( p, is );
|
||||
|
||||
@@ -170,92 +223,36 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
return true;
|
||||
}
|
||||
|
||||
public void makeItem( EntityPlayer p, ItemStack is )
|
||||
{
|
||||
super.onPickupFromSlot( p, is );
|
||||
}
|
||||
|
||||
public void postCraft( EntityPlayer p, IMEMonitor<IAEItemStack> inv, ItemStack[] set, ItemStack result )
|
||||
{
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if ( Platform.isServer() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// set new items onto the crafting table...
|
||||
for ( int x = 0; x < this.craftInv.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.craftInv.getSizeInventory(); x++ )
|
||||
{
|
||||
if ( this.craftInv.getStackInSlot( x ) == null )
|
||||
if( this.craftInv.getStackInSlot( x ) == null )
|
||||
{
|
||||
this.craftInv.setInventorySlotContents( x, set[x] );
|
||||
}
|
||||
else if ( set[x] != null )
|
||||
else if( set[x] != null )
|
||||
{
|
||||
// eek! put it back!
|
||||
IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc );
|
||||
if ( fail != null )
|
||||
if( fail != null )
|
||||
drops.add( fail.getItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( drops.size() > 0 )
|
||||
Platform.spawnDrops( p.worldObj, ( int ) p.posX, ( int ) p.posY, ( int ) p.posZ, drops );
|
||||
if( drops.size() > 0 )
|
||||
Platform.spawnDrops( p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops );
|
||||
}
|
||||
|
||||
public void doClick( InventoryAction action, EntityPlayer who )
|
||||
{
|
||||
if ( this.getStack() == null )
|
||||
return;
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
IMEMonitor<IAEItemStack> inv = this.storage.getItemInventory();
|
||||
int howManyPerCraft = this.getStack().stackSize;
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if ( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor( who, null );
|
||||
maxTimesToCraft = ( int ) Math.floor( ( double ) this.getStack().getMaxStackSize() / ( double ) howManyPerCraft );
|
||||
}
|
||||
else if ( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorPlayerHand( who );
|
||||
maxTimesToCraft = ( int ) Math.floor( ( double ) this.getStack().getMaxStackSize() / ( double ) howManyPerCraft );
|
||||
}
|
||||
else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorPlayerHand( who );
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
maxTimesToCraft = this.CapCraftingAttempts( maxTimesToCraft );
|
||||
|
||||
if ( ia == null )
|
||||
return;
|
||||
|
||||
ItemStack rs = Platform.cloneItemStack( this.getStack() );
|
||||
if ( rs == null )
|
||||
return;
|
||||
|
||||
for ( int x = 0; x < maxTimesToCraft; x++ )
|
||||
{
|
||||
if ( ia.simulateAdd( rs ) == null )
|
||||
{
|
||||
IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) );
|
||||
if ( extra != null )
|
||||
{
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add( extra );
|
||||
Platform.spawnDrops( who.worldObj, ( int ) who.posX, ( int ) who.posY, ( int ) who.posZ, drops );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int CapCraftingAttempts( int maxTimesToCraft )
|
||||
{
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,28 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotDisabled extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotDisabled(IInventory par1iInventory, int slotIndex, int x, int y) {
|
||||
public SlotDisabled( IInventory par1iInventory, int slotIndex, int x, int y )
|
||||
{
|
||||
super( par1iInventory, slotIndex, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
public boolean isItemValid( ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,50 +18,52 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotFake extends AppEngSlot
|
||||
{
|
||||
|
||||
final int invSlot;
|
||||
|
||||
public SlotFake(IInventory inv, int idx, int x, int y) {
|
||||
public SlotFake( IInventory inv, int idx, int x, int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
this.invSlot = idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public void onPickupFromSlot( EntityPlayer par1EntityPlayer, ItemStack par2ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1)
|
||||
public ItemStack decrStackSize( int par1 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
|
||||
public boolean isItemValid( ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack is)
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
is = is.copy();
|
||||
|
||||
super.putStack( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,19 +18,16 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotFakeBlacklist extends SlotFakeTypeOnly
|
||||
{
|
||||
|
||||
public SlotFakeBlacklist(IInventory inv, int idx, int x, int y) {
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem()
|
||||
public SlotFakeBlacklist( IInventory inv, int idx, int x, int y )
|
||||
{
|
||||
return true;
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,14 +36,19 @@ public class SlotFakeBlacklist extends SlotFakeTypeOnly
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIcon()
|
||||
{
|
||||
if ( this.getHasStack() )
|
||||
if( this.getHasStack() )
|
||||
{
|
||||
return this.getStack().stackSize > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotFakeCraftingMatrix extends SlotFake
|
||||
{
|
||||
|
||||
public SlotFakeCraftingMatrix(IInventory inv, int idx, int x, int y) {
|
||||
public SlotFakeCraftingMatrix( IInventory inv, int idx, int x, int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,28 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotFakeTypeOnly extends SlotFake
|
||||
{
|
||||
|
||||
public SlotFakeTypeOnly(IInventory inv, int idx, int x, int y) {
|
||||
public SlotFakeTypeOnly( IInventory inv, int idx, int x, int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack is)
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
is = is.copy();
|
||||
if ( is.stackSize > 1 )
|
||||
if( is.stackSize > 1 )
|
||||
is.stackSize = 1;
|
||||
else if ( is.stackSize < -1 )
|
||||
else if( is.stackSize < -1 )
|
||||
is.stackSize = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,29 +18,26 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotInaccessible extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotInaccessible(IInventory i, int slotIdx, int x, int y) {
|
||||
ItemStack dspStack = null;
|
||||
|
||||
public SlotInaccessible( IInventory i, int slotIdx, int x, int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
|
||||
ItemStack dspStack = null;
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
public boolean isItemValid( ItemStack i )
|
||||
{
|
||||
if ( this.dspStack == null )
|
||||
{
|
||||
ItemStack dsp = super.getDisplayStack();
|
||||
if ( dsp != null )
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
return this.dspStack;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,15 +48,20 @@ public class SlotInaccessible extends AppEngSlot
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack i)
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
return false;
|
||||
if( this.dspStack == null )
|
||||
{
|
||||
ItemStack dsp = super.getDisplayStack();
|
||||
if( dsp != null )
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotInaccessibleHD extends SlotInaccessible
|
||||
{
|
||||
|
||||
public SlotInaccessibleHD(IInventory i, int slotIdx, int x, int y) {
|
||||
public SlotInaccessibleHD( IInventory i, int slotIdx, int x, int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,25 +18,27 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
|
||||
|
||||
public class SlotMACPattern extends AppEngSlot
|
||||
{
|
||||
|
||||
final ContainerMAC mac;
|
||||
|
||||
public SlotMACPattern(ContainerMAC mac, IInventory i, int slotIdx, int x, int y) {
|
||||
public SlotMACPattern( ContainerMAC mac, IInventory i, int slotIdx, int x, int y )
|
||||
{
|
||||
super( i, slotIdx, x, y );
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack i)
|
||||
public boolean isItemValid( ItemStack i )
|
||||
{
|
||||
return this.mac.isValidItemForSlot( this.getSlotIndex(), i );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotNormal extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotNormal(IInventory inv, int slot, int xPos, int yPos) {
|
||||
public SlotNormal( IInventory inv, int slot, int xPos, int yPos )
|
||||
{
|
||||
super( inv, slot, xPos, yPos );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,19 +18,22 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotOutput extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotOutput(IInventory a, int b, int c, int d, int i) {
|
||||
public SlotOutput( IInventory a, int b, int c, int d, int i )
|
||||
{
|
||||
super( a, b, c, d );
|
||||
this.IIcon = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack i)
|
||||
public boolean isItemValid( ItemStack i )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotPatternOutputs extends OptionalSlotFake
|
||||
{
|
||||
|
||||
public SlotPatternOutputs(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
|
||||
public SlotPatternOutputs( IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum )
|
||||
{
|
||||
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -32,28 +33,32 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
|
||||
|
||||
public class SlotPatternTerm extends SlotCraftingTerm
|
||||
{
|
||||
|
||||
final int groupNum;
|
||||
final IOptionalSlotHost host;
|
||||
|
||||
public SlotPatternTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
|
||||
IInventory secondMatrix, IInventory output, int x, int y, IOptionalSlotHost h, int groupNumber, IContainerCraftingPacket c)
|
||||
public SlotPatternTerm( EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix, IInventory secondMatrix, IInventory output, int x, int y, IOptionalSlotHost h, int groupNumber, IContainerCraftingPacket c )
|
||||
{
|
||||
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );
|
||||
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
|
||||
public AppEngPacket getRequest( boolean shift ) throws IOException
|
||||
{
|
||||
return new PacketPatternSlot( this.pattern, AEApi.instance().storage().createItemStack( this.getStack() ), shift );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if ( !this.isEnabled() )
|
||||
if( !this.isEnabled() )
|
||||
{
|
||||
if ( this.getDisplayStack() != null )
|
||||
if( this.getDisplayStack() != null )
|
||||
this.clearStack();
|
||||
}
|
||||
|
||||
@@ -63,15 +68,9 @@ public class SlotPatternTerm extends SlotCraftingTerm
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
if ( this.host == null )
|
||||
if( this.host == null )
|
||||
return false;
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
|
||||
public AppEngPacket getRequest(boolean shift) throws IOException
|
||||
{
|
||||
return new PacketPatternSlot( this.pattern, AEApi.instance().storage().createItemStack( this.getStack() ), shift );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
|
||||
public class SlotPlayerHotBar extends AppEngSlot
|
||||
{
|
||||
|
||||
public SlotPlayerHotBar(IInventory par1iInventory, int par2, int par3, int par4) {
|
||||
public SlotPlayerHotBar( IInventory par1iInventory, int par2, int par3, int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
this.isPlayerSide = true;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
// 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 SlotPlayerInv(IInventory par1iInventory, int par2, int par3, int par4) {
|
||||
public SlotPlayerInv( IInventory par1iInventory, int par2, int par3, int par4 )
|
||||
{
|
||||
super( par1iInventory, par2, par3, par4 );
|
||||
|
||||
this.isPlayerSide = true;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -44,67 +45,17 @@ import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class SlotRestrictedInput extends AppEngSlot
|
||||
{
|
||||
|
||||
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),
|
||||
|
||||
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),
|
||||
|
||||
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);
|
||||
|
||||
public final int IIcon;
|
||||
|
||||
PlacableItemType( int o ) {
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
if ( this.stackLimit != -1 )
|
||||
return this.stackLimit;
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
|
||||
public boolean isValid(ItemStack is, World theWorld)
|
||||
{
|
||||
if ( this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT )
|
||||
{
|
||||
ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) is.getItem()).getPatternForItem( is, theWorld )
|
||||
: null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public final PlacableItemType which;
|
||||
private final InventoryPlayer p;
|
||||
public boolean allowEdit = true;
|
||||
public int stackLimit = -1;
|
||||
private final InventoryPlayer p;
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
||||
public SlotRestrictedInput( PlacableItemType valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p )
|
||||
{
|
||||
return this.allowEdit;
|
||||
}
|
||||
|
||||
public Slot setStackLimit(int i)
|
||||
{
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SlotRestrictedInput(PlacableItemType valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||
super( i, slotIndex, x, y );
|
||||
this.which = valid;
|
||||
this.IIcon = valid.IIcon;
|
||||
@@ -112,58 +63,66 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
if ( Platform.isClient() && (this.which == PlacableItemType.ENCODED_PATTERN) )
|
||||
if( this.stackLimit != -1 )
|
||||
return this.stackLimit;
|
||||
return super.getSlotStackLimit();
|
||||
}
|
||||
|
||||
public boolean isValid( ItemStack is, World theWorld )
|
||||
{
|
||||
if( this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT )
|
||||
{
|
||||
ItemStack is = super.getStack();
|
||||
if ( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
ItemStack out = iep.getOutput( is );
|
||||
if ( out != null )
|
||||
return out;
|
||||
}
|
||||
ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem ? ( (ICraftingPatternItem) is.getItem() ).getPatternForItem( is, theWorld ) : null;
|
||||
return ap != null;
|
||||
}
|
||||
return super.getStack();
|
||||
return true;
|
||||
}
|
||||
|
||||
public Slot setStackLimit( int i )
|
||||
{
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack i)
|
||||
public boolean isItemValid( ItemStack i )
|
||||
{
|
||||
if ( !this.myContainer.isValidForSlot( this, i ) )
|
||||
if( !this.myContainer.isValidForSlot( this, i ) )
|
||||
return false;
|
||||
|
||||
if ( i == null )
|
||||
if( i == null )
|
||||
return false;
|
||||
if ( i.getItem() == null )
|
||||
if( i.getItem() == null )
|
||||
return false;
|
||||
|
||||
if ( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) )
|
||||
if( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) )
|
||||
return false;
|
||||
|
||||
if ( !this.allowEdit )
|
||||
if( !this.allowEdit )
|
||||
return false;
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
switch (this.which)
|
||||
switch( this.which )
|
||||
{
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if ( i.getItem() instanceof ICraftingPatternItem )
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
{
|
||||
ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.worldObj );
|
||||
if ( de != null )
|
||||
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 )
|
||||
case ENCODED_PATTERN:
|
||||
{
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
return true;
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
@@ -174,19 +133,19 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
|
||||
case PATTERN:
|
||||
|
||||
if ( i.getItem() instanceof ICraftingPatternItem )
|
||||
if( i.getItem() instanceof ICraftingPatternItem )
|
||||
return true;
|
||||
|
||||
return materials.blankPattern().isSameAs( i );
|
||||
|
||||
case INSCRIBER_PLATE:
|
||||
if ( materials.namePress().isSameAs( i ) )
|
||||
if( materials.namePress().isSameAs( i ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ItemStack is : Inscribe.PLATES )
|
||||
if ( Platform.isSameItemPrecise( is, i ) )
|
||||
for( ItemStack is : Inscribe.PLATES )
|
||||
if( Platform.isSameItemPrecise( is, i ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -217,15 +176,15 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
return materials.wirelessBooster().isSameAs( i );
|
||||
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell && ((ISpatialStorageCell) i.getItem()).isSpatialStorage( i );
|
||||
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 );
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ( (ICellWorkbenchItem) i.getItem() ).isEditable( i );
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i );
|
||||
return i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i );
|
||||
case TRASH:
|
||||
if ( AEApi.instance().registries().cell().isCellHandled( i ) )
|
||||
if( AEApi.instance().registries().cell().isCellHandled( i ) )
|
||||
return false;
|
||||
|
||||
return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) );
|
||||
@@ -234,7 +193,7 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType( i ) != null;
|
||||
return i.getItem() instanceof IUpgradeModule && ( (IUpgradeModule) i.getItem() ).getType( i ) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -242,20 +201,65 @@ public class SlotRestrictedInput extends AppEngSlot
|
||||
return false;
|
||||
}
|
||||
|
||||
static public boolean isMetalIngot(ItemStack i)
|
||||
@Override
|
||||
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
if ( Platform.isSameItemPrecise( i, new ItemStack( Items.iron_ingot ) ) )
|
||||
return this.allowEdit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack()
|
||||
{
|
||||
if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) )
|
||||
{
|
||||
ItemStack is = super.getStack();
|
||||
if( is != null && is.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
ItemStack out = iep.getOutput( is );
|
||||
if( out != null )
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
static public boolean isMetalIngot( ItemStack i )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( i, new ItemStack( Items.iron_ingot ) ) )
|
||||
return true;
|
||||
|
||||
for (String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" })
|
||||
for( String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } )
|
||||
{
|
||||
for (ItemStack ingot : OreDictionary.getOres( "ingot" + name ))
|
||||
for( ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
|
||||
{
|
||||
if ( Platform.isSameItemPrecise( i, ingot ) )
|
||||
if( Platform.isSameItemPrecise( i, ingot ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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 ),
|
||||
|
||||
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 ),
|
||||
|
||||
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 );
|
||||
|
||||
public final int IIcon;
|
||||
|
||||
PlacableItemType( int o )
|
||||
{
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user