forked from PleahMaCaka/forge-kotlin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSadObsidianMaker.kt
47 lines (42 loc) · 1.44 KB
/
SadObsidianMaker.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.pleahmacaka.examplemod.items
import net.minecraft.core.particles.ParticleTypes
import net.minecraft.server.level.ServerLevel
import net.minecraft.sounds.SoundSource
import net.minecraft.world.InteractionResult
import net.minecraft.world.item.Item
import net.minecraft.world.item.context.UseOnContext
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.SoundType
object SadObsidianMaker : Item(
Properties()
.stacksTo(1)
) {
override fun useOn(context: UseOnContext): InteractionResult {
if (context.level.isClientSide) return InteractionResult.PASS
val level = context.level as ServerLevel
val blockPos = context.clickedPos
if (level.getBlockState(blockPos).block == Blocks.OBSIDIAN) {
level.setBlock(blockPos, Blocks.CRYING_OBSIDIAN.defaultBlockState(), 1)
level.playSound(
null,
blockPos,
SoundType.AMETHYST.placeSound,
SoundSource.BLOCKS,
1.0f,
1.0f
)
level.sendParticles(
ParticleTypes.LANDING_OBSIDIAN_TEAR,
blockPos.x.toDouble() + 0.5,
blockPos.y.toDouble() + 1,
blockPos.z.toDouble() + 0.5,
30,
0.2,
0.3,
0.2,
0.5
)
}
return InteractionResult.SUCCESS
}
}