Im trying to change model in code like that
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity playerEntity, Hand hand, BlockRayTraceResult result) {
if (state.getValue(LOCKED)) {
world.setBlock(pos, state.setValue(LOCKED, false), 3);
System.out.println("unlocked");
} else {
world.setBlock(pos, state.setValue(LOCKED, true), 3);
System.out.println("locked");
}
return ActionResultType.PASS;
}
{
"variants": {
"locked=true": {
"model": "sovietmod:block/vinyl_record_player"
},
"locked=false": {
"model": "sovietmod:block/vinyl_record_player2"
}
}
}
But when i click. Block twice change its model.
[17:47:12] [Server thread/INFO] [STDOUT/]: [com.Soviet.sovietmod.block.custom.VinylRecordPlayer:use:60]: locked
[17:47:12] [Server thread/INFO] [STDOUT/]: [com.Soviet.sovietmod.block.custom.VinylRecordPlayer:use:57]: unlocked