|
1 | 1 | package crystallized.modid.item.custom; |
2 | 2 |
|
3 | 3 | import crystallized.modid.block.ModBlocks; |
| 4 | +import crystallized.modid.item.ModItems; |
4 | 5 | import net.minecraft.block.Block; |
5 | 6 | import net.minecraft.block.Blocks; |
6 | 7 | import net.minecraft.entity.EquipmentSlot; |
@@ -30,21 +31,27 @@ public ActionResult useOnBlock(ItemUsageContext context) { |
30 | 31 | World world = context.getWorld(); |
31 | 32 | Block clickBlock = world.getBlockState(context.getBlockPos()).getBlock(); |
32 | 33 |
|
33 | | - if(EXALTER_MAP.containsKey(clickBlock)) { |
34 | | - if(!world.isClient()) { |
35 | | - world.setBlockState(context.getBlockPos(), EXALTER_MAP.get(clickBlock).getDefaultState()); |
36 | | - |
37 | | - |
| 34 | + if (clickBlock == Blocks.NETHERITE_BLOCK) { |
| 35 | + if (!world.isClient()) { |
| 36 | + world.breakBlock(context.getBlockPos(), false); |
| 37 | + |
| 38 | + Item itemToDrop = ModItems.ENDO_INGOT; |
| 39 | + world.spawnEntity(new net.minecraft.entity.ItemEntity( |
| 40 | + world, |
| 41 | + context.getBlockPos().getX() + 0.5, |
| 42 | + context.getBlockPos().getY() + 0.5, |
| 43 | + context.getBlockPos().getZ() + 0.5, |
| 44 | + new net.minecraft.item.ItemStack(itemToDrop) |
| 45 | + )); |
38 | 46 | context.getStack().damage(1, ((ServerWorld) world), ((ServerPlayerEntity) context.getPlayer()), |
39 | 47 | item -> { |
40 | 48 | assert context.getPlayer() != null; |
41 | 49 | context.getPlayer().sendEquipmentBreakStatus(item, EquipmentSlot.MAINHAND); |
42 | 50 | }); |
43 | | - |
44 | | - world.playSound(null, context.getBlockPos(), SoundEvents.BLOCK_BELL_USE, SoundCategory.BLOCKS); |
| 51 | + world.playSound(null, context.getBlockPos(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS); |
45 | 52 | } |
| 53 | + return ActionResult.SUCCESS; |
46 | 54 | } |
47 | | - |
48 | | - return ActionResult.SUCCESS; |
| 55 | + return ActionResult.PASS; |
49 | 56 | } |
50 | 57 | } |
0 commit comments