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

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) {
	
	}

}

 

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"

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

1 minute ago, drok0920 said:

I have set it to obey gravity by calling


this.setNoGravity(false);

And i have provided my Entity class

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

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

  • Author

i solved my own problem.  It turns out i had to manually set the motion and position of my entity.

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!

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.