renamed fields for clarity

This commit is contained in:
CreepyCre 2021-01-27 11:58:00 +01:00
parent 1e8ff2b71f
commit 615aa06606
2 changed files with 8 additions and 9 deletions

View file

@ -28,8 +28,8 @@ public class SchematicV2Handler {
private static final Gson GSON = new GsonBuilder().setLenient().setPrettyPrinting().create();
private static final SchematicV2Handler INSTANCE = new SchematicV2Handler();
private final Map<Identifier, PocketTemplateV2> templates = Maps.newHashMap();
private final Map<String, WeightedList<VirtualPocket, PocketGenerationParameters>> templateMap = Maps.newHashMap(); //TODO: un-ugly-fy
private final List<PocketGroup> pocketTypes = Lists.newArrayList();
private final Map<String, WeightedList<VirtualPocket, PocketGenerationParameters>> weightedPocketGroups = Maps.newHashMap(); //TODO: un-ugly-fy
private final List<PocketGroup> pocketGroups = Lists.newArrayList();
private boolean loaded = false;
private SchematicV2Handler() {
@ -55,10 +55,10 @@ public class SchematicV2Handler {
JsonObject json = GSON.fromJson(String.join("", result), JsonObject.class);
PocketGroup type = PocketGroup.CODEC.decode(JsonOps.INSTANCE, json).getOrThrow(false, System.err::println).getFirst();
this.pocketTypes.add(type);
this.pocketGroups.add(type);
WeightedList<VirtualPocket, PocketGenerationParameters> weightedPockets = new WeightedList<>();
templateMap.put(type.getGroup(), weightedPockets);
weightedPocketGroups.put(type.getGroup(), weightedPockets);
for (VirtualPocket virtualPocket : type.getEntries()) {
virtualPocket.init(type.getGroup());
@ -95,7 +95,7 @@ public class SchematicV2Handler {
}
public VirtualPocket getRandomPocketFromGroup(String group, PocketGenerationParameters parameters) {
return templateMap.get(group).getRandomWeighted(parameters);
return weightedPocketGroups.get(group).getRandomWeighted(parameters);
}
public static SchematicV2Handler getInstance() {
@ -106,7 +106,7 @@ public class SchematicV2Handler {
return this.templates;
}
public List<PocketGroup> getPocketTypes() {
return this.pocketTypes;
public List<PocketGroup> getPocketGroups() {
return this.pocketGroups;
}
}

View file

@ -14,7 +14,6 @@ import org.dimdev.dimdoors.util.Weighted;
import org.dimdev.dimdoors.world.pocket.Pocket;
// TODO: possibly rename to PocketHandler (and rename subclasses accordingly)
// TODO: do something about getting correct Pocket sizes
public abstract class VirtualPocket implements Weighted<PocketGenerationParameters> {
public static final Registry<VirtualPocketType<? extends VirtualPocket>> REGISTRY = FabricRegistryBuilder.from(new SimpleRegistry<VirtualPocketType<? extends VirtualPocket>>(RegistryKey.ofRegistry(new Identifier("dimdoors", "virtual_pocket_type")), Lifecycle.stable())).buildAndRegister();
@ -44,7 +43,7 @@ public abstract class VirtualPocket implements Weighted<PocketGenerationParamete
public interface VirtualPocketType<T extends VirtualPocket> {
VirtualPocketType<SchematicGenerator> SCHEMATIC = register(new Identifier("dimdoors", SchematicGenerator.KEY), SchematicGenerator.CODEC);
VirtualPocketType<DepthDependentSelector> DEPTH_DEPENDENT = register(new Identifier("dimdoors", DepthDependentSelector.KEY), DepthDependentSelector.CODEC);