TIS-3D

TIS-3D

981k Downloads

CapabilityRedstoneEmitter.getCapability<T> returning wrong value

vddCore opened this issue ยท 2 comments

commented

This bug causes SimpleLogic Wires to crash, so I suppose the bug is two-fold, since Charset lib doesn't check if it's importing a correct capability. Here's the stack trace.

[18:11:42] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
java.lang.ClassCastException: li.cil.tis3d.common.integration.charset.CapabilityRedstoneEmitter$Provider cannot be cast to pl.asie.charset.api.wires.IRedstoneEmitter
        at pl.asie.simplelogic.wires.LogicWireUtils.getWeakRedstoneLevel(LogicWireUtils.java:121) ~[LogicWireUtils.class:?]
        at pl.asie.simplelogic.wires.logic.PartWireNormal.propagate(PartWireNormal.java:178) ~[PartWireNormal.class:?]
        at pl.asie.simplelogic.wires.logic.PropagationQueue.propagate(PropagationQueue.java:45) ~[PropagationQueue.class:?]
        at pl.asie.simplelogic.wires.logic.PartWireInsulated.onSignalChanged(PartWireInsulated.java:61) ~[PartWireInsulated.class:?]
        at pl.asie.simplelogic.wires.logic.PartWireSignalBase.scheduleLogicUpdate(PartWireSignalBase.java:83) ~[PartWireSignalBase.class:?]
        at pl.asie.simplelogic.wires.logic.PartWireSignalBase.updateConnections(PartWireSignalBase.java:206) ~[PartWireSignalBase.class:?]
        at pl.asie.charset.lib.scheduler.ScheduledEvent.run(ScheduledEvent.java:37) ~[ScheduledEvent.class:?]
        at pl.asie.charset.lib.scheduler.Scheduler.onWorldTick(Scheduler.java:72) ~[Scheduler.class:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_281_Scheduler_onWorldTick_WorldTickEvent.invoke(.dynamic) ~[?:?]
        at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
        at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) ~[EventBus.class:?]
        at net.minecraftforge.fml.common.FMLCommonHandler.onPostWorldTick(FMLCommonHandler.java:273) ~[FMLCommonHandler.class:?]
        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:776) ~[MinecraftServer.class:?]
        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396) ~[nz.class:?]
        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) ~[MinecraftServer.class:?]
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
commented

Thanks again for finding this and providing the fix!

commented

I'm not supposed to be checking if I'm getting the correct capability object. That responsibility falls on the getCapability provider, and the usage of generics is done in such a way as to promote correct usage (capability.cast(...) exists for this reason).