dont use pack instance where unneeded

This commit is contained in:
dfsek
2021-07-20 15:12:06 -07:00
parent d807abb165
commit 0ff6a9cce1
10 changed files with 11 additions and 29 deletions
@@ -24,7 +24,7 @@ public class PaletteAddon extends TerraAddon implements EventListener {
}
public void onPackLoad(ConfigPackPreLoadEvent event) {
event.getPack().registerConfigType(new PaletteConfigType(event.getPack(), main), "PALETTE", 2);
event.getPack().registerConfigType(new PaletteConfigType(main), "PALETTE", 2);
event.getPack().applyLoader(PaletteLayerHolder.class, new PaletteLayerLoader());
}
}
@@ -15,13 +15,11 @@ import java.util.function.Supplier;
public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
private final PaletteFactory factory = new PaletteFactory();
private final ConfigPack pack;
private final TerraPlugin main;
public static final TypeKey<Palette> PALETTE_TYPE_TOKEN = new TypeKey<>(){};
public PaletteConfigType(ConfigPack pack, TerraPlugin main) {
this.pack = pack;
public PaletteConfigType(TerraPlugin main) {
this.main = main;
}
@@ -42,7 +40,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
@Override
public Supplier<OpenRegistry<Palette>> registrySupplier(ConfigPack pack) {
return () -> this.pack.getRegistryFactory().create(registry -> (TypeLoader<Palette>) (t, c, loader) -> {
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.
Palette obj = registry.get((String) c);