Geolosys

Geolosys

5M Downloads

Crash with custom stone as valid replaceable. Primal

Rosethorns opened this issue ยท 16 comments

commented

Forge: 1.12.2 forge-14.23.2.2613
Geolosys: 1.12.2 1.8.5
Crash report: https://pastebin.com/9Z7E6yT5

Caused by: java.lang.NullPointerException
at nmd.primal.core.common.blocks.stone.StoneBrickType.getStateForPlacement(StoneBrickType.java:182)

Can't get default state for replacement?

commented

Hey Rorax! Hmmm. Can I get a copy of your config for Geolosys?

commented

Hiya Jose :) pastebin of config linked below
https://pastebin.com/9XHFq5D8

commented

Thanks! I'm testing it real quick (about to leave for class), but I'll have a solution soon.

One thing I did notice (which didn't resolve the crash for me, unfortunately) was that you've added primal:purite_stone:0 when it's actually called purpurite_stone.

commented

Oh so I did! thanks xD and thanks for taking a look into it :)

commented

Hey @An-Sar, can I get a little bit of help here? Since PrimalCore is closed source (respectably), I can't see what your blocks do to the default state method... almost all blocks have some sort of default state, so I don't know if you're doing something special which is causing my getStateFromMeta to return null..

commented

Hey @An-Sar, can I ask a huge favor?

I don't know of too many other mods that rely on the player to get meta. Meta is passed as a parameter in getStateForPlacement, can you maybe switch your blocks to use that instead of placer.getHeldItem(hand).getItemDamage()? Plus it shortens code big time and removes the dependency for a player when it can technically be null :)

Otherwise I'd have to create a fake player, modify its inventory contents, set the held item to the itemstack, and then pass it to getStateForPlacement

EDIT: Actually, just tried to do the above lengthy solution and forgot that the constructor for a FakePlayer requires a world - and since I run this at game-load (faaaaar before a world is created), I literally cannot create a FakePlayer to solve this issue.

commented

here is some of the state methods from my StoneBrickType class

StoneBrickType#getStateForPlacement, placement infers state from the ItemStack
return this.getDefaultState().withProperty(TYPE, ITypeBrick.EnumType.byMetadata(placer.getHeldItem(hand).getItemDamage()));

StoneBrickType#setDefaultState
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, ITypeBrick.EnumType.NORMAL).withProperty(UP, false).withProperty(DOWN, false).withProperty(IPhased.PHASED, false));

UP/DOWN states get used in getActualState similar to fence connections.

PHASED state is always false in Primal, it's currently only used by my add-on MagnumOpus

commented

Ah, that makes sense! You call placer .getHeldItem when I pass null for all of those... I guess Iโ€™ll have to figure something out.

commented

let me know if i can do anything on my end

commented

Really? Weird, I'll play with it.

Ok, then could you add this to the beginning of your getStateForPlacement:

if (placer == null)
{
    return this.getDefaultState().withProperty(TYPE, TypeBrick.EnumType.byMetadata(meta));
}

Where meta is the meta passed in for getStateForPlacement

That way at the very least if there's no player (such as in pre-init instances) you can still obtain a state somehow.

commented

yeah i was thinking about a null check like that, i kind of want to know why it the method itself isn't returning a useful value, but either way i will put together a dev build to test in the next few days.

commented

see if this build works

commented

The good news is that it works for most things! Still crashing on Salt Ore, but others are fixed! :D

commented

Hey @Rosethorns, it seems to work with the above build if you remove the ore_salt entry :)

Is this stuff for a certain pack I've been seeing on your Twitter? ๐Ÿ˜‰

commented

it's strange the supplied meta value always produces 0

commented

i've added the null check to salt ores