Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • 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.

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 :P)

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.

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/

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.