Posted June 24, 20178 yr 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) { } }
June 24, 20178 yr 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"
June 24, 20178 yr 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
June 24, 20178 yr 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.
June 24, 20178 yr 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.
June 24, 20178 yr Author i solved my own problem. It turns out i had to manually set the motion and position of my entity.
June 26, 20178 yr 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.