@@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
package appeng.container.slot;
|
package appeng.container.slot;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ import appeng.util.Platform;
|
|||||||
import appeng.util.inv.AdaptorPlayerHand;
|
import appeng.util.inv.AdaptorPlayerHand;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class SlotCraftingTerm extends AppEngCraftingSlot
|
public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -36,8 +39,8 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
private final IStorageMonitorable storage;
|
private final IStorageMonitorable storage;
|
||||||
private final IContainerCraftingPacket container;
|
private final IContainerCraftingPacket container;
|
||||||
|
|
||||||
public SlotCraftingTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
|
public SlotCraftingTerm( EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
|
||||||
IInventory secondMatrix, IInventory output, int x, int y, IContainerCraftingPacket ccp)
|
IInventory secondMatrix, IInventory output, int x, int y, IContainerCraftingPacket ccp )
|
||||||
{
|
{
|
||||||
super( player, cMatrix, output, 0, x, y );
|
super( player, cMatrix, output, 0, x, y );
|
||||||
this.energySrc = energySrc;
|
this.energySrc = energySrc;
|
||||||
@@ -54,22 +57,21 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
|
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickupFromSlot(EntityPlayer p, ItemStack is)
|
public void onPickupFromSlot( EntityPlayer p, ItemStack is )
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
public void makeItem(EntityPlayer p, ItemStack is)
|
public void makeItem( EntityPlayer p, ItemStack is )
|
||||||
{
|
{
|
||||||
super.onPickupFromSlot( p, is );
|
super.onPickupFromSlot( p, is );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack craftItem(EntityPlayer p, ItemStack request, IMEMonitor<IAEItemStack> inv, IItemList all)
|
public ItemStack craftItem( EntityPlayer p, ItemStack request, IMEMonitor<IAEItemStack> inv, IItemList all )
|
||||||
{
|
{
|
||||||
// update crafting matrix...
|
// update crafting matrix...
|
||||||
ItemStack is = getStack();
|
ItemStack is = getStack();
|
||||||
@@ -82,7 +84,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
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, pattern.getStackInSlot( x ) );
|
ic.setInventorySlotContents( x, pattern.getStackInSlot( x ) );
|
||||||
|
|
||||||
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
|
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
|
||||||
@@ -93,7 +95,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( target.isDamageable() && target.isRepairable() )
|
if ( target.isDamageable() && target.isRepairable() )
|
||||||
{
|
{
|
||||||
boolean isBad = false;
|
boolean isBad = false;
|
||||||
for (int x = 0; x < ic.getSizeInventory(); x++)
|
for ( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||||
{
|
{
|
||||||
ItemStack pis = ic.getStackInSlot( x );
|
ItemStack pis = ic.getStackInSlot( x );
|
||||||
if ( pis == null )
|
if ( pis == null )
|
||||||
@@ -104,8 +106,8 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( !isBad )
|
if ( !isBad )
|
||||||
{
|
{
|
||||||
super.onPickupFromSlot( p, is );
|
super.onPickupFromSlot( p, is );
|
||||||
// actually necessary to cleanup this case...
|
// actually necessary to cleanup this case...
|
||||||
p.openContainer.onCraftMatrixChanged( getCraftingMatrix() );
|
p.openContainer.onCraftMatrixChanged( getCraftingMatrix() );
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +118,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
|
|
||||||
if ( inv != null )
|
if ( inv != null )
|
||||||
{
|
{
|
||||||
for (int x = 0; x < pattern.getSizeInventory(); x++)
|
for ( int x = 0; x < pattern.getSizeInventory(); x++ )
|
||||||
{
|
{
|
||||||
if ( pattern.getStackInSlot( x ) != null )
|
if ( pattern.getStackInSlot( x ) != null )
|
||||||
{
|
{
|
||||||
@@ -144,12 +146,12 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean preCraft(EntityPlayer p, IMEMonitor<IAEItemStack> inv, ItemStack[] set, ItemStack result)
|
public boolean preCraft( EntityPlayer p, IMEMonitor<IAEItemStack> inv, ItemStack[] set, ItemStack result )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postCraft(EntityPlayer p, IMEMonitor<IAEItemStack> inv, ItemStack set[], ItemStack result)
|
public void postCraft( EntityPlayer p, IMEMonitor<IAEItemStack> inv, ItemStack set[], ItemStack result )
|
||||||
{
|
{
|
||||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
@@ -157,7 +159,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
// set new items onto the crafting table...
|
// set new items onto the crafting table...
|
||||||
for (int x = 0; x < getCraftingMatrix().getSizeInventory(); x++)
|
for ( int x = 0; x < getCraftingMatrix().getSizeInventory(); x++ )
|
||||||
{
|
{
|
||||||
if ( getCraftingMatrix().getStackInSlot( x ) == null )
|
if ( getCraftingMatrix().getStackInSlot( x ) == null )
|
||||||
getCraftingMatrix().setInventorySlotContents( x, set[x] );
|
getCraftingMatrix().setInventorySlotContents( x, set[x] );
|
||||||
@@ -172,10 +174,10 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( drops.size() > 0 )
|
if ( drops.size() > 0 )
|
||||||
Platform.spawnDrops( p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops );
|
Platform.spawnDrops( p.worldObj, ( int ) p.posX, ( int ) p.posY, ( int ) p.posZ, drops );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doClick(InventoryAction action, EntityPlayer who)
|
public void doClick( InventoryAction action, EntityPlayer who )
|
||||||
{
|
{
|
||||||
if ( getStack() == null )
|
if ( getStack() == null )
|
||||||
return;
|
return;
|
||||||
@@ -190,12 +192,12 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
if ( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
|
||||||
{
|
{
|
||||||
ia = InventoryAdaptor.getAdaptor( who, null );
|
ia = InventoryAdaptor.getAdaptor( who, null );
|
||||||
maxTimesToCraft = (int) Math.floor( (double) getStack().getMaxStackSize() / (double) howManyPerCraft );
|
maxTimesToCraft = ( int ) Math.floor( ( double ) getStack().getMaxStackSize() / ( double ) howManyPerCraft );
|
||||||
}
|
}
|
||||||
else if ( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
else if ( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
|
||||||
{
|
{
|
||||||
ia = new AdaptorPlayerHand( who );
|
ia = new AdaptorPlayerHand( who );
|
||||||
maxTimesToCraft = (int) Math.floor( (double) getStack().getMaxStackSize() / (double) howManyPerCraft );
|
maxTimesToCraft = ( int ) Math.floor( ( double ) getStack().getMaxStackSize() / ( double ) howManyPerCraft );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// pick up what was crafted...
|
// pick up what was crafted...
|
||||||
@@ -213,7 +215,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
if ( rs == null )
|
if ( rs == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int x = 0; x < maxTimesToCraft; x++)
|
for ( int x = 0; x < maxTimesToCraft; x++ )
|
||||||
{
|
{
|
||||||
if ( ia.simulateAdd( rs ) == null )
|
if ( ia.simulateAdd( rs ) == null )
|
||||||
{
|
{
|
||||||
@@ -223,14 +225,14 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
|||||||
{
|
{
|
||||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
drops.add( extra );
|
drops.add( extra );
|
||||||
Platform.spawnDrops( who.worldObj, (int) who.posX, (int) who.posY, (int) who.posZ, drops );
|
Platform.spawnDrops( who.worldObj, ( int ) who.posX, ( int ) who.posY, ( int ) who.posZ, drops );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int CapCraftingAttempts(int maxTimesToCraft)
|
protected int CapCraftingAttempts( int maxTimesToCraft )
|
||||||
{
|
{
|
||||||
return maxTimesToCraft;
|
return maxTimesToCraft;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user