Jump to content

Best way to manipulate gravity?


KeeganDeathman

Recommended Posts

I am trying to perfect my mod's Gravity Manipulator block. Currently, every tick it adds the negative of a value typed into the GUI to every player's y-velocity within 25 blocks in all directions.

I feel like there's a better way to do this. I think I'll make it every second instead, by tracking how many times the updateEntity method is called, and when it's 20 or whatever, reset it and do the velocity adding ONLY then.

But there's has also got to be a better way to change gravity, one that could affect all entities in the space.

Any ideas?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Link to comment
Share on other sites

No.. If you saw the 'Gravitation Code' for entity, it is just a one line of hard-coding:

  this.motionY+=0.2353455252...

So it is really pity that there is really no way to change gravity with any ease.

(It is more because gravitation manipulation is one of the core concepts of my mod.. :< )

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

The way he did is,

  1. Just hook into player and change gravity. It is much easier than changing entity gravity.

  2. Register substitution mobs which has less gravity value,

          and make Overworld Mobs can't spawn/live in the dimension. (like Moon with no air..)

 

So.. it would be kinda depressing;

 

I think your first way would be the best.

 

& To 61352151511 : patching them all would be impossibly hard, since there is too much hard-coded entities..

 

EDIT: Galacticraft seems to do the patches, too. (Using MicdoodleCore, maybe.)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

So what I have now is best? Okay. But is there any way for it to apply to all entities in the given range?

Yes, but only for vanilla (or compatible) entities.

1. Hard-coded Patching to every entity type would work for all vanilla entities.

2. Save default gravity acceleration for each entities, and modify its motionY value based on the information on each tick.

 

So. What you have should be the best.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

So what is your problem..? Do you want to change gravitation of other entities, too?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Every world has list of ALL entities. For server there is just no getter for it. For client (there is SideOnly annotation there) there is World#getLoadedEntityList() (might not be the exact name). Field is public so you can use it.

 

List contains all loaded entities for given world, that is Entity - so consider that you will also get stuff like EntityItem.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

You don't have to look at the list of all entities in the world.  World already has a method called getEntitiesWithinAABBExcludingEntity() that gets only the entities in region you specify.

 

And regarding the original question, why are you looking for a "better" way.  Your way is already as simple as it can be -- some code is going to have to execute and modify the motionY for all the entities, so you can't get around that.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.