Jump to content

Entity Doesn't Obey Gravity


drok0920

Recommended Posts

Hello

I have created a projectile that that needs to obey gravity.  I have made sure that i call this.setNoGravity(false); in the constructor.   How ever it doesnt obey gravity.  Here is my current code:

 

package com.drok.progressiveg.entity.projectile;

import com.drok.progressiveg.GunMod;

import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IThrowableEntity;

public class EntityLeadBullet extends Entity implements IThrowableEntity {

	
	public EntityLeadBullet(World worldIn) {
		super(worldIn);
		this.setSize(0.5F, 0.5F);
		this.setNoGravity(false);
	}

	@Override
	protected void entityInit() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void readEntityFromNBT(NBTTagCompound compound) {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void writeEntityToNBT(NBTTagCompound compound) {
		// TODO Auto-generated method stub
		
	}
	
	protected void onHit(RayTraceResult raytraceResultIn)
    {
    }
	
	@Override
	public void onUpdate()
    {
		super.onUpdate();
		GunMod.log("onUpdate");
		
    }

	@Override
	public Entity getThrower() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setThrower(Entity entity) {
	
	}

}

 

Link to comment
Share on other sites

I don't know much about Minecraft programming but I am a reasonably good programmer (smiple, high-level multiclass game from relative scratch).

Therefore, my humble suggestion: You did not put obeysgravity as a parameter anywhere in the consructor. So perhaps it's just that it doesn't personally have any gravity settings, only the class itself (this) does. It would also be helpful if you included the Entity class (we know virtually nothing about the setNoGravity variable otherwise.

Thanks!

Fritz

"The Hydræfall"

Link to comment
Share on other sites

Just now, hydraefall said:

I don't know much about Minecraft programming but I am a reasonably good programmer (smiple, high-level multiclass game from relative scratch).

Therefore, my humble suggestion: You did not put obeysgravity as a parameter anywhere in the consructor. So perhaps it's just that it doesn't personally have any gravity settings, only the class itself (this) does. It would also be helpful if you included the Entity class (we know virtually nothing about the setNoGravity variable otherwise.

Thanks!

Fritz

"The Hydræfall"

I have set it to obey gravity by calling

this.setNoGravity(false);

And i have provided my Entity class

Link to comment
Share on other sites

13 minutes ago, hydraefall said:

Yeah no I meant the Entity class that EntityLeadBullet was extended from, not EntityLeadBullet itself.

If you are making a mod then you should have access to the Entity class.  If your not making a mod then i do not believe this is a section for you although i do appreciate you trying to help.

  • Like 1
Link to comment
Share on other sites

On 6/24/2017 at 10:03 AM, drok0920 said:

If you are making a mod then you should have access to the Entity class.  If your not making a mod then i do not believe this is a section for you although i do appreciate you trying to help.

You're right, and thanks for the politeness. I'm super interested in modding tho. Congrats on the fix!

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