fix toggling modules not working for doors
@@ -52,7 +52,7 @@ public abstract class SpecialDoorBlockEntity extends LinkableBlockEntity {
super.onModuleDisabled(stack, module);
}
- private void handleModule(ItemStack stack, ModuleType module, boolean removed) {
+ private void handleModule(ItemStack stack, ModuleType module, boolean disabled) {
DoubleBlockHalf myHalf = getBlockState().getValue(DoorBlock.HALF);
BlockPos otherPos;
@@ -65,13 +65,21 @@ public abstract class SpecialDoorBlockEntity extends LinkableBlockEntity {
if (other.getValue(DoorBlock.HALF) != myHalf) {
if (level.getBlockEntity(otherPos) instanceof SpecialDoorBlockEntity otherDoorBe) {
- if (!removed && !otherDoorBe.isModuleEnabled(module))
+ if (!disabled) {
+ if (otherDoorBe.hasModule(module))
+ otherDoorBe.enableModule(module);
+ else
otherDoorBe.insertModule(stack);
- else if (removed && otherDoorBe.isModuleEnabled(module))
+ }
+ else if (disabled) {
+ if (hasModule(module))
+ otherDoorBe.disableModule(module);
+ else
otherDoorBe.removeModule(module);
}
}
}
+ }
@Override
protected void onLinkedBlockAction(LinkedAction action, Object[] parameters, ArrayList<LinkableBlockEntity> excludedBEs) {
