CammiePone / Hookshot

Hookshot is a small mod that adds a grappling hook-like tool for the player to use to get around.
Other
14 stars 6 forks source link

Make the server report an error #13

Closed DSRoie closed 3 years ago

DSRoie commented 3 years ago

I have no problem using it locally, or on the server before, but I don’t know when it will start. Once the hook is used, everyone will be disconnected.I installed a lot of mods during the period, I don’t know what might conflict with it... QQ图片20210623000619 I don't know if this is the correct error report, it is just accidental. More often, it just dropped everyone and can reconnect back quickly. The server did not crash, and there was no feedback or error message. The following is my mod list adventurez: AdventureZ 1.2.2 amecsapi: Amecs API 1.1.4+mc1.16.5 angerable-patch: Angerable Patch 1.1.0-1.16.4 artifacts: Artifacts 3.2.1+fabric artifice: Artifice 0.14.6+1.16.5 attributefix: Attribute Fix {FABRIC} 1.0.1 autoconfig1u: Auto Config v1 Updated 3.3.1 autofish: Autofish 0.9.2 backslot: BackSlot 1.1.11 battletowers: Battle Towers 3.3.4-1.16.4 bendy-lib: Bendy api 1.1.0 bettercaves: YUNG's Better Caves 1.16.5-1.2 betterdroppeditems: Better Dropped Items 1.2.4-1.16.2 betterend: Better End 0.9.6-pre betterf3: BetterF3 1.1.3 bettermineshafts: YUNG's Better Mineshafts 1.16.4-1.0.1 betternether: Better Nether 5.0.7 bettersleeping: Better Sleeping 0.4.0 betterstrongholds: YUNG's Better Strongholds 1.16.5-1.0 betterthirdperson: Better Third Person 1.4.0 black-powder: Black Powder 1.0.2 blue_endless_jankson: jankson 1.2.0 byg: BYG 1.1.8 cardinal-components: Cardinal Components API 2.8.3 cardinal-components-base: Cardinal Components API (base) 2.8.3 cardinal-components-block: Cardinal Components API (blocks) 2.8.3 cardinal-components-chunk: Cardinal Components API (chunks) 2.8.3 cardinal-components-entity: Cardinal Components API (entities) 2.8.3 cardinal-components-item: Cardinal Components API (items) 2.8.3 cardinal-components-level: Cardinal Components API (world saves) 2.8.3 cardinal-components-scoreboard: Cardinal Components API (scoreboard) 2.8.3 cardinal-components-util: Cardinal Components API (utilities) 2.8.3 cardinal-components-world: Cardinal Components API (worlds) 2.8.3 cavebiomes: Cave Biomes 0.6.2 chainmail: Chainmail 0.5.0 chorus_links: Chorus Links 1.2.2 cloth-basic-math: Cloth Basic Math 0.5.1 cloth-client-events-v0: Cloth Client Events v0 1.5.47 cloth-config2: Cloth Config v4 4.11.26 cloth-dynamic-registry-api-v1: Cloth Dynamic Registry API v1 1.2.1 colwater: ColWater 1.4.1 cosmetic-armor: Cosmetic Armor 1.0.0 couplings: Couplings 1.3.3 cpas: conveniently placed armor slots 1.3.0+1.16.5 crowdin-translate: CrowdinTranslate 1.2 curios: Curios API 0.0.13-1.16.5 dashloader: DashLoader 1.4.5 deadlydaggers: DeadlyDaggers 1.0-1.16.5 disable_custom_worlds_advice: Disable Custom Worlds Advice 1.2 dragonloot: DragonLoot 1.0.6 dualwielding: Dual Wielding 1.0.2 dynamicsoundfilters: Dynamic Sound Filters 1.2.0+1.16.5 eldritch_mobs: Eldritch Mobs 1.6.9 emotecraft: Emotecraft 2.0.4 enchant_giver: Enchant Giver 1.0.3 enhancement: Enhancement (Fabric) 0.7.0 expanded_weapon_enchanting: Expanded Weapon Enchanting 1.0.0 expandedstorage: ExpandedStorage 5.6.33 expcontainer: Experience Container [XP] 1.15 extraalchemy: Extra Alchemy 1.4.5 extrasounds: Extra Sounds 1.4.0 fabric: Fabric API 0.34.2+1.16 fabricloader: Fabric Loader 0.11.3 fabricshieldlib: Fabric Shield Lib 1.3.5-1.16.5 fallingtree: FallingTree 2.11.0 flytre_lib: FlytreLib 0.2.10 geckolib3: Geckolib 3.0.36 givemehats: Give Me Hats! 1.5.1 gravestones: Gravestones v1.9 grindenchantments: Grind Enchantments 1.1.3+1.16.3 guardiansgalore: Guardians Galore 1.0-SNAPSHOT hole_filler_mod: Hole Filler Mod 1.2.4 hookshot: Hookshot 13.0 horseinfo: Horse Info 0.2.2-1.16.1 illuminations: Illuminations 1.5.1 inmis: Inmis 2.1.3-1.16.5 inventory_control_tweaks: Inventory Control Tweaks 1.3.4+MC1.16.2-1.16.5 inventoryprofiles: Inventory Profiles 0.4.2 inventorysorter: Inventory Sorter 1.7.9-1.16 io_activej_activej-codegen: activej-codegen 4.2 io_activej_activej-serializer: activej-serializer 4.2 iris: Iris 1.0.0-rc1 jankson: Jankson 3.0.1+j1.2.0 java: Java HotSpot(TM) 64-Bit Server VM 8 kirin: Kirin UI 1.7-1.16.2 kyrptconfig: Kytpt Config 1.1.6-1.16 libgui: LibGui 3.3.2+1.16.4 libstructure: LibStructure 1.5 luckyblocks: Fabricated Lucky Blocks 1.0.0-1.16.5 magic_mirror: Magic Mirror 1.2.1 maybe-data: Maybe data 1.0.0-1.16.2 mcda: MC Dungeons Armors 1.5.0 mcdar: MC Dungeons Artifacts 1.2.0 mcdw: MC Dungeons Weapons 3.2.0 mcsa: MC Story Mode Armor 2.3.2 medievalweapons: Medieval Weapons 1.1.3 mimics: Mimics 0.1.4 minecraft: Minecraft 1.16.5 mobz: MobZ 2.4.6 modmenu: Mod Menu 1.16.9 multi_item_lib: Multi Item Lib 1.3.0 nbtcrafting: NBT Crafting 2.0.14+mc1.16.4 net_gudenau_lib_unsafe: unsafe 1.4.1 obsdncontainer: Obsidian Container [Experience Container Addon] 1.0.1 omega-config: OmegaConfig 1.0.2 org_aeonbits_owner_owner: owner 1.0.12 org_jetbrains_kotlin_kotlin-reflect: kotlin-reflect 1.5.10 org_jetbrains_kotlin_kotlin-stdlib: kotlin-stdlib 1.5.10 org_jetbrains_kotlin_kotlin-stdlib-jdk7: kotlin-stdlib-jdk7 1.5.10 org_jetbrains_kotlin_kotlin-stdlib-jdk8: kotlin-stdlib-jdk8 1.5.10 org_jetbrains_kotlinx_kotlinx-coroutines-core-jvm: kotlinx-coroutines-core-jvm 1.5.0 org_jetbrains_kotlinx_kotlinx-coroutines-jdk8: kotlinx-coroutines-jdk8 1.5.0 org_jetbrains_kotlinx_kotlinx-serialization-core-jvm: kotlinx-serialization-core-jvm 1.2.1 org_jetbrains_kotlinx_kotlinx-serialization-json-jvm: kotlinx-serialization-json-jvm 1.2.1 org_slf4j_slf4j-api: slf4j-api 1.7.29 phosphor: Phosphor 0.7.2+build.12 polymorph: Polymorph 0.0.10-1.16.5 presencefootsteps: Presence Footsteps r29+1.16.4 rangers_haven: Ranger's Haven 2.2.1 rare-ice: Rare Ice 0.2.2 reach-entity-attributes: Reach Entity Attributes 1.1.0 repurposed_structures: Repurposed Structures 1.16.5-1.10.5-fabric respawnablepets: Respawnable Pets 1.16.5-2 roughlyenoughitems: Roughly Enough Items 5.11.218 roughlyenoughitems-api: REI (API) 5.11.218 roughlyenoughitems-default-plugin: REI (Default Plugin) 5.11.218 roughlyenoughitems-runtime: REI (Runtime) 5.11.218 rpgz: RPGZ 0.4.7 seasons: Fabric Seasons 1.2-BETA servertick: Server Tick 1.4 sit: Sit 1.16.5-11 sodium: Sodium 0.2.0+IRIS_rev.400af47 spellbound: Spellbound 1.3.0 static-content: Static Content 1.0.2-1.16.2 staticdata: Static Data 1.1.2 step-height-entity-attribute: Step Height Entity Attribute 1.0.0 stitchedsnow: Stiched Snow 1.0.1 stoneholm: Stoneholm 1.2.1 structure-helpers: Structure Helpers 3.0.0 tk_valoeghese_zoesteriaconfig: ZoesteriaConfig 1.3.6 torchbowmod: TorchBowMod 1.0-Beta torohealth: ToroHealth Damage Indicators 1.16.4-fabric-4 transparent_cosmetics: Transparent Cosmetics 1.2.0 transportables: Transportables 1.0.1 trinkets: Trinkets 2.6.7 voidz: VoidZ 1.0.0 voyager: Voyager 1.0.0 waila: Hwyla 1.9.22 walljump: Wall-Jump! 1.3.3+1.16.1 waystones: Waystones 1.1.1.1 windchimes: Windchimes 1.1.1 wolveswitharmor: Wolves With Armor 1.5.4-1.16.5 xp_storage: XP Storage 1.4+1.16.5 yalbm: Yet Another Lucky BLock Mod 1.2.2 yungsapi: YUNG's API 1.16.5-Fabric-5

