javaminecraft-forge

What do you use instead of onBlockActivated for Minecraft Forge 1.16.5?


I'm trying to make a block that sends me to a new dimension, but when I try right clicking it, nothing happens.

I've put a few debug messages to send a message to the chat or to show up in the logs when right clicked. Right now I am using:

public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) // Client-side: Only show a status message
    if (worldIn.isRemote()) {
        player.sendStatusMessage(new StringTextComponent("Client: Block activated!"), true);
        return ActionResultType.SUCCESS;
    }

    // Server-side logic below
    player.sendMessage(new StringTextComponent("blockActivated"), player.getUniqueID());
}

I am getting a warning "Overrides deprecated method in 'net.minecraft.block.AbstractBlock'" is deprecated, but I'm not sure what to use instead.


Solution

  • The problem was I wasn't calling the class in the registration.