mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-03 19:36:53 -04:00
优化原理图管理功能 (#3978)
This commit is contained in:
parent
d317844b28
commit
ee652f6f31
@ -299,6 +299,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
new IconedMenuItem(SVG.SETTINGS, i18n("folder.config"), () -> control.onBrowse("config"), browsePopup),
|
new IconedMenuItem(SVG.SETTINGS, i18n("folder.config"), () -> control.onBrowse("config"), browsePopup),
|
||||||
new IconedMenuItem(SVG.TEXTURE, i18n("folder.resourcepacks"), () -> control.onBrowse("resourcepacks"), browsePopup),
|
new IconedMenuItem(SVG.TEXTURE, i18n("folder.resourcepacks"), () -> control.onBrowse("resourcepacks"), browsePopup),
|
||||||
new IconedMenuItem(SVG.WB_SUNNY, i18n("folder.shaderpacks"), () -> control.onBrowse("shaderpacks"), browsePopup),
|
new IconedMenuItem(SVG.WB_SUNNY, i18n("folder.shaderpacks"), () -> control.onBrowse("shaderpacks"), browsePopup),
|
||||||
|
new IconedMenuItem(SVG.SCHEMA, i18n("folder.schematics"), () -> control.onBrowse("schematics"), browsePopup),
|
||||||
new IconedMenuItem(SVG.SCREENSHOT_MONITOR, i18n("folder.screenshots"), () -> control.onBrowse("screenshots"), browsePopup),
|
new IconedMenuItem(SVG.SCREENSHOT_MONITOR, i18n("folder.screenshots"), () -> control.onBrowse("screenshots"), browsePopup),
|
||||||
new IconedMenuItem(SVG.PUBLIC, i18n("folder.saves"), () -> control.onBrowse("saves"), browsePopup),
|
new IconedMenuItem(SVG.PUBLIC, i18n("folder.saves"), () -> control.onBrowse("saves"), browsePopup),
|
||||||
new IconedMenuItem(SVG.SCRIPT, i18n("folder.logs"), () -> control.onBrowse("logs"), browsePopup)
|
new IconedMenuItem(SVG.SCRIPT, i18n("folder.logs"), () -> control.onBrowse("logs"), browsePopup)
|
||||||
|
@ -435,6 +435,7 @@ folder.mod=Mods
|
|||||||
folder.resourcepacks=Resource Packs
|
folder.resourcepacks=Resource Packs
|
||||||
folder.shaderpacks=Shader Packs
|
folder.shaderpacks=Shader Packs
|
||||||
folder.saves=Saves
|
folder.saves=Saves
|
||||||
|
folder.schematics=Schematics
|
||||||
folder.screenshots=Screenshots
|
folder.screenshots=Screenshots
|
||||||
|
|
||||||
game=Games
|
game=Games
|
||||||
|
@ -406,6 +406,7 @@ folder.mod=模組目錄
|
|||||||
folder.resourcepacks=資源包目錄
|
folder.resourcepacks=資源包目錄
|
||||||
folder.shaderpacks=著色器包目錄
|
folder.shaderpacks=著色器包目錄
|
||||||
folder.saves=遊戲存檔目錄
|
folder.saves=遊戲存檔目錄
|
||||||
|
folder.schematics=原理圖目錄
|
||||||
folder.screenshots=截圖目錄
|
folder.screenshots=截圖目錄
|
||||||
|
|
||||||
game=遊戲
|
game=遊戲
|
||||||
|
@ -415,6 +415,7 @@ folder.mod=模组文件夹
|
|||||||
folder.resourcepacks=资源包文件夹
|
folder.resourcepacks=资源包文件夹
|
||||||
folder.shaderpacks=光影包文件夹
|
folder.shaderpacks=光影包文件夹
|
||||||
folder.saves=存档文件夹
|
folder.saves=存档文件夹
|
||||||
|
folder.schematics=原理图文件夹
|
||||||
folder.screenshots=截图文件夹
|
folder.screenshots=截图文件夹
|
||||||
|
|
||||||
game=游戏
|
game=游戏
|
||||||
|
@ -64,83 +64,65 @@ public final class LitematicFile {
|
|||||||
else if (!(versionTag instanceof IntTag))
|
else if (!(versionTag instanceof IntTag))
|
||||||
throw new IOException("Version tag is not an integer");
|
throw new IOException("Version tag is not an integer");
|
||||||
|
|
||||||
|
|
||||||
Tag metadataTag = root.get("Metadata");
|
Tag metadataTag = root.get("Metadata");
|
||||||
if (metadataTag == null)
|
if (metadataTag == null)
|
||||||
throw new IOException("Metadata tag not found");
|
throw new IOException("Metadata tag not found");
|
||||||
else if (!(metadataTag instanceof CompoundTag))
|
else if (!(metadataTag instanceof CompoundTag))
|
||||||
throw new IOException("Metadata tag is not a compound tag");
|
throw new IOException("Metadata tag is not a compound tag");
|
||||||
|
|
||||||
return new LitematicFile(file, root);
|
int regions = 0;
|
||||||
|
Tag regionsTag = root.get("Regions");
|
||||||
|
if (regionsTag instanceof CompoundTag)
|
||||||
|
regions = ((CompoundTag) regionsTag).size();
|
||||||
|
|
||||||
|
return new LitematicFile(file, (CompoundTag) metadataTag,
|
||||||
|
((IntTag) versionTag).getValue(),
|
||||||
|
tryGetInt(root.get("SubVersion")),
|
||||||
|
tryGetInt(root.get("MinecraftDataVersion")),
|
||||||
|
regions
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final @NotNull Path file;
|
private final @NotNull Path file;
|
||||||
private final @NotNull CompoundTag root;
|
|
||||||
|
|
||||||
private LitematicFile(@NotNull Path file, @NotNull CompoundTag root) {
|
private final int version;
|
||||||
|
private final int subVersion;
|
||||||
|
private final int minecraftDataVersion;
|
||||||
|
private final int regionCount;
|
||||||
|
private final int[] previewImageData;
|
||||||
|
private final String name;
|
||||||
|
private final String author;
|
||||||
|
private final String description;
|
||||||
|
private final Instant timeCreated;
|
||||||
|
private final Instant timeModified;
|
||||||
|
private final int totalBlocks;
|
||||||
|
private final int totalVolume;
|
||||||
|
private final Point3D enclosingSize;
|
||||||
|
|
||||||
|
private LitematicFile(@NotNull Path file, @NotNull CompoundTag metadata,
|
||||||
|
int version, int subVersion, int minecraftDataVersion, int regionCount) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.root = root;
|
this.version = version;
|
||||||
}
|
this.subVersion = subVersion;
|
||||||
|
this.minecraftDataVersion = minecraftDataVersion;
|
||||||
|
this.regionCount = regionCount;
|
||||||
|
|
||||||
private @NotNull CompoundTag getMetadata() {
|
Tag previewImageData = metadata.get("PreviewImageData");
|
||||||
return root.get("Metadata");
|
this.previewImageData = previewImageData instanceof IntArrayTag
|
||||||
}
|
? ((IntArrayTag) previewImageData).getValue()
|
||||||
|
: null;
|
||||||
|
|
||||||
public @NotNull Path getFile() {
|
this.name = tryGetString(metadata.get("Name"));
|
||||||
return file;
|
this.author = tryGetString(metadata.get("Author"));
|
||||||
}
|
this.description = tryGetString(metadata.get("Description"));
|
||||||
|
this.timeCreated = tryGetLongTimestamp(metadata.get("TimeCreated"));
|
||||||
|
this.timeModified = tryGetLongTimestamp(metadata.get("TimeModified"));
|
||||||
|
this.totalBlocks = tryGetInt(metadata.get("TotalBlocks"));
|
||||||
|
this.totalVolume = tryGetInt(metadata.get("TotalVolume"));
|
||||||
|
|
||||||
public int getVersion() {
|
|
||||||
return root.<IntTag>get("Version").getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSubVersion() {
|
Point3D enclosingSize = null;
|
||||||
return tryGetInt(root.get("SubVersion"));
|
Tag enclosingSizeTag = metadata.get("EnclosingSize");
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinecraftDataVersion() {
|
|
||||||
return tryGetInt(root.get("MinecraftDataVersion"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getPreviewImageData() {
|
|
||||||
Tag previewImageData = getMetadata().get("PreviewImageData");
|
|
||||||
if (previewImageData instanceof IntArrayTag) {
|
|
||||||
return ((IntArrayTag) previewImageData).getValue().clone();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return tryGetString(getMetadata().get("Name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthor() {
|
|
||||||
return tryGetString(getMetadata().get("Author"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return tryGetString(getMetadata().get("Description"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getTimeCreated() {
|
|
||||||
return tryGetLongTimestamp(getMetadata().get("TimeCreated"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getTimeModified() {
|
|
||||||
return tryGetLongTimestamp(getMetadata().get("TimeModified"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalBlocks() {
|
|
||||||
return tryGetInt(getMetadata().get("TotalBlocks"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalVolume() {
|
|
||||||
return tryGetInt(getMetadata().get("TotalVolume"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point3D getEnclosingSize() {
|
|
||||||
Tag enclosingSizeTag = getMetadata().get("EnclosingSize");
|
|
||||||
if (enclosingSizeTag instanceof CompoundTag) {
|
if (enclosingSizeTag instanceof CompoundTag) {
|
||||||
CompoundTag list = (CompoundTag) enclosingSizeTag;
|
CompoundTag list = (CompoundTag) enclosingSizeTag;
|
||||||
int x = tryGetInt(list.get("x"));
|
int x = tryGetInt(list.get("x"));
|
||||||
@ -148,16 +130,65 @@ public final class LitematicFile {
|
|||||||
int z = tryGetInt(list.get("z"));
|
int z = tryGetInt(list.get("z"));
|
||||||
|
|
||||||
if (x >= 0 && y >= 0 && z >= 0)
|
if (x >= 0 && y >= 0 && z >= 0)
|
||||||
return new Point3D(x, y, z);
|
enclosingSize = new Point3D(x, y, z);
|
||||||
|
}
|
||||||
|
this.enclosingSize = enclosingSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
public @NotNull Path getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSubVersion() {
|
||||||
|
return subVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinecraftDataVersion() {
|
||||||
|
return minecraftDataVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getPreviewImageData() {
|
||||||
|
return previewImageData != null ? previewImageData.clone() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getTimeCreated() {
|
||||||
|
return timeCreated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getTimeModified() {
|
||||||
|
return timeModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalBlocks() {
|
||||||
|
return totalBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalVolume() {
|
||||||
|
return totalVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point3D getEnclosingSize() {
|
||||||
|
return enclosingSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRegionCount() {
|
public int getRegionCount() {
|
||||||
Tag regions = root.get("Regions");
|
return regionCount;
|
||||||
if (regions instanceof CompoundTag)
|
|
||||||
return ((CompoundTag) regions).size();
|
|
||||||
else return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user