Skip to content

Commit

Permalink
Fix the missing "Import Sponge" file type, when the code already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Aug 25, 2024
1 parent 0aad606 commit 4583a40
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ author = masa
mod_file_name = litematica-fabric

# Current mod version
mod_version = 0.19.3-sakura.1
mod_version = 0.19.3-sakura.2

# Required malilib version
malilib_version = 0.20.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class GuiSchematicManager extends GuiSchematicBrowserBase implements ISelectionListener<DirectoryEntry>
{
private static PreviewGenerator previewGenerator;
private ExportType exportType = ExportType.SCHEMATIC;
private ExportType exportType = ExportType.V6_LITEMATIC;

public GuiSchematicManager()
{
Expand Down Expand Up @@ -87,7 +87,7 @@ private void createButtons()
x = this.createButton(x, y, ButtonListener.Type.IMPORT_SCHEMATIC);
x = this.createButton(x, y, ButtonListener.Type.DELETE_SCHEMATIC);
}
else if (type == FileType.SCHEMATICA_SCHEMATIC || type == FileType.VANILLA_STRUCTURE)
else if (type == FileType.SPONGE_SCHEMATIC || type == FileType.SCHEMATICA_SCHEMATIC || type == FileType.VANILLA_STRUCTURE)
{
x = this.createButton(x, y, ButtonListener.Type.IMPORT_SCHEMATIC);
x = this.createButton(x, y, ButtonListener.Type.DELETE_SCHEMATIC);
Expand Down Expand Up @@ -167,7 +167,7 @@ public IConfigOptionListEntry getOptionListValue()
@Override
public IConfigOptionListEntry getDefaultOptionListValue()
{
return ExportType.SCHEMATIC;
return ExportType.V6_LITEMATIC;
}

@Override
Expand Down Expand Up @@ -238,6 +238,7 @@ public void actionPerformedWithButton(ButtonBase button, int mouseButton)
else if (this.type == Type.IMPORT_SCHEMATIC)
{
if (fileType == FileType.LITEMATICA_SCHEMATIC ||
fileType == FileType.SPONGE_SCHEMATIC ||
fileType == FileType.SCHEMATICA_SCHEMATIC ||
fileType == FileType.VANILLA_STRUCTURE)
{
Expand Down Expand Up @@ -535,7 +536,7 @@ public static ExportType fromStringStatic(String name)
}
}

return ExportType.SCHEMATIC;
return ExportType.V6_LITEMATIC;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ public void actionPerformedWithButton(ButtonBase button, int mouseButton)

if (fileType == FileType.LITEMATICA_SCHEMATIC)
{
if (this.gui.exportType == ExportType.SCHEMATIC)
if (this.gui.exportType == ExportType.V6_LITEMATIC)
{
if (WorldUtils.convertLitematicaSchematicToSchematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
if (WorldUtils.convertLitematicaSchematicToV6LitematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
{
this.gui.addMessage(MessageType.SUCCESS, "litematica.message.schematic_exported_as", fileName);
this.gui.addMessage(MessageType.SUCCESS, "litematica.message.litematic_downgrade_exported_as", fileName);
this.gui.getListWidget().refreshEntries();
}
}
else if (this.gui.exportType == ExportType.V6_LITEMATIC)
else if (this.gui.exportType == ExportType.SCHEMATIC)
{
if (WorldUtils.convertLitematicaSchematicToV6LitematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
if (WorldUtils.convertLitematicaSchematicToSchematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
{
this.gui.addMessage(MessageType.SUCCESS, "litematica.message.litematic_downgrade_exported_as", fileName);
this.gui.addMessage(MessageType.SUCCESS, "litematica.message.schematic_exported_as", fileName);
this.gui.getListWidget().refreshEntries();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public void actionPerformedWithButton(ButtonBase button, int mouseButton)

return;
}
else if (fileType == FileType.SPONGE_SCHEMATIC)
{
if (WorldUtils.convertSpongeSchematicToLitematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
{
this.gui.addMessage(MessageType.SUCCESS, "litematica.message.schematic_saved_as", fileName);
this.gui.getListWidget().refreshEntries();
}

return;
}
else if (fileType == FileType.SCHEMATICA_SCHEMATIC)
{
if (WorldUtils.convertSchematicaSchematicToLitematicaSchematic(inDir, inFile, dir, fileName, ignoreEntities, override, this.gui))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ private boolean readFromFile(FileType schematicType)
{
if (schematicType == FileType.SPONGE_SCHEMATIC)
{
String name = FileUtils.getNameWithoutExtension(this.schematicFile.getName()) + " (Converted Structure)";
String name = FileUtils.getNameWithoutExtension(this.schematicFile.getName()) + " (Converted Sponge)";
return this.readFromSpongeSchematic(name, nbt);
}
if (schematicType == FileType.VANILLA_STRUCTURE)
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/fi/dy/masa/litematica/util/WorldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public static boolean convertLitematicaSchematicToLitematicaSchematic(
return litematicaSchematic != null && litematicaSchematic.writeToFile(outputDir, outputFileName, override);
}

public static boolean convertSpongeSchematicToLitematicaSchematic(
File inputDir, String inputFileName, File outputDir, String outputFileName, boolean ignoreEntities, boolean override, IStringConsumer feedback)
{
LitematicaSchematic litematicaSchematic = convertSpongeSchematicToLitematicaSchematic(inputDir, inputFileName);
return litematicaSchematic != null && litematicaSchematic.writeToFile(outputDir, outputFileName, override);
}

public static boolean convertSchematicaSchematicToLitematicaSchematic(
File inputDir, String inputFileName, File outputDir, String outputFileName, boolean ignoreEntities, boolean override, IStringConsumer feedback)
{
Expand Down Expand Up @@ -624,7 +631,8 @@ else if (protocol == EasyPlaceProtocol.SLAB_ONLY)
ActionResult result = mc.interactionManager.interactBlock(mc.player, hand, hitResult);

// swing hand fix, see MinecraftClient#doItemUse
if (result.shouldSwingHand() && Configs.Generic.EASY_PLACE_SWING_HAND.getBooleanValue())
if (result.shouldSwingHand() &&
Configs.Generic.EASY_PLACE_SWING_HAND.getBooleanValue())
{
mc.player.swingHand(hand);
}
Expand Down

0 comments on commit 4583a40

Please sign in to comment.