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
Next revision
Previous revision
tutorial:blockstate [2019/11/14 11:53]
fudge
tutorial:blockstate [2020/03/19 10:19] (current)
juuz don't hardcode a single Block instance in onUse
Line 19: Line 19:
     [...]     [...]
     @Override     @Override
-    protected void appendProperties(StateFactory.Builder<​Block,​ BlockState> ​stateFactory) { +    protected void appendProperties(StateManager.Builder<​Block,​ BlockState> ​stateManager) { 
-        ​stateFactory.add(HARDENED);​+        ​stateManager.add(HARDENED);​
     }     }
     ​     ​
Line 31: Line 31:
     public MyBlock(Settings settings) {     public MyBlock(Settings settings) {
         super(settings);​         super(settings);​
-        setDefaultState(getStateFactory().getDefaultState().with(HARDENED,​ false));+        setDefaultState(getStateManager().getDefaultState().with(HARDENED,​ false));
     }     }
     ​     ​
Line 45: Line 45:
     [...]     [...]
     @Override     @Override
-    public ​boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult ​blockHitResult) { +    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 ​true;+        return ​ActionResult.SUCCESS;
     }     }
 } }
tutorial/blockstate.1573732406.txt.gz · Last modified: 2019/11/14 11:53 by fudge