CammiePone commented 3 years ago

Kinda weird. I never changed how the hook is spawned. Ill need to check better when I get back to my computer.

CammiePone commented 3 years ago

so yeah, it's the isPulling variable that's supposed to be saved, which it's never null so idk why it's erroring. My suggestion is try and disable the Z mods (the ones that end in a capital Z) as they're known to cause problems.

Otherwise you may just have to do a binary search (disable half the mods and test, if it doesn't happen disable the half that aren't disabled and enable the half that was disabled, see if it happens, and slowly whittle it down by halving the number of mods that it happens with until you find the mod that causes the issue).

DSRoie commented 3 years ago

so yeah, it's the variable that's supposed to be saved, which it's never null so idk why it's erroring. My suggestion is try and disable the Z mods (the ones that end in a capital Z) as they're known to cause problems.isPulling

Otherwise you may just have to do a binary search (disable half the mods and test, if it doesn't happen disable the half that aren't disabled and enable the half that was disabled, see if it happens, and slowly whittle it down by halving the number of mods that it happens with until you find the mod that causes the issue).

thanks,I will try

DSRoie commented 3 years ago

so yeah, it's the variable that's supposed to be saved, which it's never null so idk why it's erroring. My suggestion is try and disable the Z mods (the ones that end in a capital Z) as they're known to cause problems.isPulling

