-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...xtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/BreezeEntity.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,59 @@ | ||
package com.typewritermc.entity.entries.entity.minecraft | ||
|
||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes | ||
import com.typewritermc.core.books.pages.Colors | ||
import com.typewritermc.core.entries.Ref | ||
import com.typewritermc.core.entries.emptyRef | ||
import com.typewritermc.core.extension.annotations.Entry | ||
import com.typewritermc.core.extension.annotations.OnlyTags | ||
import com.typewritermc.core.extension.annotations.Tags | ||
import com.typewritermc.core.utils.point.Position | ||
import com.typewritermc.engine.paper.entry.entity.FakeEntity | ||
import com.typewritermc.engine.paper.entry.entity.SimpleEntityDefinition | ||
import com.typewritermc.engine.paper.entry.entity.SimpleEntityInstance | ||
import com.typewritermc.engine.paper.entry.entries.* | ||
import com.typewritermc.engine.paper.utils.Sound | ||
import com.typewritermc.entity.entries.data.minecraft.applyGenericEntityData | ||
import com.typewritermc.entity.entries.data.minecraft.living.applyLivingEntityData | ||
import com.typewritermc.entity.entries.entity.WrapperFakeEntity | ||
import org.bukkit.entity.Player | ||
|
||
@Entry("breeze_definition", "A breeze entity", Colors.BLUE, "solar:wind-bold") | ||
@Tags("breeze_definition") | ||
/** | ||
* The `BreezeDefinition` class is an entry that shows up as a breeze in-game. | ||
* | ||
* ## How could this be used? | ||
* This could be used to create a breeze entity. | ||
*/ | ||
class BreezeDefinition( | ||
override val id: String = "", | ||
override val name: String = "", | ||
override val displayName: Var<String> = ConstVar(""), | ||
override val sound: Sound = Sound.EMPTY, | ||
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "breeze_data") | ||
override val data: List<Ref<EntityData<*>>> = emptyList(), | ||
) : SimpleEntityDefinition { | ||
override fun create(player: Player): FakeEntity = BreezeEntity(player) | ||
} | ||
|
||
@Entry("breeze_instance", "An instance of a breeze entity", Colors.CYAN, "solar:wind-bold") | ||
class BreezeInstance( | ||
override val id: String = "", | ||
override val name: String = "", | ||
override val definition: Ref<BreezeDefinition> = emptyRef(), | ||
override val spawnLocation: Position = Position.ORIGIN, | ||
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "breeze_data") | ||
override val data: List<Ref<EntityData<*>>> = emptyList(), | ||
override val activity: Ref<out SharedEntityActivityEntry> = emptyRef(), | ||
) : SimpleEntityInstance | ||
|
||
private class BreezeEntity(player: Player) : WrapperFakeEntity( | ||
EntityTypes.BREEZE, | ||
player, | ||
) { | ||
override fun applyProperty(property: EntityProperty) { | ||
if (applyGenericEntityData(entity, property)) return | ||
if (applyLivingEntityData(entity, property)) return | ||
} | ||
} |
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