mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
create BiomeDelegateLoader
This commit is contained in:
parent
3bb52b5cfe
commit
f93842dc94
@ -20,4 +20,18 @@ public interface BiomeDelegate extends StringIdentifiable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BiomeDelegate from(Biome biome) {
|
||||||
|
return new BiomeDelegate() {
|
||||||
|
@Override
|
||||||
|
public Biome getBiome() {
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getID() {
|
||||||
|
return biome.getID();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.dfsek.terra.addons.biome.pipeline.config;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.exception.LoadException;
|
||||||
|
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||||
|
import com.dfsek.tectonic.loading.TypeLoader;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.AnnotatedType;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.biome.pipeline.api.BiomeDelegate;
|
||||||
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
|
|
||||||
|
|
||||||
|
public class BiomeDelegateLoader implements TypeLoader<BiomeDelegate> {
|
||||||
|
private final Registry<Biome> biomeRegistry;
|
||||||
|
|
||||||
|
public BiomeDelegateLoader(Registry<Biome> biomeRegistry) {
|
||||||
|
this.biomeRegistry = biomeRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeDelegate load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader) throws LoadException {
|
||||||
|
return biomeRegistry
|
||||||
|
.get((String) c)
|
||||||
|
.map(BiomeDelegate::from)
|
||||||
|
.orElseGet(() -> BiomeDelegate.ephemeral((String) c));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user