Otherwise you may just have to do a binary search (disable half the mods and test, if it doesn't happen disable the half that aren't disabled and enable the half that was disabled, see if it happens, and slowly whittle it down by halving the number of mods that it happens with until you find the mod that causes the issue).

Because my server is not local and the response is very slow, it is difficult for me to use the binary search, but I still did it. A mod named "PresenceFootsteps" can cause this crash. Although it sounds strange, this is just a simple sound effect mod. Maybe it conflicts with the sizzle when the hook is retracting? I'm not sure, but hope that it can help you.

Sollace commented 3 years ago

owner here has potential to be null. So does stack (you do not initialise it to an empty itemstack in the entity constructor). https://github.com/CammiePone/Hookshot/blob/8ff5f1466ebc88ffe932dfd7764da5c30e73819c/src/main/java/dev/cammiescorner/hookshot/common/entity/HookshotEntity.java#L306

The stacktrace is from version 13, so you have to look at the code from that version to know what it's pointing it. 🙂

CammiePone commented 3 years ago

Ah didn't realise I'd managed to add an extra two lines in my current dev environment. Well, it'll be fixed in 1.17 then, since I no longer have a 1.16 version of the mod on hand.

Never had an issue like that before, and didn't make all that many changes to the entity class, so I'm not sure why it's crashing now, or why Presence Footsteps would cause the issue to arise (assuming it is the reason?), given it should be impossible for the user and hand parameters passed into the use() method to be null. https://github.com/CammiePone/Hookshot/blob/8ff5f1466ebc88ffe932dfd7764da5c30e73819c/src/main/java/dev/cammiescorner/hookshot/common/item/HookshotItem.java#L47

