The Camping Mod

The Camping Mod

2M Downloads

StructureHemp blockstate mishandling

pau101 opened this issue ยท 0 comments

commented

Hello,

Currently StructureHemp does not ensure successful placement of its hemp block before trying to modify its properties. This causes IllegalArgumentExceptions when placement does not succeed as seen in the crash from this issue we recieved BobMowzie/MowziesMobs#155

The erroring code seen here:

if (CampingMod.OBJ.hemp.canStay(world, posNew)) {
world.setBlockState(posNew, CampingMod.OBJ.hemp.getDefaultState)
CampingMod.OBJ.hemp.setState(world, posNew, Definitions.Hemp.STATE_AGE, age)
}
}

The preferred solution is to directly set the desired blockstate using withProperty, however alternatively it is possible to guard the setState like so:

if (world.setBlockState(posNew, CampingMod.OBJ.hemp.getDefaultState)) {
    CampingMod.OBJ.hemp.setState(world, posNew, Definitions.Hemp.STATE_AGE, age) 
}

Thank you for your time