Skip to content

Commit

Permalink
Create BreezeEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Jan 6, 2025
1 parent bbe1068 commit 896d776
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SkeletonDefinition(
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")
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "skeleton_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = SkeletonEntity(player)
Expand All @@ -43,7 +43,7 @@ class SkeletonInstance(
override val name: String = "",
override val definition: Ref<SkeletonDefinition> = emptyRef(),
override val spawnLocation: Position = Position.ORIGIN,
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data")
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "skeleton_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
override val activity: Ref<out SharedEntityActivityEntry> = emptyRef(),
) : SimpleEntityInstance
Expand Down

0 comments on commit 896d776

Please sign in to comment.