-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23b846e
commit 6279638
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomBiome.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.dfsek.terra.minestom.biome; | ||
|
||
import com.dfsek.terra.api.world.biome.PlatformBiome; | ||
|
||
import net.minestom.server.world.biome.Biome; | ||
|
||
|
||
public class MinestomBiome implements PlatformBiome { | ||
private final Biome biome; | ||
|
||
public MinestomBiome(Biome biome) { this.biome = biome; } | ||
|
||
@Override | ||
public Biome getHandle() { | ||
return biome; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
platforms/minestom/src/main/java/com/dfsek/terra/minestom/biome/MinestomBiomeLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.dfsek.terra.minestom.biome; | ||
|
||
import com.dfsek.tectonic.api.depth.DepthTracker; | ||
import com.dfsek.tectonic.api.exception.LoadException; | ||
import com.dfsek.tectonic.api.loader.ConfigLoader; | ||
import com.dfsek.tectonic.api.loader.type.TypeLoader; | ||
|
||
import com.dfsek.terra.api.world.biome.PlatformBiome; | ||
|
||
import net.minestom.server.MinecraftServer; | ||
import net.minestom.server.registry.DynamicRegistry; | ||
import net.minestom.server.utils.NamespaceID; | ||
import net.minestom.server.world.biome.Biome; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.lang.reflect.AnnotatedType; | ||
|
||
|
||
public class MinestomBiomeLoader implements TypeLoader<PlatformBiome> { | ||
private final DynamicRegistry<Biome> biomeRegistry = MinecraftServer.getBiomeRegistry(); | ||
|
||
@Override | ||
public PlatformBiome load(@NotNull AnnotatedType annotatedType, @NotNull Object o, @NotNull ConfigLoader configLoader, | ||
DepthTracker depthTracker) throws LoadException { | ||
String id = (String) o; | ||
NamespaceID biomeID = NamespaceID.from(id); | ||
Biome biome = biomeRegistry.get(biomeID); | ||
if (biome == null) throw new LoadException("Biome %s does not exist in registry".formatted(id), depthTracker); | ||
return new MinestomBiome(biome); | ||
} | ||
} |