-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Sry for the mouthful of a title, this is a pretty specific issue, also i produced this from inside ForgeGradle 3 and 5 and have been sent here MinecraftForge/ForgeGradle#821 !
gonna put the original issue text below Okay
forgegradle-based test case is at https://github.com/quat1024/bugtest if you wanna try it
Easiest to explain by example, so here's the scene:
public abstract class Superclass extends DirectionalBlock {
public Superclass(Properties props) {
super(props);
registerDefaultState(defaultBlockState()
.setValue(FACING, Direction.UP)
.setValue(POWERED, false));
}
public static final EnumProperty<Direction> FACING = DirectionalBlock.FACING; //shadows a field from superclass (!)
public static final BooleanProperty POWERED = BlockStateProperties.POWERED; //for comparison's sake
@Override
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) {
builder.add(FACING, POWERED);
}
}
//...
public class Subclass extends Superclass {
public Subclass(Properties props) {
super(props);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return defaultBlockState()
.setValue(FACING, ctx.getClickedFace().getOpposite())
.setValue(POWERED, false);
}
}The important parts:
Superclassextends Minecraft'sDirectionalBlock, and both classes have a field namedFACING. Mine shadows theirs.- References to
DirectionalBlock.FACINGshould be remapped toDirectionalBlock.field_176387_N, but references toSuperclass.FACINGshould stay the same. Subclassrefers to that field.
I built a reobf jar using ForgeGradle's standard build task. One of its subtasks remaps the mod to SRG names using SpecialSource, and here's what i found:
Superclasscorrectly contains two fields namedFACINGandPOWERED,Superclass#createBlockStateDefinitioncorrectly refers to the fields namedFACINGandPOWERED,Subclass#getStateForPlacementincorrectly refers to fields namedfield_176387_NandPOWEREDinstead.
This fails at runtime with a NoSuchFieldError, see quat1024/incorporeal-2-forge#11.
👀 Only accesses from subclasses are incorrectly remapped. Referring to the public static field Superclass.FACING from an unrelated class uses the correct name of FACING