Areas (Forge)

Areas (Forge)

890k Downloads

Sided violation in right-click event handler for Sleep Sooner

noobanidus opened this issue ยท 3 comments

commented

Information

Minecraft version: 1.14.4
Forge version: 28.2.3
Environment: Multiplayer

Mod name: Sleep Sooner
Mod version: 1.0

Description

Block.getNameTextComponent is a purely client-side only thing.

If you want to check if the block is a bed, I'd recommend using block instanceof BlockBed instead of relying on translation keys. For one, the information isn't available on the server, and secondly comparing against the translation component is liable to fail in other languages.

I don't even need to decompile or look at your code to guess what you're doing simply based on looking up the function in MCP and, honestly, I feel like you're making more work for yourself just not straight-up checking instanceof.

If you want to be even faster you could place all beds in a static, pre-initialized set and then check for block membership of that set -- but that would fail with modded beds.

Crash report

https://gist.github.com/noobanidus/53386e0eb82798db045b7878d702fbe3

commented

And apologies if I sounded harsh, I meant to be a little more diplomatic and understanding but this was written quite late one night after I'd been struggling with a slow internet connection and only FTP access to a server to delete an old instance and install a new one. Apologies!

commented

Ah, thanks for letting me know. I'll fix it soon. Sleep Sooner was one of my first mod (I think number 5?) and I've learned some new tricks since then. Appreciate the detailed description, the instanceof is definitely a lot better than what the check is currently using.

commented

No problem! Sorry for the inconvenience caused. I've fixed it in version 1.1 of the mod!

https://www.curseforge.com/minecraft/mc-mods/sleep-sooner