Posted February 28, 201510 yr 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]
February 28, 201510 yr 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.
February 28, 201510 yr Author Which mod is that? [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
February 28, 201510 yr I have no idea how forge patches work but could something like that be put into a patch to allow the setting of fall speed? If so someone should do that.
February 28, 201510 yr Author I am idiot. I must look at galacticraft code and find the way he did gravity! To the github! And to find my grammer! [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 1, 201510 yr 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.
March 1, 201510 yr Author So what I have now is best? Okay. But is there any way for it to apply to all entities in the given range? [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 2, 201510 yr 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.
March 2, 201510 yr Author Okay, but the big thing is I'm getting all my player entities from the playerEntities list in world. There is no list for the others that I can see. [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 2, 201510 yr 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.
March 2, 201510 yr 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.
March 2, 201510 yr Author I found that literally the second after I posted that [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
March 3, 201510 yr 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/
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.