Fixed issues with modules vanishing and their toggle state not updating
Fixed module toggle states getting overridden when opening customize screen
Fixed modules in a connected inventory scanner getting removed when toggled
Fixed module vanishing when trying to take it out of a connected inventory scanner
@@ -169,6 +169,8 @@ public interface IModuleInventory extends IItemHandlerModifiable {
return ItemStack.EMPTY;
else {
if (!simulate) {
+ getInventory().set(slot, ItemStack.EMPTY);
+
if (stack.getItem() instanceof ModuleItem module) {
onModuleRemoved(stack, module.getModuleType(), false);
@@ -176,7 +178,7 @@ public interface IModuleInventory extends IItemHandlerModifiable {
be.createLinkedBlockAction(new ILinkedAction.ModuleRemoved(((ModuleItem) stack.getItem()).getModuleType(), false), be);
}
- return getInventory().set(slot, ItemStack.EMPTY).copy();
+ return stack;
}
else
return stack.copy();
@@ -227,6 +229,10 @@ public interface IModuleInventory extends IItemHandlerModifiable {
ItemStack previous = getModuleInSlot(slot);
+ //Prevent module from being removed and re-added when the slot initializes
+ if (previous.equals(stack, false))
+ return;
+
//call the correct methods, should there have been a module in the slot previously
if (!previous.isEmpty()) {
onModuleRemoved(previous, ((ModuleItem) previous.getItem()).getModuleType(), false);
@@ -349,7 +355,7 @@ public interface IModuleInventory extends IItemHandlerModifiable {
if (!toggled)
modules.set(i, ItemStack.EMPTY);
- onModuleRemoved(modules.get(i), module, false);
+ onModuleRemoved(modules.get(i), module, toggled);
}
}
}
