mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-16 18:44:44 +00:00
Implemented a recursion limiter to the magnet ring's blacklist API for pesky items that intercept getItemDamage().
This commit is contained in:
1 parent
f5ef8ed2ed
commit
3b6ebcae1e
2 files changed
+18
-4
No files matched your search
@@ -302,9 +302,16 @@ public final class BotaniaAPI {
|
||||
}
|
||||
|
||||
public static boolean isItemBlacklistedFromMagnet(ItemStack stack) {
|
||||
return isItemBlacklistedFromMagnet(stack, 0);
|
||||
}
|
||||
|
||||
public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) {
|
||||
if(recursion > 5)
|
||||
return false;
|
||||
|
||||
if(stack.getItemDamage() != Short.MAX_VALUE) {
|
||||
ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE);
|
||||
boolean general = isItemBlacklistedFromMagnet(copy);
|
||||
boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1);
|
||||
if(general)
|
||||
return true;
|
||||
}
|
||||
@@ -312,10 +319,17 @@ public final class BotaniaAPI {
|
||||
String key = getMagnetKey(stack);
|
||||
return magnetBlacklist.contains(key);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) {
|
||||
return isBlockBlacklistedFromMagnet(block, meta, 0);
|
||||
}
|
||||
|
||||
public static boolean isBlockBlacklistedFromMagnet(Block block, int meta, int recursion) {
|
||||
if(recursion >= 5)
|
||||
return false;
|
||||
|
||||
if(meta != Short.MAX_VALUE) {
|
||||
boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE);
|
||||
boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE, recursion + 1);
|
||||
if(general)
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user