mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
implement new tectonic depthtracker API
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -85,14 +86,14 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
super.register(registry);
|
||||
registry.registerLoader(BlockState.class, (t, o, l) -> handle.createBlockState((String) o))
|
||||
.registerLoader(PlatformBiome.class, (t, o, l) -> parseBiome((String) o))
|
||||
.registerLoader(EntityType.class, (t, o, l) -> EntityType.valueOf((String) o));
|
||||
registry.registerLoader(BlockState.class, (type, o, loader, depthTracker) -> handle.createBlockState((String) o))
|
||||
.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker))
|
||||
.registerLoader(EntityType.class, (type, o, loader, depthTracker) -> EntityType.valueOf((String) o));
|
||||
|
||||
}
|
||||
|
||||
private BukkitPlatformBiome parseBiome(String id) throws LoadException {
|
||||
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id);
|
||||
private BukkitPlatformBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException {
|
||||
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id, depthTracker);
|
||||
return new BukkitPlatformBiome(org.bukkit.block.Biome.valueOf(id.toUpperCase(Locale.ROOT).substring(10)));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
|
||||
@Override
|
||||
public @NotNull EntityType getEntity(@NotNull String id) {
|
||||
if(!id.startsWith("minecraft:")) throw new LoadException("Invalid entity identifier " + id);
|
||||
if(!id.startsWith("minecraft:")) throw new IllegalArgumentException("Invalid entity identifier " + id);
|
||||
return new BukkitEntityType(org.bukkit.entity.EntityType.valueOf(id.toUpperCase(Locale.ROOT).substring(10)));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,6 @@ public class CLIPlatform extends AbstractPlatform {
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
super.register(registry);
|
||||
registry.registerLoader(PlatformBiome.class, (TypeLoader<PlatformBiome>) (annotatedType, o, configLoader) -> () -> o);
|
||||
registry.registerLoader(PlatformBiome.class, (TypeLoader<PlatformBiome>) (annotatedType, o, configLoader, depthTracker) -> () -> o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.MinecraftVersion;
|
||||
@@ -137,19 +138,19 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
@Override
|
||||
public void register(TypeRegistry registry) {
|
||||
super.register(registry);
|
||||
registry.registerLoader(PlatformBiome.class, (t, o, l) -> parseBiome((String) o))
|
||||
.registerLoader(Identifier.class, (t, o, l) -> {
|
||||
registry.registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker))
|
||||
.registerLoader(Identifier.class, (type, o, loader, depthTracker) -> {
|
||||
Identifier identifier = Identifier.tryParse((String) o);
|
||||
if(identifier == null)
|
||||
throw new LoadException("Invalid identifier: " + o);
|
||||
throw new LoadException("Invalid identifier: " + o, depthTracker);
|
||||
return identifier;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private ProtoPlatformBiome parseBiome(String id) throws LoadException {
|
||||
private ProtoPlatformBiome parseBiome(String id, DepthTracker tracker) throws LoadException {
|
||||
Identifier identifier = Identifier.tryParse(id);
|
||||
if(BuiltinRegistries.BIOME.get(identifier) == null) throw new LoadException("Invalid Biome ID: " + identifier); // failure.
|
||||
if(BuiltinRegistries.BIOME.get(identifier) == null) throw new LoadException("Invalid Biome ID: " + identifier, tracker); // failure.
|
||||
return new ProtoPlatformBiome(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user