### Create BoxRoutings with Fluids (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This example illustrates creating a BoxRoutings object that includes fluid inputs and outputs. It requires item stacks, fluid stacks, the machine ItemStack, voltage tier, and duration. This is suitable for recipes involving liquids. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import gregtech.api.capability.TierEU; import gregtech.api.util.TickTime; // Create routing with fluids BoxRoutings fluidRouting = new BoxRoutings( new ItemStack[] { inputItem1, inputItem2 }, // Item inputs outputItem, // Item output new FluidStack[] { fluidInput }, // Fluid inputs machineStack, // Machine TierEU.RECIPE_UV, // Voltage TickTime.MINUTE // Duration ); ``` -------------------------------- ### Implement IBoxable Interface for Custom Machines (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This Java code demonstrates how to implement the `IBoxable` interface to register custom GregTech multiblock machines with the Box System. It requires defining a module ID and optionally overriding methods for specific recipe maps or module upgrade status. ```java package com.silvermoon.boxplusplus.api; import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; import gregtech.api.recipe.RecipeMap; public class MyCustomMachine extends MTEMultiBlockBase implements IBoxable { @Override public int getModuleID() { // Return module ID (0-11) - corresponds to module core block meta value // 0 = Atomic Manipulation Claw (mixers, chemical reactors) // 1 = Facility 3826 (crafters, assemblers) // 2 = Sinopec Group (crackers, distillation) // 3 = Residential Gas Water Heater (furnaces, thermal processing) // 4 = AMD Wafer Fabrication (compressors, lathes, separators) // 5 = Liquid Level Regulator (rock crushers, fluid heaters) // 6 = Solid State Reshaper (cutters, macerators, benders) // 7 = Residential Flush Toilet (washers, sifters, centrifuges) // 8 = Extreme Temperature Difference Tower (coke ovens, freezers) // 9 = Superstructure Assembly Plant (assembly lines) // 10-11 = Phase Parallel Matrix (alloy smelters) return 0; } @Override public boolean isUpdateModule() { // Return true if machine requires upgraded (T2) module version return false; } @Override public RecipeMap getRealRecipeMap(MTEMultiBlockBase machine) { // Override for machines with multiple modes // Return the specific recipe map to use for encapsulation return machine.getRecipeMap(); } } ``` -------------------------------- ### Build and Access BoxRecipe Properties Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This Java code demonstrates how to build a consolidated recipe from routings, access its properties, serialize it to NBT, and generate an AE2 pattern. It handles input/output consolidation, recipe locking, and time/voltage calculations. ```java import com.silvermoon.boxplusplus.util.BoxRecipe; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; // Build recipe from routings in GTMachineBox public void buildRecipe() { ItemContainer inputItemContainer = new ItemContainer(); ItemContainer outputItemContainer = new ItemContainer(); FluidContainer inputFluidContainer = new FluidContainer(); FluidContainer outputFluidContainer = new FluidContainer(); BoxRecipe recipe = new BoxRecipe(); // Aggregate all routing inputs/outputs with parallel multipliers for (BoxRoutings routing : routingMap) { inputItemContainer.addItemStackList(routing.InputItem, routing.Parallel); outputItemContainer.addItemStackList(routing.OutputItem, routing.OutputChance, routing.Parallel); inputFluidContainer.addFluidStackList(routing.InputFluid, routing.Parallel); outputFluidContainer.addFluidStackList(routing.OutputFluid, routing.Parallel); // Calculate time using sigmoid curve for parallel scaling recipe.FinalTime += routing.time * 5000L / (1 + Math.exp(-(routing.Parallel - 2000) / 320.0)); recipe.FinalVoteage += routing.voltage; recipe.parallel += routing.Parallel; } // Set final consolidated inputs/outputs recipe.FinalItemInput = inputItemContainer.getItemStack(); recipe.FinalItemOutput = outputItemContainer.getItemStack(); recipe.FinalFluidInput = inputFluidContainer.getFluidStack(); recipe.FinalFluidOutput = outputFluidContainer.getFluidStack(); // Cancel out matching inputs/outputs (net recipe calculation) BoxRecipe.ItemOnBox(recipe.FinalItemInput, recipe.FinalItemOutput); BoxRecipe.FluidOnBox(recipe.FinalFluidInput, recipe.FinalFluidOutput); // Lock recipe to prevent further modification recipe.islocked = true; } // Recipe properties List finalInputs = recipe.FinalItemInput; List finalOutputs = recipe.FinalItemOutput; List finalFluidInputs = recipe.FinalFluidInput; List finalFluidOutputs = recipe.FinalFluidOutput; HashMap requiredModules = recipe.requireModules; // moduleID -> tier long totalTime = recipe.FinalTime; long totalVoltage = recipe.FinalVoteage; long totalParallel = recipe.parallel; boolean isLocked = recipe.islocked; // Serialize for storage NBTTagCompound recipeNbt = recipe.RecipeToNBT(); BoxRecipe restored = new BoxRecipe(recipeNbt); // Generate AE2 pattern NBTTagCompound ae2Pattern = recipe.RecipeToAE2ItemPattern("1-3,5"); // Select outputs 1-3 and 5 IAEItemStack[] ae2Inputs = recipe.transInputsToAE2Stuff(); IAEItemStack[] ae2Outputs = recipe.transOutputsToAE2Stuff("1,2", "1"); // Items "1,2", Fluids "1" ``` -------------------------------- ### Create BoxRoutings from GT Recipe (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This snippet demonstrates how to create a BoxRoutings object from an existing GregTech recipe. It requires GregTech API and Box++ utility classes. The inputs and outputs are derived from the GT recipe, and the machine ItemStack is also provided. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import gregtech.api.recipe.GTRecipe; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; // Create routing from GT recipe GTRecipe recipe = RecipeMaps.chemicalReactorRecipes.findRecipeQuery() .items(inputItems) .fluids(inputFluids) .find(); ItemStack machineStack = myMachine.getStackForm(1); BoxRoutings routing = new BoxRoutings(recipe, machineStack); ``` -------------------------------- ### Create Simple Item Transformation Routing (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This code shows how to create a basic BoxRoutings object for a simple item transformation. It takes an input item, an output item, the machine ItemStack, voltage, and duration as parameters. This is useful for straightforward crafting recipes. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import net.minecraft.item.ItemStack; // Create simple item transformation routing BoxRoutings simpleRouting = new BoxRoutings( inputItem, // ItemStack input outputItem, // ItemStack output machineStack, // Machine ItemStack 30L, // Voltage (EU/t) 100 // Duration (ticks) ); ``` -------------------------------- ### Register Custom Machines with Box System (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This Java code snippet shows how to use the `boxRegister` utility class to register custom machines with the Box System. Registration should be performed during the `postInit` phase of the mod lifecycle. It supports registering single or multiple machines and provides access to lists of registered machines. ```java package com.example.mymod; import com.silvermoon.boxplusplus.api.boxRegister; import cpw.mods.fml.common.event.FMLPostInitializationEvent; public class CommonProxy { public void postInit(FMLPostInitializationEvent event) { // Register single machine boxRegister.registerMachineToBox(new MyCustomMachine()); // Register multiple machines at once boxRegister.registerMachineToBox( new MyChemicalReactor(), new MyAssemblyLine(), new MyFurnaceArray() ); // Access registered machines // boxRegister.customerMachineList - List of all registered machines // boxRegister.customModuleList - Multimap for standard modules // boxRegister.customUpdatedModuleList - Multimap for upgraded modules } } ``` -------------------------------- ### Utility Functions for NBT, Items, Fluids, and Player Lookup (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt Provides helper functions for internationalization, recipe map retrieval, item/circuit finding, NBT serialization (standard and universal), deep copying lists, NBT compression, pattern validation, and player lookup by UUID. These functions are essential for various automation and data handling tasks within the mod. ```java import com.silvermoon.boxplusplus.util.Util; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import java.util.List; import net.minecraft.entity.player.EntityPlayer; // Internationalization with color code support String translated = Util.i18n("tile.boxplusplus.boxinfo.01"); // Converts & to section symbol // Get recipe map for Industrial Multi-Machine by circuit mode // RecipeMap recipeMap = Util.getMMRecipeMap(1); // 1=compressor, 2=lathe, etc. // Find programmed circuit in input list // ItemStack circuit = Util.findfirstCircuit(inputItems); // int circuitConfig = circuit.getItemDamage(); // Check if item is AE2 pattern // boolean isPattern = Util.isPattern(itemStack); // Extended NBT item serialization (supports stack sizes > 127) // NBTTagCompound itemNbt = Util.writeBoxItemToNBT(itemStack, new NBTTagCompound()); // ItemStack restored = Util.loadBoxItemFromNBT(itemNbt); // Universal NBT (uses mod:name instead of numeric IDs for cross-world compatibility) // NBTTagCompound universalNbt = Util.writeBoxItemToUNBT(itemStack, new NBTTagCompound()); // ItemStack fromUniversal = Util.readBoxItemFromUNBT(universalNbt); // Deep copy lists // List itemCopy = Util.deepCopyItemList(originalItems); // List fluidCopy = Util.deepCopyFluidList(originalFluids); // NBT compression for clipboard/network transfer // String serialized = Util.serialize(nbtCompound); // Base64 encoded compressed NBT // NBTTagCompound deserialized = Util.deserialize(serialized); // Validate pattern output selection string // String validated = Util.validator(recipe, "1-3,5", false); // Items // String validatedFluid = Util.validator(recipe, "1,2", true); // Fluids // Returns empty string if invalid, original string if valid // Player lookup by UUID // EntityPlayer player = Util.getPlayerFromUUID(uuidString); ``` -------------------------------- ### Access and Determine BoxModule Information Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This Java code shows how to retrieve a BoxModule by its index and access its properties like name, offsets, and structure. It also demonstrates how to determine the required module and tier for a given routing. ```java import com.silvermoon.boxplusplus.common.BoxModule; import com.silvermoon.boxplusplus.util.BoxRoutings; // Get module by index (0-13) BoxModule module = BoxModule.getModuleByIndex(0); // Atomic_Manipulation_Claw String moduleName = module.name; int horizontalOffset = module.horizontalOffset; int verticalOffset = module.verticalOffset; int depthOffset = module.depthOffset; String[][] structure = module.moduleStructure; // Available modules: // 0 - Atomic_Manipulation_Claw: Mixers, Chemical Reactors // 1 - Facility_3826: Crafters, Assemblers, Precise Assembler // 2 - Sinopec_Group: Crackers, Distillation Towers // 3 - Residential_Gas_Water_Heater: Multi-furnaces, Thermal Centrifuges // 4 - AMD_Wafer_Fabrication_Plant: Compressors, Lathes, Electromagnetic Separators // 5 - Liquid_Level_Regulator: Rock Crushers, Fluid Heaters // 6 - Solid_State_Reshaper: Cutting Machines, Macerators, Benders // 7 - Residential_Flush_Toilet: Wash Plants, Sifters, Centrifuges // 8 - Extreme_Temperature_Difference_Tower: Coke Ovens, Vacuum Freezers // 9 - Superstructure_Assembly_Plant: Assembly Lines, Component Assembly Lines // 10 - Phase_Parallel_Matrix: Alloy Smelters // 11 - Phase_Parallel_Matrix (alt): Same as 10 // 12 - Hyperbeam_Receiver: Laser Engravers, Wireless Energy // 13 - CAERULA_ARBOR: Debug/Creative mode // Determine required module for a routing int[] moduleInfo = BoxModule.transMachinesToModule(routing); int moduleId = moduleInfo[0]; // Module ID (0-14) int moduleTier = moduleInfo[1]; // Tier (0=standard, 1=upgraded) ``` -------------------------------- ### Item and Fluid Aggregation with Parallel Multipliers (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt Classes for aggregating items and fluids, supporting parallel multipliers and output chances. `ItemContainer` and `FluidContainer` consolidate collections of items or fluids, useful for managing complex crafting or processing chains. ```java import com.silvermoon.boxplusplus.util.ItemContainer; import com.silvermoon.boxplusplus.util.FluidContainer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import java.util.List; import java.util.Arrays; // Item aggregation with parallel multiplier ItemContainer itemContainer = new ItemContainer(); itemContainer.addItemStackList(inputItems, 64); // 64x parallel itemContainer.addItemStack(singleItem, 32, 10000); // 32x parallel, 100% chance List consolidated = itemContainer.getItemStack(); // Item aggregation with output chances ItemContainer outputContainer = new ItemContainer(); List chances = Arrays.asList(10000, 7500, 5000); // 100%, 75%, 50% outputContainer.addItemStackList(outputItems, chances, 16); // 16x parallel List outputs = outputContainer.getItemStack(); // Fluid aggregation FluidContainer fluidContainer = new FluidContainer(); fluidContainer.addFluidStackList(inputFluids, 128); // 128x parallel List consolidatedFluids = fluidContainer.getFluidStack(); ``` -------------------------------- ### Serialize and Deserialize BoxRoutings to NBT (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This code demonstrates how to serialize a BoxRoutings object into an NBTTagCompound for storage or transfer, and then deserialize it back into a BoxRoutings object. This is crucial for saving and loading routing configurations. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import net.minecraft.nbt.NBTTagCompound; // Serialize to NBT for storage/transfer NBTTagCompound nbt = routing.routingToNbt(); BoxRoutings restored = new BoxRoutings(nbt); ``` -------------------------------- ### Export BoxRoutings for Cross-World Sharing (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This snippet explains how to export a BoxRoutings object to an NBTTagCompound suitable for cross-world sharing, using mod:name identifiers instead of numeric IDs. It also shows how to import such a configuration. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import net.minecraft.nbt.NBTTagCompound; // Export for cross-world sharing (uses mod:name instead of numeric IDs) NBTTagCompound universalNbt = routing.routingToUNbt(); BoxRoutings imported = new BoxRoutings(universalNbt, true); ``` -------------------------------- ### Access BoxRoutings Properties (Java) Source: https://context7.com/realsilvermoon/boxplusplus/llms.txt This snippet shows how to access various properties of a BoxRoutings object, such as item and fluid inputs/outputs, output chances, parallel multiplier, voltage, and time. This is useful for inspecting or modifying routing configurations. ```java import com.silvermoon.boxplusplus.util.BoxRoutings; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import java.util.List; // Access routing properties List inputs = routing.InputItem; List outputs = routing.OutputItem; List chances = routing.OutputChance; // Output chances (10000 = 100%) List fluidInputs = routing.InputFluid; List fluidOutputs = routing.OutputFluid; int parallel = routing.Parallel; // Parallel multiplier long voltage = routing.voltage; int time = routing.time; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.