Skip to content

Commit

Permalink
Merge pull request #186 from Kerzinator24/entities
Browse files Browse the repository at this point in the history
Add Additional mobs
  • Loading branch information
gabber235 authored May 11, 2024
2 parents 609cb26 + 82165df commit a0ce841
Show file tree
Hide file tree
Showing 18 changed files with 787 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package me.gabber235.typewriter.entries.data.minecraft.living

import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.Help
import me.gabber235.typewriter.entry.entity.SinglePropertyCollectorSupplier
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.extensions.packetevents.metas
import me.tofaa.entitylib.meta.mobs.HoglinMeta
import me.tofaa.entitylib.meta.mobs.monster.piglin.BasePiglinMeta
import me.tofaa.entitylib.wrapper.WrapperEntity
import org.bukkit.entity.Player
import java.util.*
import kotlin.reflect.KClass

@Entry("trembling_data", "Makes nether mobs tremble", Colors.RED, "game-icons:eye-monster")
@Tags("trembling_data")
class TremblingData(
override val id: String = "",
override val name: String = "",
@Help("Whether the entity is trembling.")
val trembling: Boolean = false,
override val priorityOverride: Optional<Int> = Optional.empty(),
) : EntityData<TremblingProperty> {
override fun type(): KClass<TremblingProperty> = TremblingProperty::class

override fun build(player: Player): TremblingProperty = TremblingProperty(trembling)
}

data class TremblingProperty(val trembling: Boolean) : EntityProperty {
companion object : SinglePropertyCollectorSupplier<TremblingProperty>(TremblingProperty::class)
}

fun applyTremblingData(entity: WrapperEntity, property: TremblingProperty) {
entity.metas {
meta<BasePiglinMeta> { isImmuneToZombification = property.trembling.not() }
meta<HoglinMeta> { isImmuneToZombification = property.trembling.not() }
error("Could not apply TremblingData to ${entity.entityType} entity.")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package me.gabber235.typewriter.entries.data.minecraft.living.piglin

import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.Help
import me.gabber235.typewriter.entry.entity.SinglePropertyCollectorSupplier
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.extensions.packetevents.metas
import me.tofaa.entitylib.meta.mobs.monster.piglin.PiglinMeta
import me.tofaa.entitylib.wrapper.WrapperEntity
import org.bukkit.entity.Player
import java.util.*
import kotlin.reflect.KClass

@Entry(
"dancing_data",
"Whether an entity is dancing",
Colors.RED,
"streamline:travel-wayfinder-man-arm-raises-2-man-raise-arm-scaning-detect-posture-security"
)
@Tags("data", "dancing_data")
class DancingData(
override val id: String = "",
override val name: String = "",
@Help("Whether the piglin is dancing.")
val dancing: Boolean = false,
override val priorityOverride: Optional<Int> = Optional.empty(),
) : EntityData<DancingProperty> {
override fun type(): KClass<DancingProperty> = DancingProperty::class

override fun build(player: Player): DancingProperty = DancingProperty(dancing)
}

data class DancingProperty(val dancing: Boolean) : EntityProperty {
companion object : SinglePropertyCollectorSupplier<DancingProperty>(DancingProperty::class)
}

fun applyDancingData(entity: WrapperEntity, property: DancingProperty) {
entity.metas {
meta<PiglinMeta> { isDancing = property.dancing }
error("Could not apply DancingData to ${entity.entityType} entity.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import org.bukkit.entity.Player

@Entry("cow_definition", "A cow entity", Colors.ORANGE, "fa6-solid:cow")
@Tags("cow_definition")
/**
* The `CowDefinition` class is an entry that shows up as a cow in-game.
*
* ## How could this be used?
* This could be used to create a cow entity.
*/
class CowDefinition(
override val id: String = "",
override val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package me.gabber235.typewriter.entries.entity.minecraft

import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.OnlyTags
import me.gabber235.typewriter.entries.data.minecraft.applyGenericEntityData
import me.gabber235.typewriter.entries.data.minecraft.living.*
import me.gabber235.typewriter.entry.Ref
import me.gabber235.typewriter.entry.emptyRef
import me.gabber235.typewriter.entry.entity.FakeEntity
import me.gabber235.typewriter.entry.entity.SimpleEntityDefinition
import me.gabber235.typewriter.entry.entity.SimpleEntityInstance
import me.gabber235.typewriter.entry.entity.WrapperFakeEntity
import me.gabber235.typewriter.entry.entries.EntityActivityEntry
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.utils.Sound
import org.bukkit.Location
import org.bukkit.entity.Player

@Entry("enderman_definition", "A enderman entity", Colors.ORANGE, "gravity-ui:sphere")
@Tags("enderman_definition")
/**
* The `EndermanDefinition` class is an entry that shows up as a enderman in-game.
*
* ## How could this be used?
* This could be used to create a enderman entity.
*/
class EndermanDefinition(
override val id: String = "",
override val name: String = "",
override val displayName: String = "",
override val sound: Sound = Sound.EMPTY,
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = EndermanEntity(player)
}

@Entry("enderman_instance", "An instance of a enderman entity", Colors.YELLOW, "gravity-ui:sphere")
class EndermanInstance(
override val id: String = "",
override val name: String = "",
override val definition: Ref<EndermanDefinition> = emptyRef(),
override val spawnLocation: Location = Location(null, 0.0, 0.0, 0.0),
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
override val activities: List<Ref<out EntityActivityEntry>> = emptyList(),
) : SimpleEntityInstance

private class EndermanEntity(player: Player) : WrapperFakeEntity(
EntityTypes.ENDERMAN,
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
@@ -0,0 +1,70 @@
package me.gabber235.typewriter.entries.entity.minecraft

import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.OnlyTags
import me.gabber235.typewriter.entries.data.minecraft.applyGenericEntityData
import me.gabber235.typewriter.entries.data.minecraft.living.*
import me.gabber235.typewriter.entry.Ref
import me.gabber235.typewriter.entry.emptyRef
import me.gabber235.typewriter.entry.entity.FakeEntity
import me.gabber235.typewriter.entry.entity.SimpleEntityDefinition
import me.gabber235.typewriter.entry.entity.SimpleEntityInstance
import me.gabber235.typewriter.entry.entity.WrapperFakeEntity
import me.gabber235.typewriter.entry.entries.EntityActivityEntry
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.utils.Sound
import org.bukkit.Location
import org.bukkit.entity.Player

@Entry("hoglin_definition", "A hoglin entity", Colors.ORANGE, "icon-park-outline:pig")
@Tags("hoglin_definition")
/**
* The `HoglinDefinition` class is an entry that shows up as a hoglin in-game.
*
* ## How could this be used?
* This could be used to create a hoglin entity.
*/
class HoglinDefinition(
override val id: String = "",
override val name: String = "",
override val displayName: String = "",
override val sound: Sound = Sound.EMPTY,
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "trembling_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = HoglinEntity(player)
}

@Entry("hoglin_instance", "An instance of a hoglin entity", Colors.YELLOW, "icon-park-outline:pig")
class HoglinInstance(
override val id: String = "",
override val name: String = "",
override val definition: Ref<HoglinDefinition> = emptyRef(),
override val spawnLocation: Location = Location(null, 0.0, 0.0, 0.0),
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "trembling_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
override val activities: List<Ref<out EntityActivityEntry>> = emptyList(),
) : SimpleEntityInstance

private class HoglinEntity(player: Player) : WrapperFakeEntity(
EntityTypes.HOGLIN,
player,
) {
init {
consumeProperties(TremblingProperty(false))
}

override fun applyProperty(property: EntityProperty) {
when (property) {
is AgableProperty -> applyAgeableData(entity, property)
is TremblingProperty -> applyTremblingData(entity, property)
else -> {}
}
if (applyGenericEntityData(entity, property)) return
if (applyLivingEntityData(entity, property)) return
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package me.gabber235.typewriter.entries.entity.minecraft

import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.OnlyTags
import me.gabber235.typewriter.entries.data.minecraft.applyGenericEntityData
import me.gabber235.typewriter.entries.data.minecraft.living.applyLivingEntityData
import me.gabber235.typewriter.entry.Ref
import me.gabber235.typewriter.entry.emptyRef
import me.gabber235.typewriter.entry.entity.FakeEntity
import me.gabber235.typewriter.entry.entity.SimpleEntityDefinition
import me.gabber235.typewriter.entry.entity.SimpleEntityInstance
import me.gabber235.typewriter.entry.entity.WrapperFakeEntity
import me.gabber235.typewriter.entry.entries.EntityActivityEntry
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.utils.Sound
import org.bukkit.Location
import org.bukkit.entity.Player

@Entry("husk_definition", "A husk entity", Colors.ORANGE, "game-icons:shambling-zombie")
@Tags("husk_definition")
/**
* The `HuskDefinition` class is an entry that shows up as a husk in-game.
*
* ## How could this be used?
* This could be used to create a husk entity.
*/
class HuskDefinition(
override val id: String = "",
override val name: String = "",
override val displayName: String = "",
override val sound: Sound = Sound.EMPTY,
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = HuskEntity(player)
}

@Entry("husk_instance", "An instance of a husk entity", Colors.YELLOW, "game-icons:shambling-zombie")
class HuskInstance(
override val id: String = "",
override val name: String = "",
override val definition: Ref<HuskDefinition> = emptyRef(),
override val spawnLocation: Location = Location(null, 0.0, 0.0, 0.0),
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
override val activities: List<Ref<out EntityActivityEntry>> = emptyList(),
) : SimpleEntityInstance

private class HuskEntity(player: Player) : WrapperFakeEntity(
EntityTypes.HUSK,
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
@@ -0,0 +1,61 @@
package me.gabber235.typewriter.entries.entity.minecraft

import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes
import me.gabber235.typewriter.adapters.Colors
import me.gabber235.typewriter.adapters.Entry
import me.gabber235.typewriter.adapters.Tags
import me.gabber235.typewriter.adapters.modifiers.OnlyTags
import me.gabber235.typewriter.entries.data.minecraft.applyGenericEntityData
import me.gabber235.typewriter.entries.data.minecraft.living.applyLivingEntityData
import me.gabber235.typewriter.entry.Ref
import me.gabber235.typewriter.entry.emptyRef
import me.gabber235.typewriter.entry.entity.FakeEntity
import me.gabber235.typewriter.entry.entity.SimpleEntityDefinition
import me.gabber235.typewriter.entry.entity.SimpleEntityInstance
import me.gabber235.typewriter.entry.entity.WrapperFakeEntity
import me.gabber235.typewriter.entry.entries.EntityActivityEntry
import me.gabber235.typewriter.entry.entries.EntityData
import me.gabber235.typewriter.entry.entries.EntityProperty
import me.gabber235.typewriter.utils.Sound
import org.bukkit.Location
import org.bukkit.entity.Player

@Entry("iron_golem_definition", "An iron golem entity", Colors.ORANGE, "game-icons:strong")
@Tags("iron_golem_definition")
/**
* The `IronGolemDefinition` class is an entry that shows up as an iron golem in-game.
*
* ## How could this be used?
* This could be used to create an iron golem entity.
*/
class IronGolemDefinition(
override val id: String = "",
override val name: String = "",
override val displayName: String = "",
override val sound: Sound = Sound.EMPTY,
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = IronGolemEntity(player)
}

@Entry("iron_golem_instance", "An instance of an iron golem entity", Colors.YELLOW, "game-icons:strong")
class IronGolemInstance(
override val id: String = "",
override val name: String = "",
override val definition: Ref<IronGolemDefinition> = emptyRef(),
override val spawnLocation: Location = Location(null, 0.0, 0.0, 0.0),
@OnlyTags("generic_entity_data", "living_entity_data", "mob_data")
override val data: List<Ref<EntityData<*>>> = emptyList(),
override val activities: List<Ref<out EntityActivityEntry>> = emptyList(),
) : SimpleEntityInstance

private class IronGolemEntity(player: Player) : WrapperFakeEntity(
EntityTypes.IRON_GOLEM,
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 @@ -26,6 +26,12 @@ import org.bukkit.entity.Player

@Entry("item_display_definition", "An item display entity", Colors.ORANGE, "mingcute:sword-fill")
@Tags("item_display_definition")
/**
* The `ItemDisplayDefinition` class is an entry that represents an item display entity.
*
* ## How could this be used?
* This could be used to create an entity that displays an item.
*/
class ItemDisplayDefinition(
override val id: String = "",
override val name: String = "",
Expand Down
Loading

0 comments on commit a0ce841

Please sign in to comment.