Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Mostly more glacier-style fixes.
Browse files Browse the repository at this point in the history
- found a missing break causing stone never to decay
- a thick snow cover will break down everything down to gravel, but
  not to dirt. Grass will still become dirt. This makes mountains
  that are covered with snow become gravel producers
- under snow degradation goes faster, but displacement stays behind
  a bit as it did before.
- lots of minor adjustments
  • Loading branch information
ahkok committed Dec 24, 2013
1 parent a4e5c27 commit 622c31a
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions src/org/foo_projects/sofar/Sedimentology/Sedimentology.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void sedRandomBlock() {
}

@SuppressWarnings("deprecation")
private void snow(int x, int y, int z) {
private int snow(int x, int y, int z) {
byte snowcount = 0;
int snowheight = 0;
int stackheight = 1;
Expand All @@ -408,23 +408,23 @@ private void snow(int x, int y, int z) {
if (top.getLightLevel() >= 12) {
/* melt is slower than snowfall */
if (Math.random() > 0.25)
return;
return stackheight;
if (top.getData() > 0) {
top.setData((byte)(top.getData() - 1));
} else {
top.setType(Material.AIR);
}
}
return;
return stackheight;
}

/* cold enough for snow accumulation? */
if (bottom.getTemperature() > 0.25)
return;
return stackheight;

/* don't stack snow on leaves and plants */
if (isCrushable(bottom.getRelative(BlockFace.DOWN)))
return;
return stackheight;

/* scan area for snow depth to even out snow height */
for (int xx = x - 1; xx <= x + 1; xx++) {
Expand All @@ -444,7 +444,7 @@ private void snow(int x, int y, int z) {

/* don't grow snow if there's no neighbour blocks with snow */
if (snowcount == 0)
return;
return stackheight;

/* snow stack? */
long maxstackheight = Math.max((y - 64) / 16, Math.round((0.25 - bottom.getTemperature()) / 0.9));
Expand All @@ -460,6 +460,8 @@ private void snow(int x, int y, int z) {
if ((((top.getY() - 1) * 8) + top.getData()) < avg + 2)
top.setData((byte)Math.min((int)top.getData() + 1, ((snowcount > 0) ? snowcount - 1 : 0)));
}

return stackheight;
}

public void sedBlock(int x, int z) {
Expand All @@ -468,6 +470,8 @@ public void sedBlock(int x, int z) {

int y;

int snowdepth = 0;

double hardness;
double resistance;
double waterfactor;
Expand All @@ -485,7 +489,7 @@ public void sedBlock(int x, int z) {
y = world.getHighestBlockYAt(x, z);
switch (world.getBlockAt(x, y, z).getType()) {
case SNOW:
snow(x, y, z);
snowdepth = snow(x, y, z);
undersnow = true;
break;
default:
Expand Down Expand Up @@ -565,6 +569,15 @@ public void sedBlock(int x, int z) {
return;
}

/*
* if under a significant snow cover, lower hardness drastically.
*
* There's no need to lower resistance, since that is the obvious result
* of lowering the hardness as the resulting block will be easier to move.
*/
if ((undersnow) && (snowdepth >= 2))
hardness = Math.pow(hardness, 1 / (snowdepth - 0.5));

/* lower overall chance due to lack of water */
stormfactor = 0.1;
if (world.hasStorm()) {
Expand Down Expand Up @@ -609,14 +622,6 @@ else if (underwater)
return;
}

/* a snow cover slows down things a bit */
if (undersnow) {
if (dice.roll(0.25)) {
stat_ignored_water++;
return;
}
}

/* slow down when deeper under the sealevel */
if (underwater) {
if (y < world.getSeaLevel()) {
Expand Down Expand Up @@ -730,6 +735,14 @@ else if (underwater)
return;
}

/* a snow cover slows down displacement */
if (undersnow) {
if (dice.roll(0.25)) {
stat_ignored_water++;
return;
}
}

/* roll to move it */
if (dice.roll(resistance)) {
stat_ignored_resistance++;
Expand Down Expand Up @@ -834,8 +847,6 @@ else if (underwater)

// degrade should factor in elevation?

//FIXME should detect the presence of ice near and factor in.

/*
* compensate for speed - this prevents at high block rates that
* everything just turns into a mudbath - We do want the occasional
Expand All @@ -848,6 +859,13 @@ else if (underwater)
}
}

/* do not decay gravel (and dirt, sand, etc.) further if under snow */
if ((b.getType() == Material.GRAVEL) && (undersnow)) {
stat_ignored_sand++;
return;
}


/* do not decay sand further unless in a wet Biome, and under water, and under sealevel */
if (b.getType() == Material.SAND) {
if (!(b.inClayBiome() && underwater && b.block.getY() < world.getSeaLevel())) {
Expand Down Expand Up @@ -906,8 +924,9 @@ else if (underwater)
break;
default:
b.setType(Material.COBBLESTONE);
break;
break; /* breaks inner switch only */
}
break;
case COAL_ORE:
case IRON_ORE:
case LAPIS_ORE:
Expand Down

0 comments on commit 622c31a

Please sign in to comment.