#Entity JS - A Creaking Clone

45 messages · Page 1 of 1 (latest)

echo beacon
#

I attempted to use the onhurt but i can't make it play an animation
and cancel the hurt event when not on fire/lava/outofworld.

/**
 * @param {Internal.ContextUtils$EntityDamageContext} context
 */
//     builder.onHurtTarget(context => global.hurting(context))
global.assbeating = context => {
    let { damageSource, entity, damageAmount, amount } = context
    if (damageSource != entity.level.damageSources().onFire() && damageSource != entity.level.damageSources().fellOutOfWorld() && damageSource != entity.level.damageSources().lava() && damageSource != entity.level.damageSources().inFire()) {
        entity.triggerAnimation("trigger_anims", "weakling")
        entity.playSound("rootoffear:entity.wilted.sway")
    } else {
        entity.triggerAnimation("trigger_anims", "hurt")
    }
}
cinder tigerBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

echo beacon
#

the damage invulnerability metheod works but i wanna make it play an anim when hit by a non fire/out of world dmg source using the invun methed prevents that from happening

echo beacon
#

I think i found what i want

// Wonderland
  public boolean m_6469_(DamageSource source, float amount) {
    if (source.m_276093_(DamageTypes.f_268631_))
      return false; 
    if (source.m_7640_() instanceof net.minecraft.world.entity.projectile.AbstractArrow)
      return false; 
    if (source.m_7640_() instanceof Player)
      return false; 
    if (source.m_7640_() instanceof net.minecraft.world.entity.projectile.ThrownPotion || source.m_7640_() instanceof net.minecraft.world.entity.AreaEffectCloud)
      return false; 
    if (source.m_276093_(DamageTypes.f_268671_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268585_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268722_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268450_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268565_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268714_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268526_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268482_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268493_))
      return false; 
    if (source.m_276093_(DamageTypes.f_268641_))
      return false; 
    return super.m_6469_(source, amount);
  }
#

m_6469_ is hurt right?

#

yea probably

echo beacon
#

uea it did not wokr :(

wooden relic
#

you have the createCustom method for this

#

which will clone ai/behavior/ect and you will have the modifyBuilder to modify it as needed

#

as for the onhurt youll want to use the EntityEvents.hurt event if you want to cancel damage which you would be able to detect with event.source, either that or the forge living hurt event which lets you change damage output if you need that

#

onHurt is only on Hurt, it does not replace it, only adds a hook into the hurt method itself

#

the other option would instead be builder.isInvulnerableTo() method

#

this is specifically meant to cancel certain damage sources

echo beacon
#

ooh got it

#

oh btw im on 1.20.1 so i need to create the ai from scratch

#

not from scratch really i have the java files for it

wooden relic
#

did not mean to ping for that btw 💀 but yeah you got this bro

#

i wonder if theres a backport mod for creakings where you could just do modifyentity event with

echo beacon
#

alright today i'll attempt this

echo beacon
#

ForgeEvents.onEvent("net.minecraftforge.event.entity.living.LivingHurtEvent", event => global.wiltlingGetsWreked(event))
/**
* @param {Internal.LivingHurtEvent} event 
*/
let WildlingVulnerable = [
  "onFire", 
  "inFire", 
  "genericKill",
  "minecraft:lava",
  "outOfWorld"
]
global.wiltlingGetsWreked = event => {
  let { entity, amount, source} = event
  let wiltling = entity.type == "rootoffear:wiltling"
  if (!wiltling) return
  if (WildlingVulnerable.includes(source.getType())){
    event.setAmount(amount)
  } else {
    event.cancel()
  }
}

YEES

#

but the entity still glows red for some reason

#

when hit

#

nvm im going to let it take 0.5 dmg why not

#

Oh btw i kinda lied, this entity is a hybreed of the creeking and wilted
https://modrinth.com/mod/the-root-of-fear/versions
I want it to burn when the lightlevel is greater then 0.5 like the entity but im having a bit of a difficult time doing so

// aistep btw
/** @param {Internal.LivingEntity} context*/
global.wiltedstep = context => {
  try {
    function LightBurn() {
      if (!context.level.isDay() && !context.level.isClientSide()) {
        lightlevel = context.level.getMaxLightLevel()
        blockpos = BlockPos.containing(context.getX(), context.getEyeY(), context.getZ());
        WetOrInSnow = context.isInWaterRainOrBubble() || context.isInPowderSnow || context.wasInPowderSnow
        if (lightlevel > 0.5 && !WetOrInSnow && context.level().canSeeSky(blockpos)) {
          return true;
        }
      }
      return false;
    }

  if (LightBurn()) {
    context.setSecondsOnFire(8)
    context.potionEffects.add("minecraft:speed" , 10 , 0, true, false)
  } else {
    return
  }
  } catch (e) {
    console.error("OHGOD: ", e)
  }

}
#

tried mimicing the burn metheod for zombies and skellies but it did not turn out well

#

getLightLevelDependentMagicValue is depreciated i think and idk if there is another metheod i can use bcs its depended on the wait a second

#

there is getLightProbePosition but its vec3

#

getmaxlightlvevl via context.level

#

there are errors but they just poofed idk why

echo beacon
#

Nvm I got it to work noww

#

Yippie!!!!!!

#

It's get emissions due to my pack having dynamic lights

#

For the goals can we load and use them in the server

#

Load modded ones I think, I wanna use the torch break event from the moth men from Alex's caves

echo beacon
#

nvm it somehow broke :(

/** @param {Internal.LivingEntity} context*/
global.wiltedstep = context => {
  function LightBurn() {
    if (!context.level.isClientSide()) {
      let lightlevel = context.level.getLightEmission(context.blockPosition)
      //let lightlevel = context.level.getBrightness("block", context.block)
      let WetOrInSnow = context.inFluidType || context.isInWaterRainOrBubble() || context.isInPowderSnow || context.wasInPowderSnow
      if (lightlevel > 1 && !WetOrInSnow) {
        return true
      }
    }
    return false
  }

  if (LightBurn()) {
    context.setSecondsOnFire(2)
    context.potionEffects.add("minecraft:speed", 10, 0, true, false)
  }
}
#

i swear it did work 30mins ago wa

#

other great news is that i implamented axe bonuses via the hurt forge event and this cool snippet

//   builder.onHurt(context => global.assbeating(context))
//  builder.addAnimationController("name", 0 <- Make sure the seconds be 0

/**
 * @param {Internal.ContextUtils$EntityDamageContext} context
 */
global.assbeating = context => {
  let { damageSource, entity } = context
  if (damageSource != entity.level.damageSources().onFire()) {
    entity.triggerAnimation("trigger_anims", "weakling")
    entity.playSound("rootoffear:entity.wilted.sway")
  } else {
    entity.triggerAnimation("trigger_anims", "hurt")
  }
}
#

using onHurt and triggeranimations makes the hurt anims play instantly

#

don't use the entity.hurtTime methoed as it blends the anims

wooden relic
#

so you were able to figure the main issue out?

echo beacon
#

yup

#

maybe i should make a new ticket