KubeJS

KubeJS

69M Downloads

Item modification got fired each time when server in SinglePlayer starts up

Prunoideae opened this issue ยท 0 comments

commented

Minecraft Version

1.18.2

KubeJS Version

1802.5.4-build.492

Rhino Version

1802.1.13-build.175

Architectury Version

4.4.68

Forge/Fabric Version

Forge 40.1.19

Describe your issue

Each time a player enters the world in SinglePlayer, the ItemModificationEvent fires since a dedicated server is created, thus triggering the startup script. Or at least triggers all the registered modifications.

Consider a script to modify diamond pickaxe's dig speed to 50%:

onEvent("item.modification", event => {
	//Modify
	event.modify("diamond_pickaxe", modification => {
		console.info(`modifying ${modification.item}`)
		modification.digSpeed *= 0.5
	})
}

Will make the pickaxe 50% slower each time player exits and re-enters the save.

[23:23:37] [INFO ] Hello, World! (You will only see this line once in console, during startup)
[23:23:37] [INFO ] Loaded script startup_scripts:script.js in 0.197 s
[23:23:37] [INFO ] Loaded 1/1 KubeJS startup scripts in 0.805 s
[23:23:59] [INFO ] modifying diamond_pickaxe
[23:24:08] [INFO ] modifying diamond_pickaxe
[23:24:35] [INFO ] modifying diamond_pickaxe

Crash report/logs

No response