This commit is contained in:
mezz committed 2015-03-25 00:51:48 -07:00
1 parent ce3d891eaa
commit 9989451c1c
64 files changed
+234 -439

No files matched your search

@@ -99,12 +99,7 @@ public class BackpackDefinition implements IBackpackDefinition {
// isValidItem can get called multiple times per tick if the player's inventory is full
// and they are standing on multiple items.
// It is a slow call, so we need a cache to make it fast
private Map<ItemStack, Boolean> isValidItemCache = new LinkedHashMap<ItemStack, Boolean>() {
@Override
protected boolean removeEldestEntry(Map.Entry<ItemStack, Boolean> eldest) {
return size() > 64;
}
};
private final Map<ItemStack, Boolean> isValidItemCache = new ValidItemCache();
@Override
public boolean isValidItem(EntityPlayer player, ItemStack itemstack) {
@@ -128,4 +123,11 @@ public class BackpackDefinition implements IBackpackDefinition {
isValidItemCache.put(itemstack, false);
return false;
}
private static class ValidItemCache extends LinkedHashMap<ItemStack, Boolean> {
@Override
protected boolean removeEldestEntry(Map.Entry<ItemStack, Boolean> eldest) {
return size() > 64;
}
}
}