SteamWar/BauSystem2.0
Archiviert
12
0

Add and increase Threshold

Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Chaoscaot 2021-05-24 12:01:09 +02:00
Ursprung 2f72d011e6
Commit d75fe24ebe

Datei anzeigen

@ -27,6 +27,8 @@ import org.bukkit.inventory.ItemStack;
public class InventoryListener_15 { public class InventoryListener_15 {
private static final int threshold = 2048;
public static boolean checkItemStack(ItemStack item) { public static boolean checkItemStack(ItemStack item) {
net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item); net.minecraft.server.v1_15_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound tag = nmsItem.getTag(); NBTTagCompound tag = nmsItem.getTag();
@ -34,13 +36,13 @@ public class InventoryListener_15 {
NBTTagCompound blockTag = tag.getCompound("BlockEntityTag"); NBTTagCompound blockTag = tag.getCompound("BlockEntityTag");
assert blockTag != null; assert blockTag != null;
if (blockTag.hasKey("Items")) { if (blockTag.hasKey("Items")) {
return drillDown(blockTag.getList("Items", 10), 0, 0) > 1024; return drillDown(blockTag.getList("Items", 10), 0, 0) > threshold;
} }
return false; return false;
} }
private static int drillDown(NBTTagList items, int layer, int start) { private static int drillDown(NBTTagList items, int layer, int start) {
if (layer > 2) return start + 1024; if (layer > 2) return start + threshold;
int invalid = start; int invalid = start;
for (NBTBase nbtBase : items) { for (NBTBase nbtBase : items) {
if (!(nbtBase instanceof NBTTagCompound)) if (!(nbtBase instanceof NBTTagCompound))
@ -56,7 +58,7 @@ public class InventoryListener_15 {
} }
} }
} }
if (invalid > 1024) if (invalid > threshold)
break; break;
} }
return invalid; return invalid;