Skip to content

Commit

Permalink
feat: Case-insensitive biome id and renamed property 'displayName' (#1)
Browse files Browse the repository at this point in the history
* feat: Use Name instead String for biome ids
* chore: update module version and dependencies
* chore: update module.txt

Co-authored-by: Niruandaleth <jd.rueckert@googlemail.com>
  • Loading branch information
skaldarnar and jdrueckert committed May 17, 2020
1 parent e23cdf3 commit 1ef1c69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
18 changes: 9 additions & 9 deletions module.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id" : "BiomesAPI",
"version" : "3.2.1",
"isReleaseManaged" : true,
"author" : "The Terasology Foundation",
"displayName" : "BiomesAPI",
"description" : "Provides API for working with biomes, i.e., thematic sections of world.",
"dependencies" : [],
"serverSideOnly" : false,
"isLibrary" : true
"id": "BiomesAPI",
"version": "4.0.0",
"isReleaseManaged": true,
"author": "The Terasology Foundation",
"displayName": "BiomesAPI",
"description": "Provides API for working with biomes, i.e., thematic sections of world.",
"dependencies": [],
"serverSideOnly": false,
"isLibrary": true
}
8 changes: 5 additions & 3 deletions src/main/java/org/terasology/biomesAPI/Biome.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.terasology.biomesAPI;

import org.terasology.naming.Name;

/**
* Biomes can be assigned to different blocks during worldgen as well as on runtime, to provide additional metadata
* about player's surroundings usable to enhance player experience.
Expand All @@ -29,12 +31,12 @@ public interface Biome {
* @return An identifier that includes both the Module the biome originates from
* and a unique biome id (unique to that module).
*/
String getId();
Name getId();

/**
* Returns human readable name of the biome.
*/
String getName();
String getDisplayName();

/**
* Biome hashCode must be deterministic, non-zero, and unique for every biome.
Expand All @@ -47,7 +49,7 @@ public interface Biome {
*/
default short biomeHash() {
short hash = 0;
char[] chars = getId().toCharArray();
char[] chars = getId().toLowerCase().toCharArray();

for (char c : chars) {
hash = (short) (c + 31 * hash);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/terasology/biomesAPI/BiomeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void checkBiomeChangeEvent(MovedEvent event, EntityRef entity) {
Biome oldBiome = oldBiomeOptional.get();
if (oldBiome != newBiome) {
entity.send(new OnBiomeChangedEvent(oldBiome, newBiome));
metricsMode.setBiome(newBiome.getId());
metricsMode.setBiome(newBiome.getId().toString());
}
}
}
Expand All @@ -166,7 +166,7 @@ public void checkBiomeChangeEvent(MovedEvent event, EntityRef entity) {
public void checkPlayerSpawnedEvent(OnPlayerSpawnedEvent event, EntityRef entity, LocationComponent locationComponent) {
Vector3i spawnPos = new Vector3i(locationComponent.getWorldPosition());
getBiome(spawnPos)
.ifPresent(spawnBiome -> metricsMode.setBiome(spawnBiome.getId()));
.ifPresent(spawnBiome -> metricsMode.setBiome(spawnBiome.getId().toString()));

}
}

0 comments on commit 1ef1c69

Please sign in to comment.