Skip to content

Commit

Permalink
fix location.biome tags, fixes #2007
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 28, 2019
1 parent b018afb commit 5964582
Showing 1 changed file with 24 additions and 2 deletions.
Expand Up @@ -426,6 +426,28 @@ public static BlockState getBlockStateSafe(Block block) {
}
}

public Biome getBiomeForTag(Attribute attribute) {
NMSHandler.getChunkHelper().changeChunkServerThread(getWorld());
try {
if (getWorld() == null) {
if (!attribute.hasAlternative()) {
Debug.echoError("LocationTag trying to read block, but cannot because no world is specified.");
}
return null;
}
if (!isChunkLoaded()) {
if (!attribute.hasAlternative()) {
Debug.echoError("LocationTag trying to read block, but cannot because the chunk is unloaded. Use the 'chunkload' command to ensure the chunk is loaded.");
}
return null;
}
return super.getBlock().getBiome();
}
finally {
NMSHandler.getChunkHelper().restoreServerThread(getWorld());
}
}

public BlockState getBlockState() {
return getBlockStateFor(getBlock());
}
Expand Down Expand Up @@ -2352,7 +2374,7 @@ else if (this.getWorldName().equalsIgnoreCase(toLocation.getWorldName())) {
// Returns the formatted biome name at the location.
// -->
if (attribute.startsWith("biome.formatted")) {
return new ElementTag(CoreUtilities.toLowerCase(getBlockForTag(attribute).getBiome().name()).replace('_', ' '))
return new ElementTag(CoreUtilities.toLowerCase(getBiomeForTag(attribute).name()).replace('_', ' '))
.getAttribute(attribute.fulfill(2));
}

Expand All @@ -2364,7 +2386,7 @@ else if (this.getWorldName().equalsIgnoreCase(toLocation.getWorldName())) {
// Returns the biome at the location.
// -->
if (attribute.startsWith("biome")) {
return new BiomeTag(getBlockForTag(attribute).getBiome())
return new BiomeTag(getBiomeForTag(attribute))
.getAttribute(attribute.fulfill(1));
}

Expand Down

0 comments on commit 5964582

Please sign in to comment.