Jump to content

[1.7.10]How to add a property to every biome, vanilla or not


Recommended Posts

Posted

Hello everyone!!!I'm trying to make a mod that would allow the player to forecast the weather.

 

I added a Block that - when placed - writes to NBT the temperature and the humidity of the biome where the block is placed in. Now, I was able to get the temperature and the humidity of the biome but one of the factors of forecasting is Atmospheric Pressure. How can I add atmospheric pressure into Minecraft? I found the Temperature and the Humidity of the Biome from the BiomeGenBase class. How can I add to that class my variable with it's own methods (getters and setters) and make sure that every new world/chunk has that in? Is there any other better way to do it?

 

This is what I've got so far:

 

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/blocks/Station.java // The Weather Station block

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/blocks/te/StationTE.java // The Weather Station TileEntity

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/proxy/CommonProxy.java // Common Proxy, I register the TEs

 

 

Thanks guys, any help would be really appreciated.

 

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Posted

Thanks for your quick reply.

 

Does my class need to extend something? Where do I create the new instance of that class and in the end, where do I put the map? Sorry for my dumbness

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Posted

Then you create a new instance of that class for every biome and put it in the Map.

 

That's why I asked you where I create the instance, I mean in which class. I guess it would make sense to do it in the same class where the Map is.

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Posted

Ok, so something like this

 

biomesMap.put(new BiomeGenOcean(0), new Pressure());
biomesMap.put(new BiomeGenPlains(1), new Pressure());
biomesMap.put(new BiomeGenDesert(2), new Pressure());

 

just for all the biomes, right?

 

Here's Pressure

 

package com.gjkf.fc.weather;

import net.minecraft.world.biome.BiomeGenBase;

public class Pressure {

public float pressure;

public float getPressure(){
	return pressure;
}

public void setPressure(float temperature, float humidity){
	pressure = temperature * 25 + humidity * 100;
}

}

 

Am I doing it right? If so, how would I then be sure that that's actually working? If not, what am I doing wrong? I have never used Maps, I'm only 15.

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Posted

Thanks, I will look into maps, you are right about learning Java while modding isn't a good idea. I tried because I thought I had enough knowledge. Apparently I don't. Back to study then!!!

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Posted

I got it to work properly. Instead of doing what you suggested me, I used a double for the temperature, then I calculated the Atmospherical Pressure based on that. The temperature I choose is arbitrary, not related to the Minecraft one.

 

I have a last question:

What if there's Biomes O' Plenty installed along with my mod? I choose Biomes O' Plenty but I could choose any mod that add Biomes. How can I detect if there are another biomes a part of the Vanilla ones?

 

If you want code examples go here:

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/Main.java#L82-L119 //Main where the Map is

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/weather/Pressure.java#L39-L41 //The Pressure Class

https://github.com/gjkf/ForeCraft/blob/master/src/main/java/com/gjkf/fc/blocks/Station.java#L111-L117 //The Weather Station Block Class

 

Thanks for your huge help.

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

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.