Electroblob's Wizardry

Electroblob's Wizardry

18M Downloads

Element?

MagicMaxcer opened this issue ยท 3 comments

commented

Please read the guide for contributing before posting.

Minecraft version: 1.12.2 [change as necessary]
Wizardry version: 4.2.10 [change as necessary]
Environment: Singleplayer/ [delete as necessary]

Issue details: I used flans mod explosive ammo and fired my minigun at a fire rune stone shrine that spawns blazes and it crashed

Other mods involved: Flans [only list mods that are relevant to the problem]

Link to crash report (if applicable): [give a link to the crash report on gist, pastebin, etc.]
https://paste.dimdev.org/bukiladumi.bash

commented

I'm surprised nothing's triggered this bug before... The error is here:
return this.getDefaultState().withProperty(ELEMENT, Element.values()[metadata]);
I think this is the only place where there isn't a proper conversion between the external Element enum and the internal ELEMENT property, which are offset by one because of dropping MAGIC...

So it should be:
return this.getDefaultState().withProperty(ELEMENT, Element.values()[metadata+1]);
I don't have a current dev environment to test, but couldn't you just use:
return this.getDefaultState().withProperty(ELEMENT, ELEMENT.values()[metadata]);?

commented

what?

commented

@MagicMaxcer I think Tora-B's comment was intended for me! Thanks for reporting this issue.

@Tora-B That's not the error. The property is not offset by one, MAGIC is simply excluded from the allowedValues list (I decided to keep the index consistent specifically to avoid this kind of confusion). I could indeed use ELEMENT.values()[metadata-1] instead of Element.values()[metadata], it would make no difference.

What's actually happened here is somehow, Flan's mod has managed to place runestone with metadata 0, which of course is not a valid state so it crashes the game. I can recreate this without Flan's mod by doing /give [player] ebwizardry:runestone 1 0, which results in a pink-and-black box item, and then trying to place it.

Admittedly, having meta 0 as an invalid state is probably not ideal so I guess I should add a failsafe that just converts it to meta 1 (fire).