Posted June 11, 201510 yr 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!!
June 11, 201510 yr 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/
June 11, 201510 yr Author It does need to hit a block.. How exactly do I cauculate the block under the entity? Im serious don't look at it!!
June 11, 201510 yr Author also does anybody know how I can increase the amount of damage done to an entity by a lightning bolt Im serious don't look at it!!
June 11, 201510 yr Gettting the block under an entity is simple math.. Take The actual Position of the entity and go down until you find an entity To increase The dmg of a lightning Bild use entityHurt
June 11, 201510 yr Author 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!!
June 12, 201510 yr Author there isn't event.ammount in 1.7.10. anymore help? Im serious don't look at it!!
June 12, 201510 yr 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); } } }
June 12, 201510 yr 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/
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.