band-aid fix for json door rift destinations
This commit is contained in:
parent
e4bd7e00e4
commit
2d8f9f0255
2 changed files with 17 additions and 15 deletions
|
@ -49,7 +49,7 @@ public class DoorDataReader {
|
|||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:iron_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PublicPocketTarget()), Optional.empty()), AlwaysTrueCondition.INSTANCE)))
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PublicPocketTarget()), Optional.empty()).toJson(new JsonObject()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
public static final DoorData DEFAULT_GOLD_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:gold_dimensional_door",
|
||||
|
@ -63,7 +63,7 @@ public class DoorDataReader {
|
|||
new DoorData.UnbakedBlockSettings(
|
||||
"dimdoors:gold_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(DefaultDungeonDestinations.getDeeperDungeonDestination()), Optional.of(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES)), AlwaysTrueCondition.INSTANCE)))
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(DefaultDungeonDestinations.getDeeperDungeonDestination()), Optional.of(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES)).toJson(new JsonObject()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
public static final DoorData DEFAULT_OAK_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:oak_dimensional_door",
|
||||
|
@ -77,7 +77,7 @@ public class DoorDataReader {
|
|||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:oak_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(DefaultDungeonDestinations.getShallowerDungeonDestination()), Optional.of(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES)), AlwaysTrueCondition.INSTANCE)))
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(DefaultDungeonDestinations.getShallowerDungeonDestination()), Optional.of(DefaultDungeonDestinations.POCKET_LINK_PROPERTIES)).toJson(new JsonObject()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
public static final DoorData DEFAULT_QUARTZ_DIMENSIONAL_DOOR = new DoorData(
|
||||
"dimdoors:quartz_dimensional_door",
|
||||
|
@ -93,8 +93,8 @@ public class DoorDataReader {
|
|||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> {
|
||||
WorldMatchCondition condition = new WorldMatchCondition(ModDimensions.PERSONAL);
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketExitTarget()), Optional.empty()), condition));
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketTarget()), Optional.empty()), new InverseCondition(condition)));
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketExitTarget()), Optional.empty()).toJson(new JsonObject()), condition));
|
||||
list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new PrivatePocketTarget()), Optional.empty()).toJson(new JsonObject()), new InverseCondition(condition)));
|
||||
})
|
||||
));
|
||||
public static final DoorData DEFAULT_UNSTABLE_DIMENSIONAL_DOOR = new DoorData(
|
||||
|
@ -109,7 +109,7 @@ public class DoorDataReader {
|
|||
new DoorData.UnbakedBlockSettings(
|
||||
"minecraft:iron_door",
|
||||
OptionalInt.of(10)
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new UnstableTarget()), Optional.of(LinkProperties.builder().linksRemaining(1).groups(IntStream.of(0, 1).boxed().collect(Collectors.toSet())).build())), AlwaysTrueCondition.INSTANCE)))
|
||||
), new RiftDataList(Util.make(new LinkedList<>(), list -> list.add(new Pair<>(new RiftDataList.OptRiftData(Optional.of(new UnstableTarget()), Optional.of(LinkProperties.builder().linksRemaining(1).groups(IntStream.of(0, 1).boxed().collect(Collectors.toSet())).build())).toJson(new JsonObject()), AlwaysTrueCondition.INSTANCE)))
|
||||
));
|
||||
|
||||
public static void read() {
|
||||
|
|
|
@ -18,34 +18,36 @@ import net.minecraft.nbt.NbtOps;
|
|||
import net.minecraft.util.Pair;
|
||||
|
||||
public class RiftDataList {
|
||||
private final LinkedList<Pair<OptRiftData, Condition>> riftDataConditions;
|
||||
private final LinkedList<Pair<JsonObject, Condition>> riftDataConditions;
|
||||
|
||||
public static RiftDataList fromJson(JsonArray jsonArray) {
|
||||
LinkedList<Pair<OptRiftData, Condition>> riftDataConditions = new LinkedList<>();
|
||||
LinkedList<Pair<JsonObject, Condition>> riftDataConditions = new LinkedList<>();
|
||||
for (JsonElement json : jsonArray) {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
OptRiftData riftData = OptRiftData.fromJson(jsonObject.getAsJsonObject("data"));
|
||||
//OptRiftData riftData = OptRiftData.fromJson(jsonObject.getAsJsonObject("data"));
|
||||
JsonObject unbakedRiftData = jsonObject.getAsJsonObject("data");
|
||||
Condition condition = Condition.fromJson(jsonObject.getAsJsonObject("condition"));
|
||||
riftDataConditions.add(new Pair<>(riftData, condition));
|
||||
riftDataConditions.add(new Pair<>(unbakedRiftData, condition));
|
||||
}
|
||||
return new RiftDataList(riftDataConditions);
|
||||
}
|
||||
|
||||
public RiftDataList(LinkedList<Pair<OptRiftData, Condition>> riftDataConditions) {
|
||||
public RiftDataList(LinkedList<Pair<JsonObject, Condition>> riftDataConditions) {
|
||||
this.riftDataConditions = riftDataConditions;
|
||||
}
|
||||
|
||||
public OptRiftData getRiftData(EntranceRiftBlockEntity rift) {
|
||||
return riftDataConditions.stream().filter(pair -> pair.getRight().matches(rift)).findFirst().orElseThrow(() -> new RuntimeException("Could not find any matching rift data")).getLeft();
|
||||
JsonObject unbakedRiftData = riftDataConditions.stream().filter(pair -> pair.getRight().matches(rift)).findFirst().orElseThrow(() -> new RuntimeException("Could not find any matching rift data")).getLeft();
|
||||
return OptRiftData.fromJson(unbakedRiftData);
|
||||
}
|
||||
|
||||
public JsonArray toJson() {
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for (Map.Entry<OptRiftData, Condition> entry : this.riftDataConditions.stream().collect(Collectors.toMap(Pair::getLeft, Pair::getRight)).entrySet()) {
|
||||
OptRiftData riftData = entry.getKey();
|
||||
for (Map.Entry<JsonObject, Condition> entry : this.riftDataConditions.stream().collect(Collectors.toMap(Pair::getLeft, Pair::getRight)).entrySet()) {
|
||||
JsonObject unbakedRiftData = entry.getKey();
|
||||
Condition condition = entry.getValue();
|
||||
JsonObject jsonInner = new JsonObject();
|
||||
jsonInner.add("data", riftData.toJson(new JsonObject()));
|
||||
jsonInner.add("data", unbakedRiftData);
|
||||
jsonInner.add("condition", condition.toJson(new JsonObject()));
|
||||
jsonArray.add(jsonInner);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue