add a right click event listener
Some checks failed
构建 / build (push) Failing after 2m10s

This commit is contained in:
David-123 2025-03-17 17:29:05 +08:00
parent 14e11bd458
commit bcdb41d6ac
2 changed files with 10 additions and 0 deletions

View File

@ -5,7 +5,10 @@ import java.util.List;
import net.minecraft.block.AbstractBlock; import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -31,4 +34,10 @@ public class DamageBlock extends Block {
super.appendTooltip(stack, context, tooltip, type); super.appendTooltip(stack, context, tooltip, type);
tooltip.add(Text.translatable("toolTip.learning.damage_block")); tooltip.add(Text.translatable("toolTip.learning.damage_block"));
} }
@Override
protected ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
player.sendMessage(Text.translatable("block.learning.damage_block.on_use"), false);
return ActionResult.SUCCESS;
}
} }

View File

@ -4,6 +4,7 @@
"item.learning.overcooked_toast": "Overcooked Toast", "item.learning.overcooked_toast": "Overcooked Toast",
"block.learning.damage_block": "Damage Block", "block.learning.damage_block": "Damage Block",
"block.learning.damage_block.on_use": "Make 5 damage per hurt.",
"block.learning.transform_block": "Transform Block", "block.learning.transform_block": "Transform Block",
"itemGroup.learning.custom_itemgroup": "My Dear...", "itemGroup.learning.custom_itemgroup": "My Dear...",