### ToolMode - Litematica Operation Modes Source: https://context7.com/sakura-ryoko/litematica/llms.txt Control and query the active operation mode for the Litematica tool. Use `DataManager.getToolMode()` to get the current mode and `DataManager.setToolMode()` to change it. Modes can be cycled using `mode.cycle()`, and properties like `getUsesSchematic()` or `getUsesBlockPrimary()` can be checked. Block-specific modes allow setting primary and secondary blocks. ```java import fi.dy.masa.litematica.tool.ToolMode; import fi.dy.masa.litematica.data.DataManager; import net.minecraft.world.entity.player.Player; // Get current tool mode ToolMode mode = DataManager.getToolMode(); // Set specific tool mode DataManager.setToolMode(ToolMode.AREA_SELECTION); // Available tool modes: // AREA_SELECTION - Create and modify area selections // SCHEMATIC_PLACEMENT - Manage schematic placements // FILL - Fill areas with blocks (creative only) // REPLACE_BLOCK - Replace specific blocks (creative only) // PASTE_SCHEMATIC - Paste schematics to world (creative only) // GRID_PASTE - Paste in grid pattern (creative only) // MOVE - Move selections/placements (creative only) // DELETE - Delete blocks (creative only) // REBUILD - Rebuild mode for verification // Cycle through modes Player player = mc.player; ToolMode nextMode = mode.cycle(player, true); // forward ToolMode prevMode = mode.cycle(player, false); // backward // Check mode properties boolean usesSchematic = mode.getUsesSchematic(); boolean usesAreaSelection = mode.getUsesAreaSelection(); // For block replacement modes if (mode.getUsesBlockPrimary()) { mode.setPrimaryBlock(Blocks.STONE.defaultBlockState()); } if (mode.getUsesBlockSecondary()) { mode.setSecondaryBlock(Blocks.AIR.defaultBlockState()); } ``` -------------------------------- ### Create and Configure Schematic Placement Source: https://context7.com/sakura-ryoko/litematica/llms.txt Load a schematic, create a placement in the world, and configure its transformations and rendering. Ensure the schematic file exists and is accessible. ```java import fi.dy.masa.litematica.schematic.placement.SchematicPlacement; import fi.dy.masa.litematica.schematic.placement.SubRegionPlacement; import fi.dy.masa.litematica.schematic.LitematicaSchematic; import fi.dy.masa.litematica.data.SchematicHolder; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.Mirror; // Load and create a placement Path schematicFile = DataManager.getSchematicsBaseDirectory().resolve("my_build.litematic"); LitematicaSchematic schematic = SchematicHolder.getInstance().getOrLoad(schematicFile); BlockPos placementOrigin = new BlockPos(100, 64, 200); SchematicPlacement placement = SchematicPlacement.createFor( schematic, placementOrigin, "My Build Placement", true, // enabled true // enableRender ); // Configure placement transformations placement.setRotation(Rotation.CLOCKWISE_90, feedbackConsumer); placement.setMirror(Mirror.FRONT_BACK, feedbackConsumer); // Move placement origin placement.setOrigin(new BlockPos(150, 70, 250), feedbackConsumer); // Toggle placement state placement.setEnabled(true); placement.setRenderSchematic(true); placement.toggleLocked(); // Configure sub-region placements ImmutableMap subRegions = placement.getEnabledRelativeSubRegionPlacements(); for (Map.Entry entry : subRegions.entrySet()) { SubRegionPlacement subPlacement = entry.getValue(); subPlacement.setEnabled(true); subPlacement.setRotation(Rotation.NONE); } // Get placement bounding boxes for rendering/verification ImmutableMap boxes = placement.getSubRegionBoxes(RequiredEnabled.PLACEMENT_ENABLED); Set touchedChunks = placement.getTouchedChunks(); // Access material list MaterialListBase materialList = placement.getMaterialList(); // Access schematic verifier SchematicVerifier verifier = placement.getSchematicVerifier(); // Register placement with manager DataManager.getSchematicPlacementManager().addSchematicPlacement(placement, true); ``` -------------------------------- ### Material List System in Java Source: https://context7.com/sakura-ryoko/litematica/llms.txt Access and manage material lists for schematic placements. This includes refreshing the list, retrieving missing items, and controlling HUD rendering. Use DataManager to set the active material list. ```java import fi.dy.masa.litematica.materials.MaterialListBase; import fi.dy.masa.litematica.materials.MaterialListPlacement; import fi.dy.masa.litematica.materials.MaterialListEntry; import fi.dy.masa.litematica.materials.MaterialListHudRenderer; import fi.dy.masa.litematica.data.DataManager; // Get material list from placement SchematicPlacement placement = // ... get placement MaterialListBase materialList = placement.getMaterialList(); // Refresh/recalculate material list materialList.reCreateMaterialList(); // Get material entries List entries = materialList.getMaterialsMissingOnly(true); for (MaterialListEntry entry : entries) { ItemStack stack = entry.getStack(); long countTotal = entry.getCountTotal(); long countMissing = entry.getCountMissing(); long countAvailable = entry.getCountAvailable(); } // Get counts long totalMissing = materialList.getCountMissing(); long totalMismatched = materialList.getCountMismatched(); // HUD rendering MaterialListHudRenderer hudRenderer = materialList.getHudRenderer(); hudRenderer.toggleShouldRender(); // Set as active material list DataManager.setMaterialList(materialList); MaterialListBase active = DataManager.getMaterialList(); ``` -------------------------------- ### Configs - Access Mod Configuration Source: https://context7.com/sakura-ryoko/litematica/llms.txt Interact with Litematica's configuration settings through the `Configs` and `Hotkeys` classes. Access generic, visual, overlay, info overlay, and color settings. Modify values using their respective setters (e.g., `setBooleanValue`, `setDoubleValue`) and save changes with `Configs.saveToFile()` or load with `Configs.loadFromFile()`. ```java import fi.dy.masa.litematica.config.Configs; import fi.dy.masa.litematica.config.Hotkeys; // Generic settings boolean easyPlaceMode = Configs.Generic.EASY_PLACE_MODE.getBooleanValue(); Configs.Generic.EASY_PLACE_MODE.setBooleanValue(true); String toolItem = Configs.Generic.TOOL_ITEM.getStringValue(); Configs.Generic.TOOL_ITEM.setValueFromString("minecraft:blaze_rod"); int commandLimit = Configs.Generic.COMMAND_LIMIT.getIntegerValue(); Configs.Generic.COMMAND_FILL_MAX_VOLUME.setIntegerValue(32768); // Visual settings boolean renderEnabled = Configs.Visuals.ENABLE_RENDERING.getBooleanValue(); double ghostAlpha = Configs.Visuals.GHOST_BLOCK_ALPHA.getDoubleValue(); Configs.Visuals.GHOST_BLOCK_ALPHA.setDoubleValue(0.7); // Overlay settings boolean schematicOverlay = Configs.Visuals.ENABLE_SCHEMATIC_OVERLAY.getBooleanValue(); boolean renderEntities = Configs.Visuals.RENDER_SCHEMATIC_ENTITIES.getBooleanValue(); // Info overlay settings HudAlignment alignment = (HudAlignment) Configs.InfoOverlays.INFO_HUD_ALIGNMENT.getOptionListValue(); SelectionMode defaultMode = (SelectionMode) Configs.InfoOverlays.DEFAULT_SELECTION_MODE.getOptionListValue(); // Color settings int overlayColorMissing = Configs.Colors.SCHEMATIC_OVERLAY_COLOR_MISSING.getIntegerValue(); // Hotkey configuration String mainMenuKey = Hotkeys.OPEN_GUI_MAIN_MENU.getKeybind().getStringValue(); // Default: "M" String easyPlaceKey = Hotkeys.EASY_PLACE_ACTIVATION.getKeybind().getStringValue(); // Default: "BUTTON_2" (middle mouse) // Save/load configuration Configs.saveToFile(); Configs.loadFromFile(); ``` -------------------------------- ### Access Litematica DataManager Source: https://context7.com/sakura-ryoko/litematica/llms.txt Use the DataManager singleton to access core subsystems like selection, placement, and tool configuration. ```java import fi.dy.masa.litematica.data.DataManager; import fi.dy.masa.litematica.selection.SelectionManager; import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager; import fi.dy.masa.litematica.tool.ToolMode; // Get the singleton instance DataManager dataManager = DataManager.getInstance(); // Access selection manager for area selections SelectionManager selectionManager = DataManager.getSelectionManager(); // Access schematic placement manager SchematicPlacementManager placementManager = DataManager.getSchematicPlacementManager(); // Get/set the current tool mode ToolMode currentMode = DataManager.getToolMode(); DataManager.setToolMode(ToolMode.AREA_SELECTION); // Get the schematic base directory Path schematicsDir = DataManager.getSchematicsBaseDirectory(); // Check for server integration boolean hasCarpet = DataManager.isCarpetServer(); boolean hasServux = DataManager.hasServuxServer(); // Configure the tool item DataManager.setToolItem("minecraft:stick"); ``` -------------------------------- ### Perform Litematica Schematic Operations Source: https://context7.com/sakura-ryoko/litematica/llms.txt Manage schematic files by creating them from world selections, saving to disk, and retrieving metadata or block data. ```java import fi.dy.masa.litematica.schematic.LitematicaSchematic; import fi.dy.masa.litematica.schematic.LitematicaSchematic.SchematicSaveInfo; import fi.dy.masa.litematica.selection.AreaSelection; import fi.dy.masa.litematica.util.FileType; import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; import java.nio.file.Path; // Create a schematic from world selection Level world = mc.level; AreaSelection area = DataManager.getSelectionManager().getCurrentSelection(); String authorName = mc.player.getName().getString(); SchematicSaveInfo saveInfo = new SchematicSaveInfo( false, // visibleOnly - only save exposed blocks false, // includeSupportBlocks - include blocks supporting gravity blocks false, // ignoreEntities - skip entity capture false // fromSchematicWorld - save from schematic world instead ); LitematicaSchematic schematic = LitematicaSchematic.createFromWorld( world, area, saveInfo, authorName, feedbackConsumer ); // Save schematic to file Path outputDir = DataManager.getSchematicsBaseDirectory(); boolean success = schematic.writeToFile(outputDir, "my_schematic", true); // Load schematic from file LitematicaSchematic loaded = LitematicaSchematic.createFromFile( outputDir, "my_schematic.litematic", FileType.LITEMATICA_SCHEMATIC ); // Get schematic metadata SchematicMetadata metadata = loaded.getMetadata(); String name = metadata.getName(); String author = metadata.getAuthor(); Vec3i totalSize = loaded.getTotalSize(); int regionCount = loaded.getSubRegionCount(); // Access sub-regions Map regionPositions = loaded.getAreaPositions(); Map regionSizes = loaded.getAreaSizes(); // Get block data for a region LitematicaBlockStateContainer container = loaded.getSubRegionContainer("regionName"); BlockState state = container.get(x, y, z); // Get entities and tile entities List entities = loaded.getEntityListForRegion("regionName"); Map tileEntities = loaded.getBlockEntityMapForRegion("regionName"); ``` -------------------------------- ### DataManager - Central Data Access Source: https://context7.com/sakura-ryoko/litematica/llms.txt The DataManager class provides singleton access to major subsystems like selection management, schematic placement, and material lists. It also allows configuration of tool items and checks for server integrations. ```APIDOC ## DataManager - Central Data Access ### Description Provides singleton access to Litematica's core subsystems and configuration options. ### Method N/A (Singleton class) ### Endpoint N/A (Client-side mod API) ### Parameters N/A ### Request Example ```java import fi.dy.masa.litematica.data.DataManager; import fi.dy.masa.litematica.selection.SelectionManager; import fi.dy.masa.litematica.schematic.placement.SchematicPlacementManager; import fi.dy.masa.litematica.tool.ToolMode; // Get the singleton instance DataManager dataManager = DataManager.getInstance(); // Access selection manager for area selections SelectionManager selectionManager = DataManager.getSelectionManager(); // Access schematic placement manager SchematicPlacementManager placementManager = DataManager.getSchematicPlacementManager(); // Get/set the current tool mode ToolMode currentMode = DataManager.getToolMode(); DataManager.setToolMode(ToolMode.AREA_SELECTION); // Get the schematic base directory Path schematicsDir = DataManager.getSchematicsBaseDirectory(); // Check for server integration boolean hasCarpet = DataManager.isCarpetServer(); boolean hasServux = DataManager.hasServuxServer(); // Configure the tool item DataManager.setToolItem("minecraft:stick"); ``` ### Response N/A (Direct Java API calls) ``` -------------------------------- ### SchematicHolder - Cache Loaded Schematics Source: https://context7.com/sakura-ryoko/litematica/llms.txt Manage a cache of loaded schematics to optimize file access. Use `getOrLoad` to retrieve a schematic, `addSchematic` to cache it, and `removeSchematic` to unload it. `getAllSchematics` retrieves all cached schematics, and `clearLoadedSchematics` empties the cache. ```java import fi.dy.masa.litematica.data.SchematicHolder; import fi.dy.masa.litematica.schematic.LitematicaSchematic; import java.nio.file.Path; import java.util.Collection; // Get singleton instance SchematicHolder holder = SchematicHolder.getInstance(); // Load or get cached schematic Path schematicPath = DataManager.getSchematicsBaseDirectory().resolve("building.litematic"); LitematicaSchematic schematic = holder.getOrLoad(schematicPath); // Add schematic to cache holder.addSchematic(schematic, false); // false = don't allow duplicates // Remove schematic (also removes all placements using it) boolean removed = holder.removeSchematic(schematic); // Get all loaded schematics Collection allSchematics = holder.getAllSchematics(); // Clear all loaded schematics holder.clearLoadedSchematics(); ``` -------------------------------- ### LitematicaSchematic - Schematic File Operations Source: https://context7.com/sakura-ryoko/litematica/llms.txt The LitematicaSchematic class handles loading, saving, and manipulating schematic data, including blocks, entities, and tile entities. It supports various schematic formats. ```APIDOC ## LitematicaSchematic - Schematic File Operations ### Description Handles loading, saving, and manipulation of schematic data. ### Method N/A (Class methods) ### Endpoint N/A (Client-side mod API) ### Parameters N/A ### Request Example ```java import fi.dy.masa.litematica.schematic.LitematicaSchematic; import fi.dy.masa.litematica.schematic.LitematicaSchematic.SchematicSaveInfo; import fi.dy.masa.litematica.selection.AreaSelection; import fi.dy.masa.litematica.util.FileType; import net.minecraft.world.level.Level; import net.minecraft.core.BlockPos; import java.nio.file.Path; // Create a schematic from world selection Level world = mc.level; AreaSelection area = DataManager.getSelectionManager().getCurrentSelection(); String authorName = mc.player.getName().getString(); SchematicSaveInfo saveInfo = new SchematicSaveInfo( false, // visibleOnly - only save exposed blocks false, // includeSupportBlocks - include blocks supporting gravity blocks false, // ignoreEntities - skip entity capture false // fromSchematicWorld - save from schematic world instead ); LitematicaSchematic schematic = LitematicaSchematic.createFromWorld( world, area, saveInfo, authorName, feedbackConsumer ); // Save schematic to file Path outputDir = DataManager.getSchematicsBaseDirectory(); boolean success = schematic.writeToFile(outputDir, "my_schematic", true); // Load schematic from file LitematicaSchematic loaded = LitematicaSchematic.createFromFile( outputDir, "my_schematic.litematic", FileType.LITEMATICA_SCHEMATIC ); // Get schematic metadata SchematicMetadata metadata = loaded.getMetadata(); String name = metadata.getName(); String author = metadata.getAuthor(); Vec3i totalSize = loaded.getTotalSize(); int regionCount = loaded.getSubRegionCount(); // Access sub-regions Map regionPositions = loaded.getAreaPositions(); Map regionSizes = loaded.getAreaSizes(); // Get block data for a region LitematicaBlockStateContainer container = loaded.getSubRegionContainer("regionName"); BlockState state = container.get(x, y, z); // Get entities and tile entities List entities = loaded.getEntityListForRegion("regionName"); Map tileEntities = loaded.getBlockEntityMapForRegion("regionName"); ``` ### Response N/A (Direct Java API calls) ``` -------------------------------- ### Manage Area Selections Source: https://context7.com/sakura-ryoko/litematica/llms.txt Utilize the SelectionManager to create, modify, and interact with 3D area selections for schematic capture. This includes switching modes, defining boxes, and performing interactive selections. ```java import fi.dy.masa.litematica.selection.SelectionManager; import fi.dy.masa.litematica.selection.AreaSelection; import fi.dy.masa.litematica.selection.Box; import fi.dy.masa.litematica.selection.SelectionMode; import fi.dy.masa.litematica.data.DataManager; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; // Get the selection manager SelectionManager selectionManager = DataManager.getSelectionManager(); // Check and switch selection mode SelectionMode mode = selectionManager.getSelectionMode(); selectionManager.switchSelectionMode(); // Cycles between SIMPLE and NORMAL // Create a new selection Path selectionsDir = DataManager.getAreaSelectionsBaseDirectory(); String selectionId = selectionManager.createNewSelection(selectionsDir, "My Selection"); // Get current selection AreaSelection selection = selectionManager.getCurrentSelection(); // Work with selection boxes selection.createNewSubRegionBox(new BlockPos(0, 64, 0), "Main Area"); Box selectedBox = selection.getSelectedSubRegionBox(); if (selectedBox != null) { // Set corner positions selection.setSelectedSubRegionCornerPos(new BlockPos(0, 64, 0), Corner.CORNER_1); selection.setSelectedSubRegionCornerPos(new BlockPos(50, 128, 50), Corner.CORNER_2); } // Move selection selection.moveSelectedElement(Direction.UP, 5); // Get all boxes in selection List allBoxes = selection.getAllSubRegionBoxes(); // Set explicit origin for schematic selection.setExplicitOrigin(new BlockPos(25, 64, 25)); BlockPos effectiveOrigin = selection.getEffectiveOrigin(); // Rename and manage sub-regions selection.renameSubRegionBox("oldName", "newName"); selection.removeSubRegionBox("regionToRemove"); // Interactive selection (ray tracing) boolean changed = selectionManager.changeSelection(world, player, 200); selectionManager.grabElement(mc, 200); // Grab for moving selectionManager.releaseGrabbedElement(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.