- youll want
.isPushable(false)
- add a triggerable animation to the animationcontroller and trigger it on added to world, also note youll have to rename your
stone_golem.spawn.json to stone_golem.animation.json
- get the geo bone and rotate it along the entity's head rotation, then in the .tick() method after it's 20 ticks old have it look at the nearest player if there is one
.sized(1,1)
isInvulnerableTo()
let RenderUtils = Java.loadClass("software.bernie.geckolib.util.RenderUtils")
StartupEvents.registry('entity_type', e => {
e.create('amfc:stone_golem', 'entityjs:living')
.addAnimationController("somecontrollername", 1, event => {
let { entity } = event
event.addTriggerableAnimation('animation.stone_golem.spawn', 'spawning', 'default')
let geoModel = RenderUtils.getGeoModelForEntity(entity)
let head = geoModel.getBone("head").get()
if (head) {
head.setRotX(entity.yHeadRot)
}
return true;
})
.onAddedToWorld( entity => {
entity.triggerAnimation("somecontrollername", "spawning")
})
.tick(entity => {
let aabb = entity.boundingBox.inflate(20)
entity.level.getEntitiesWithin(aabb).forEach(target => {
if ((!target || !target.isPlayer())) return
if (entity.age > 20) {
entity.lookAt("eyes", new Vec3d(target.x, target.y, target.z))
}
})
})
.isPushable(false)
.sized(1, 1)
.isInvulnerableTo(ctx => {
let { damageSource, entity } = ctx
if (damageSource == entity.level.damageSources().fall() ||
damageSource == entity.level.damageSources().inFire() ||
damageSource == entity.level.damageSources().onFire() ||
damageSource == entity.level.damageSources().lava() ||
damageSource == entity.level.damageSources().hotFloor() ||
damageSource == entity.level.damageSources().drown()
) {
return true
}
return false
})
.canJump(false)
.canBreatheUnderwater(true)
.fireImmune(true)
.isAlwaysExperienceDropper(false)
.noEggItem()
})```