This commit is contained in:
ruby
2025-01-02 18:29:04 +13:00
parent c082691845
commit 35c7124451

View File

@ -1,4 +1,4 @@
package com.pobnellion.aoe.ui; package com.pobnellion.aoe.ui
import com.comphenix.protocol.PacketType import com.comphenix.protocol.PacketType
import com.comphenix.protocol.ProtocolLibrary import com.comphenix.protocol.ProtocolLibrary
@ -30,7 +30,7 @@ import kotlin.math.floor
class PlaceHint { class PlaceHint {
companion object : Listener { companion object : Listener {
private const val MAX_TARGET_DISTANCE = 64 private const val MAX_TARGET_DISTANCE = 64
private val playerHints = HashMap<UUID, PlaceHint>(); private val playerHints = HashMap<UUID, PlaceHint>()
fun add( fun add(
player: Player, player: Player,
@ -44,7 +44,7 @@ class PlaceHint {
createOutlineTeam(player) createOutlineTeam(player)
playerHints[player.uniqueId] = PlaceHint(player, sizeX, sizeY, sizeZ, onConfirm, validate) playerHints[player.uniqueId] = PlaceHint(player, sizeX, sizeY, sizeZ, onConfirm, validate)
val block = player.getTargetBlockExact(MAX_TARGET_DISTANCE); val block = player.getTargetBlockExact(MAX_TARGET_DISTANCE)
playerHints[player.uniqueId]!!.moveTo(block?.location) playerHints[player.uniqueId]!!.moveTo(block?.location)
} }
@ -58,7 +58,7 @@ class PlaceHint {
createOutlineTeam(player) createOutlineTeam(player)
playerHints[player.uniqueId] = PlaceHint(player, schematicName, onConfirm, validate) playerHints[player.uniqueId] = PlaceHint(player, schematicName, onConfirm, validate)
val block = player.getTargetBlockExact(MAX_TARGET_DISTANCE); val block = player.getTargetBlockExact(MAX_TARGET_DISTANCE)
playerHints[player.uniqueId]!!.moveTo(block?.location) playerHints[player.uniqueId]!!.moveTo(block?.location)
} }
@ -93,8 +93,8 @@ class PlaceHint {
if (!playerHints.containsKey(event.player.uniqueId)) if (!playerHints.containsKey(event.player.uniqueId))
return return
val target = event.player.getTargetBlockExact(MAX_TARGET_DISTANCE); val target = event.player.getTargetBlockExact(MAX_TARGET_DISTANCE)
val block = if (target == null) null else event.player.getTargetBlock(MaterialSetTag.REPLACEABLE.values, MAX_TARGET_DISTANCE); val block = if (target == null) null else event.player.getTargetBlock(MaterialSetTag.REPLACEABLE.values, MAX_TARGET_DISTANCE)
playerHints[event.player.uniqueId]!!.moveTo(block?.location) playerHints[event.player.uniqueId]!!.moveTo(block?.location)
} }
@ -179,7 +179,7 @@ class PlaceHint {
private fun show(initialLocation: Location) { private fun show(initialLocation: Location) {
initialLocation.add(-floor(sizeX / 2.0), 1.0, -floor(sizeZ / 2.0)) initialLocation.add(-floor(sizeX / 2.0), 1.0, -floor(sizeZ / 2.0))
currentLocation = initialLocation; currentLocation = initialLocation
val spawnMarkerPacket = PacketContainer(PacketType.Play.Server.SPAWN_ENTITY) val spawnMarkerPacket = PacketContainer(PacketType.Play.Server.SPAWN_ENTITY)
spawnMarkerPacket.integers.write(0, marker.first) spawnMarkerPacket.integers.write(0, marker.first)
@ -321,7 +321,7 @@ class PlaceHint {
private fun updateColour() { private fun updateColour() {
// base // base
val dataPacket = PacketContainer(PacketType.Play.Server.ENTITY_METADATA) val dataPacket = PacketContainer(PacketType.Play.Server.ENTITY_METADATA)
dataPacket.integers.write(0, base.first); dataPacket.integers.write(0, base.first)
val material = if (isValid) Material.LIME_STAINED_GLASS else Material.RED_STAINED_GLASS val material = if (isValid) Material.LIME_STAINED_GLASS else Material.RED_STAINED_GLASS
val blockData = BukkitConverters val blockData = BukkitConverters