Jump to content

[1.7.10][solved] spawnEntityInWorld producing unresponsive mobs


Recommended Posts

Posted

 

 

 

public void wakeTheDamned() {

 

if(!this.worldObj.isRemote)

{

for(int i = 0; i < 2; ++i) {

 

//"Wake the Dead"

EntitySacrificialSkeleton aid = new EntitySacrificialSkeleton(this.worldObj);

aid.setLocationAndAngles((double)this.posX-5+this.rand.nextInt(10), (double)this.posY+1, (double)this.posZ-5+this.rand.nextInt(10), 0.0F, 0.0F);

aid.onSpawnWithEgg((IEntityLivingData)null);

aid.setCurrentItemOrArmor(0, new ItemStack(w2theJungle.boneGripBow));

aid.setCurrentItemOrArmor(4, new ItemStack(w2theJungle.obshelmet));

 

this.worldObj.spawnEntityInWorld(aid);

this.playSound("mob.skeleton.hurt", 0.5f, 1);

aid.spawnExplosionParticle();

}

}

}

 

 

 

 

This code is part of a boss entity. He summons these adds and can pass his attack target to them. But the mobs summoned in this code are largely idle,  don't fight back and won't respond to passed threat. In contrast the same skeletons summoned using an egg will happily attack anything that they're told to by the boss.

 

According to the system.out i used, the constructor  for the sacrifical skeletons is run, so presumably the super [which calls EntitySkeleton] is too, yet, it's like it isn't.

 

 

Posted

Post your EntitySacrificialSkeleton code, I'm assuming it has something to do with

onSpawnWithEgg(null)

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

The problem predates the inclusion of aid.onspawnwithegg. I added that today after seeing it used in similar circumstances for vanilla code. it made no difference. the sac. skel entity has no implimentation of onspawn, anyway. also note that my skeleton, when spawned by other means, behaves correctly. it is only the version summoned by the boss code that is not working correctly.

 

the class:

 

 

 

public class EntitySacrificialSkeleton extends EntitySkeleton {

 

public EntitySacrificialSkeleton(World p_i1741_1_) {

super(p_i1741_1_);

 

System.out.println("i been made");

 

}

 

protected boolean isValidLightLevel()

    {

        int i = MathHelper.floor_double(this.posX);

        int j = MathHelper.floor_double(this.boundingBox.minY);

        int k = MathHelper.floor_double(this.posZ);

 

        if (this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > this.rand.nextInt(32))

        {

            return false;

        }

        else

        {

            int l = this.worldObj.getBlockLightValue(i, j, k);

 

            if (this.worldObj.isThundering())

            {

                int i1 = this.worldObj.skylightSubtracted;

                this.worldObj.skylightSubtracted = 10;

                l = this.worldObj.getBlockLightValue(i, j, k);

                this.worldObj.skylightSubtracted = i1;

            }

 

            return true; //l <= this.rand.nextInt(13);

           

//            return l >= this.rand.nextInt(12) + 6;

        }

    }

 

    public void onLivingUpdate() {

   

    //this.setDead();

    super.onLivingUpdate();

    }

   

    public void updateRidden()

    {

    //this.renderYawOffset = 1.5f;

    super.updateRidden();

   

    }

   

    @Override   

    public boolean attackEntityFrom(DamageSource ds, float f0)

    {

    if(ds == DamageSource.onFire) {

    return false;

    }

   

    if(this.ridingEntity != null && ds.getEntity() == this.ridingEntity)

    {

    return false;

    }

   

    return super.attackEntityFrom(ds, f0);

    }

   

    public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)

    {

    if(this.ridingEntity != null && p_82196_1_ == this.ridingEntity)

    {

    }

   

    this.height = this.isRiding() ? 1.8f * 1.25f : 1.8f;

   

        EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.difficultySetting.getDifficultyId() * 4));

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());

        int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());

        entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11F));

 

        if (i > 0)

        {

            entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);

        }

 

        if (j > 0)

        {

            entityarrow.setKnockbackStrength(j);

        }

 

        if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)

        {

            entityarrow.setFire(100);

        }

 

        this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

        this.worldObj.spawnEntityInWorld(entityarrow);

    }

 

    protected Item getDropItem()

    {

        return Items.arrow;

    }

   

   

 

    protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)

    {

        int j;

        int k;

 

        j = this.rand.nextInt(3 + p_70628_2_);

 

        for (k = 0; k < j; ++k)

        {

        this.dropItem(Items.arrow, 1);

      }

 

        j = this.rand.nextInt(1 + p_70628_2_);

 

        for (k = 0; k < j; ++k)

        {

            this.dropItem(w2theJungle.carvedBone, 1);

        }

    }

 

    protected void dropRareDrop(int p_70600_1_)

    {

    this.entityDropItem(new ItemStack(w2theJungle.ancientSkull, 1, 1), 0.0F);

    }

}

 

 

 

 

as you can see, theres nothing here but tweaks to code for loot and valid light checks. if it wasn't for an issue with mounted shooting and an abandoned interest in upping their dmg, the ranged attack method wouldn't even be here.

 

is there a chance this is due to an issue with an older forge? my 1.7.10 is a year old, i think.

Posted

Hm, the Forge version shouldn't affect it, no. Are you getting any interesting messages in your console log?

 

Are your skeleton aids stuck in the ground at all? I notice you don't really adjust the y position other than +1, but with the random x/z position, that may not be enough.

 

Otherwise, your spawn code looks pretty standard, especially if your entity is working as expected otherwise... I dunno, maybe show the code that calls the #wakeTheDamned method?

Posted

so, yeah. ID-10T issue.

 

the wakeTheDamned() method gives the skeletons a custom bow. the combat tasks method in EntitySkeleton only checks against Items.bow, so the aid has no ranged attack task. eliminating the appropriate line fixed everything, even if i have new stuff to deal with. :) I will most likely overwrite the combat task method to allow a check for the custom bow.

 

i was staring at it only yesterday and am kicking myself for not managing to put 2 and 2 together.

 

thanks for the troubleshooting.

Posted

Do note that in order to add AI tasks, you need to wait until after the entity has spawned in the world.  EntityLivingBase#tasks is null until then.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Do note that in order to add AI tasks, you need to wait until after the entity has spawned in the world.  EntityLivingBase#tasks is null until then.

 

EntityLiving#tasks

is initialised in the

EntityLiving

constructor, so you can add tasks in the constructor of your entity class (if you're spawning your own entity) or after the entity has been constructed (if you're spawning an existing entity with new AI tasks).

 

If you're dealing with entities being spawned from external code (e.g. vanilla or other mods), you can't add tasks in

EntityEvent.EntityConstructing

as it's called from the

Entity

constructor before the

EntityLiving

constructor has run. The first event fired after the

EntityLiving

constructor has run is

EntityJoinWorldEvent

, which is the earliest you can add tasks in this situation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.