aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt')
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt b/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
index b7282ea..33ea7d1 100644
--- a/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
@@ -1,3 +1,51 @@
package moe.nea.potatocrime.entity
-import net.minecraft.entity.LivingEntity
+import moe.nea.potatocrime.registry.PotatoRegistry
+import net.minecraft.entity.EntityType
+import net.minecraft.entity.ai.goal.*
+import net.minecraft.entity.attribute.DefaultAttributeContainer
+import net.minecraft.entity.attribute.EntityAttributes
+import net.minecraft.entity.mob.HostileEntity
+import net.minecraft.entity.mob.PathAwareEntity
+import net.minecraft.entity.player.PlayerEntity
+import net.minecraft.world.World
+
+class PotatoGuardEntity(entityType: EntityType<out PotatoGuardEntity>, world: World?) :
+ PathAwareEntity(entityType, world) {
+ companion object {
+ fun createMobAttributes(): DefaultAttributeContainer.Builder {
+ return HostileEntity.createHostileAttributes()
+ .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 35.0)
+ .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.4)
+ .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 10.0)
+ .add(EntityAttributes.GENERIC_ARMOR, 4.0)
+ .add(EntityAttributes.GENERIC_MAX_HEALTH, 40.0)
+ }
+ }
+
+
+ override fun initGoals() {
+ goalSelector.add(3, MeleeAttackGoal(this, 1.0, false))
+ goalSelector.add(8, LookAroundGoal(this))
+ goalSelector.add(7, WanderAroundFarGoal(this, 1.0))
+ goalSelector.add(6, object : Goal() {
+ override fun canStart(): Boolean {
+ return this@PotatoGuardEntity.target == null && this@PotatoGuardEntity.getRandom().nextFloat() < 0.01
+ }
+ })
+ targetSelector.add(
+ 1,
+ ActiveTargetGoal(
+ this,
+ PlayerEntity::class.java,
+ true
+ ) { player ->
+ (player as PlayerEntity)
+ .inventory
+ .getMatchingStacks { it.isIn(PotatoRegistry.carrotIshItems) }
+ .isNotEmpty()
+ }
+ )
+ }
+
+}