rename main parameters/fields to platform

This commit is contained in:
dfsek
2021-09-26 13:22:45 -07:00
parent 8f51707505
commit 4945a3bbfa
117 changed files with 535 additions and 516 deletions
@@ -17,17 +17,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
@Version("1.0.0")
public class PaletteAddon extends TerraAddon {
@Inject
private Platform main;
private Platform platform;
@Override
public void initialize() {
main.getEventManager()
.getHandler(FunctionalEventHandler.class)
.register(this, ConfigPackPreLoadEvent.class)
.then(event -> {
event.getPack().registerConfigType(new PaletteConfigType(main), "PALETTE", 2);
platform.getEventManager()
.getHandler(FunctionalEventHandler.class)
.register(this, ConfigPackPreLoadEvent.class)
.then(event -> {
event.getPack().registerConfigType(new PaletteConfigType(platform), "PALETTE", 2);
event.getPack().applyLoader(PaletteLayerHolder.class, new PaletteLayerLoader());
})
.failThrough();
.failThrough();
}
}
@@ -19,10 +19,10 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
public static final TypeKey<Palette> PALETTE_TYPE_TOKEN = new TypeKey<>() {
};
private final PaletteFactory factory = new PaletteFactory();
private final Platform main;
private final Platform platform;
public PaletteConfigType(Platform main) {
this.main = main;
public PaletteConfigType(Platform platform) {
this.platform = platform;
}
@Override
@@ -30,7 +30,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
return () -> pack.getRegistryFactory().create(registry -> (TypeLoader<Palette>) (t, c, loader) -> {
if(((String) c).startsWith("BLOCK:"))
return new PaletteImpl.Singleton(
main.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
platform.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
Palette obj = registry.get((String) c);
if(obj == null)
throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry.");
@@ -39,7 +39,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
}
@Override
public PaletteTemplate getTemplate(ConfigPack pack, Platform main) {
public PaletteTemplate getTemplate(ConfigPack pack, Platform platform) {
return new PaletteTemplate();
}
@@ -9,7 +9,7 @@ import com.dfsek.terra.api.world.generator.Palette;
public class PaletteFactory implements ConfigFactory<PaletteTemplate, Palette> {
@Override
public Palette build(PaletteTemplate config, Platform main) {
public Palette build(PaletteTemplate config, Platform platform) {
NoisePalette palette = new NoisePalette(config.getNoise());
for(PaletteLayerHolder layer : config.getPalette()) {
palette.add(layer.getLayer(), layer.getSize(), layer.getSampler());