Jump to content

Lightning striking entity [1.7.10]


Recommended Posts

I made an entity that strikes a large amount of lightning. problem is, when ever the entity makes contact with an entity it doesn't render on the screen. it only renders when it hits a block. how should I fix this. here is the code.

 

package com.OlympiansMod.entity;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityMasterBolt extends EntityThrowable{

public EntityMasterBolt(World p_i1776_1_) {
	super(p_i1776_1_);
}
public EntityMasterBolt(World world, EntityLivingBase entity){
	super(world, entity);


}
@Override
protected void onImpact(MovingObjectPosition p_70184_1_) {
	    for(int i = 0; i < 25; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.setDead();
		EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
		undead.setPosition(this.posX, this.posY, this.posZ);
		worldObj.spawnEntityInWorld(undead);





	  }

	if (!this.worldObj.isRemote){
		this.setDead();
		//his.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 3.0f, true);

	}


	}
}







Im serious don't look at it!!

Link to comment
Share on other sites

I wonder if the lightning bolt needs to hit a block. So maybe you should spawn it at the position under the entity that was hit. You can get entityHit from the moving object position, then calculate the block below the entity position. Note that depending on which version you're using the math might be different because I think in 1.7.10 and earlier that on the server side the position doesn't take account the eye height.

 

Anyway, that's the only thing I can think of as otherwise it looks correct to me.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

how do I specifically set the damage for the lightning not the entityThrowable?

 

if(Pos.entityHit != null)
	       {
	          byte b0 = 100;
	           if (Pos.entityHit instanceof EntityLightningBolt)
	           {
	               b0 = 100;
	           }

		Pos.entityHit.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, this.getThrower()), b0);
	       

Im serious don't look at it!!

Link to comment
Share on other sites

Try this:

 

@Override
protected void onImpact(MovingObjectPosition mop) {
	    for(int i = 0; i < 25; i++){
		this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0f, 0f, 0f);
		this.setDead();


                        if (mop.entityHit == null){
                            EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
		    undead.setPosition(this.posX, this.posY, this.posZ);
		    worldObj.spawnEntityInWorld(undead);
                        } else {
                            EntityLightningBolt undead = new EntityLightningBolt(worldObj, 10, 10, 10);
                            undead.setPosition(this.posX, this.posY - 1, this.posZ);
                            worldObj.spawnEntityInWorld(undead);
                        }





	  }

	if (!this.worldObj.isRemote){
		this.setDead();
		//his.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 3.0f, true);

	}


	}
}

Link to comment
Share on other sites

there isn't event.ammount in 1.7.10. anymore help?

 

There is an EntityStruckByLightningEvent. it will give the entity struck. You can then cause more damage to the entity using methods for attacking the entity (check out how lightning normally applies it).

 

I think you could also use the EntityHurtEvent and check if damage source is lightning and if so you could increase the damage.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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