Skip to content

Commit 4d8095e

Browse files
committed
fic ExcavationFocus
1 parent 76f70ff commit 4d8095e

File tree

3 files changed

+44
-40
lines changed

3 files changed

+44
-40
lines changed

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ loader_version=0.16.3
99
fabric_kotlin_version=1.12.1+kotlin.2.0.20
1010

1111
# Mod Properties
12-
mod_version=0.1.3
12+
mod_version=0.1.4
1313
maven_group=dev.sterner
1414
archives_base_name=voidbound
1515

Diff for: src/main/kotlin/dev/sterner/common/item/focus/ExcavationFocus.kt

+42-38
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,39 @@ class ExcavationFocus : IWandFocus {
4444
private var blockState: BlockState? = null
4545

4646
override fun onUsingFocusTick(stack: ItemStack, level: Level, player: Player) {
47-
if (level.isClientSide) {
48-
val client = Minecraft.getInstance()
49-
val maxReach = 10.0
50-
val tickDelta = 1.0f
51-
val includeFluids = false
52-
53-
val hit: HitResult? = client.cameraEntity?.pick(maxReach, tickDelta, includeFluids)
54-
55-
if (hit != null) {
56-
if (hit.type == HitResult.Type.BLOCK) {
57-
val blockHit = hit as BlockHitResult
58-
val blockPos = blockHit.blockPos
59-
val newState = client.level?.getBlockState(blockPos) ?: return
60-
61-
if (blockState != newState) {
62-
this.breakTime = 0
63-
this.breakProgress = -1
64-
}
47+
val maxReach = 10.0
48+
val tickDelta = 1.0f
49+
val includeFluids = false
50+
51+
val hit: HitResult? = player.pick(maxReach, tickDelta, includeFluids)
52+
53+
if (hit != null) {
54+
if (hit.type == HitResult.Type.BLOCK) {
55+
val blockHit = hit as BlockHitResult
56+
val blockPos = blockHit.blockPos
57+
val newState = level.getBlockState(blockPos) ?: return
58+
59+
if (blockState != newState) {
60+
this.breakTime = 0
61+
this.breakProgress = -1
62+
}
6563

66-
blockState = newState
64+
blockState = newState
6765

6866

69-
val pos = getProjectileSpawnPos(player, InteractionHand.MAIN_HAND, 1.5f, 0.6f)
67+
val pos = getProjectileSpawnPos(player, InteractionHand.MAIN_HAND, 1.5f, 0.6f)
68+
if (level.isClientSide) {
7069
spawnChargeParticles(player.level(), player, pos, 0.5f)
7170
spec(level, player.lookAngle.normalize(), pos, SpiritTypeRegistry.EARTHEN_SPIRIT, level.random)
71+
}
7272

73-
if (!VoidBoundApi.canPlayerBreakBlock(level, player, blockPos)) {
74-
ParticleEngineMixinLogic.logic(level, blockPos, blockState!!, level.random, hit.direction)
75-
return
76-
}
73+
if (!VoidBoundApi.canPlayerBreakBlock(level, player, blockPos)) {
74+
ParticleEngineMixinLogic.logic(level, blockPos, blockState!!, level.random, hit.direction)
75+
return
76+
}
7777

78-
timeToBreak = (20 * blockState!!.getDestroySpeed(level, blockPos))
78+
timeToBreak = (20 * blockState!!.getDestroySpeed(level, blockPos))
79+
if (level.isClientSide) {
7980
val coordPos: List<Vec3> = VoidBoundPosUtils.getFaceCoords(level, blockState!!, blockPos)
8081
for (pos1 in coordPos) {
8182
val lightSpecs: ParticleEffectSpawner =
@@ -86,9 +87,12 @@ class ExcavationFocus : IWandFocus {
8687
lightSpecs.spawnParticles()
8788
lightSpecs.spawnParticles()
8889
}
89-
this.breakTime++
90-
val progress: Int = (this.breakTime / this.timeToBreak!!.toFloat() * 10).toInt()
90+
}
91+
92+
this.breakTime++
93+
val progress: Int = (this.breakTime / this.timeToBreak!!.toFloat() * 10).toInt()
9194

95+
if (level.isClientSide) {
9296
VoidBoundPacketRegistry.VOID_BOUND_CHANNEL.sendToServer(
9397
ExcavationPacket(
9498
blockPos,
@@ -97,20 +101,20 @@ class ExcavationFocus : IWandFocus {
97101
progress
98102
)
99103
)
104+
}
100105

101-
if (breakTime % 6 == 0) {
102-
level.playSound(player, blockPos, blockState!!.soundType.breakSound, SoundSource.BLOCKS)
103-
}
106+
if (breakTime % 6 == 0 && level.isClientSide) {
107+
level.playSound(player, blockPos, blockState!!.soundType.breakSound, SoundSource.BLOCKS)
108+
}
104109

105-
if (progress != this.breakProgress) {
106-
this.breakProgress = progress
107-
}
108-
level.destroyBlockProgress(player.id + ExcavationPacket.generatePosHash(blockPos), blockPos, progress)
110+
if (progress != this.breakProgress) {
111+
this.breakProgress = progress
112+
}
113+
level.destroyBlockProgress(player.id + ExcavationPacket.generatePosHash(blockPos), blockPos, progress)
109114

110-
if (this.breakTime >= this.timeToBreak!!) {
111-
this.breakTime = 0
112-
this.breakProgress = -1
113-
}
115+
if (this.breakTime >= this.timeToBreak!!) {
116+
this.breakTime = 0
117+
this.breakProgress = -1
114118
}
115119
}
116120
}

Diff for: src/main/resources/assets/voidbound/lang/en_us.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"item.voidbound.soulwood_totemic_staff": "Soulwood Totemic Staff",
3636
"item.voidbound.tear_of_ender": "Tear of Ender",
3737
"item.voidbound.strange_matter": "Strange Matter",
38-
"item.voidbound.tear_of_grimcult": "Tear of Brimstone",
38+
"item.voidbound.tear_of_brimstone": "Tear of Brimstone",
3939
"item.voidbound.ichorium_sword": "Ichorium Sword",
4040
"item.voidbound.ichorium_pickaxe": "Ichorium Pickaxe",
4141
"item.voidbound.ichorium_shovel": "Ichorium Shovel",

0 commit comments

Comments
 (0)