Not able to use method setEnabled() with Diesel Generator in CC: Tweaked (ComputerCraft)
pespinho opened this issue ยท 2 comments
Minecraft Version
1.18
Immersive Engineering Version
8.1.0-150
Expected Behavior
The expected behavior would be to be able enable or disable the Diesel Generator through a lua script in ComputerCraft after wrapping it as a peripheral:
lua> g = peripheral.wrap("diesel_generator_0")
lua> g.setEnabled(true) -- Enables generator.
lua> g.setEnabled(false) -- Disables generator.
lua>
Actual Behavior
When using the method, an exception is thrown instead:
lua> g = peripheral.wrap("diesel_generator_0")
lua> g.setEnabled(true) -- Enables generator.
lua> g.setEnabled(false) -- Disables generator.
lua:1: class blusunrize.immersiveengineering.common.blocks.metal.DieselGeneratorBlockEntity cannot be cast to class blusunrize.immersiveengineering.common.blocks.generic.PoweredMultiblockBlockEntity (blusunrize.immersiveengineering.common.blocks.metal.DieselGeneratorBlockEntity and blusunrize.immersiveengineering.common.blocks.generic.PowerdMultiblockBlockEntity are in module immersiveengineering@1.18.2-8.1.0-150 of loader 'TRANSFORMER' @15c6027d)
lua>
Steps to reproduce
- Connect a Computer from CC: Tweaked to the Redstone interface of a diesel generator using two wired modems networking cable
- Certify that both devices are in the network. Both modems shows red "ring".
- Right click computer to open the interface.
- Open the Lua interactive shell, by typing
lua
and pressing [ENTER]. - Wrap the diesel as a peripheral using the
peripheral.wrap()
method of CC: Tweaked as seen above and use thesetEnabled()
method. - Exception is thrown.
Debug Crash Log
My theory is that the problem could be in:
ImmersiveEngineering/src/main/java/blusunrize/immersiveengineering/common/util/compat/computers/generic/impl/MultiblockCallbacks.java
because setEnabled()
expects the parameter env
to have a type of CallbackEnvironment<PoweredMultiblockBlockEntity<?, ?>>
and the diesel generator isn't a "Powered Multiblock Entity".
I also see that DieselGeneratorBlockEntity
extends MultiblockPartBlockEntity<DieselGeneratorBlockEntity>
and the MultiblockPartBlockEntity<T>
has the field:
public final ComputerControlState computerControl = new ComputerControlState();
This field is used in the setEnabled()
method.
So in theory, this could work if setEnabled()
would expect the env
variable to be of type CallbackEnvironment< MultiblockPartBlockEntity <?>>
instead.