Skip to content

Commit

Permalink
Version 0.5.00 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRedMagic committed Jun 2, 2024
1 parent c02848c commit 067ff12
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
18 changes: 18 additions & 0 deletions api/src/main/java/com/redmagic/undefinedapi/nms/NMSPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,26 @@ interface NMSPlayer: NMSEntity {
* Kills the entity.
*/
fun kill()
/**
* Triggers a death animation for the entity.
*
* This method plays the animation of the entity dying. It does not directly apply any damage or modify the entity's health.
* The animation can be used to provide visual feedback to the player or create special effects.
*
* @receiver The entity to perform the death animation on.
*/
fun deathAnimation()

/**
* Resets the pose of the entity.
*
* This method resets the pose of the entity to the default standing position. It can be used to reset any custom
* poses or animations applied to the entity.
*
* Note: This method does not have any parameters or return values.
*/
fun resetPose()

/**
* Triggers a damage animation for the entity.
*
Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

apply(plugin = "maven-publish")
val versionVar = "0.4.51"
val versionVar = "0.5.00"
val groupIdVar = "com.redmagic"
val artifactIdVar = "UndefinedAPI"

Expand All @@ -36,6 +36,10 @@ publishing {
artifactId = artifactIdVar
version = versionVar

artifact("dev"){
enabled = false
}

from(components["java"])
}
}
Expand Down
19 changes: 15 additions & 4 deletions server/src/main/java/com/redmagic/undefinedapi/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.redmagic.undefinedapi.nms.ItemSlot
import com.redmagic.undefinedapi.nms.createFakePlayer
import com.redmagic.undefinedapi.scheduler.delay
import org.bukkit.Bukkit
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.inventory.ItemStack
Expand All @@ -22,11 +23,19 @@ class Main: JavaPlugin() {
event<PlayerJoinEvent> {

val npc = api.createFakePlayer("TheRedMagic", "TheRedMagic")!!
npc.viewers.add(player)
npc.spawn(player.location)
npc.viewers.remove(player)

val newLoc = Location(Bukkit.getWorld("world"), 10.0, 10.0, 10.0)

npc.moveOrTeleport(newLoc)

npc.name = "NewName"

npc.resetPose()


delay(20) {
npc.location = player.location.clone().add(0.0,5.0,0.0)
npc.teleport(newLoc)
delay(20) {
npc.name = "Jeff"
npc.isCrouching = true
Expand All @@ -40,7 +49,9 @@ class Main: JavaPlugin() {

npc.setItem(ItemSlot.MAINHAND, ItemStack(Material.SHIELD))

npc.useMainHand()
npc.moveMainHand()

npc.moveOffHand()
delay(20) {
npc.kill()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,13 @@ class NMSPlayer1_20_4(name: String, skin: String): NMSPlayer {

}

/**
* Resets the pose of the player.
*/
override fun resetPose() {
isCrouching = false
}

/**
* Returns whether the player is alive.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@ class NMSPlayer1_20_5(name: String, skin: String): NMSPlayer {
}

}
/**
* Resets the pose of the player.
*/
override fun resetPose() {
isCrouching = false
}

/**
* Returns whether the player is alive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ class NMSPlayer1_20_6(name: String, skin: String): NMSPlayer {

}

/**
* Resets the pose of the player.
*/
override fun resetPose() {
isCrouching = false
}

/**
* Returns whether the player is alive.
*
Expand All @@ -645,6 +652,8 @@ class NMSPlayer1_20_6(name: String, skin: String): NMSPlayer {

val nmsPose = net.minecraft.world.entity.Pose.valueOf(pose.name)

if (serverPlayer.pose == nmsPose) return

serverPlayer.pose = nmsPose

val dataList: MutableList<SynchedEntityData.DataValue<*>> = mutableListOf(
Expand Down

0 comments on commit 067ff12

Please sign in to comment.