Skip to content

Commit

Permalink
Merge branch 'release/v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
hoqhuuep committed Mar 10, 2015
2 parents a985d37 + 683ec6c commit e21ce4c
Show file tree
Hide file tree
Showing 51 changed files with 1,142 additions and 129 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.checkstyle
/.classpath
/.project
IslandCraft-NMS-v1_8_R1/bin/
2 changes: 1 addition & 1 deletion IslandCraft-Api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>IslandCraft-Api</artifactId>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
21 changes: 7 additions & 14 deletions IslandCraft-Core/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>IslandCraft</artifactId>
<groupId>com.github.hoqhuuep</groupId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>IslandCraft-Core</artifactId>
Expand All @@ -26,38 +26,31 @@
<include>org.mcstats.*:*</include>
<include>com.github.hoqhuuep:IslandCraft-Api</include>
<include>com.github.hoqhuuep:IslandCraft-NMS*</include>
<include>com.google*:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>com.github.hoqhuuep.islandcraft.mcstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.github.hoqhuuep.islandcraft.google</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>IslandCraft-1.0.0</finalName>
<finalName>IslandCraft-1.0.1</finalName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>jsr305</artifactId>
<groupId>com.google.code.findbugs</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down
51 changes: 36 additions & 15 deletions IslandCraft-Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,91 @@
<parent>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>IslandCraft-Core</artifactId>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>10.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-Api</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_8_R2</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_8_R1</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_7_R4</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_7_R3</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_7_R2</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_7_R1</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_6_R3</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_6_R2</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_6_R1</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_5_R3</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_5_R2</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_5_R1</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.github.hoqhuuep</groupId>
<artifactId>IslandCraft-NMS-v1_4_R1</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>

Expand All @@ -88,13 +104,18 @@
<include>org.mcstats.*:*</include>
<include>com.github.hoqhuuep:IslandCraft-Api</include>
<include>com.github.hoqhuuep:IslandCraft-NMS*</include>
<include>com.google*:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>com.github.hoqhuuep.islandcraft.mcstats</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.github.hoqhuuep.islandcraft.google</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand All @@ -111,7 +132,7 @@
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<finalName>IslandCraft-1.0.0</finalName>
<finalName>IslandCraft-1.0.1</finalName>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading

0 comments on commit e21ce4c

Please sign in to comment.