The method onUse(World, PlayerEntity, BlockHitResult) of type ExampleBlock must override or implement a supertype method #3849
-
DescriptionTrying to follow the Fabric Mod wiki to make a basic mod and ran into an issue when copying in code. Under the Creating a Custom Block Class section, it provides a snippet of code that supposedly makes the block say "Hello, world!" when it's right clicked. Copying that code into my ExampleBlock.java file raises a bug. My code, copied from the wiki (with package imports): package dev.rackodo.minesillies;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.world.World;
public class ExampleBlock extends Block {
public ExampleBlock(Settings settings) {
super(settings);
}
@Override
public ActionResult onUse(World world, PlayerEntity player, BlockHitResult hit) {
if (!world.isClient) {
player.sendMessage(Text.literal("Hello, world!"), false);
}
return ActionResult.SUCCESS;
}
} Error occurs on
This is a 1.20.6 mod generated from the Template Mod Generator. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
UPDATE: Resolved by matching the onUse method with the one found in Changed: |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what's up with the tutorial. It's pretty normal for the tutorials to be outdated though, particularly with Mojang's current rapid release pace. This seems to be a mistake though, which should be fixed. |
Beta Was this translation helpful? Give feedback.
UPDATE:
Resolved by matching the onUse method with the one found in
AbstractBlock.class
.Changed:
onUse(World world, PlayerEntity player, BlockHitResult hit)
to:
onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit)