-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from Kerzinator24/entities
Add Additional mobs
- Loading branch information
Showing
18 changed files
with
787 additions
and
4 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...er/src/main/kotlin/me/gabber235/typewriter/entries/data/minecraft/living/TremblingData.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,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.") | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...c/main/kotlin/me/gabber235/typewriter/entries/data/minecraft/living/piglin/DancingData.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,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.") | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
...dapter/src/main/kotlin/me/gabber235/typewriter/entries/entity/minecraft/EndermanEntity.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,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 | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...yAdapter/src/main/kotlin/me/gabber235/typewriter/entries/entity/minecraft/HoglinEntity.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,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 | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...ityAdapter/src/main/kotlin/me/gabber235/typewriter/entries/entity/minecraft/HuskEntity.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,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 | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...apter/src/main/kotlin/me/gabber235/typewriter/entries/entity/minecraft/IronGolemEntity.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,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 | ||
} | ||
} |
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.