remove some now unnecessary code from the laser be
@@ -56,27 +56,10 @@ public class LaserBlockBlockEntity extends LinkableBlockEntity {
disabled.copy(option);
toggleLaser((BooleanOption) option);
}
- else if (action instanceof ILinkedAction.ModuleInserted moduleInserted) {
- ItemStack module = moduleInserted.stack();
- boolean toggled = moduleInserted.wasModuleToggled();
-
- insertModule(module, toggled);
-
- if (moduleInserted.module().getModuleType() == ModuleType.DISGUISE)
- onInsertDisguiseModule(module, toggled);
- }
- else if (action instanceof ILinkedAction.ModuleRemoved moduleRemoved) {
- ModuleType module = moduleRemoved.moduleType();
- ItemStack moduleStack = getModule(module);
- boolean toggled = moduleRemoved.wasModuleToggled();
-
- removeModule(module, toggled);
-
- if (module == ModuleType.DISGUISE)
- onRemoveDisguiseModule(moduleStack, toggled);
- else if (module == ModuleType.REDSTONE)
- onRemoveRedstoneModule();
- }
+ else if (action instanceof ILinkedAction.ModuleInserted moduleInserted)
+ insertModule(moduleInserted.stack(), moduleInserted.wasModuleToggled());
+ else if (action instanceof ILinkedAction.ModuleRemoved moduleRemoved)
+ removeModule(moduleRemoved.moduleType(), moduleRemoved.wasModuleToggled());
else if (action instanceof ILinkedAction.OwnerChanged ownerChanged) {
Owner owner = ownerChanged.newOwner();
@@ -91,21 +74,7 @@ public class LaserBlockBlockEntity extends LinkableBlockEntity {
public void onModuleInserted(ItemStack stack, ModuleType module, boolean toggled) {
super.onModuleInserted(stack, module, toggled);
- if (module == ModuleType.DISGUISE)
- onInsertDisguiseModule(stack, toggled);
- }
-
- @Override
- public void onModuleRemoved(ItemStack stack, ModuleType module, boolean toggled) {
- super.onModuleRemoved(stack, module, toggled);
-
- if (module == ModuleType.DISGUISE)
- onRemoveDisguiseModule(stack, toggled);
- else if (module == ModuleType.REDSTONE)
- onRemoveRedstoneModule();
- }
-
- private void onInsertDisguiseModule(ItemStack stack, boolean toggled) {
+ if (module == ModuleType.DISGUISE) {
BlockState state = getBlockState();
if (!level.isClientSide) {
@@ -123,8 +92,13 @@ public class LaserBlockBlockEntity extends LinkableBlockEntity {
level.getChunkSource().getLightEngine().checkBlock(worldPosition);
}
}
+ }
+
+ @Override
+ public void onModuleRemoved(ItemStack stack, ModuleType module, boolean toggled) {
+ super.onModuleRemoved(stack, module, toggled);
- private void onRemoveDisguiseModule(ItemStack stack, boolean toggled) {
+ if (module == ModuleType.DISGUISE) {
if (!level.isClientSide) {
BlockState state = getBlockState();
@@ -143,13 +117,13 @@ public class LaserBlockBlockEntity extends LinkableBlockEntity {
});
}
}
-
- private void onRemoveRedstoneModule() {
+ else if (module == ModuleType.REDSTONE) {
if (getBlockState().getValue(LaserBlock.POWERED)) {
level.setBlockAndUpdate(worldPosition, getBlockState().setValue(LaserBlock.POWERED, false));
BlockUtils.updateIndirectNeighbors(level, worldPosition, SCContent.LASER_BLOCK.get());
}
}
+ }
@Override
public void handleUpdateTag(CompoundTag tag) {
