diff --git a/.gitignore b/.gitignore
index c449f83..fb4ec25 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
/.checkstyle
/.classpath
/.project
+IslandCraft-NMS-v1_8_R1/bin/
diff --git a/IslandCraft-Api/pom.xml b/IslandCraft-Api/pom.xml
index 7b7738d..137bbfb 100644
--- a/IslandCraft-Api/pom.xml
+++ b/IslandCraft-Api/pom.xml
@@ -3,7 +3,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-Api
\ No newline at end of file
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java b/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
index bb6a00a..d742921 100644
--- a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
+++ b/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICIsland.java
@@ -51,6 +51,28 @@ public interface ICIsland {
*/
ICBiome getBiomeAt(int relativeX, int relativeZ);
+ /**
+ * Returns the biomes for a whole chunk.
+ *
+ * @param relativeLocation
+ * location of the chunk relative to the island
+ * @return an ICBiome[16 * 16] containing the biomes for the whole chunk
+ * such that each element is at index [x + z * 16]
+ */
+ ICBiome[] getBiomeChunk(ICLocation relativeLocation);
+
+ /**
+ * Returns the biomes for a whole chunk.
+ *
+ * @param relativeX
+ * location of the chunk relative to the island
+ * @param relativeZ
+ * location of the chunk relative to the island
+ * @return an ICBiome[16 * 16] containing the biomes for the whole chunk
+ * such that each element is at index [x + z * 16]
+ */
+ ICBiome[] getBiomeChunk(int relativeX, int relativeZ);
+
/**
* Returns the biomes for the whole island.
*
diff --git a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java b/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
index e65559d..e024473 100644
--- a/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
+++ b/IslandCraft-Api/src/main/java/com/github/hoqhuuep/islandcraft/api/ICWorld.java
@@ -39,6 +39,28 @@ public interface ICWorld {
*/
ICBiome getBiomeAt(int x, int z);
+ /**
+ * Returns the biomes for a whole chunk.
+ *
+ * @param location
+ * location of the chunk in the world
+ * @return an ICBiome[16 * 16] containing the biomes for the whole chunk
+ * such that each element is at index [x + z * 16]
+ */
+ ICBiome[] getBiomeChunk(ICLocation location);
+
+ /**
+ * Returns the biomes for a whole chunk.
+ *
+ * @param x
+ * location of the chunk in the world (measured in blocks)
+ * @param z
+ * location of the chunk in the world (measured in blocks)
+ * @return an ICBiome[16 * 16] containing the biomes for the whole chunk
+ * such that each element is at index [x + z * 16]
+ */
+ ICBiome[] getBiomeChunk(int x, int z);
+
/**
* Returns the island whose inner-region contains the given location.
*
diff --git a/IslandCraft-Core/dependency-reduced-pom.xml b/IslandCraft-Core/dependency-reduced-pom.xml
index aa4fba6..0175584 100644
--- a/IslandCraft-Core/dependency-reduced-pom.xml
+++ b/IslandCraft-Core/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
IslandCraft
com.github.hoqhuuep
- 1.0.0
+ 1.0.1
4.0.0
IslandCraft-Core
@@ -26,6 +26,7 @@
org.mcstats.*:*
com.github.hoqhuuep:IslandCraft-Api
com.github.hoqhuuep:IslandCraft-NMS*
+ com.google*:*
@@ -33,6 +34,10 @@
org.mcstats
com.github.hoqhuuep.islandcraft.mcstats
+
+ com.google
+ com.github.hoqhuuep.islandcraft.google
+
@@ -40,24 +45,12 @@
maven-jar-plugin
2.3.2
- IslandCraft-1.0.0
+ IslandCraft-1.0.1
-
- com.google.guava
- guava
- 10.0.1
- provided
-
-
- jsr305
- com.google.code.findbugs
-
-
-
commons-lang
commons-lang
diff --git a/IslandCraft-Core/pom.xml b/IslandCraft-Core/pom.xml
index fa12235..b5fc04b 100644
--- a/IslandCraft-Core/pom.xml
+++ b/IslandCraft-Core/pom.xml
@@ -4,75 +4,91 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-Core
+
+ com.google.guava
+ guava
+ 10.0.1
+ compile
+
com.github.hoqhuuep
IslandCraft-Api
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
+
+
+ com.github.hoqhuuep
+ IslandCraft-NMS-v1_8_R2
+ 1.0.1
+
+
+ com.github.hoqhuuep
+ IslandCraft-NMS-v1_8_R1
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_7_R4
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_7_R3
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_7_R2
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_7_R1
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_6_R3
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_6_R2
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_6_R1
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_5_R3
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_5_R2
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_5_R1
- 1.0.0
+ 1.0.1
com.github.hoqhuuep
IslandCraft-NMS-v1_4_R1
- 1.0.0
+ 1.0.1
@@ -88,6 +104,7 @@
org.mcstats.*:*
com.github.hoqhuuep:IslandCraft-Api
com.github.hoqhuuep:IslandCraft-NMS*
+ com.google*:*
@@ -95,6 +112,10 @@
org.mcstats
com.github.hoqhuuep.islandcraft.mcstats
+
+ com.google
+ com.github.hoqhuuep.islandcraft.google
+
@@ -111,7 +132,7 @@
maven-jar-plugin
2.3.2
- IslandCraft-1.0.0
+ IslandCraft-1.0.1
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
index 853f7ea..4ed3d31 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/bukkit/IslandCraftBiomeGenerator.java
@@ -1,5 +1,7 @@
package com.github.hoqhuuep.islandcraft.bukkit;
+import java.util.Arrays;
+
import com.github.hoqhuuep.islandcraft.api.ICBiome;
import com.github.hoqhuuep.islandcraft.api.ICWorld;
import com.github.hoqhuuep.islandcraft.core.ICLogger;
@@ -23,4 +25,23 @@ public ICBiome generateBiome(final int x, final int z) {
return ICBiome.DEEP_OCEAN;
}
}
+
+ @Override
+ public ICBiome[] generateChunkBiomes(final int x, final int z) {
+ try {
+ return world.getBiomeChunk(x, z);
+ } catch (final Exception e) {
+ ICLogger.logger.warning(String.format("Error generating biomes for chunk with x: %d, z: %d", x, z));
+ ICLogger.logger.warning("Default biome 'DEEP_OCEAN' used instead");
+ ICLogger.logger.warning("Exception message: " + e.getMessage());
+ final ICBiome[] result = new ICBiome[256];
+ Arrays.fill(result, ICBiome.DEEP_OCEAN);
+ return result;
+ }
+ }
+
+ @Override
+ public void cleanupCache() {
+ // NOP
+ }
}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
index e7a93b8..97d844a 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultIsland.java
@@ -55,6 +55,16 @@ public ICBiome getBiomeAt(final int relativeX, final int relativeZ) {
return cache.biomeAt(this, relativeX, relativeZ);
}
+ @Override
+ public ICBiome[] getBiomeChunk(ICLocation relativeLocation) {
+ return getBiomeChunk(relativeLocation.getX(), relativeLocation.getZ());
+ }
+
+ @Override
+ public ICBiome[] getBiomeChunk(int relativeX, int relativeZ) {
+ return cache.biomeChunk(this, relativeX, relativeZ);
+ }
+
@Override
public ICBiome[] getBiomeAll() {
return cache.biomeAll(this);
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
index b2e3b8e..6aea4a9 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/DefaultWorld.java
@@ -94,6 +94,38 @@ public ICBiome getBiomeAt(final int x, final int z) {
return biome;
}
+ @Override
+ public ICBiome[] getBiomeChunk(ICLocation location) {
+ return getBiomeChunk(location.getX(), location.getZ());
+ }
+
+ @Override
+ public ICBiome[] getBiomeChunk(int x, int z) {
+ final ICIsland island = getIslandAt(x, z);
+ if (island == null) {
+ final ICBiome[] chunk = new ICBiome[256];
+ for (int i = 0; i < 256; ++i) {
+ chunk[i] = ocean.biomeAt(x + i % 16, z + i / 16, worldSeed);
+ }
+ return chunk;
+ }
+ final ICLocation origin = island.getInnerRegion().getMin();
+ final ICBiome[] biomes = island.getBiomeChunk(x - origin.getX(), z - origin.getZ());
+ if (biomes == null) {
+ final ICBiome[] chunk = new ICBiome[256];
+ for (int i = 0; i < 256; ++i) {
+ chunk[i] = ocean.biomeAt(x + i % 16, z + i / 16, worldSeed);
+ }
+ return chunk;
+ }
+ for (int i = 0; i < 256; ++i) {
+ if (biomes[i] == null) {
+ biomes[i] = ocean.biomeAt(x + i % 16, z + i / 16, worldSeed);
+ }
+ }
+ return biomes;
+ }
+
@Override
public ICIsland getIslandAt(final ICLocation location) {
return getIslandAt(location.getX(), location.getZ());
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
index e60a704..37b32f0 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/HexagonalIslandDistribution.java
@@ -29,13 +29,13 @@ public HexagonalIslandDistribution(final String[] args) {
islandSize = Integer.parseInt(args[0]);
oceanSize = Integer.parseInt(args[1]);
// Validate configuration values
- if (islandSize <= 0 || islandSize % 2 != 0) {
- ICLogger.logger.severe("HexagonalIslandDistribution.island-size must be a positive multiple of 2");
- throw new IllegalArgumentException("HexagonalIslandDistribution.island-size must be a positive multiple of 2");
+ if (islandSize <= 0 || islandSize % 32 != 0) {
+ ICLogger.logger.severe("HexagonalIslandDistribution.island-size must be a positive multiple of 32");
+ throw new IllegalArgumentException("HexagonalIslandDistribution.island-size must be a positive multiple of 32");
}
- if (oceanSize <= 0 || oceanSize % 2 != 0) {
- ICLogger.logger.severe("HexagonalIslandDistribution.ocean-size must be a positive multiple of 2");
- throw new IllegalArgumentException("HexagonalIslandDistribution.ocean-size must be a positive multiple of 2");
+ if (oceanSize <= 0 || oceanSize % 32 != 0) {
+ ICLogger.logger.severe("HexagonalIslandDistribution.ocean-size must be a positive multiple of 32");
+ throw new IllegalArgumentException("HexagonalIslandDistribution.ocean-size must be a positive multiple of 32");
}
islandSeparation = islandSize + oceanSize;
twiceIslandSeparation = islandSeparation * 2;
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
index 566191a..e0d3243 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/IslandCache.java
@@ -21,6 +21,18 @@ public ICBiome biomeAt(final ICIsland island, final int relativeX, final int rel
return biomes[relativeZ * xSize + relativeX];
}
+ private static final int BLOCKS_PER_CHUNK = 16;
+
+ public ICBiome[] biomeChunk(final ICIsland island, final int relativeX, final int relativeZ) {
+ final int xSize = island.getInnerRegion().getMax().getZ() - island.getInnerRegion().getMin().getZ();
+ final ICBiome[] result = new ICBiome[BLOCKS_PER_CHUNK * BLOCKS_PER_CHUNK];
+ final ICBiome[] biomes = cache.getUnchecked(island);
+ for (int z = 0; z < BLOCKS_PER_CHUNK; ++z) {
+ System.arraycopy(biomes, xSize * (relativeZ + z) + relativeX, result, z * BLOCKS_PER_CHUNK, BLOCKS_PER_CHUNK);
+ }
+ return result;
+ }
+
public ICBiome[] biomeAll(final ICIsland island) {
return cache.getUnchecked(island).clone();
}
diff --git a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
index 40c6943..a1e30ad 100644
--- a/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
+++ b/IslandCraft-Core/src/main/java/com/github/hoqhuuep/islandcraft/core/SquareIslandDistribution.java
@@ -25,13 +25,13 @@ public SquareIslandDistribution(final String[] args) {
islandSize = Integer.parseInt(args[0]);
oceanSize = Integer.parseInt(args[1]);
// Validate configuration values
- if (islandSize <= 0 || islandSize % 2 != 0) {
- ICLogger.logger.severe("SquareIslandDistribution.island-size must be a positive multiple of 2");
- throw new IllegalArgumentException("SquareIslandDistribution.island-size must be a positive multiple of 2");
+ if (islandSize <= 0 || islandSize % 32 != 0) {
+ ICLogger.logger.severe("SquareIslandDistribution.island-size must be a positive multiple of 32");
+ throw new IllegalArgumentException("SquareIslandDistribution.island-size must be a positive multiple of 32");
}
- if (oceanSize <= 0 || oceanSize % 2 != 0) {
- ICLogger.logger.severe("SquareIslandDistribution.ocean-size must be a positive multiple of 2");
- throw new IllegalArgumentException("SquareIslandDistribution.ocean-size must be a positive multiple of 2");
+ if (oceanSize <= 0 || oceanSize % 32 != 0) {
+ ICLogger.logger.severe("SquareIslandDistribution.ocean-size must be a positive multiple of 32");
+ throw new IllegalArgumentException("SquareIslandDistribution.ocean-size must be a positive multiple of 32");
}
islandSeparation = islandSize + oceanSize;
innerRadius = islandSize / 2;
diff --git a/IslandCraft-Core/src/main/resources/plugin.yml b/IslandCraft-Core/src/main/resources/plugin.yml
index 36a89c0..9db5523 100644
--- a/IslandCraft-Core/src/main/resources/plugin.yml
+++ b/IslandCraft-Core/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: IslandCraft
-version: 1.0.0
+version: 1.0.1
description: Changes the biome distribution of the world to create an ocean with islands
author: hoqhuuep
website: http://dev.bukkit.org/bukkit-plugins/islandcraft/
diff --git a/IslandCraft-NMS-v1_4_R1/pom.xml b/IslandCraft-NMS-v1_4_R1/pom.xml
index 394640c..aba6639 100644
--- a/IslandCraft-NMS-v1_4_R1/pom.xml
+++ b/IslandCraft-NMS-v1_4_R1/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_4_R1
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_4_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_4_R1/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_4_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_4_R1/CustomWorldChunkManager.java
index 701d19d..51f4b1c 100644
--- a/IslandCraft-NMS-v1_4_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_4_R1/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_4_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_4_R1/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_5_R1/pom.xml b/IslandCraft-NMS-v1_5_R1/pom.xml
index 253a2e4..5657341 100644
--- a/IslandCraft-NMS-v1_5_R1/pom.xml
+++ b/IslandCraft-NMS-v1_5_R1/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_5_R1
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_5_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R1/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_5_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R1/CustomWorldChunkManager.java
index 625f7e4..7ebfbab 100644
--- a/IslandCraft-NMS-v1_5_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R1/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_5_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R1/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_5_R2/pom.xml b/IslandCraft-NMS-v1_5_R2/pom.xml
index a978aa5..da36789 100644
--- a/IslandCraft-NMS-v1_5_R2/pom.xml
+++ b/IslandCraft-NMS-v1_5_R2/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_5_R2
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_5_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R2/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_5_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R2/CustomWorldChunkManager.java
index 9942af8..87d2083 100644
--- a/IslandCraft-NMS-v1_5_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R2/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_5_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R2/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_5_R3/pom.xml b/IslandCraft-NMS-v1_5_R3/pom.xml
index df5f0f5..3d957da 100644
--- a/IslandCraft-NMS-v1_5_R3/pom.xml
+++ b/IslandCraft-NMS-v1_5_R3/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_5_R3
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_5_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R3/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_5_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R3/CustomWorldChunkManager.java
index 2cf6838..2c3aee2 100644
--- a/IslandCraft-NMS-v1_5_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R3/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_5_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_5_R3/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_6_R1/pom.xml b/IslandCraft-NMS-v1_6_R1/pom.xml
index 126b9f3..0d17926 100644
--- a/IslandCraft-NMS-v1_6_R1/pom.xml
+++ b/IslandCraft-NMS-v1_6_R1/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_6_R1
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_6_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R1/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_6_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R1/CustomWorldChunkManager.java
index 822bb35..4891354 100644
--- a/IslandCraft-NMS-v1_6_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R1/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_6_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R1/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_6_R2/pom.xml b/IslandCraft-NMS-v1_6_R2/pom.xml
index c8ca5e9..0145dd3 100644
--- a/IslandCraft-NMS-v1_6_R2/pom.xml
+++ b/IslandCraft-NMS-v1_6_R2/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_6_R2
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_6_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R2/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_6_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R2/CustomWorldChunkManager.java
index 97d3a72..4202d37 100644
--- a/IslandCraft-NMS-v1_6_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R2/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_6_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R2/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_6_R3/pom.xml b/IslandCraft-NMS-v1_6_R3/pom.xml
index 58c8e80..946f0b5 100644
--- a/IslandCraft-NMS-v1_6_R3/pom.xml
+++ b/IslandCraft-NMS-v1_6_R3/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_6_R3
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_6_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R3/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_6_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R3/CustomWorldChunkManager.java
index 43b7a1b..17b2e7f 100644
--- a/IslandCraft-NMS-v1_6_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R3/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_6_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_6_R3/CustomWorldChunkManager.java
@@ -175,13 +175,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.e(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -249,5 +257,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_7_R1/pom.xml b/IslandCraft-NMS-v1_7_R1/pom.xml
index 57c5327..6773b60 100644
--- a/IslandCraft-NMS-v1_7_R1/pom.xml
+++ b/IslandCraft-NMS-v1_7_R1/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_7_R1
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_7_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R1/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_7_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R1/CustomWorldChunkManager.java
index 174e5d2..4985244 100644
--- a/IslandCraft-NMS-v1_7_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R1/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_7_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R1/CustomWorldChunkManager.java
@@ -159,13 +159,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -233,5 +241,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_7_R2/pom.xml b/IslandCraft-NMS-v1_7_R2/pom.xml
index 95b66e0..65bac36 100644
--- a/IslandCraft-NMS-v1_7_R2/pom.xml
+++ b/IslandCraft-NMS-v1_7_R2/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_7_R2
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_7_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R2/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_7_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R2/CustomWorldChunkManager.java
index ef612f0..0220625 100644
--- a/IslandCraft-NMS-v1_7_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R2/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_7_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R2/CustomWorldChunkManager.java
@@ -159,13 +159,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -233,5 +241,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_7_R3/pom.xml b/IslandCraft-NMS-v1_7_R3/pom.xml
index ee3b873..37d26ef 100644
--- a/IslandCraft-NMS-v1_7_R3/pom.xml
+++ b/IslandCraft-NMS-v1_7_R3/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_7_R3
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_7_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R3/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_7_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R3/CustomWorldChunkManager.java
index e3610dd..ca1b480 100644
--- a/IslandCraft-NMS-v1_7_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R3/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_7_R3/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R3/CustomWorldChunkManager.java
@@ -159,13 +159,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -233,5 +241,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_7_R4/pom.xml b/IslandCraft-NMS-v1_7_R4/pom.xml
index de8dbd6..dad61c2 100644
--- a/IslandCraft-NMS-v1_7_R4/pom.xml
+++ b/IslandCraft-NMS-v1_7_R4/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS-v1_7_R4
@@ -18,7 +18,7 @@
com.github.hoqhuuep
IslandCraft-NMS
- 1.0.0
+ 1.0.1
diff --git a/IslandCraft-NMS-v1_7_R4/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R4/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_7_R4/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R4/CustomWorldChunkManager.java
index e3d7a5f..f0da0e9 100644
--- a/IslandCraft-NMS-v1_7_R4/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R4/CustomWorldChunkManager.java
+++ b/IslandCraft-NMS-v1_7_R4/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_7_R4/CustomWorldChunkManager.java
@@ -159,13 +159,21 @@ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final i
result = new BiomeBase[xSize * zSize];
}
// More efficient handling of whole chunk
- if (useCache && xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
- // Happens most of the time
- final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
- System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.d(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
return result;
}
- // This only happens in getWetness above
+ // In reality this never happens...
for (int x = 0; x < xSize; ++x) {
for (int z = 0; z < zSize; ++z) {
final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
@@ -233,5 +241,6 @@ public ChunkPosition a(final int x, final int z, final int radius, @SuppressWarn
public void b() {
// Clean up biomeCache
biomeCache.a();
+ biomeGenerator.cleanupCache();
}
}
diff --git a/IslandCraft-NMS-v1_8_R1/.gitignore b/IslandCraft-NMS-v1_8_R1/.gitignore
new file mode 100644
index 0000000..c449f83
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/.gitignore
@@ -0,0 +1,5 @@
+/target
+/.settings
+/.checkstyle
+/.classpath
+/.project
diff --git a/IslandCraft-NMS-v1_8_R1/bin/.classpath.old b/IslandCraft-NMS-v1_8_R1/bin/.classpath.old
new file mode 100644
index 0000000..7092a1c
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/bin/.classpath.old
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IslandCraft-NMS-v1_8_R1/bin/.gitignore b/IslandCraft-NMS-v1_8_R1/bin/.gitignore
new file mode 100644
index 0000000..c449f83
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/bin/.gitignore
@@ -0,0 +1,5 @@
+/target
+/.settings
+/.checkstyle
+/.classpath
+/.project
diff --git a/IslandCraft-NMS-v1_8_R1/bin/pom.xml b/IslandCraft-NMS-v1_8_R1/bin/pom.xml
new file mode 100644
index 0000000..3eb725c
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/bin/pom.xml
@@ -0,0 +1,24 @@
+
+ 4.0.0
+
+ com.github.hoqhuuep
+ IslandCraft
+ 1.0.1
+
+ IslandCraft-NMS-v1_8_R1
+
+
+
+ org.bukkit
+ craftbukkit
+ 1.7.8-R1-SNAPSHOT
+ provided
+
+
+ com.github.hoqhuuep
+ IslandCraft-NMS
+ 1.0.1
+
+
+
diff --git a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class
new file mode 100644
index 0000000..e2e6ae4
Binary files /dev/null and b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.class differ
diff --git a/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class
new file mode 100644
index 0000000..f01e8d2
Binary files /dev/null and b/IslandCraft-NMS-v1_8_R1/bin/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.class differ
diff --git a/IslandCraft-NMS-v1_8_R1/pom.xml b/IslandCraft-NMS-v1_8_R1/pom.xml
new file mode 100644
index 0000000..ce51762
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/pom.xml
@@ -0,0 +1,25 @@
+
+ 4.0.0
+
+ com.github.hoqhuuep
+ IslandCraft
+ 1.0.1
+
+ IslandCraft-NMS-v1_8_R1
+
+
+
+ org.bukkit
+ craftbukkit
+ 1.8-R1-SNAPSHOT
+ system
+ C:\Users\Daniel\Dropbox\Projects\IslandCraft\Spigot\craftbukkit-1.8.jar
+
+
+ com.github.hoqhuuep
+ IslandCraft-NMS
+ 1.0.1
+
+
+
diff --git a/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.java
new file mode 100644
index 0000000..40bdd9b
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/CustomWorldChunkManager.java
@@ -0,0 +1,253 @@
+package com.github.hoqhuuep.islandcraft.nms.v1_8_R1;
+
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import net.minecraft.server.v1_8_R1.BiomeBase;
+import net.minecraft.server.v1_8_R1.BiomeCache;
+import net.minecraft.server.v1_8_R1.BlockPosition;
+import net.minecraft.server.v1_8_R1.WorldChunkManager;
+
+import com.github.hoqhuuep.islandcraft.api.ICBiome;
+import com.github.hoqhuuep.islandcraft.nms.BiomeGenerator;
+
+public class CustomWorldChunkManager extends WorldChunkManager {
+ private static final Map biomeMap = new EnumMap(ICBiome.class);
+
+ private static final BiomeBase special(final BiomeBase biome) {
+ return BiomeBase.getBiome(biome.id + 128);
+ }
+
+ static {
+ biomeMap.put(ICBiome.BEACH, BiomeBase.BEACH);
+ biomeMap.put(ICBiome.BIRCH_FOREST, BiomeBase.BIRCH_FOREST);
+ biomeMap.put(ICBiome.BIRCH_FOREST_HILLS, BiomeBase.BIRCH_FOREST_HILLS);
+ biomeMap.put(ICBiome.BIRCH_FOREST_HILLS_M, special(BiomeBase.BIRCH_FOREST_HILLS));
+ biomeMap.put(ICBiome.BIRCH_FOREST_M, special(BiomeBase.BIRCH_FOREST));
+ biomeMap.put(ICBiome.COLD_BEACH, BiomeBase.COLD_BEACH);
+ biomeMap.put(ICBiome.COLD_TAIGA, BiomeBase.COLD_TAIGA);
+ biomeMap.put(ICBiome.COLD_TAIGA_HILLS, BiomeBase.COLD_TAIGA_HILLS);
+ biomeMap.put(ICBiome.COLD_TAIGA_M, special(BiomeBase.COLD_TAIGA));
+ biomeMap.put(ICBiome.DEEP_OCEAN, BiomeBase.DEEP_OCEAN);
+ biomeMap.put(ICBiome.DESERT, BiomeBase.DESERT);
+ biomeMap.put(ICBiome.DESERT_HILLS, BiomeBase.DESERT_HILLS);
+ biomeMap.put(ICBiome.DESERT_M, special(BiomeBase.DESERT));
+ biomeMap.put(ICBiome.END, BiomeBase.SKY);
+ biomeMap.put(ICBiome.EXTREME_HILLS, BiomeBase.EXTREME_HILLS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_EDGE, BiomeBase.SMALL_MOUNTAINS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_M, special(BiomeBase.EXTREME_HILLS));
+ biomeMap.put(ICBiome.EXTREME_HILLS_PLUS, BiomeBase.EXTREME_HILLS_PLUS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_PLUS_M, special(BiomeBase.EXTREME_HILLS_PLUS));
+ biomeMap.put(ICBiome.FLOWER_FOREST, special(BiomeBase.FOREST));
+ biomeMap.put(ICBiome.FOREST, BiomeBase.FOREST);
+ biomeMap.put(ICBiome.FOREST_HILLS, BiomeBase.FOREST_HILLS);
+ biomeMap.put(ICBiome.FROZEN_OCEAN, BiomeBase.FROZEN_OCEAN);
+ biomeMap.put(ICBiome.FROZEN_RIVER, BiomeBase.FROZEN_RIVER);
+ biomeMap.put(ICBiome.ICE_MOUNTAINS, BiomeBase.ICE_MOUNTAINS);
+ biomeMap.put(ICBiome.ICE_PLAINS, BiomeBase.ICE_PLAINS);
+ biomeMap.put(ICBiome.ICE_PLAINS_SPIKES, special(BiomeBase.ICE_PLAINS));
+ biomeMap.put(ICBiome.JUNGLE, BiomeBase.JUNGLE);
+ biomeMap.put(ICBiome.JUNGLE_EDGE, BiomeBase.JUNGLE_EDGE);
+ biomeMap.put(ICBiome.JUNGLE_HILLS, BiomeBase.JUNGLE_HILLS);
+ biomeMap.put(ICBiome.JUNGLE_M, special(BiomeBase.JUNGLE));
+ biomeMap.put(ICBiome.JUNGLE_EDGE_M, special(BiomeBase.JUNGLE_EDGE));
+ biomeMap.put(ICBiome.MEGA_SPRUCE_TAIGA, special(BiomeBase.MEGA_TAIGA));
+ biomeMap.put(ICBiome.MEGA_SPRUCE_TAIGA_HILLS, special(BiomeBase.MEGA_TAIGA_HILLS));
+ biomeMap.put(ICBiome.MEGA_TAIGA, BiomeBase.MEGA_TAIGA);
+ biomeMap.put(ICBiome.MEGA_TAIGA_HILLS, BiomeBase.MEGA_TAIGA_HILLS);
+ biomeMap.put(ICBiome.MESA, BiomeBase.MESA);
+ biomeMap.put(ICBiome.MESA_BRYCE, special(BiomeBase.MESA));
+ biomeMap.put(ICBiome.MESA_PLATEAU, BiomeBase.MESA_PLATEAU);
+ biomeMap.put(ICBiome.MESA_PLATEAU_F, BiomeBase.MESA_PLATEAU_F);
+ biomeMap.put(ICBiome.MESA_PLATEAU_F_M, special(BiomeBase.MESA_PLATEAU_F));
+ biomeMap.put(ICBiome.MESA_PLATEAU_M, special(BiomeBase.MESA_PLATEAU));
+ biomeMap.put(ICBiome.MUSHROOM_ISLAND, BiomeBase.MUSHROOM_ISLAND);
+ biomeMap.put(ICBiome.MUSHROOM_ISLAND_SHORE, BiomeBase.MUSHROOM_SHORE);
+ biomeMap.put(ICBiome.NETHER, BiomeBase.HELL);
+ biomeMap.put(ICBiome.OCEAN, BiomeBase.OCEAN);
+ biomeMap.put(ICBiome.PLAINS, BiomeBase.PLAINS);
+ biomeMap.put(ICBiome.RIVER, BiomeBase.RIVER);
+ biomeMap.put(ICBiome.ROOFED_FOREST, BiomeBase.ROOFED_FOREST);
+ biomeMap.put(ICBiome.ROOFED_FOREST_M, special(BiomeBase.ROOFED_FOREST));
+ biomeMap.put(ICBiome.SAVANNA, BiomeBase.SAVANNA);
+ biomeMap.put(ICBiome.SAVANNA_M, special(BiomeBase.SAVANNA));
+ biomeMap.put(ICBiome.SAVANNA_PLATEAU, BiomeBase.SAVANNA_PLATEAU);
+ biomeMap.put(ICBiome.SAVANNA_PLATEAU_M, special(BiomeBase.SAVANNA_PLATEAU));
+ biomeMap.put(ICBiome.STONE_BEACH, BiomeBase.STONE_BEACH);
+ biomeMap.put(ICBiome.SUNFLOWER_PLAINS, special(BiomeBase.PLAINS));
+ biomeMap.put(ICBiome.SWAMPLAND, BiomeBase.SWAMPLAND);
+ biomeMap.put(ICBiome.SWAMPLAND_M, special(BiomeBase.SWAMPLAND));
+ biomeMap.put(ICBiome.TAIGA, BiomeBase.TAIGA);
+ biomeMap.put(ICBiome.TAIGA_HILLS, BiomeBase.TAIGA_HILLS);
+ biomeMap.put(ICBiome.TAIGA_M, special(BiomeBase.TAIGA));
+ }
+
+ private final BiomeCache biomeCache;
+ private final BiomeGenerator biomeGenerator;
+
+ public CustomWorldChunkManager(final BiomeGenerator biomeGenerator) {
+ this.biomeGenerator = biomeGenerator;
+ this.biomeCache = new BiomeCache(this);
+ }
+
+ /** Returns a list of biome's which are valid for spawn */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public List a() {
+ return super.a();
+ }
+
+ /** Returns the biome at a position. Used for various things. */
+ @Override
+ public BiomeBase getBiome(BlockPosition blockPosition) {
+ // Get from cache
+ return this.biomeCache.a(blockPosition.getX(), blockPosition.getZ(), (BiomeBase) null);
+ }
+
+ /** Returns the biome at a position. Used for various things. */
+ @Override
+ public BiomeBase getBiome(BlockPosition blockPosition, BiomeBase biomeBase) {
+ // Get from cache
+ return this.biomeCache.a(blockPosition.getX(), blockPosition.getZ(), biomeBase);
+ }
+
+ /** Used in creating ChunkSnapshot's */
+ @Override
+ public float[] getWetness(float[] result, final int x, final int z, int xSize, final int zSize) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ // In reality result is always null
+ result = new float[xSize * zSize];
+ }
+ // In reality size is always 1 chunk's worth
+ final BiomeBase[] biomes = a(null, x, z, xSize, zSize, false);
+ for (int i = 0; i < xSize * zSize; i++) {
+ final float wetness = biomes[i].h() / 65536.0F;
+ if (wetness > 1.0F) {
+ result[i] = 1.0F;
+ } else {
+ result[i] = wetness;
+ }
+ }
+ return result;
+ }
+
+ /** Used for height map and temperature */
+ @Override
+ public BiomeBase[] getBiomes(BiomeBase[] result, final int xMin, final int zMin, final int xSize, final int zSize) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ result = new BiomeBase[xSize * zSize];
+ }
+ // 1 in every 4
+ for (int i = 0; i < xSize * zSize; ++i) {
+ final int x = (xMin + (i % xSize)) << 2;
+ final int z = (zMin + (i / xSize)) << 2;
+ final ICBiome biome = biomeGenerator.generateBiome(x, z);
+ result[i] = biomeMap.get(biome);
+ }
+ return result;
+ }
+
+ /** Used in chunk creation */
+ @Override
+ public BiomeBase[] getBiomeBlock(final BiomeBase[] array, final int x, final int z, final int xSize, final int zSize) {
+ return a(array, x, z, xSize, zSize, true);
+ }
+
+ /** Only used in above method... and getWetness */
+ @Override
+ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final int xSize, final int zSize, final boolean useCache) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ // Happens for nether, end, and flat worlds...
+ result = new BiomeBase[xSize * zSize];
+ }
+ // More efficient handling of whole chunk
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.c(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
+ return result;
+ }
+ // In reality this never happens...
+ for (int x = 0; x < xSize; ++x) {
+ for (int z = 0; z < zSize; ++z) {
+ final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
+ result[x + z * xSize] = biomeMap.get(temp);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns true if all biome's in area are in allowedBiomes. x, z and radius
+ * are in blocks. Used for checking where a village can go.
+ */
+ @Override
+ public boolean a(final int x, final int z, final int radius, @SuppressWarnings("rawtypes") final List allowedBiomes) {
+ // Convert center and radius to minimum and size
+ final int xMin = (x - radius) >> 2;
+ final int zMin = (z - radius) >> 2;
+ final int xMax = (x + radius) >> 2;
+ final int zMax = (z + radius) >> 2;
+ final int xSize = xMax - xMin + 1;
+ final int zSize = zMax - zMin + 1;
+ // Generate biome's
+ final BiomeBase[] biomes = getBiomes(null, xMin, zMin, xSize, zSize);
+ // Make sure all biomes are allowed
+ for (int i = 0; i < xSize * zSize; i++) {
+ if (!allowedBiomes.contains(biomes[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns random position within biome if it can be found in given area.
+ * Otherwise null. Used for initial guess at spawn point and stronghold
+ * locations.
+ */
+ @Override
+ public BlockPosition a(final int x, final int z, final int radius, @SuppressWarnings("rawtypes") final List allowedBiomes, final Random random) {
+ // Convert center and radius to minimum and size
+ final int xMin = (x - radius) >> 2;
+ final int zMin = (z - radius) >> 2;
+ final int xMax = (x + radius) >> 2;
+ final int zMax = (z + radius) >> 2;
+ final int xSize = xMax - xMin + 1;
+ final int zSize = zMax - zMin + 1;
+ // Generate biome's
+ final BiomeBase[] biomes = getBiomes(null, xMin, zMin, xSize, zSize);
+ BlockPosition result = null;
+ int count = 0;
+ for (int i = 0; i < xSize * zSize; i++) {
+ final int xPosition = (xMin + (i % xSize)) << 2;
+ final int zPosition = (zMin + (i / xSize)) << 2;
+ if (allowedBiomes.contains(biomes[i]) && (result == null || random.nextInt(count + 1) == 0)) {
+ result = new BlockPosition(xPosition, 0, zPosition);
+ count++;
+ }
+ }
+ return result;
+ }
+
+ /** Cleans up biomeCache, called in tick */
+ @Override
+ public void b() {
+ // Clean up biomeCache
+ biomeCache.a();
+ biomeGenerator.cleanupCache();
+ }
+}
diff --git a/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.java b/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.java
new file mode 100644
index 0000000..9b2e67f
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R1/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R1/NmsHandler.java
@@ -0,0 +1,53 @@
+package com.github.hoqhuuep.islandcraft.nms.v1_8_R1;
+
+import java.lang.reflect.Field;
+
+import org.bukkit.World;
+import org.bukkit.craftbukkit.v1_8_R1.CraftWorld;
+
+import net.minecraft.server.v1_8_R1.WorldProvider;
+
+import com.github.hoqhuuep.islandcraft.nms.BiomeGenerator;
+import com.github.hoqhuuep.islandcraft.nms.NmsWrapper;
+
+public class NmsHandler extends NmsWrapper {
+
+ @Override
+ public boolean installBiomeGenerator(final World world, final BiomeGenerator biomeGenerator) {
+ if (!(world instanceof CraftWorld)) {
+ // Wrong version?
+ return false;
+ }
+ final CraftWorld craftWorld = (CraftWorld) world;
+ final WorldProvider worldProvider = craftWorld.getHandle().worldProvider;
+ try {
+ Field field = getField(worldProvider.getClass(), "c");
+ field.setAccessible(true);
+ if (field.get(worldProvider) instanceof CustomWorldChunkManager) {
+ // Already installed
+ return false;
+ }
+ field.set(worldProvider, new CustomWorldChunkManager(biomeGenerator));
+ return true;
+ } catch (NoSuchFieldException e) {
+ return false;
+ } catch (IllegalArgumentException e) {
+ return false;
+ } catch (IllegalAccessException e) {
+ return false;
+ }
+ }
+
+ private static Field getField(Class> clazz, String fieldName) throws NoSuchFieldException {
+ try {
+ return clazz.getDeclaredField(fieldName);
+ } catch (NoSuchFieldException e) {
+ Class> superClass = clazz.getSuperclass();
+ if (superClass == null) {
+ throw e;
+ } else {
+ return getField(superClass, fieldName);
+ }
+ }
+ }
+}
diff --git a/IslandCraft-NMS-v1_8_R2/.gitignore b/IslandCraft-NMS-v1_8_R2/.gitignore
new file mode 100644
index 0000000..c449f83
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R2/.gitignore
@@ -0,0 +1,5 @@
+/target
+/.settings
+/.checkstyle
+/.classpath
+/.project
diff --git a/IslandCraft-NMS-v1_8_R2/pom.xml b/IslandCraft-NMS-v1_8_R2/pom.xml
new file mode 100644
index 0000000..d0bb8d5
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R2/pom.xml
@@ -0,0 +1,25 @@
+
+ 4.0.0
+
+ com.github.hoqhuuep
+ IslandCraft
+ 1.0.1
+
+ IslandCraft-NMS-v1_8_R2
+
+
+
+ org.bukkit
+ craftbukkit
+ 1.8.3-R0.1-SNAPSHOT
+ system
+ C:\Users\Daniel\Dropbox\Projects\IslandCraft\Spigot-1.8.3\craftbukkit-1.8.3.jar
+
+
+ com.github.hoqhuuep
+ IslandCraft-NMS
+ 1.0.1
+
+
+
diff --git a/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java
new file mode 100644
index 0000000..5ef6166
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/CustomWorldChunkManager.java
@@ -0,0 +1,253 @@
+package com.github.hoqhuuep.islandcraft.nms.v1_8_R2;
+
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import net.minecraft.server.v1_8_R2.BiomeBase;
+import net.minecraft.server.v1_8_R2.BiomeCache;
+import net.minecraft.server.v1_8_R2.BlockPosition;
+import net.minecraft.server.v1_8_R2.WorldChunkManager;
+
+import com.github.hoqhuuep.islandcraft.api.ICBiome;
+import com.github.hoqhuuep.islandcraft.nms.BiomeGenerator;
+
+public class CustomWorldChunkManager extends WorldChunkManager {
+ private static final Map biomeMap = new EnumMap(ICBiome.class);
+
+ private static final BiomeBase special(final BiomeBase biome) {
+ return BiomeBase.getBiome(biome.id + 128);
+ }
+
+ static {
+ biomeMap.put(ICBiome.BEACH, BiomeBase.BEACH);
+ biomeMap.put(ICBiome.BIRCH_FOREST, BiomeBase.BIRCH_FOREST);
+ biomeMap.put(ICBiome.BIRCH_FOREST_HILLS, BiomeBase.BIRCH_FOREST_HILLS);
+ biomeMap.put(ICBiome.BIRCH_FOREST_HILLS_M, special(BiomeBase.BIRCH_FOREST_HILLS));
+ biomeMap.put(ICBiome.BIRCH_FOREST_M, special(BiomeBase.BIRCH_FOREST));
+ biomeMap.put(ICBiome.COLD_BEACH, BiomeBase.COLD_BEACH);
+ biomeMap.put(ICBiome.COLD_TAIGA, BiomeBase.COLD_TAIGA);
+ biomeMap.put(ICBiome.COLD_TAIGA_HILLS, BiomeBase.COLD_TAIGA_HILLS);
+ biomeMap.put(ICBiome.COLD_TAIGA_M, special(BiomeBase.COLD_TAIGA));
+ biomeMap.put(ICBiome.DEEP_OCEAN, BiomeBase.DEEP_OCEAN);
+ biomeMap.put(ICBiome.DESERT, BiomeBase.DESERT);
+ biomeMap.put(ICBiome.DESERT_HILLS, BiomeBase.DESERT_HILLS);
+ biomeMap.put(ICBiome.DESERT_M, special(BiomeBase.DESERT));
+ biomeMap.put(ICBiome.END, BiomeBase.SKY);
+ biomeMap.put(ICBiome.EXTREME_HILLS, BiomeBase.EXTREME_HILLS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_EDGE, BiomeBase.SMALL_MOUNTAINS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_M, special(BiomeBase.EXTREME_HILLS));
+ biomeMap.put(ICBiome.EXTREME_HILLS_PLUS, BiomeBase.EXTREME_HILLS_PLUS);
+ biomeMap.put(ICBiome.EXTREME_HILLS_PLUS_M, special(BiomeBase.EXTREME_HILLS_PLUS));
+ biomeMap.put(ICBiome.FLOWER_FOREST, special(BiomeBase.FOREST));
+ biomeMap.put(ICBiome.FOREST, BiomeBase.FOREST);
+ biomeMap.put(ICBiome.FOREST_HILLS, BiomeBase.FOREST_HILLS);
+ biomeMap.put(ICBiome.FROZEN_OCEAN, BiomeBase.FROZEN_OCEAN);
+ biomeMap.put(ICBiome.FROZEN_RIVER, BiomeBase.FROZEN_RIVER);
+ biomeMap.put(ICBiome.ICE_MOUNTAINS, BiomeBase.ICE_MOUNTAINS);
+ biomeMap.put(ICBiome.ICE_PLAINS, BiomeBase.ICE_PLAINS);
+ biomeMap.put(ICBiome.ICE_PLAINS_SPIKES, special(BiomeBase.ICE_PLAINS));
+ biomeMap.put(ICBiome.JUNGLE, BiomeBase.JUNGLE);
+ biomeMap.put(ICBiome.JUNGLE_EDGE, BiomeBase.JUNGLE_EDGE);
+ biomeMap.put(ICBiome.JUNGLE_HILLS, BiomeBase.JUNGLE_HILLS);
+ biomeMap.put(ICBiome.JUNGLE_M, special(BiomeBase.JUNGLE));
+ biomeMap.put(ICBiome.JUNGLE_EDGE_M, special(BiomeBase.JUNGLE_EDGE));
+ biomeMap.put(ICBiome.MEGA_SPRUCE_TAIGA, special(BiomeBase.MEGA_TAIGA));
+ biomeMap.put(ICBiome.MEGA_SPRUCE_TAIGA_HILLS, special(BiomeBase.MEGA_TAIGA_HILLS));
+ biomeMap.put(ICBiome.MEGA_TAIGA, BiomeBase.MEGA_TAIGA);
+ biomeMap.put(ICBiome.MEGA_TAIGA_HILLS, BiomeBase.MEGA_TAIGA_HILLS);
+ biomeMap.put(ICBiome.MESA, BiomeBase.MESA);
+ biomeMap.put(ICBiome.MESA_BRYCE, special(BiomeBase.MESA));
+ biomeMap.put(ICBiome.MESA_PLATEAU, BiomeBase.MESA_PLATEAU);
+ biomeMap.put(ICBiome.MESA_PLATEAU_F, BiomeBase.MESA_PLATEAU_F);
+ biomeMap.put(ICBiome.MESA_PLATEAU_F_M, special(BiomeBase.MESA_PLATEAU_F));
+ biomeMap.put(ICBiome.MESA_PLATEAU_M, special(BiomeBase.MESA_PLATEAU));
+ biomeMap.put(ICBiome.MUSHROOM_ISLAND, BiomeBase.MUSHROOM_ISLAND);
+ biomeMap.put(ICBiome.MUSHROOM_ISLAND_SHORE, BiomeBase.MUSHROOM_SHORE);
+ biomeMap.put(ICBiome.NETHER, BiomeBase.HELL);
+ biomeMap.put(ICBiome.OCEAN, BiomeBase.OCEAN);
+ biomeMap.put(ICBiome.PLAINS, BiomeBase.PLAINS);
+ biomeMap.put(ICBiome.RIVER, BiomeBase.RIVER);
+ biomeMap.put(ICBiome.ROOFED_FOREST, BiomeBase.ROOFED_FOREST);
+ biomeMap.put(ICBiome.ROOFED_FOREST_M, special(BiomeBase.ROOFED_FOREST));
+ biomeMap.put(ICBiome.SAVANNA, BiomeBase.SAVANNA);
+ biomeMap.put(ICBiome.SAVANNA_M, special(BiomeBase.SAVANNA));
+ biomeMap.put(ICBiome.SAVANNA_PLATEAU, BiomeBase.SAVANNA_PLATEAU);
+ biomeMap.put(ICBiome.SAVANNA_PLATEAU_M, special(BiomeBase.SAVANNA_PLATEAU));
+ biomeMap.put(ICBiome.STONE_BEACH, BiomeBase.STONE_BEACH);
+ biomeMap.put(ICBiome.SUNFLOWER_PLAINS, special(BiomeBase.PLAINS));
+ biomeMap.put(ICBiome.SWAMPLAND, BiomeBase.SWAMPLAND);
+ biomeMap.put(ICBiome.SWAMPLAND_M, special(BiomeBase.SWAMPLAND));
+ biomeMap.put(ICBiome.TAIGA, BiomeBase.TAIGA);
+ biomeMap.put(ICBiome.TAIGA_HILLS, BiomeBase.TAIGA_HILLS);
+ biomeMap.put(ICBiome.TAIGA_M, special(BiomeBase.TAIGA));
+ }
+
+ private final BiomeCache biomeCache;
+ private final BiomeGenerator biomeGenerator;
+
+ public CustomWorldChunkManager(final BiomeGenerator biomeGenerator) {
+ this.biomeGenerator = biomeGenerator;
+ this.biomeCache = new BiomeCache(this);
+ }
+
+ /** Returns a list of biome's which are valid for spawn */
+ @Override
+ @SuppressWarnings("rawtypes")
+ public List a() {
+ return super.a();
+ }
+
+ /** Returns the biome at a position. Used for various things. */
+ @Override
+ public BiomeBase getBiome(BlockPosition blockPosition) {
+ // Get from cache
+ return this.biomeCache.a(blockPosition.getX(), blockPosition.getZ(), (BiomeBase) null);
+ }
+
+ /** Returns the biome at a position. Used for various things. */
+ @Override
+ public BiomeBase getBiome(BlockPosition blockPosition, BiomeBase biomeBase) {
+ // Get from cache
+ return this.biomeCache.a(blockPosition.getX(), blockPosition.getZ(), biomeBase);
+ }
+
+ /** Used in creating ChunkSnapshot's */
+ @Override
+ public float[] getWetness(float[] result, final int x, final int z, int xSize, final int zSize) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ // In reality result is always null
+ result = new float[xSize * zSize];
+ }
+ // In reality size is always 1 chunk's worth
+ final BiomeBase[] biomes = a(null, x, z, xSize, zSize, false);
+ for (int i = 0; i < xSize * zSize; i++) {
+ final float wetness = biomes[i].h() / 65536.0F;
+ if (wetness > 1.0F) {
+ result[i] = 1.0F;
+ } else {
+ result[i] = wetness;
+ }
+ }
+ return result;
+ }
+
+ /** Used for height map and temperature */
+ @Override
+ public BiomeBase[] getBiomes(BiomeBase[] result, final int xMin, final int zMin, final int xSize, final int zSize) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ result = new BiomeBase[xSize * zSize];
+ }
+ // 1 in every 4
+ for (int i = 0; i < xSize * zSize; ++i) {
+ final int x = (xMin + (i % xSize)) << 2;
+ final int z = (zMin + (i / xSize)) << 2;
+ final ICBiome biome = biomeGenerator.generateBiome(x, z);
+ result[i] = biomeMap.get(biome);
+ }
+ return result;
+ }
+
+ /** Used in chunk creation */
+ @Override
+ public BiomeBase[] getBiomeBlock(final BiomeBase[] array, final int x, final int z, final int xSize, final int zSize) {
+ return a(array, x, z, xSize, zSize, true);
+ }
+
+ /** Only used in above method... and getWetness */
+ @Override
+ public BiomeBase[] a(BiomeBase[] result, final int xMin, final int zMin, final int xSize, final int zSize, final boolean useCache) {
+ // Create result array if given one is insufficient
+ if (result == null || result.length < xSize * zSize) {
+ // Happens for nether, end, and flat worlds...
+ result = new BiomeBase[xSize * zSize];
+ }
+ // More efficient handling of whole chunk
+ if (xSize == 16 && zSize == 16 && (xMin & 0xF) == 0 && (zMin & 0xF) == 0) {
+ if (useCache) {
+ // Happens most of the time
+ final BiomeBase[] biomes = this.biomeCache.c(xMin, zMin);
+ System.arraycopy(biomes, 0, result, 0, xSize * zSize);
+ return result;
+ }
+ // This only happens in getWetness above
+ final ICBiome[] temp = biomeGenerator.generateChunkBiomes(xMin, zMin);
+ for (int i = 0; i < xSize * zSize; ++i) {
+ result[i] = biomeMap.get(temp[i]);
+ }
+ return result;
+ }
+ // In reality this never happens...
+ for (int x = 0; x < xSize; ++x) {
+ for (int z = 0; z < zSize; ++z) {
+ final ICBiome temp = biomeGenerator.generateBiome(xMin + x, zMin + z);
+ result[x + z * xSize] = biomeMap.get(temp);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns true if all biome's in area are in allowedBiomes. x, z and radius
+ * are in blocks. Used for checking where a village can go.
+ */
+ @Override
+ public boolean a(final int x, final int z, final int radius, @SuppressWarnings("rawtypes") final List allowedBiomes) {
+ // Convert center and radius to minimum and size
+ final int xMin = (x - radius) >> 2;
+ final int zMin = (z - radius) >> 2;
+ final int xMax = (x + radius) >> 2;
+ final int zMax = (z + radius) >> 2;
+ final int xSize = xMax - xMin + 1;
+ final int zSize = zMax - zMin + 1;
+ // Generate biome's
+ final BiomeBase[] biomes = getBiomes(null, xMin, zMin, xSize, zSize);
+ // Make sure all biomes are allowed
+ for (int i = 0; i < xSize * zSize; i++) {
+ if (!allowedBiomes.contains(biomes[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns random position within biome if it can be found in given area.
+ * Otherwise null. Used for initial guess at spawn point and stronghold
+ * locations.
+ */
+ @Override
+ public BlockPosition a(final int x, final int z, final int radius, @SuppressWarnings("rawtypes") final List allowedBiomes, final Random random) {
+ // Convert center and radius to minimum and size
+ final int xMin = (x - radius) >> 2;
+ final int zMin = (z - radius) >> 2;
+ final int xMax = (x + radius) >> 2;
+ final int zMax = (z + radius) >> 2;
+ final int xSize = xMax - xMin + 1;
+ final int zSize = zMax - zMin + 1;
+ // Generate biome's
+ final BiomeBase[] biomes = getBiomes(null, xMin, zMin, xSize, zSize);
+ BlockPosition result = null;
+ int count = 0;
+ for (int i = 0; i < xSize * zSize; i++) {
+ final int xPosition = (xMin + (i % xSize)) << 2;
+ final int zPosition = (zMin + (i / xSize)) << 2;
+ if (allowedBiomes.contains(biomes[i]) && (result == null || random.nextInt(count + 1) == 0)) {
+ result = new BlockPosition(xPosition, 0, zPosition);
+ count++;
+ }
+ }
+ return result;
+ }
+
+ /** Cleans up biomeCache, called in tick */
+ @Override
+ public void b() {
+ // Clean up biomeCache
+ biomeCache.a();
+ biomeGenerator.cleanupCache();
+ }
+}
diff --git a/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/NmsHandler.java b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/NmsHandler.java
new file mode 100644
index 0000000..b43dbfa
--- /dev/null
+++ b/IslandCraft-NMS-v1_8_R2/src/main/java/com/github/hoqhuuep/islandcraft/nms/v1_8_R2/NmsHandler.java
@@ -0,0 +1,53 @@
+package com.github.hoqhuuep.islandcraft.nms.v1_8_R2;
+
+import java.lang.reflect.Field;
+
+import org.bukkit.World;
+import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
+
+import net.minecraft.server.v1_8_R2.WorldProvider;
+
+import com.github.hoqhuuep.islandcraft.nms.BiomeGenerator;
+import com.github.hoqhuuep.islandcraft.nms.NmsWrapper;
+
+public class NmsHandler extends NmsWrapper {
+
+ @Override
+ public boolean installBiomeGenerator(final World world, final BiomeGenerator biomeGenerator) {
+ if (!(world instanceof CraftWorld)) {
+ // Wrong version?
+ return false;
+ }
+ final CraftWorld craftWorld = (CraftWorld) world;
+ final WorldProvider worldProvider = craftWorld.getHandle().worldProvider;
+ try {
+ Field field = getField(worldProvider.getClass(), "c");
+ field.setAccessible(true);
+ if (field.get(worldProvider) instanceof CustomWorldChunkManager) {
+ // Already installed
+ return false;
+ }
+ field.set(worldProvider, new CustomWorldChunkManager(biomeGenerator));
+ return true;
+ } catch (NoSuchFieldException e) {
+ return false;
+ } catch (IllegalArgumentException e) {
+ return false;
+ } catch (IllegalAccessException e) {
+ return false;
+ }
+ }
+
+ private static Field getField(Class> clazz, String fieldName) throws NoSuchFieldException {
+ try {
+ return clazz.getDeclaredField(fieldName);
+ } catch (NoSuchFieldException e) {
+ Class> superClass = clazz.getSuperclass();
+ if (superClass == null) {
+ throw e;
+ } else {
+ return getField(superClass, fieldName);
+ }
+ }
+ }
+}
diff --git a/IslandCraft-NMS/pom.xml b/IslandCraft-NMS/pom.xml
index 9d61985..8a22a32 100644
--- a/IslandCraft-NMS/pom.xml
+++ b/IslandCraft-NMS/pom.xml
@@ -4,7 +4,7 @@
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
IslandCraft-NMS
@@ -12,7 +12,7 @@
com.github.hoqhuuep
IslandCraft-Api
- 1.0.0
+ 1.0.1
\ No newline at end of file
diff --git a/IslandCraft-NMS/src/main/java/com/github/hoqhuuep/islandcraft/nms/BiomeGenerator.java b/IslandCraft-NMS/src/main/java/com/github/hoqhuuep/islandcraft/nms/BiomeGenerator.java
index 31cd5b7..7cf722f 100644
--- a/IslandCraft-NMS/src/main/java/com/github/hoqhuuep/islandcraft/nms/BiomeGenerator.java
+++ b/IslandCraft-NMS/src/main/java/com/github/hoqhuuep/islandcraft/nms/BiomeGenerator.java
@@ -3,6 +3,18 @@
import com.github.hoqhuuep.islandcraft.api.ICBiome;
public abstract class BiomeGenerator {
+ /**
+ * Determines which biomes should be used for world generation for the given
+ * chunk. Result must be a Biome[256] for the 16x16 area of the chunk.
+ *
+ * @param x
+ * X-coordinate of the chunk
+ * @param z
+ * Z-coordinate of the chunk
+ * @return Biome[256] containing biomes for each location in the chunk
+ */
+ public abstract ICBiome[] generateChunkBiomes(int x, int z);
+
/**
* Determines which biome should used for world generation at the given
* coordinates.
@@ -14,4 +26,10 @@ public abstract class BiomeGenerator {
* @return Biome for the location
*/
public abstract ICBiome generateBiome(int x, int z);
+
+ /**
+ * Called by the server every tick. Can be used to occasionally clean up old
+ * data from a cache if needed.
+ */
+ public abstract void cleanupCache();
}
diff --git a/pom.xml b/pom.xml
index b56fa24..6b0b4e9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.github.hoqhuuep
IslandCraft
- 1.0.0
+ 1.0.1
pom
@@ -20,6 +20,8 @@
IslandCraft-Core
IslandCraft-NMS
+ IslandCraft-NMS-v1_8_R2
+ IslandCraft-NMS-v1_8_R1
IslandCraft-NMS-v1_7_R4
IslandCraft-NMS-v1_7_R3
IslandCraft-NMS-v1_7_R2
@@ -46,6 +48,15 @@
1.6
+
+ org.apache.maven.plugins
+ maven-eclipse-plugin
+
+ true
+ true
+
+ 2.9
+
@@ -54,6 +65,10 @@
bukkit-repo
http://repo.bukkit.org/content/groups/public/
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
Plugin Metrics
http://repo.mcstats.org/content/repositories/public
@@ -66,7 +81,7 @@
com.google.guava
guava
10.0.1
- provided
+ compile
@@ -82,10 +97,10 @@
provided
- org.mcstats.bukkit
- metrics
- R7
- compile
-
+ org.mcstats.bukkit
+ metrics
+ R7
+ compile
+