Hello modders. I can't seem to update a boolean property on the server. I confirmed that I can update another property (enum type) for the same block. I also confirmed that I can update the block state object with the correct property before attempting to update the server. After I run setBlockState on the world object, the boolean property does not change, but the enum property does change. Can someone please tell me what I'm missing in the code below?
// enum property
public static final EnumProperty<RailShape> POWERSHAPE = EnumProperty.<RailShape>create("shape", RailShape.class, new Predicate<RailShape>()
{
public boolean apply(RailShape p_apply_1_)
{
return p_apply_1_ != RailShape.NORTH_EAST && p_apply_1_ != RailShape.NORTH_WEST && p_apply_1_ != RailShape.SOUTH_EAST && p_apply_1_ != RailShape.SOUTH_WEST;
}
});
// boolean property
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
@Override
public ActionResultType onItemUse(ItemUseContext context)
{
// get context
World worldIn = context.getWorld();
BlockPos pos = context.getPos();
PlayerEntity player = context.getPlayer();
if(!worldIn.isRemote) {
if (worldIn.getBlockState(pos).getBlock().getRegistryName().toString().equals("minecraft:powered_rail")){
BlockState blockState = worldIn.getBlockState(pos);
TestMod.LOGGER.debug("** Properties:");
TestMod.LOGGER.debug(" old POWERED: " + blockState.get(POWERED));
TestMod.LOGGER.debug(" old POWERSHAPE: " + blockState.get(POWERSHAPE));
blockState = blockState.with(POWERED, true).with(POWERSHAPE, RailShape.NORTH_SOUTH);
worldIn.getWorld().setBlockState(pos, blockState);
worldIn.notifyBlockUpdate(pos, blockState, blockState, 3);
// check for the update
blockState = worldIn.getWorld().getBlockState(pos);
// Enum property is updated (POWERSHAPE), but bolean property (POWERED) was not
TestMod.LOGGER.debug(" new block state POWERED: " + blockState.get(POWERED));
TestMod.LOGGER.debug(" new block state POWERSHAPE: " + blockState.get(POWERSHAPE));
}
return ActionResultType.PASS;
}