fix SchematicV2Handler, see https://bugs.openjdk.java.net/browse/JDK-8153248
This commit is contained in:
parent
7640be0787
commit
7b1d154ea2
3 changed files with 4 additions and 9 deletions
|
@ -86,12 +86,14 @@ public class SchematicV2Handler {
|
||||||
return reader.apply(tag);
|
return reader.apply(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fix, some weird "/" stuff
|
||||||
private void loadJson(Path path, String[] idParts, BiConsumer<String, Tag> loader) {
|
private void loadJson(Path path, String[] idParts, BiConsumer<String, Tag> loader) {
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
try {
|
try {
|
||||||
for (Path directoryPath : Files.newDirectoryStream(path)) {
|
for (Path directoryPath : Files.newDirectoryStream(path)) {
|
||||||
String[] directoryIdParts = Arrays.copyOf(idParts, idParts.length + 1);
|
String[] directoryIdParts = Arrays.copyOf(idParts, idParts.length + 1);
|
||||||
String fileName = directoryPath.getFileName().toString();
|
String fileName = directoryPath.getFileName().toString();
|
||||||
|
if (fileName.endsWith("/")) fileName = fileName.substring(0, fileName.length()-1); // https://bugs.openjdk.java.net/browse/JDK-8153248
|
||||||
if (Files.isRegularFile(directoryPath)) fileName = fileName.substring(0, fileName.lastIndexOf('.')); // cut extension
|
if (Files.isRegularFile(directoryPath)) fileName = fileName.substring(0, fileName.lastIndexOf('.')); // cut extension
|
||||||
directoryIdParts[directoryIdParts.length - 1] = fileName;
|
directoryIdParts[directoryIdParts.length - 1] = fileName;
|
||||||
loadJson(directoryPath, directoryIdParts, loader);
|
loadJson(directoryPath, directoryIdParts, loader);
|
||||||
|
@ -100,7 +102,7 @@ public class SchematicV2Handler {
|
||||||
LOGGER.error("could not load pocket data in path " + path.toString() + " due to malformed json.", e);
|
LOGGER.error("could not load pocket data in path " + path.toString() + " due to malformed json.", e);
|
||||||
}
|
}
|
||||||
} else if(Files.isRegularFile(path) && path.getFileName().toString().endsWith(".json")) {
|
} else if(Files.isRegularFile(path) && path.getFileName().toString().endsWith(".json")) {
|
||||||
String id = String.join("", idParts);
|
String id = String.join("/", idParts);
|
||||||
try {
|
try {
|
||||||
JsonElement json = GSON.fromJson(String.join("", Files.readAllLines(path)), JsonElement.class);
|
JsonElement json = GSON.fromJson(String.join("", Files.readAllLines(path)), JsonElement.class);
|
||||||
loader.accept(id, JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json));
|
loader.accept(id, JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json));
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package org.dimdev.dimdoors.pockets.modifier;
|
package org.dimdev.dimdoors.pockets.modifier;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.util.NbtType;
|
import net.fabricmc.fabric.api.util.NbtType;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -22,18 +20,13 @@ import org.dimdev.dimdoors.block.DimensionalDoorBlock;
|
||||||
import org.dimdev.dimdoors.block.ModBlocks;
|
import org.dimdev.dimdoors.block.ModBlocks;
|
||||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||||
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
|
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
|
||||||
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
|
|
||||||
import org.dimdev.dimdoors.block.entity.RiftData;
|
import org.dimdev.dimdoors.block.entity.RiftData;
|
||||||
import org.dimdev.dimdoors.pockets.SchematicV2Handler;
|
import org.dimdev.dimdoors.pockets.SchematicV2Handler;
|
||||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
|
||||||
import org.dimdev.dimdoors.rift.targets.IdMarker;
|
import org.dimdev.dimdoors.rift.targets.IdMarker;
|
||||||
import org.dimdev.dimdoors.rift.targets.PocketEntranceMarker;
|
|
||||||
import org.dimdev.dimdoors.rift.targets.PocketExitMarker;
|
|
||||||
import org.dimdev.dimdoors.util.PocketGenerationParameters;
|
import org.dimdev.dimdoors.util.PocketGenerationParameters;
|
||||||
import org.dimdev.dimdoors.util.TagEquations;
|
import org.dimdev.dimdoors.util.TagEquations;
|
||||||
import org.dimdev.dimdoors.util.math.Equation;
|
import org.dimdev.dimdoors.util.math.Equation;
|
||||||
import org.dimdev.dimdoors.util.math.Equation.EquationParseException;
|
import org.dimdev.dimdoors.util.math.Equation.EquationParseException;
|
||||||
import org.dimdev.dimdoors.world.pocket.Pocket;
|
|
||||||
|
|
||||||
public class DimensionalDoorModifier implements Modifier {
|
public class DimensionalDoorModifier implements Modifier {
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class RiftManager {
|
||||||
return maxId + 1;
|
return maxId + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean available(int id) {
|
public boolean available(int id) { // TODO: remove? method is likely redundant
|
||||||
return !map.containsKey(id);
|
return !map.containsKey(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue