Posted November 12, 20231 yr 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
November 12, 20231 yr Author @Override public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity playerEntity, Hand hand, BlockRayTraceResult result) { state = state.cycle(LOCKED); world.setBlock(pos, state, 10); return ActionResultType.sidedSuccess(world.isClientSide); } i change code to this and its work
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.