Hello!
I'm very new to modding and I'm trying to strip a rotatable custom block. I don't know how to strip it and set a right BlockState, if you know, please help me.
What should I write into setBlockState function?
public ActionResultType onItemUse(ItemUseContext context) {
World world = context.getWorld();
BlockPos blockpos = context.getPos();
BlockState blockstate = world.getBlockState(blockpos);
blockpos.add(0, 0, 1);
if (blockstate.getBlock() == BlockInit.ROTATABLE_CUSTOM_BLOCK.get()) {
PlayerEntity playerentity = context.getPlayer();
world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isRemote) {
world.setBlockState(blockpos, BlockInit.ROTATABLE_CUSTOM_BLOCK_STRIPPED.get().getStateAtViewpoint(blockstate, world, blockpos, context.getHitVec()), 11);
if (playerentity != null) {
context.getItem().damageItem(1, playerentity, (p_220040_1_) -> {
p_220040_1_.sendBreakAnimation(context.getHand());
});
}
}
}
return ActionResultType.PASS;
}