Jump to content

[1.12] Projectile not registering collisions at short range


blfngl

Recommended Posts

Exactly the title. I've got this projectile (EntityThrowable extension) that's not registering collisions at point-blank range, but if the player fires it approximately 5-6 blocks away hits register perfectly fine.

 

Projectile:

Spoiler

public class EntityBullet extends EntityThrowable
{
	private float damage;

	public EntityBullet(World worldIn)
	{
		super(worldIn);
	}

	public EntityBullet(World worldIn, EntityLivingBase throwerIn, float damage)
	{
		super(worldIn, throwerIn);
		this.damage = damage;
	}

	public EntityBullet(World worldIn, double x, double y, double z)
	{
		super(worldIn, x, y, z);
	}


	// Spawns impact particles
	@SideOnly(Side.CLIENT)
	public void handleStatusUpdate(byte id)
	{
		if (id == 3)
			for (int i = 0; i < 8; ++i)
				this.world.spawnParticle(EnumParticleTypes.CRIT, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);

	}

	/**
	 * Called when this EntityThrowable hits a block or entity.
	 */
	@Override
	protected void onImpact(RayTraceResult result)
	{
		if (result.entityHit != null)
			result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);

		if (!this.world.isRemote)
		{
			// Make it so that particles will spawn on impact
			this.world.setEntityState(this, (byte) 3);
			this.setDead();
		}
	}

	@Override
	protected float getGravityVelocity()
	{
		return 0.0f;
	}
}

 

 

Registry:

Spoiler

EntityRegistry.registerModEntity(new ResourceLocation(Reference.MODID + ":textures/entity/projectile/bullet.png"),
			EntityBullet.class, "entityBullet", id++, Fallout.instance, 64, 1, false);

 

 

Any ideas how to fix this?

Link to comment
Share on other sites

Sorry, here's the shoot method, where bulletSpeed is 7.0f:

 

if (!world.isRemote)
{
	EntityBullet bullet = new EntityBullet(world, player, damage);
	bullet.shoot(player, player.rotationPitch, player.rotationYaw, 0.0f, bulletSpeed, 1.0f);
	world.spawnEntity(bullet);
}

 

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.



×
×
  • Create New...

Important Information

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