Skip to content

Calling setFilter with nil causes an error #839

Description

@rassvet-ii

Describe

Calling setFilter with nil to clear the filter does clear the filter, but it causes an error.
Considering this line, I think this is the intended way to clear the filter, but since filterTable becomes null here, this call to optInt throws a NPE.

Steps to reproduce

  1. Place and connect any create block that has a filter slot
  2. Run this code
peripheral.find('filtering_behaviour').setFilter(nil)
  1. Error occured
lua[1]:1 Java Exception Thrown
java.lang.NullPointerException: Cannot invoke "dan200.computercraft.api.lua.LuaTable.optInt(String)" because "filterTable" is null
Stacktrace from log
[18:02:22] [Server thread/ERROR] [da.co.co.co.LuaContext/COMPUTER_ERROR.JAVA]: Error running task
java.lang.NullPointerException: Cannot invoke "dan200.computercraft.api.lua.LuaTable.optInt(String)" because "filterTable" is null
	at TRANSFORMER/advancedperipherals@1.21.1-0.8.1a/de.srendi.advancedperipherals.common.addons.create.FilteringBehaviourIntegration.setFilter(FilteringBehaviourIntegration.java:50) ~[AdvancedPeripherals-1.21.1-0.8.1a.jar%23517!/:1.21.1-0.8.1a] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$1(PeripheralMethodSupplier.java:28) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$4(PeripheralMethodSupplier.java:35) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.api.lua.TaskCallback.execute(TaskCallback.java:28) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.GuardedLuaContext.lambda$issueMainThreadTask$0(GuardedLuaContext.java:45) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.GuardedLuaContext.lambda$issueMainThreadTask$0(GuardedLuaContext.java:45) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.LuaContext.lambda$issueMainThreadTask$0(LuaContext.java:29) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.mainthread.MainThreadExecutor.execute(MainThreadExecutor.java:138) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.core.computer.mainthread.MainThread.tick(MainThread.java:139) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.computer.core.ServerContext.tick(ServerContext.java:154) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:mixin,re:classloading,pl:mixin:APP:ccsecureboot.mixin.json:ServerContextAccessor from mod ccsecureboot,pl:mixin:A}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.CommonHooks.onServerTickStart(CommonHooks.java:75) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at TRANSFORMER/computercraft@1.120.2/dan200.computercraft.shared.ForgeCommonHooks.onServerTick(ForgeCommonHooks.java:39) ~[cc-tweaked-1.21.1-forge-1.120.2.jar%23545!/:1.120.2] {re:classloading}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:360) ~[bus-8.0.5.jar%23164!/:?] {}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:328) ~[bus-8.0.5.jar%23164!/:?] {}
	at TRANSFORMER/neoforge@21.1.250/net.neoforged.neoforge.event.EventHooks.fireServerTickPre(EventHooks.java:1010) ~[neoforge-21.1.250-universal.jar%23507!/:?] {re:mixin,re:classloading}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:915) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:110) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:connector_pre_launch:A,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:openpartiesandclaims.mixins.json:MixinIntegratedServer from mod openpartiesandclaims,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.thread_priorities.IntegratedServerMixin from mod modernfix,pl:mixin:APP:modernfix-modernfix.mixins.json:perf.suspend_integrated_server_during_load.IntegratedServerMixin from mod modernfix,pl:mixin:APP:blueprint.mixins.json:client.IntegratedServerMixin from mod blueprint,pl:mixin:APP:sable.mixins.json:toast.IntegratedServerMixin from mod sable,pl:mixin:APP:lithostitched.mixins.json:client.IntegratedServerMixin from mod lithostitched,pl:mixin:A,pl:connector_pre_launch:A,pl:runtimedistcleaner:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:707) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at TRANSFORMER/minecraft@1.21.1/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:267) ~[client-1.21.1-20240808.144430-srg.jar%23506!/:?] {re:mixin,pl:accesstransformer:B,pl:connector_pre_launch:A,re:classloading,pl:accesstransformer:B,pl:mixin:A,pl:connector_pre_launch:A}
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?] {re:mixin}

Multiplayer?

No

Version

1.21.1-0.8.1a (Latest 1.21.1)

Minecraft, Forge and maybe other related mods versions

NeoForge 21.1.250 Minecraft 1.21.1

Screenshots or Videos

No response

Crashlog/log

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions