Skip to content

Commit 227f6cf

Browse files
perf: use setters instead of states for griffin burrows
1 parent dd9113c commit 227f6cf

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

src/main/kotlin/gg/skytils/skytilsmod/features/impl/events/GriffinBurrows.kt

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object GriffinBurrows {
132132
if (Skytils.config.showGriffinBurrows) {
133133
val matrixStack = UMatrixStack()
134134
for (pb in particleBurrows.values) {
135-
if (pb.hasEnchant && pb.hasFootstep && pb.type.get() != -1) {
135+
if (pb.hasEnchant && pb.hasFootstep && pb.type != -1) {
136136
pb.drawWaypoint(event.partialTicks, matrixStack)
137137
}
138138
}
@@ -193,15 +193,15 @@ object GriffinBurrows {
193193
when (type) {
194194
ParticleType.FOOTSTEP -> burrow.hasFootstep = true
195195
ParticleType.ENCHANT -> burrow.hasEnchant = true
196-
ParticleType.EMPTY -> burrow.type.set(0)
197-
ParticleType.MOB -> burrow.type.set(1)
198-
ParticleType.TREASURE -> burrow.type.set(2)
196+
ParticleType.EMPTY -> burrow.type = 0
197+
ParticleType.MOB -> burrow.type = 1
198+
ParticleType.TREASURE -> burrow.type = 2
199199
}
200200
}
201201
}
202202
}
203203
is S04PacketEntityEquipment -> {
204-
if (!Skytils.config.burrowEstimation) return
204+
if (!Skytils.config.burrowEstimation || SBInfo.mode != SkyblockIsland.Hub.mode) return
205205
val entity = mc.theWorld?.getEntityByID(event.packet.entityID)
206206
(entity as? EntityArmorStand)?.let { armorStand ->
207207
if (event.packet.itemStack?.item != Items.arrow) return
@@ -219,7 +219,7 @@ object GriffinBurrows {
219219
}
220220
}
221221
is S29PacketSoundEffect -> {
222-
if (!Skytils.config.burrowEstimation) return
222+
if (!Skytils.config.burrowEstimation || SBInfo.mode != SkyblockIsland.Hub.mode) return
223223
if (event.packet.soundName != "note.harp") return
224224
val (arrow, distance) = BurrowEstimation.arrows.keys
225225
.associateWith { arrow ->
@@ -255,8 +255,8 @@ object GriffinBurrows {
255255
BlockPos(x, y, z)
256256
}
257257

258-
protected abstract val waypointText: State<String>
259-
protected abstract val color: State<Color>
258+
protected abstract val waypointText: String
259+
protected abstract val color: Color
260260
fun drawWaypoint(partialTicks: Float, matrixStack: UMatrixStack) {
261261
val (viewerX, viewerY, viewerZ) = RenderUtil.getViewerPos(partialTicks)
262262
val renderX = this.x - viewerX
@@ -268,13 +268,13 @@ object GriffinBurrows {
268268
RenderUtil.drawFilledBoundingBox(
269269
matrixStack,
270270
AxisAlignedBB(renderX, renderY, renderZ, renderX + 1, renderY + 1, renderZ + 1).expandBlock(),
271-
this.color.get(),
271+
this.color,
272272
(0.1f + 0.005f * distSq.toFloat()).coerceAtLeast(0.2f)
273273
)
274274
GlStateManager.disableTexture2D()
275-
if (distSq > 5 * 5) RenderUtil.renderBeaconBeam(renderX, renderY + 1, renderZ, this.color.get().rgb, 1.0f, partialTicks)
275+
if (distSq > 5 * 5) RenderUtil.renderBeaconBeam(renderX, renderY + 1, renderZ, this.color.rgb, 1.0f, partialTicks)
276276
RenderUtil.renderWaypointText(
277-
waypointText.get(),
277+
waypointText,
278278
x + 0.5,
279279
y + 5.0,
280280
z + 0.5,
@@ -293,8 +293,8 @@ object GriffinBurrows {
293293
override val y: Int,
294294
override val z: Int
295295
) : Diggable() {
296-
override val waypointText = BasicState("§aBurrow §6(Guess)")
297-
override val color = BasicState(Color.ORANGE)
296+
override val waypointText = "§aBurrow §6(Guess)"
297+
override val color = Color.ORANGE
298298
}
299299

300300
data class ParticleBurrow(
@@ -312,26 +312,30 @@ object GriffinBurrows {
312312
hasEnchant
313313
)
314314

315-
val type = BasicState(-1)
316-
317-
override val waypointText = type.map {
318-
"${
319-
when (it) {
320-
0 -> "§aStart"
321-
1 -> "§cMob"
322-
2 -> "§6Treasure"
323-
else -> "§7Unknown"
315+
var type = -1
316+
set(value) {
317+
field = value
318+
when (value) {
319+
0 -> {
320+
waypointText = "§aStart §a(Particle)"
321+
color = Skytils.config.emptyBurrowColor
322+
}
323+
1 -> {
324+
waypointText = "§cMob §a(Particle)"
325+
color = Skytils.config.mobBurrowColor
326+
}
327+
2 -> {
328+
waypointText = "§6Treasure §a(Particle)"
329+
color = Skytils.config.treasureBurrowColor
330+
}
324331
}
325-
} §a(Particle)"
326-
}
327-
override val color = type.map {
328-
when (it) {
329-
0 -> Skytils.config.emptyBurrowColor
330-
1 -> Skytils.config.mobBurrowColor
331-
2 -> Skytils.config.treasureBurrowColor
332-
else -> Color.WHITE
333332
}
334-
}
333+
334+
override var waypointText = "§7Unknown §a(Particle)"
335+
private set
336+
337+
override var color = Color.WHITE
338+
private set
335339
}
336340

337341
private val ItemStack?.isSpade

0 commit comments

Comments
 (0)