1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Lightened some heavy calls in (dis)enchantable checks

This commit is contained in:
Poslovitch 2017-06-19 18:49:38 +02:00
parent 8910839e31
commit 18779b114b
2 changed files with 12 additions and 2 deletions

View File

@ -95,7 +95,12 @@ public class AutoDisenchanter extends AContainer {
for (int slot: getInputSlots()) {
ItemStack target = BlockStorage.getInventory(b).getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
ItemStack item = BlockStorage.getInventory(b).getItemInSlot(slot);
if(SlimefunItem.getByItem(item) != null && !SlimefunItem.getByItem(item).isDisenchantable()) return;
// Check if disenchantable
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !sfItem.isDisenchantable()) return;
// Disenchant
if (item != null && target != null && target.getType() == Material.BOOK) {
int amount = 0;

View File

@ -93,8 +93,13 @@ public class AutoEnchanter extends AContainer {
slots:
for (int slot: getInputSlots()) {
ItemStack target = BlockStorage.getInventory(b).getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
if(SlimefunItem.getByItem(target) != null && !SlimefunItem.getByItem(target).isEnchantable()) return;
// Check if enchantable
SlimefunItem sfTarget = SlimefunItem.getByItem(target);
if(sfTarget != null && !sfTarget.isEnchantable()) return;
ItemStack item = BlockStorage.getInventory(b).getItemInSlot(slot);
// Enchant
if (item != null && item.getType() == Material.ENCHANTED_BOOK && target != null) {
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>();
Set<ItemEnchantment> enchantments2 = new HashSet<ItemEnchantment>();