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);
|
||||
}
|
||||
|
||||
// TODO: fix, some weird "/" stuff
|
||||
private void loadJson(Path path, String[] idParts, BiConsumer<String, Tag> loader) {
|
||||
if (Files.isDirectory(path)) {
|
||||
try {
|
||||
for (Path directoryPath : Files.newDirectoryStream(path)) {
|
||||
String[] directoryIdParts = Arrays.copyOf(idParts, idParts.length + 1);
|
||||
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
|
||||
directoryIdParts[directoryIdParts.length - 1] = fileName;
|
||||
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);
|
||||
}
|
||||
} else if(Files.isRegularFile(path) && path.getFileName().toString().endsWith(".json")) {
|
||||
String id = String.join("", idParts);
|
||||
String id = String.join("/", idParts);
|
||||
try {
|
||||
JsonElement json = GSON.fromJson(String.join("", Files.readAllLines(path)), JsonElement.class);
|
||||
loader.accept(id, JsonOps.INSTANCE.convertTo(NbtOps.INSTANCE, json));
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.dimdev.dimdoors.pockets.modifier;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.fabricmc.fabric.api.util.NbtType;
|
||||
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.entity.EntranceRiftBlockEntity;
|
||||
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.pockets.SchematicV2Handler;
|
||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
||||
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.TagEquations;
|
||||
import org.dimdev.dimdoors.util.math.Equation;
|
||||
import org.dimdev.dimdoors.util.math.Equation.EquationParseException;
|
||||
import org.dimdev.dimdoors.world.pocket.Pocket;
|
||||
|
||||
public class DimensionalDoorModifier implements Modifier {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class RiftManager {
|
|||
return maxId + 1;
|
||||
}
|
||||
|
||||
public boolean available(int id) {
|
||||
public boolean available(int id) { // TODO: remove? method is likely redundant
|
||||
return !map.containsKey(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue