Compare commits

..

8 Commits

Author SHA1 Message Date
yueh ece09a956b Merge pull request #1016 from yueh/fix-1015
Fixes #1015 no longer eat a single item when not able to satisfy the recipe
2015-03-13 23:49:12 +01:00
yueh db5493f60b Merge pull request #1012 from yueh/fix-1011
Fixes #1011 skip null values
2015-03-12 19:23:21 +01:00
yueh f0482dd391 Fixes #1015 no longer eat a single item when not able to satisfy the recipe 2015-03-12 19:07:59 +01:00
yueh c53b3b5dfc Fixes #1011 skip null values 2015-03-11 23:57:48 +01:00
thatsIch ad16550a86 Merge pull request #1009 from bakaxyf/patch-2
Update zh_CN.lang
2015-03-11 17:11:30 +01:00
bakaxyf 99e4928542 Update zh_CN.lang 2015-03-12 00:09:12 +08:00
yueh 43995a4b32 Merge pull request #987 from yueh/feature-improve-aeitemstack-compareto
Improved AEItemStack.compareTo performance.
2015-03-11 16:54:09 +01:00
yueh 53f448e578 Improved AEItemStack.compareTo performance. 2015-03-08 15:27:27 +01:00
5 changed files with 47 additions and 33 deletions
@@ -18,6 +18,7 @@
package appeng.core.sync.packets;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@@ -56,13 +57,14 @@ import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.IPartitionList;
public class PacketNEIRecipe extends AppEngPacket
{
ItemStack[][] recipe;
// automatic.
public PacketNEIRecipe(ByteBuf stream) throws IOException
public PacketNEIRecipe( ByteBuf stream ) throws IOException
{
ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
bytes.skip( stream.readerIndex() );
@@ -70,13 +72,13 @@ public class PacketNEIRecipe extends AppEngPacket
if ( comp != null )
{
this.recipe = new ItemStack[9][];
for (int x = 0; x < this.recipe.length; x++)
for ( int x = 0; x < this.recipe.length; x++ )
{
NBTTagList list = comp.getTagList( "#" + x, 10 );
if ( list.tagCount() > 0 )
{
this.recipe[x] = new ItemStack[list.tagCount()];
for (int y = 0; y < list.tagCount(); y++)
for ( int y = 0; y < list.tagCount(); y++ )
{
this.recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt( y ) );
}
@@ -86,14 +88,14 @@ public class PacketNEIRecipe extends AppEngPacket
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
{
EntityPlayerMP pmp = (EntityPlayerMP) player;
EntityPlayerMP pmp = ( EntityPlayerMP ) player;
Container con = pmp.openContainer;
if ( con != null && con instanceof IContainerCraftingPacket )
{
IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
IContainerCraftingPacket cct = ( IContainerCraftingPacket ) con;
IGridNode node = cct.getNetworkNode();
if ( node != null )
{
@@ -112,11 +114,11 @@ public class PacketNEIRecipe extends AppEngPacket
if ( inv != null && this.recipe != null && security != null )
{
InventoryCrafting testInv = new InventoryCrafting( new ContainerNull(), 3, 3 );
for (int x = 0; x < 9; x++)
for ( int x = 0; x < 9; x++ )
{
if ( this.recipe[x] != null && this.recipe[x].length > 0 )
{
testInv.setInventorySlotContents(x, this.recipe[x][0]);
testInv.setInventorySlotContents( x, this.recipe[x][0] );
}
}
@@ -132,16 +134,16 @@ public class PacketNEIRecipe extends AppEngPacket
IItemList all = storage.getStorageList();
IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for (int x = 0; x < craftMatrix.getSizeInventory(); x++)
for ( int x = 0; x < craftMatrix.getSizeInventory(); x++ )
{
ItemStack PatternItem = testInv.getStackInSlot( x );
ItemStack currentItem = craftMatrix.getStackInSlot( x );
if ( currentItem != null )
{
testInv.setInventorySlotContents(x, currentItem);
testInv.setInventorySlotContents( x, currentItem );
ItemStack newItemStack = r.matches( testInv, pmp.worldObj ) ? r.getCraftingResult( testInv ) : null;
testInv.setInventorySlotContents(x, PatternItem);
testInv.setInventorySlotContents( x, PatternItem );
if ( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
{
@@ -171,7 +173,7 @@ public class PacketNEIRecipe extends AppEngPacket
// TODO see if this code is necessary
if ( whichItem == null )
{
for (int y = 0; y < this.recipe[x].length; y++)
for ( int y = 0; y < this.recipe[x].length; y++ )
{
IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
if ( request != null )
@@ -191,19 +193,23 @@ public class PacketNEIRecipe extends AppEngPacket
}
// If that doesn't work, grab from the player's inventory
if ( whichItem == null && playerInventory != null ) {
if ( whichItem == null && playerInventory != null )
{
ItemStack playerItemStack = null;
for ( int y = 0; y < playerInventory.getSizeInventory(); y++ )
{
// Put the item in the test inventory, and check if the recipe is satisfied
testInv.setInventorySlotContents(x, playerInventory.getStackInSlot(y));
if ( r.matches(testInv, pmp.worldObj) )
// check if the item in slot y matches the required item.
playerItemStack = playerInventory.getStackInSlot( y );
if ( playerItemStack != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
{
// Take the item out.
if ( realForFake == Actionable.SIMULATE ) {
whichItem = playerInventory.getStackInSlot(y).copy();
if ( realForFake == Actionable.SIMULATE )
{
whichItem = playerInventory.getStackInSlot( y ).copy();
whichItem.stackSize = 1;
} else {
whichItem = playerInventory.decrStackSize(y, 1);
}
else
{
whichItem = playerInventory.decrStackSize( y, 1 );
}
break;
}
@@ -222,7 +228,7 @@ public class PacketNEIRecipe extends AppEngPacket
}
// api
public PacketNEIRecipe(NBTTagCompound recipe) throws IOException
public PacketNEIRecipe( NBTTagCompound recipe ) throws IOException
{
ByteBuf data = Unpooled.buffer();
@@ -37,7 +37,7 @@ public class AEItemDef
public int def;
private final int itemID;
public final int itemID;
public final Item item;
public int damageValue;
@@ -62,7 +62,7 @@ public class AEItemDef
public AEItemDef(Item it) {
this.item = it;
this.itemID = System.identityHashCode( this.item );
this.itemID = Item.getIdFromItem( it );
}
public AEItemDef copy()
@@ -261,11 +261,19 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@Override
public int compareTo(AEItemStack b)
{
int id = this.compare( this.def.item.hashCode(), b.def.item.hashCode() );
int damageValue = this.compare( this.def.damageValue, b.def.damageValue );
int displayDamage = this.compare( this.def.displayDamage, b.def.displayDamage );
// AELog.info( "NBT: " + nbt );
return id == 0 ? (damageValue == 0 ? (displayDamage == 0 ? this.compareNBT( b.def ) : displayDamage) : damageValue) : id;
int id = this.def.itemID - b.def.itemID;
if (id != 0)
return id;
int damageValue = this.def.damageValue - b.def.damageValue ;
if (damageValue != 0)
return damageValue;
int displayDamage = this.def.displayDamage - b.def.displayDamage;
if (displayDamage != 0)
return displayDamage;
return (this.def.tagCompound == b.def.tagCompound) ? 0 : this.compareNBT( b.def );
}
private int compareNBT(AEItemDef b)
@@ -276,7 +284,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
return nbt;
}
private int compare(int l, long m)
private int compare(int l, int m)
{
return l < m ? -1 : (l > m ? 1 : 0);
}
@@ -76,8 +76,8 @@ public class OreHelper
for ( String ore : OreDictionary.getOreNames() )
{
// skip ore if it is a match already.
if ( toAdd.contains( ore ) )
// skip ore if it is a match already or null.
if ( ore == null || toAdd.contains( ore ) )
{
continue;
}
@@ -252,7 +252,7 @@ gui.tooltips.appliedenergistics2.AlwaysActive=总是激活
gui.tooltips.appliedenergistics2.ActiveWithoutSignal=无信号时激活
gui.tooltips.appliedenergistics2.ActiveWithSignal=有信号时激活
gui.tooltips.appliedenergistics2.ActiveOnPulse=有脉冲信号时激活
gui.tooltips.appliedenergistics2.EmitLevelsBelow=当容量标准小于等于设定限制时发出信号.
gui.tooltips.appliedenergistics2.EmitLevelsBelow=当容量标准小于设定限制时发出信号.
gui.tooltips.appliedenergistics2.EmitLevelAbove=当容量标准大于等于设定限制时发出信号.
gui.tooltips.appliedenergistics2.SearchMode_Auto=自动搜索
gui.tooltips.appliedenergistics2.SearchMode_Standard=标准搜索