User Tools

Site Tools


tutorial:blockstate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorial:blockstate [2020/03/19 10:10]
juuz 1.15
tutorial:blockstate [2020/03/19 10:19] (current)
juuz don't hardcode a single Block instance in onUse
Line 46: Line 46:
     @Override     @Override
     public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {     public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
-        world.setBlockState(pos, ​MyBlocks.MY_BLOCK_INSTANCE.getDefaultState().with(HARDENED,​ true));+        world.setBlockState(pos, ​state.with(HARDENED,​ true));
         return ActionResult.SUCCESS;​         return ActionResult.SUCCESS;​
     }     }
tutorial/blockstate.txt ยท Last modified: 2020/03/19 10:19 by juuz