forked from xjboss/KCauldronX
Reduce calls to heavy nbt comparsion
Spigot patch: 0157-Use-FastMatches-for-ItemStack-Dirty-Check.patch
This commit is contained in:
parent
e6ac67c28c
commit
f3a73d8d68
@ -47,7 +47,7 @@ archivesBaseName = 'kcauldron'
|
||||
ext.mcVersion = "1.7.10"
|
||||
ext.cauldronVersion = "3"
|
||||
ext.forgeVersion = "1403"
|
||||
ext.revision = "57"
|
||||
ext.revision = "58"
|
||||
version = "${mcVersion}-${cauldronVersion}.${forgeVersion}.${revision}"
|
||||
|
||||
launch4j {
|
||||
|
@ -26,7 +26,7 @@
|
||||
+ public int field_94536_g; // CraftBukkit - private -> public
|
||||
private final Set field_94537_h = new HashSet();
|
||||
+ public InventoryView bukkitView = null; // Cauldron
|
||||
+
|
||||
+ private int tickCount = 0; // Spigot
|
||||
protected List crafters = new ArrayList();
|
||||
private Set playerList = new HashSet();
|
||||
private static final String __OBFID = "CL_00001730";
|
||||
@ -85,7 +85,24 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,6 +164,10 @@
|
||||
@@ -74,7 +129,7 @@
|
||||
ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack();
|
||||
ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);
|
||||
|
||||
- if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
|
||||
+ if (!areItemStacksEqual(itemstack1, itemstack))
|
||||
{
|
||||
itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
this.inventoryItemStacks.set(i, itemstack1);
|
||||
@@ -85,6 +140,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ tickCount++;
|
||||
}
|
||||
|
||||
public boolean enchantItem(EntityPlayer p_75140_1_, int p_75140_2_)
|
||||
@@ -109,6 +165,10 @@
|
||||
|
||||
public Slot getSlot(int p_75139_1_)
|
||||
{
|
||||
@ -96,7 +113,7 @@
|
||||
return (Slot)this.inventorySlots.get(p_75139_1_);
|
||||
}
|
||||
|
||||
@@ -168,6 +227,7 @@
|
||||
@@ -168,6 +228,7 @@
|
||||
itemstack3 = inventoryplayer.getItemStack().copy();
|
||||
i1 = inventoryplayer.getItemStack().stackSize;
|
||||
Iterator iterator = this.field_94537_h.iterator();
|
||||
@ -104,7 +121,7 @@
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
@@ -190,18 +250,55 @@
|
||||
@@ -190,18 +251,55 @@
|
||||
}
|
||||
|
||||
i1 -= itemstack1.stackSize - j1;
|
||||
@ -165,7 +182,7 @@
|
||||
}
|
||||
|
||||
this.func_94533_d();
|
||||
@@ -235,10 +332,17 @@
|
||||
@@ -235,10 +333,17 @@
|
||||
|
||||
if (p_75144_2_ == 1)
|
||||
{
|
||||
@ -184,3 +201,14 @@
|
||||
inventoryplayer.setItemStack((ItemStack)null);
|
||||
}
|
||||
}
|
||||
@@ -730,4 +835,10 @@
|
||||
return MathHelper.floor_float(f * 14.0F) + (i > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Spigot start
|
||||
+ public boolean areItemStacksEqual(ItemStack is1, ItemStack is2) {
|
||||
+ return tickCount % 20 == 0 ? ItemStack.areItemStacksEqual(is1, is2) : ItemStack.fastMatches(is1, is2);
|
||||
+ }
|
||||
+ // Spigot
|
||||
}
|
||||
|
@ -148,3 +148,16 @@
|
||||
this.stackTagCompound = p_77982_1_;
|
||||
}
|
||||
|
||||
@@ -768,4 +832,12 @@
|
||||
|
||||
return ichatcomponent;
|
||||
}
|
||||
+
|
||||
+ // Spigot start
|
||||
+ public static boolean fastMatches(ItemStack is1, ItemStack is2) {
|
||||
+ if (is1 == null && is2 == null) return true;
|
||||
+ if (is1 != null && is2 != null) return is1.stackSize == is1.stackSize && is1.field_151002_e == is2.field_151002_e && is1.itemDamage == is2.itemDamage;
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user