Posted April 21, 201510 yr Hi, i created a weapon firing multiple rockets in a row. But, since they explode, the later rockets are misdirected by the explosion. I assume it has something to do with knockback but I couldn't find where I set the resistance to it. Or maybe it can be done with something else. Any help is appreciated. EDIT: It seems to be a problem with getGravityVelocity() returning 0. With a very small value (0.005) the rockets are no longer affected by the explosion (or I cant see it). Still, if someone ones why this happens would be great. McRaichu It doesn't work, I don't know why. It works, I don't know why.
April 22, 201510 yr Could I see your code for your rocket entity? If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.
April 22, 201510 yr Author here you go: package net.McRaichu.LittleWalker.weapons; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityRocket extends EntityThrowable { float explosionRadius; public float speed; private byte damage; int ticksAlive = 0; private void initRocket() { explosionRadius = 1.5F; speed = 1.0F; damage = 10; setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, 1.0F); } public EntityRocket(World par1World) { super(par1World); initRocket(); } public EntityRocket(World par1World, EntityLivingBase entity) { super(par1World, entity); initRocket(); } public EntityRocket(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); initRocket(); } public EntityRocket(World par1World, EntityLivingBase entity, double par7, double par8, double par9) { super(par1World, entity); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * par7); this.posY -= par8; this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * par9); this.setPosition(this.posX, this.posY, this.posZ); initRocket(); } @Override protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if(par1MovingObjectPosition.entityHit != null){ if (this.getThrower().ridingEntity == par1MovingObjectPosition.entityHit) { return; } par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage); } this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, true); this.setDead(); } @Override protected float getGravityVelocity() { return 0.0005F; } @Override public void onUpdate() { super.onUpdate(); ticksAlive++; if(ticksAlive > 200) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, true); setDead(); } if(worldObj.isRemote) { for(int i = 0; i < 4; i++) { worldObj.spawnParticle("smoke", posX, posY, posZ + motionZ, -motionX, -motionY , -motionZ); } } } } It doesn't work, I don't know why. It works, I don't know why.
April 22, 201510 yr Your problem, is that the gravity system in EntityThrowable behaves like that naturally, in order to get your rockets to behave in the manner you speak of, you will need to create a custom entity that implements IProjectile. (At least I think, if someone more experienced says otherwise, than ignore what I am saying, I don't do much with entities ) If I ever say something stupid, or simply incorrect, please excuse me. I don't know anything about 1.8 modding, and I don't know much about entities either, But I try to help when I can.
April 23, 201510 yr To prevent your rockets from being affected by the explosion of other rockets, you simply need to handle the ExplosionEvent.Detonate event. In that event a list is passed in as a parameter that contains all entities that are in range of the explosion. You can simply remove your rockets from the list (if any are there) and they won't be affected. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
April 23, 201510 yr To prevent your rockets from being affected by the explosion of other rockets, you simply need to handle the ExplosionEvent.Detonate event. In that event a list is passed in as a parameter that contains all entities that are in range of the explosion. You can simply remove your rockets from the list (if any are there) and they won't be affected. I thought the Explosion Events were added recently to Forge for 1.8. If that's accurate, it won't help for 1.7.10.
April 23, 201510 yr To prevent your rockets from being affected by the explosion of other rockets, you simply need to handle the ExplosionEvent.Detonate event. In that event a list is passed in as a parameter that contains all entities that are in range of the explosion. You can simply remove your rockets from the list (if any are there) and they won't be affected. I thought the Explosion Events were added recently to Forge for 1.8. If that's accurate, it won't help for 1.7.10. It was also added to 1.7.10 but you need to update your forge to 1299 or later. They are still updating Forge for 1.7.10. They're up to 1389 now... 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.