Skip to content

Commit

Permalink
Implement V7 fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Barteks2x committed Aug 4, 2023
1 parent b264317 commit e1461b9
Show file tree
Hide file tree
Showing 4 changed files with 508 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
*/
package io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui;

import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.floatInput;
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.malisisText;
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.WIDTH_2_COL;

import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.ExtraGui;
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UITextFieldFixed;
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UIVerticalTableLayout;
import io.github.opencubicchunks.cubicchunks.cubicgen.preset.JsonObjectView;
import net.malisis.core.client.gui.component.UIComponent;
import net.malisis.core.client.gui.component.interaction.UITextField;
import net.minecraft.util.math.MathHelper;

public class ReplacerConfigTab {

Expand All @@ -41,4 +49,47 @@ public Entry(ExtraGui gui, String name) {

}
}

private static class UIReplacerEntry<T extends UIReplacerEntry<T>> extends UIVerticalTableLayout<T> {

final JsonObjectView config;
UITextField minY;
UITextField maxY;

UIReplacerEntry(ExtraGui gui, JsonObjectView conf) {
super(gui, 2);
this.config = conf;
init(gui);
}

private void init(ExtraGui gui) {
this.removeAll();
int gridY = -1;
add(floatInput(gui, malisisText("minY"), this.minY = new UITextField(gui, ""), (int) config.getDouble("minY")),
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 0, ++gridY, WIDTH_2_COL));
add(floatInput(gui, malisisText("maxY"), this.maxY = new UITextField(gui, ""), (int) config.getDouble("maxY")),
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 1, gridY, WIDTH_2_COL));
}
}
private static class UIDensityRangeReplacerEntry extends UIReplacerEntry<UIDensityRangeReplacerEntry> {

UIDensityRangeReplacerEntry(ExtraGui gui, JsonObjectView conf) {
super(gui, conf);
init(gui);
}

private void init(ExtraGui gui) {
int gridY = 0;
// public BlockStateDesc blockInRange;
// public BlockStateDesc blockOutOfRange;
// public List<BlockStateDesc> filterBlocks = new ArrayList<>();
// public FilterType blockFilterType;
// public double minDensity;
// public double maxDensity;
add(floatInput(gui, malisisText("minY"), this.minY = new UITextField(gui, ""), (int) config.getDouble("minY")),
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 0, ++gridY, WIDTH_2_COL));
add(floatInput(gui, malisisText("maxY"), this.maxY = new UITextField(gui, ""), (int) config.getDouble("maxY")),
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 1, gridY, WIDTH_2_COL));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public float getFloat(String key) {
return (float) (double) Objects.requireNonNull(this.obj.get(double.class, key), () -> "Missing float entry " + key);
}

public double getDouble(String key) {
return Objects.requireNonNull(this.obj.get(double.class, key), () -> "Missing double entry " + key);
}

public String getString(String key) {
return Objects.requireNonNull(this.obj.get(String.class, key), () -> "Missing string entry " + key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class V6Fix implements IJsonFix {
.valueTransform("cubeAreas", this::convertCubeAreas)
.build();

// TODO: why is this never called?
private void transformGenInBlockstates(JsonObject oldRoot, JsonObject newRoot, JsonTransformer.CombinedContext<Function<JsonObject, JsonObject>> ctx) {
JsonElement oldValue = oldRoot.get("genInBlockstates");
if (oldValue instanceof JsonNull) {
Expand Down
Loading

0 comments on commit e1461b9

Please sign in to comment.