Skip to content

Commit 762f3a8

Browse files
fixes
1 parent 47b7e2a commit 762f3a8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/sensor/impact/ImpactSensorBlock.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,20 @@ class ImpactSensorBlock(properties: Properties?): DirectionalBlock(properties),
121121

122122
val rotatedPos = predictPos.rotate(predictiveRot, Vector3d())
123123

124-
targetPositions.add(predictivePos.add(rotatedPos, Vector3d()).toMinecraft())
124+
val targetPos = level.toWorldCoordinates(predictivePos.add(rotatedPos, Vector3d()).toMinecraft())
125+
if (!targetPos.length().isNaN() && targetPos.length().isFinite()) targetPositions.add(targetPos)
125126
}
126127
}
127128
}
128129
var found = 0
129130
val positions = hashSetOf<Vector3dc>()
131+
positions.add(targetPositions.first().toJOML())
130132

131133
targetPositions.forEach { positions.addAll(level.transformToNearbyShipsAndWorld(it.x, it.y, it.z, 1.5)) }
132134

133135
for (position in positions) {
134-
val chunkPos = ChunkPos(BlockPos(position.toMinecraft()))
135-
if (ship != null && ship.chunkClaim.contains(chunkPos.x, chunkPos.z)) {
136+
val posShip = level.getShipObjectManagingPos(BlockPos(position.toMinecraft()))
137+
if (posShip != null && ship != null && posShip.id == ship.id) {
136138
continue
137139
}
138140
if (!level.getBlockState(BlockPos(position.toMinecraft())).isAir) {
@@ -151,6 +153,9 @@ class ImpactSensorBlock(properties: Properties?): DirectionalBlock(properties),
151153
return@forEach
152154
}
153155
}
156+
if (found == 15) {
157+
break
158+
}
154159
}
155160

156161
found

common/src/main/kotlin/org/valkyrienskies/clockwork/content/curiosities/sensor/rotation/GyroscopicSensorBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ class GyroscopicSensorBlock(properties: Properties) : DirectionalBlock(propertie
9595
override fun tick(state: BlockState, level: ServerLevel, pos: BlockPos, random: Random) {
9696
val power = this.updatePower(state, level, pos, random)
9797
val negative = power < 0
98-
if (power.absoluteValue != state.getValue(POWER)) {
98+
if (power.absoluteValue != state.getValue(POWER) || negative != state.getValue(NEGATIVE)) {
9999
var newState = state.setValue(POWER, power.absoluteValue) as BlockState
100100
if (negative != state.getValue(NEGATIVE)) {
101101
newState = newState.setValue(NEGATIVE, negative) as BlockState
102102
}
103103
level.setBlock(pos, newState, 2)
104-
level.scheduleTick(pos, this, 2)
105104
level.updateNeighborsAt(pos, this)
106105
}
106+
level.scheduleTick(pos, this, 2)
107107
this.updateNeighborsInFront(level, pos, state)
108108
}
109109

0 commit comments

Comments
 (0)