Sollace commented 3 years ago

Consider this:

Player A has entity id 123 Player A fires a hookshot that is then saved to NBT

The hookshot stores Player A's id "123" to the NBT (via writeCustomDataToNbt)

Player A then leaves the server, or is disconnected

The hookshot then gets loaded from NBT (readCustomDataFromNbt) That method then checks the world for an entity with id "123" (of which none exist)

if(world.getEntityById(tag.getInt("owner")) instanceof PlayerEntity)

If a player was found, it sets it: (owner != null)

owner = (PlayerEntity) world.getEntityById(tag.getInt("owner"));

Otherwise it doesn't (owner == null)

Because no player was found, the hookshot continues with owner remaining null, and the next time it needs to be written to NBT will cause the above exception.

You are already checking that owner is not null in other places in that class, so I would just annotate it @Nullable and put a check in when writing to NBT as well.

CammiePone commented 3 years ago

That doesn't change the fact of the matter that I never changed how it was read or written, and this has never occurred before on any of the servers I ran with Hookshot installed. Nor does it change the fact that apparently removing Presence Footsteps fixed the issue, and considering Upcraft mentioned that Presence Footsteps is known to cause issues with other mods that this particular issue is caused by Presence Footsteps.

The only reason I am going to fix it on my end is because a fix is feasible and is how it should've been done in the first place. That part is on me for not using good practices. I'm not saying Presence Footsteps needs to maybe take a look at what it may or may not be doing, but it might be an issue with other mods as well that have flown under the radar so far.

Given it doesn't occur with Hookshot on its own, it really does sound like Presence Footsteps might be the actual cause of this bug, even if it can be relatively easily fixed with a simple change on my end that should've existed since the beginning.

Sollace commented 3 years ago

PF isn't a server mod. Also it doesn't affect entity logic.

I set the nextStepDistance and I have my own code running independent of everything to check the surroundings and play sounds, so arguably Presence Footsteps shouldn't even be capable of causing this kind of issue.

CammiePone commented 3 years ago

Trust me on this: things that should(n't) occur on the server/client often will defy expectations. I've seen it happen with Bewitchment and a vanilla class that should've existed server-side, but didn't and caused headaches for a while.

I haven't run any tests myself to see if it is for a fact Presence Footsteps (mainly because I'm on a break from modding), but at least in the case of DSRoie removing it fixed the issue, which tells me that either it's Presence Footsteps, or some weird mixin jank that involves Presence Footsteps and another mod that's being loaded.

Number 1 rule of modded that I've learned: never underestimate Mojank because it will bite you when it makes the least sense to.

Sollace commented 3 years ago

Fair enough. I have been planning to see how I can test this. Probably can't today, because time, but I'll see what I can uncover during the weekend.

My first reaction is to try firing a hookshot and then running /kill to see what happens, in both cases with the mod. If it does end up being PF, then I dunno. I'll offer my apologies and pay for your lunch.

XanaDublaKublaConch commented 3 years ago

I just ran into the same issue. On a brand new server world, if I log in by myself with both mods enabled, /give myself a hookshot, and fire it, I get disconnected as soon as the hookshot hits a hookable block. There is no error on the client or server. When I log back in, I land back where I was standing as if I had been hovering an inch off the floor. If I remove Presence Footsteps, the hookshot works fine.

Sollace commented 3 years ago

Doing my own testing with a 1.17 server and hookshot r17 on its own. I'm seeing the same crash as in op when saving the world:

