-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.0.10][publish] update ui & update particle api
- Loading branch information
Showing
4 changed files
with
123 additions
and
51 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
module/module-nms-util/src/main/kotlin/taboolib/module/nms/NMSParticle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package taboolib.module.nms | ||
|
||
import org.bukkit.Location | ||
import org.bukkit.Particle | ||
import org.bukkit.util.Vector | ||
import taboolib.common.util.unsafeLazy | ||
|
||
/** | ||
* TabooLib | ||
* taboolib.module.nms.NMSParticle | ||
* | ||
* @author 坏黑 | ||
* @since 2023/5/2 21:57 | ||
*/ | ||
abstract class NMSParticle { | ||
|
||
abstract fun createParticlePacket(particle: Particle, location: Location, offset: Vector = Vector(), speed: Double = 0.0, count: Int = 1, data: Any? = null): Any | ||
|
||
companion object { | ||
|
||
val instance by unsafeLazy { nmsProxy<NMSParticle>() } | ||
|
||
/** 创建粒子数据包 */ | ||
fun Particle.createPacket(location: Location, offset: Vector = Vector(), speed: Double = 0.0, count: Int = 1, data: Any? = null): Any { | ||
return instance.createParticlePacket(this, location, offset, speed, count, data) | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
module/module-nms-util/src/main/kotlin/taboolib/module/nms/NMSParticleImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package taboolib.module.nms | ||
|
||
import net.minecraft.server.v1_16_R1.PacketPlayOutWorldParticles | ||
import org.bukkit.Location | ||
import org.bukkit.Particle | ||
import org.bukkit.craftbukkit.v1_16_R1.CraftParticle | ||
import org.bukkit.util.Vector | ||
|
||
/** | ||
* TabooLib | ||
* taboolib.module.nms.NMSParticleImpl | ||
* | ||
* @author 坏黑 | ||
* @since 2023/5/2 21:58 | ||
*/ | ||
class NMSParticleImpl : NMSParticle() { | ||
|
||
override fun createParticlePacket(particle: Particle, location: Location, offset: Vector, speed: Double, count: Int, data: Any?): Any { | ||
if (data != null && !particle.dataType.isInstance(data)) { | ||
error("data should be ${particle.dataType} got ${data.javaClass}") | ||
} | ||
return PacketPlayOutWorldParticles( | ||
CraftParticle.toNMS(particle, data), | ||
true, | ||
location.x, | ||
location.y, | ||
location.z, | ||
offset.x.toFloat(), | ||
offset.y.toFloat(), | ||
offset.z.toFloat(), | ||
speed.toFloat(), | ||
count | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters