-
i tried all of this things watcher.setObject(
WrappedDataWatcher.WrappedDataWatcherObject(11, WrappedDataWatcher.Registry.getVectorSerializer()),
Vector3F(x,y,z)
)
watcher.setObject(
WrappedDataWatcher.WrappedDataWatcherObject(10, WrappedDataWatcher.Registry.getVectorSerializer()),
Vector3F(x,y,z)
)
watcher.setObject(
WrappedDataWatcher.WrappedDataWatcherObject(19, WrappedDataWatcher.Registry.get(java.lang.Float::class.java)),
2f
)
watcher.setObject(
WrappedDataWatcher.WrappedDataWatcherObject(20, WrappedDataWatcher.Registry.get(java.lang.Float::class.java)),
2f
)
watcher.setObject(10, Vector3F(x,y,z))
watcher.setObject(11, Vector3F(x,y,z))
watcher.setObject(19, 2f)
watcher.setObject(20, 2f) |
Beta Was this translation helpful? Give feedback.
Answered by
DOKA1203
Jun 17, 2023
Replies: 2 comments 10 replies
-
so as far as setting the scale goes, the first one should be right. can you provide the rest of the code? what happens in game? |
Beta Was this translation helpful? Give feedback.
10 replies
-
i solved it package com.github.doka.advanced_selecting_chat.entities
import com.comphenix.packetwrapper.wrappers.play.clientbound.WrapperPlayServerEntityDestroy
import com.comphenix.packetwrapper.wrappers.play.clientbound.WrapperPlayServerEntityMetadata
import com.comphenix.packetwrapper.wrappers.play.clientbound.WrapperPlayServerSpawnEntity
import com.comphenix.protocol.wrappers.*
import it.unimi.dsi.fastutil.ints.IntList
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
import org.joml.Quaternionf
import org.joml.Vector3f
import java.util.*
class DisplayEntity(private val player: Player, private val type: EntityType) {
val entityID: Int = (Math.random() * 1000000).toInt()
fun spawnEntity(loc: Location) {
val wrapper = WrapperPlayServerSpawnEntity()
wrapper.id = entityID
wrapper.uuid = UUID.randomUUID()
wrapper.type = type
wrapper.x = loc.x
wrapper.y = loc.y
wrapper.z = loc.z
wrapper.sendPacket(player)
}
fun setTextDisplayText(text: WrappedChatComponent) {
val packet = WrapperPlayServerEntityMetadata()
packet.id = entityID
packet.packedItems = listOf(
WrappedDataValue(22, WrappedDataWatcher.Registry.getChatComponentSerializer(), text.handle)
)
packet.sendPacket(player)
}
fun setBlockMaterial(material: Material) {
val packet = WrapperPlayServerEntityMetadata()
packet.id = entityID
packet.packedItems = listOf(
WrappedDataValue(22, WrappedDataWatcher.Registry.getBlockDataSerializer(false), WrappedBlockData.createData(material).handle)
)
packet.sendPacket(player)
}
fun setScale(x: Float, y:Float, z: Float) {
val packet = WrapperPlayServerEntityMetadata()
packet.id = entityID
packet.packedItems = listOf(
WrappedDataValue(11, WrappedDataWatcher.Registry.get(Vector3f::class.java), Vector3f(x, y, z))
)
packet.sendPacket(player)
}
private fun removeEntity() {
val packet = WrapperPlayServerEntityDestroy()
packet.entityIds = IntList.of(entityID)
packet.sendPacket(player)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DOKA1203
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i solved it