[18:02:45] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.class_148: Saving entity NBT
        at net.minecraft.class_1297.method_5647(class_1297.java:1687) ~[intermediary-server.jar:?]
        at net.minecraft.class_1297.method_5786(class_1297.java:1605) ~[intermediary-server.jar:?]
        at net.minecraft.class_1297.method_5662(class_1297.java:1613) ~[intermediary-server.jar:?]
        at net.minecraft.class_5565.method_31734(class_5565.java:108) ~[intermediary-server.jar:?]
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) ~[?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) ~[?:?]
        at net.minecraft.class_5565.method_31760(class_5565.java:106) ~[intermediary-server.jar:?]
        at net.minecraft.class_5579.method_31812(class_5579.java:293) ~[intermediary-server.jar:?]
        at net.minecraft.class_5579.method_31846(class_5579.java:374) ~[intermediary-server.jar:?]
        at it.unimi.dsi.fastutil.longs.LongIterable.forEach(LongIterable.java:74) ~[intermediary-server.jar:?]
        at net.minecraft.class_5579.method_31829(class_5579.java:368) ~[intermediary-server.jar:?]
        at net.minecraft.class_3218.method_14176(class_3218.java:711) ~[intermediary-server.jar:?]
        at net.minecraft.server.MinecraftServer.method_3723(MinecraftServer.java:587) ~[intermediary-server.jar:?]
        at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:852) ~[intermediary-server.jar:?]
        at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:692) ~[intermediary-server.jar:?]
        at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:274) ~[intermediary-server.jar:?]
        at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1657.method_5628()" because "this.owner" is null
        at dev.cammiescorner.hookshot.common.entity.HookshotEntity.method_5652(HookshotEntity.java:308) ~[hookshot-r17.jar:?]
        at net.minecraft.class_1297.method_5647(class_1297.java:1669) ~[intermediary-server.jar:?]
        ... 16 more

This is after the server running on my local machine lagged with no players. The hookshot entity was left behind after my player disconnected, but the fact this is happening now and not when the player disconnects seems to indicate that this is unrelated to the issue with Presence Footsteps.

Will post another comment later once I know more about the other problem.

Sollace commented 3 years ago

For reference, these are the only mods I have on the server: image

The above error will basically happen any time a player disconnects whilst using a hookshot. Next time the server tries to save it will fail to save the chunk due to the player not being present.

Sollace commented 3 years ago

The problem is that hookshot on the server is sending an invalid sound event (null when deserialized on the client). I have fixed the initial error that causes the disconnect, however @CammiePone should still look at this and make sure they are registering all of their sound events on both client and server.

[18:31:54] [Render thread/FATAL]: Error executing task on Client
java.lang.NullPointerException: Cannot invoke "net.minecraft.class_3414.method_14833()" because "☃" is null
    at net.minecraft.class_1109.<init>(class_1109.java:46) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_1109.<init>(class_1109.java:42) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_638.method_8486(class_638.java:399) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_638.method_8465(class_638.java:381) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_634.method_11146(class_634.java:1557) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_2767.method_11895(class_2767.java:83) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_2767.method_11054(class_2767.java:10) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_2600.method_11072(class_2600.java:21) ~[intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_1255.method_18859(class_1255.java:151) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_4093.method_18859(class_4093.java:23) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_1255.method_16075(class_1255.java:125) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_1255.method_5383(class_1255.java:110) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_310.method_1523(class_310.java:1077) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.class_310.method_1514(class_310.java:730) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at net.minecraft.client.main.Main.main(Main.java:217) [intermediary-fabric-loader-0.11.3-1.17+build.5.jar:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-loader-0.11.3.jar:?]
    at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146) [fabric-loader-0.11.3.jar:?]
    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.3.jar:?]

It seems to be that "Hookshot Reel" sound effect that does not play when in multiplayer. It works fine in singleplayer, though.

CammiePone commented 3 years ago

Yea so fun fact, I realised the other day that I wasn't registering any of my sound events because I forgot to call the register method (I have it in my dev environment, but I don't think I ever pushed it). Good to know that's what the problem was, and I'll go and upload a fix for that asap.

CammiePone commented 3 years ago

Alright just uploaded the new file, r18, should be approved soon.

Unfortunately that won't be backported for 1.16.