Jump to content

[1.7.10] how to load non vanilla chunks


Recommended Posts

I have a mod where for each chunk there are a set of variables that go with it, i.e surfaceTemp, absolute humidity, water exposed to sun ect. It would be silly and inefficient to add these to the chunk class itself through a core-mod  so i made my own class that is very small and just hold those vars for a particular coordinates.

package src.IVWeather.util;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.Chunk;
import src.IVWeather.entity.*;

public class IVChunkDefinition{

public int positionX;
public int positionZ;
public float surfaceTemp;
public float absoluteHumidity;
public float relativeHumidity;
public int exposedWSurface;
public double exposedDirectSunlight;
public double evaporationRate;
public Chunk chunk;
private boolean[] canSeeArray = new boolean[4096];
public float kilogramsOfWater;
public boolean needUpdate;
private int ID;

public IVChunkDefinition() {


public IVChunkDefinition(int x, int z) {
	positionX = x;
	positionZ = z;

BiomeGenBase bgb;
private double evaporationTick;

public boolean[] getCanSeeArray() {
	return canSeeArray;

private float biomeDefaultRHumidity(BiomeGenBase biome) {
	if(biome instanceof BiomeGenDesert | biome instanceof BiomeGenSnow | biome instanceof BiomeGenMesa) {
		return 25f;
	}else if(biome instanceof BiomeGenForest){
		return 75;
	}else if(biome instanceof BiomeGenPlains){
		return 75;
	}else if(biome instanceof BiomeGenJungle){
		return 90;
	}else if(biome instanceof BiomeGenTaiga){
		return 50;
	}else if(biome instanceof BiomeGenHills){
		return 70;
	}else if(biome instanceof BiomeGenRiver |  biome instanceof BiomeGenOcean |  biome instanceof BiomeGenBeach){
		return 90;
	}else if(biome instanceof BiomeGenSavanna){
		return 50;
		return 75;		

public boolean check(World world, Chunk chunk) {
	this.chunk = chunk;
	int y = chunk.getTopFilledSegment();
		for(int f = 1; f < 16; f++) {
			for(int z = 1; z < 16; z++) {
				for(int y2 = 1; y2 < y; y2++) {
					if(chunk.canBlockSeeTheSky(f, y2, z)) {
						if(chunk.getBlock(f, y2, z) == Blocks.water) {
							this.canSeeArray[f * y2 * z] = true;
						if(chunk.getBlock(f, y2, z) == null) {
							return false;
		return true;

public double updateWaterValue(BiomeGenBase bgb, int timeSinceRain, boolean isDayTime, Block topblock, float airTemp) {
	if(bgb == BiomeGenBase.ocean) {
		return 100;
	}else if(timeSinceRain <= 0){
		return 100;
	}else if(isDayTime == true){
		double pws = BiomeTemperature.maxSaturationPressureWV(this.surfaceTemp); 
		double Xs = BiomeTemperature.ratioOfTheComplexHumidityThing((5f/9f) * (this.surfaceTemp - 32f) + 273f);
		double X = kilogramsOfWater / (1.293 - kilogramsOfWater);
		double O;
		List listlist = new ArrayList();
		if(isEntityPresent(listlist)) {
			for(int u = 0; u < listlist.size(); u++) {
				EntityWeatherParcel ewp = (EntityWeatherParcel) listlist.get(u);
				O = ewp.getVelocity() * 20;
				this.evaporationRate = (O * this.exposedWSurface) * (Xs - X);

			this.evaporationRate = this.exposedWSurface * (Xs - X);
		this.evaporationTick = (this.evaporationRate / Math.pow(60, 2)) / 20;

		return this.evaporationTick;

	return 0;

public boolean isEntityPresent(List par3list) {
	boolean istrue = false; 
    for (int k = 0; k <= 16; k++) {
    	List list1 = this.chunk.entityLists[k];
    	for (int l = 0; l < list1.size(); l++)
          Entity entity1 = (Entity)list1.get(l);
          if(entity1 instanceof EntityWeatherParcel) {
        	  istrue = true;
    return istrue;



How would i go about getting the chunks from their coordinates? I tried to look in vanilla decompilations for answers but it just had some interface and a blank method for creating one and i looked in many other related classes with no avail. I you know how to do this, I would appreciate your help, Thanks.

Link to comment
Share on other sites

ChunkEvent and ChunkDataEvent. You get access to the chunk's nbt data so you can store and retrieve any custom data you'd like.


Note that chunks are saved and loaded on separate threads, so if you're using any data structures (e.g. HashMap) you will need to make it concurrent.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

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.

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.