From 792b5e2e4ac24d77a8c770f9ec7581ffe6120df0 Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Thu, 18 Jun 2015 03:02:51 +0100 Subject: [PATCH] De-obfuscate GenLayerRiver - unused at the moment, but considering using this to implement riverside biomes --- .../common/world/layer/GenLayerBOPRiver.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/biomesoplenty/common/world/layer/GenLayerBOPRiver.java diff --git a/src/main/java/biomesoplenty/common/world/layer/GenLayerBOPRiver.java b/src/main/java/biomesoplenty/common/world/layer/GenLayerBOPRiver.java new file mode 100644 index 000000000..6308948c2 --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/layer/GenLayerBOPRiver.java @@ -0,0 +1,53 @@ +package biomesoplenty.common.world.layer; + +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; + +public class GenLayerBOPRiver extends GenLayer +{ + public GenLayerBOPRiver(long p_i2128_1_, GenLayer p_i2128_3_) + { + super(p_i2128_1_); + super.parent = p_i2128_3_; + } + + @Override + public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight) + { + int areaX_ = areaX - 1; + int areaY_ = areaY - 1; + int areaWidth_ = areaWidth + 2; + int areaHeight_ = areaHeight + 2; + int[] parentVals = this.parent.getInts(areaX_, areaY_, areaWidth_, areaHeight_); + int[] out = IntCache.getIntCache(areaWidth * areaHeight); + + for (int y = 0; y < areaHeight; ++y) + { + for (int x = 0; x < areaWidth; ++x) + { + int westVal = this.mod2(parentVals[x + 0 + (y + 1) * areaWidth_]); + int eastVal = this.mod2(parentVals[x + 2 + (y + 1) * areaWidth_]); + int northVal = this.mod2(parentVals[x + 1 + (y + 0) * areaWidth_]); + int southVal = this.mod2(parentVals[x + 1 + (y + 2) * areaWidth_]); + int val = this.mod2(parentVals[x + 1 + (y + 1) * areaWidth_]); + + if (val == westVal && val == northVal && val == eastVal && val == southVal) + { + out[x + y * areaWidth] = -1; + } + else + { + out[x + y * areaWidth] = BiomeGenBase.river.biomeID; + } + } + } + + return out; + } + + private int mod2(int a) + { + return a >= 2 ? 2 + (a & 1) : a; + } +} \ No newline at end of file