Skip to content

Commit

Permalink
use flame particle to detect m7 dragon spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Mar 20, 2023
1 parent 0259fcb commit 20f704d
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ import net.minecraft.entity.boss.EntityDragon
import net.minecraft.init.Blocks
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity
import net.minecraft.util.AxisAlignedBB
import net.minecraft.util.BlockPos
import net.minecraft.util.ResourceLocation
import net.minecraft.util.Vec3
import net.minecraft.util.*
import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent
Expand Down Expand Up @@ -110,17 +107,15 @@ object MasterMode7Features {
if (Skytils.config.witherKingDragonSpawnAlert) {
UChat.chat("§c§lThe ${drag.chatColor}§l${drag.name} §c§ldragon is spawning!")
}
// TODO: needs confirm
dragonSpawnTimes[drag] = System.currentTimeMillis() + 4800
}
} else if (event.packet is S2APacketParticles) {
event.packet.apply {
WitherKingDragons.values().find { it.bb.isVecInside(event.packet.vec3) }?.let {
printDevMessage(
"${it.textColor} $count ${if (isLongDistance) "long-distance" else ""} ${type.particleName} particles with $speed speed at $x, $y, $z, offset by $xOffset, $yOffset, $zOffset",
"witherkingparticles"
)
}
if (count != 20 || y != WitherKingDragons.particleYConstant || type != EnumParticleTypes.FLAME || xOffset != 2f || yOffset != 3f || zOffset != 2f || speed != 0f || !isLongDistance || x % 1 != 0.0 || z % 1 != 0.0) return
val owner = WitherKingDragons.values().find {
it.particleLocation.x == x.toInt() && it.particleLocation.z == z.toInt()
} ?: return
// TODO: needs confirm
dragonSpawnTimes[owner] = System.currentTimeMillis() + 5000
}
}
}
Expand Down Expand Up @@ -220,7 +215,8 @@ object MasterMode7Features {
"${drag.textColor} ${(diff / 1000.0).roundToPrecision(2)}s",
drag.color,
event.partialTicks,
stack
stack,
scale = 5f
)
return@removeAll diff < 0
}
Expand Down Expand Up @@ -296,9 +292,14 @@ enum class WitherKingDragons(

val itemName = "§cCorrupted $textColor Relic"
val itemId = "${textColor.uppercase()}_KING_RELIC"
val texture = ResourceLocation("skytils", "textures/dungeons/m7/dragon_${this.name.lowercase()}.png")
private val a = 13.5
val texture = ResourceLocation("skytils", "textures/dungeons/m7/dragon_${name.lowercase()}.png")
val bb = blockPos.run {
AxisAlignedBB(x - a, y - 8.0, z - a, x + a, y + a + 2, z + a)
}
val particleLocation = blockPos.up(5)

companion object {
private const val a = 13.5
const val particleYConstant = 19.0
}
}

0 comments on commit 20f704d

Please sign in to comment.