-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring more methods and fix player change health
- Loading branch information
Showing
37 changed files
with
254 additions
and
357 deletions.
There are no files selected for viewing
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
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
50 changes: 21 additions & 29 deletions
50
...engine/player/data/attribute/Attribute.kt → ...il/beengine/entity/attribute/Attribute.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
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/org/distril/beengine/entity/attribute/EntityAttributes.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,29 @@ | ||
package org.distril.beengine.entity.attribute | ||
|
||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket | ||
import org.distril.beengine.player.Player | ||
import java.util.* | ||
|
||
class EntityAttributes { | ||
|
||
private val attributes: MutableMap<Attribute.Type, Attribute> = EnumMap(Attribute.Type::class.java) | ||
|
||
init { | ||
this.setAttribute(Attribute(Attribute.Type.HEALTH, 0f, 20f, 20f)) | ||
this.setAttribute(Attribute(Attribute.Type.MOVEMENT_SPEED, 0f, Float.MAX_VALUE, 0.10f)) | ||
} | ||
|
||
fun send(player: Player) { | ||
val packet = UpdateAttributesPacket() | ||
packet.runtimeEntityId = player.id | ||
packet.attributes.addAll(this.attributes.values.map { it.toNetwork() }) | ||
|
||
player.sendPacket(packet) | ||
} | ||
|
||
fun setAttribute(attribute: Attribute) { | ||
this.attributes[attribute.type] = attribute | ||
} | ||
|
||
operator fun get(type: Attribute.Type) = this.attributes[type]!! | ||
} |
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
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
Oops, something went wrong.