mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Add temperature(includes deserts and snowy regions)
This commit is contained in:
parent
82060307bf
commit
c8fc68ec0f
BIN
cubyz-client/res/textures/blocks/snow.png
Normal file
BIN
cubyz-client/res/textures/blocks/snow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
@ -16,6 +16,7 @@ import io.cubyz.blocks.OakLeaves;
|
|||||||
import io.cubyz.blocks.OakLog;
|
import io.cubyz.blocks.OakLog;
|
||||||
import io.cubyz.blocks.RubyOre;
|
import io.cubyz.blocks.RubyOre;
|
||||||
import io.cubyz.blocks.Sand;
|
import io.cubyz.blocks.Sand;
|
||||||
|
import io.cubyz.blocks.SnowGrass;
|
||||||
import io.cubyz.blocks.Stone;
|
import io.cubyz.blocks.Stone;
|
||||||
import io.cubyz.blocks.Water;
|
import io.cubyz.blocks.Water;
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ public class BaseMod {
|
|||||||
static OakLeaves oakLeaves;
|
static OakLeaves oakLeaves;
|
||||||
static OakLog oakLog;
|
static OakLog oakLog;
|
||||||
static Sand sand;
|
static Sand sand;
|
||||||
|
static SnowGrass snow;
|
||||||
static Stone stone;
|
static Stone stone;
|
||||||
|
|
||||||
// Ores:
|
// Ores:
|
||||||
@ -61,6 +63,7 @@ public class BaseMod {
|
|||||||
oakLeaves = new OakLeaves();
|
oakLeaves = new OakLeaves();
|
||||||
oakLog = new OakLog();
|
oakLog = new OakLog();
|
||||||
sand = new Sand();
|
sand = new Sand();
|
||||||
|
snow = new SnowGrass();
|
||||||
stone = new Stone();
|
stone = new Stone();
|
||||||
|
|
||||||
// Ores
|
// Ores
|
||||||
@ -76,8 +79,7 @@ public class BaseMod {
|
|||||||
water = new Water();
|
water = new Water();
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
reg.registerAll(bedrock, grass, dirt, oakLeaves, oakLog, sand, stone, coal, diamond, emerald, gold, iron, ruby, water);
|
reg.registerAll(bedrock, grass, dirt, oakLeaves, oakLog, sand, snow, stone, coal, diamond, emerald, gold, iron, ruby, water);
|
||||||
System.out.println("Added all");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
11
cubyz-common/src/io/cubyz/blocks/SnowGrass.java
Normal file
11
cubyz-common/src/io/cubyz/blocks/SnowGrass.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package io.cubyz.blocks;
|
||||||
|
|
||||||
|
public class SnowGrass extends Block {
|
||||||
|
|
||||||
|
public SnowGrass() {
|
||||||
|
setTexture("snow");
|
||||||
|
setID("cubyz:snow");
|
||||||
|
texConverted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,6 +24,7 @@ public class Chunk {
|
|||||||
// Normal:
|
// Normal:
|
||||||
private static Block grass = br.getByID("cubyz:grass");
|
private static Block grass = br.getByID("cubyz:grass");
|
||||||
private static Block sand = br.getByID("cubyz:sand");
|
private static Block sand = br.getByID("cubyz:sand");
|
||||||
|
private static Block snow = br.getByID("cubyz:snow");
|
||||||
private static Block dirt = br.getByID("cubyz:dirt");
|
private static Block dirt = br.getByID("cubyz:dirt");
|
||||||
private static Block stone = br.getByID("cubyz:stone");
|
private static Block stone = br.getByID("cubyz:stone");
|
||||||
private static Block bedrock = br.getByID("cubyz:bedrock");
|
private static Block bedrock = br.getByID("cubyz:bedrock");
|
||||||
@ -144,7 +145,7 @@ public class Chunk {
|
|||||||
//TODO: Ore Clusters
|
//TODO: Ore Clusters
|
||||||
//TODO: Finish vegetation
|
//TODO: Finish vegetation
|
||||||
//TODO: Clean this method
|
//TODO: Clean this method
|
||||||
public void generateFrom(float[][] map, float[][] vegetation, float[][] oreMap) {
|
public void generateFrom(float[][] map, float[][] vegetation, float[][] oreMap, float[][] heatMap) {
|
||||||
if(inst == null) {
|
if(inst == null) {
|
||||||
inst = new BlockInstance[16][World.WORLD_HEIGHT][16];
|
inst = new BlockInstance[16][World.WORLD_HEIGHT][16];
|
||||||
}
|
}
|
||||||
@ -158,14 +159,19 @@ public class Chunk {
|
|||||||
int y = (int) (value * World.WORLD_HEIGHT);
|
int y = (int) (value * World.WORLD_HEIGHT);
|
||||||
if(y == World.WORLD_HEIGHT)
|
if(y == World.WORLD_HEIGHT)
|
||||||
y--;
|
y--;
|
||||||
|
int temperature = (int)((2-value+SEA_LEVEL/(float)World.WORLD_HEIGHT)*heatMap[px][py]*120) - 100;
|
||||||
for (int j = y > SEA_LEVEL ? y : SEA_LEVEL; j >= 0; j--) {
|
for (int j = y > SEA_LEVEL ? y : SEA_LEVEL; j >= 0; j--) {
|
||||||
BlockInstance bi = null;
|
BlockInstance bi = null;
|
||||||
if(j > y) {
|
if(j > y) {
|
||||||
bi = new BlockInstance(water);
|
bi = new BlockInstance(water);
|
||||||
}else if (y < SEA_LEVEL + 4 && j > y - 3) {
|
}else if ((y < SEA_LEVEL + 4 || temperature > 40) && j > y - 3) {
|
||||||
bi = new BlockInstance(sand);
|
bi = new BlockInstance(sand);
|
||||||
} else if (j == y) {
|
} else if (j == y) {
|
||||||
bi = new BlockInstance(grass);
|
if(temperature > 0) {
|
||||||
|
bi = new BlockInstance(grass);
|
||||||
|
} else {
|
||||||
|
bi = new BlockInstance(snow);
|
||||||
|
}
|
||||||
} else if (j > y - 3) {
|
} else if (j > y - 3) {
|
||||||
bi = new BlockInstance(dirt);
|
bi = new BlockInstance(dirt);
|
||||||
} else if (j > 0) {
|
} else if (j > 0) {
|
||||||
@ -196,7 +202,8 @@ public class Chunk {
|
|||||||
float value = vegetation[px][py];
|
float value = vegetation[px][py];
|
||||||
int incx = px == 0 ? 1 : -1;
|
int incx = px == 0 ? 1 : -1;
|
||||||
int incy = py == 0 ? 1 : -1;
|
int incy = py == 0 ? 1 : -1;
|
||||||
if (map[px][py] * World.WORLD_HEIGHT >= SEA_LEVEL + 3 && value > 0.5f && ((int)((vegetation[px][py]-vegetation[px+incx][py+incy]) * 10000000) & 127) == 1) { // "&127" is a faster way to do "%128"
|
int temperature = (int)((2-map[px][py]+SEA_LEVEL/(float)World.WORLD_HEIGHT)*heatMap[px][py]*120) - 100;
|
||||||
|
if (temperature < 40 && map[px][py] * World.WORLD_HEIGHT >= SEA_LEVEL + 3 && value > 0.5f && ((int)((vegetation[px][py]-vegetation[px+incx][py+incy]) * 100000000) & 63) == 1) { // "&(2^n - 1)" is a faster way to do "%(2^n)"
|
||||||
Structures.generateTree(this, wx + px, (int) (map[px][py] * World.WORLD_HEIGHT) + 1, wy + py);
|
Structures.generateTree(this, wx + px, (int) (map[px][py] * World.WORLD_HEIGHT) + 1, wy + py);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,8 @@ public class LocalWorld extends World {
|
|||||||
float[][] heightMap = Noise.generateMapFragment(x, y, 16, 16, 256, seed);
|
float[][] heightMap = Noise.generateMapFragment(x, y, 16, 16, 256, seed);
|
||||||
float[][] vegetationMap = Noise.generateMapFragment(x, y, 16, 16, 128, seed + 3 * (seed + 1 & Integer.MAX_VALUE));
|
float[][] vegetationMap = Noise.generateMapFragment(x, y, 16, 16, 128, seed + 3 * (seed + 1 & Integer.MAX_VALUE));
|
||||||
float[][] oreMap = Noise.generateMapFragment(x, y, 16, 16, 128, seed - 3 * (seed - 1 & Integer.MAX_VALUE));
|
float[][] oreMap = Noise.generateMapFragment(x, y, 16, 16, 128, seed - 3 * (seed - 1 & Integer.MAX_VALUE));
|
||||||
ch.generateFrom(heightMap, vegetationMap, oreMap);
|
float[][] heatMap = Noise.generateMapFragment(x, y, 16, 16, 4096, seed ^ 123456789);
|
||||||
|
ch.generateFrom(heightMap, vegetationMap, oreMap, heatMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -248,10 +249,10 @@ public class LocalWorld extends World {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seek(int x, int z) {
|
public void seek(int x, int z) {
|
||||||
int renderDistance/*minus 1*/ = 2;
|
int renderDistance/*minus 1*/ = 3;
|
||||||
int blockDistance = renderDistance*16;
|
int blockDistance = renderDistance*16;
|
||||||
for (int x1 = x - blockDistance-48; x1 < x + blockDistance+48; x1++) {
|
for (int x1 = x - blockDistance-48; x1 <= x + blockDistance+48; x1 += 16) {
|
||||||
for (int z1 = z - blockDistance-48; z1 < z + blockDistance+48; z1++) {
|
for (int z1 = z - blockDistance-48; z1 <= z + blockDistance+48; z1 += 16) {
|
||||||
Chunk ch = getChunk(x1/16,z1/16);
|
Chunk ch = getChunk(x1/16,z1/16);
|
||||||
if (x1>x-blockDistance&&x1<x+blockDistance&&z1>z-blockDistance&&z1<z+blockDistance && !ch.isLoaded()) {
|
if (x1>x-blockDistance&&x1<x+blockDistance&&z1>z-blockDistance&&z1<z+blockDistance && !ch.isLoaded()) {
|
||||||
if (!ch.isGenerated()) {
|
if (!ch.isGenerated()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user