### Ore Storage Type Definitions (Java) Source: https://context7.com/xsana/takotech/llms.txt Defines an enum for different ore storage cell types, each filtering items based on specific ore dictionary prefixes. This allows for specialized storage solutions for various stages of ore processing. Includes methods to retrieve allowed prefixes and get types by metadata. ```java public enum OreStorageType { GENERAL(0, "", "", true), RAW(1, "ore|rawOre", "", true), CRUSHED(2, "crushed", "crushedPurified|crushedCentrifuged", true), PURIFIED(3, "crushedPurified", "", true), CENTRIFUGED(4, "crushedCentrifuged", "", true), DUST_IMPURE(5, "dustImpure", "", true), DUST_PURE(6, "dustPure", "", true), GEM(7, "gem", "", false), DUST(8, "dust", "dustImpure|dustPure", false); public static OreStorageType byMeta(int meta) { for (OreStorageType t : values()) { if (t.meta == meta) return t; } return GENERAL; } public String[] getIncludedPrefixes() { if (this == GENERAL) { return TakoTechConfig.oreDefs; } return includedPrefixes; } } ``` -------------------------------- ### Define Configuration with GTNHLib Annotations (Java) Source: https://context7.com/xsana/takotech/llms.txt Defines configuration settings for TakoTech using GTNHLib's annotation-based system. This includes ore dictionary prefixes and initialization of configuration managers. The configuration is stored in `config/TakoTech/config.cfg`. ```java // TakoTechConfig.java - Configuration definition @Config(modid = Reference.MODID, configSubDirectory = "TakoTech", filename = "config") public class TakoTechConfig { @Config.Comment("Ore dictionary prefix matching (no regex support)") @Config.DefaultStringList(value = { "ore", // Ores, including raw ores (oreRaw) "rawOre", // Raw ores "crushed", // Crushed, washed, centrifuged "dustImpure", // Impure dust "dustPure" // Pure dust }) @Config.Sync public static String[] oreDefs; public static void init() { try { ConfigurationManager.registerConfig(TakoTechConfig.class); ConfigurationManager.registerConfig(WebControllerConfig.class); ConfigurationManager.registerConfig(ToolboxConfig.class); } catch (ConfigException e) { throw new RuntimeException(e); } } } // Config file location: config/TakoTech/config.cfg // Example config content: // S:oreDefs < // ore // rawOre // crushed // dustImpure // dustPure // > ``` -------------------------------- ### Manage Toolbox Items with Java Source: https://context7.com/xsana/takotech/llms.txt The ToolboxHelper class provides methods to interact with an advanced toolbox stored in NBT data. It allows retrieving a list of tools, setting tools to specific slots, and checking if an item is a toolbox. Dependencies include NBTTagCompound, NBTTagList, ItemStack, and custom classes like CommonUtils, MetaGeneratedTool, ItemToolboxPlus, and NBTConstants. ```java // ToolboxHelper.java - Toolbox utility methods public class ToolboxHelper { // Get list of tools in the toolbox public static List getToolItems(ItemStack itemStack) { List list = new ArrayList<>(); if (!isItemToolbox(itemStack)) return list; NBTTagCompound nbt = CommonUtils.openNbtData(itemStack); if (nbt.hasKey(NBTConstants.TOOLBOX_ITEMS, Constants.NBT.TAG_LIST)) { NBTTagList contentList = nbt.getTagList(NBTConstants.TOOLBOX_ITEMS, Constants.NBT.TAG_COMPOUND); for (int i = 0; i < contentList.tagCount(); i++) { NBTTagCompound slotNbt = contentList.getCompoundTagAt(i); int slot = slotNbt.getByte(NBTConstants.TOOLBOX_TOOLS_SLOT); ItemStack toolStack = ItemStack.loadItemStackFromNBT(slotNbt); if (toolStack != null && toolStack.getItem() instanceof MetaGeneratedTool) { list.add(new ToolData(slot, toolStack)); } } } return list; } // Set a tool to a specific slot public static void setItemToSlot(ItemStack itemStack, int slot, ItemStack toolStack) { if (!isItemToolbox(itemStack)) return; NBTTagCompound nbt = CommonUtils.openNbtData(itemStack); NBTTagList contentList = nbt.getTagList(NBTConstants.TOOLBOX_ITEMS, Constants.NBT.TAG_COMPOUND); ItemStack[] toolStackList = new ItemStack[9]; // Load existing tools for (int i = 0; i < contentList.tagCount(); i++) { NBTTagCompound slotNbt = contentList.getCompoundTagAt(i); int slotNum = slotNbt.getByte(NBTConstants.TOOLBOX_TOOLS_SLOT); toolStackList[slotNum] = ItemStack.loadItemStackFromNBT(slotNbt); } toolStackList[slot] = toolStack; // Save back to NBT NBTTagList newContentList = new NBTTagList(); for (int i = 0; i < toolStackList.length; i++) { if (toolStackList[i] != null) { NBTTagCompound slotNbt = new NBTTagCompound(); slotNbt.setByte(NBTConstants.TOOLBOX_TOOLS_SLOT, (byte) i); toolStackList[i].writeToNBT(slotNbt); newContentList.appendTag(slotNbt); } } nbt.setTag(NBTConstants.TOOLBOX_ITEMS, newContentList); } // Check if item is a toolbox public static boolean isItemToolbox(ItemStack itemStack) { return isToolboxPlus(itemStack) || (isMetaGeneratedTool(itemStack) && CommonUtils.openNbtData(itemStack).hasKey(NBTConstants.TOOLBOX_DATA)); } public static boolean isToolboxPlus(ItemStack itemStack) { return itemStack != null && itemStack.getItem() instanceof ItemToolboxPlus; } } ``` -------------------------------- ### Register Network Packets with Java Source: https://context7.com/xsana/takotech/llms.txt The NetworkHandler class is responsible for registering network packets used for client-server communication, specifically for toolbox GUI operations. It utilizes Forge's SimpleNetworkWrapper to manage packet registration and provides methods for sending packets from the client to the server. Dependencies include SimpleNetworkWrapper, NetworkRegistry, Reference, Side, and custom packet classes like PacketToolboxOpenSelectGUI and PacketToolboxSelected. ```java // NetworkHandler.java - Network packet registration public class NetworkHandler { public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID); public static void init() { // Register packet for opening toolbox selection GUI NETWORK.registerMessage( PacketToolboxOpenSelectGUI.Handler.class, PacketToolboxOpenSelectGUI.class, 1, Side.SERVER ); // Register packet for tool selection NETWORK.registerMessage( PacketToolboxSelected.Handler.class, PacketToolboxSelected.class, 2, Side.SERVER ); } } // Usage example - sending a packet from client NetworkHandler.NETWORK.sendToServer(new PacketToolboxOpenSelectGUI()); NetworkHandler.NETWORK.sendToServer(new PacketToolboxSelected(slotIndex)); ``` -------------------------------- ### Create NBT-Preserving Crafting Recipe (Java) Source: https://context7.com/xsana/takotech/llms.txt Implements a custom shaped ore recipe that preserves NBT data from input items to the output item. This is particularly useful for items like ore storage cells that contain specific data. ```java // OreStorageCellRecipe.java - NBT-preserving recipe public class OreStorageCellRecipe extends ShapedOreRecipe { public OreStorageCellRecipe(ItemStack result, Object... recipe) { super(result, recipe); } @Override public ItemStack getCraftingResult(InventoryCrafting inv) { // Copy NBT from input cell to output cell return RecipeUtils.copyNBTFromInput(inv, this.getRecipeOutput()); } } // Recipe registration example (in RecipeLoader) GameRegistry.addRecipe(new OreStorageCellRecipe( new ItemStack(ItemLoader.ITEM_ORE_STORAGE_CELL, 1, OreStorageType.RAW.getMeta()), "SCS", "CMC", "SCS", 'S', "stickSteel", 'C', "circuitBasic", 'M', new ItemStack(ItemLoader.ITEM_ORE_STORAGE_CELL, 1, OreStorageType.GENERAL.getMeta()) )); ``` -------------------------------- ### Ore Storage Cell Inventory Management (Java) Source: https://context7.com/xsana/takotech/llms.txt Manages item injection and extraction for storage cells. It handles item blacklisting, adding new item types, and extracting specified amounts. The inventory has near-infinite capacity and saves changes to persistent storage. ```java public class OreStorageCellInventory implements ITakoCellInventory { public OreStorageCellInventory(ItemStack cellItem, ISaveProvider container) throws AppEngException { this.cellItem = cellItem; this.container = container; this.tagCompound = CommonUtils.openNbtData(cellItem); this.storedItemTypes = tagCompound.getInteger("it"); this.storedItemCount = tagCompound.getLong("ic"); this.cellType = (ItemOreStorageCell) this.cellItem.getItem(); // Server-side: get world-saved data storage this.storageData = CommonUtils.isServer() ? CellItemSavedData.getInstance().getDataStorage(this.getItemStack()) : null; } // Inject items into the cell @Override public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src) { if (input == null || input.getStackSize() == 0) return null; // Check blacklist if (this.cellType.isBlackListed(this.cellItem, input)) { return input; // Rejected } if (input.getStackSize() > 0) { final IAEItemStack existingItem = this.getCellItems().findPrecise(input); if (existingItem != null && mode == Actionable.MODULATE) { // Add to existing stack existingItem.setStackSize(existingItem.getStackSize() + input.getStackSize()); this.saveChanges(); } else if (this.canHoldNewItem() && mode == Actionable.MODULATE) { // Add new item type this.cellItems.add(input); this.saveChanges(); } return null; // Fully accepted } return input; } // Extract items from the cell @Override public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) { if (request == null) return null; final long size = request.getStackSize(); final IAEItemStack stored = this.getCellItems().findPrecise(request); if (stored != null) { IAEItemStack results = stored.copy(); if (stored.getStackSize() <= size) { results.setStackSize(stored.getStackSize()); if (mode == Actionable.MODULATE) { stored.setStackSize(0); this.saveChanges(); } } else { results.setStackSize(size); if (mode == Actionable.MODULATE) { stored.setStackSize(stored.getStackSize() - size); this.saveChanges(); } } return results; } return null; } // Unlimited capacity @Override public long getFreeBytes() { return Long.MAX_VALUE; } @Override public long getRemainingItemCount() { return Long.MAX_VALUE; } } ``` -------------------------------- ### Ore Storage Cell Implementation (Java) Source: https://context7.com/xsana/takotech/llms.txt Implements specialized AE2 storage cells that filter items based on ore dictionary entries. It provides near-infinite storage capacity and supports various ore types through ore dictionary prefixes. Dependencies include Applied Energistics 2 and GTNHLib. ```java public class ItemOreStorageCell extends BaseAECellItem implements IStorageCell, IItemGroup { private static final int MAX_ORE_TYPES = 114514; private final double idleDrain = 1.14; @Override public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) { if (!(requestedAddition instanceof AEItemStack itemStack)) { return true; } OreReference oreReference = OreHelper.INSTANCE.isOre(itemStack.getItemStack()); if (oreReference == null) { return true; } Collection oreDefs = oreReference.getEquivalents(); OreStorageType storageType = getStorageType(cellItem); for (String oreDef : oreDefs) { if (isOreAllowed(storageType, oreDef)) { return false; } } return true; } @Override public void register() { GameRegistry.registerItem(this, this.name); setCreativeTab(TakoTechTabs.getInstance()); for (OreStorageType type : OreStorageType.values()) { ItemStack itemStack = new ItemStack(this, 1, type.getMeta()); Upgrades.INVERTER.registerItem(itemStack, 1); Upgrades.ORE_FILTER.registerItem(itemStack, 1); Upgrades.FUZZY.registerItem(itemStack, 1); } } } ``` -------------------------------- ### Fix Chinese Input in Minecraft GUI (Java Mixin) Source: https://context7.com/xsana/takotech/llms.txt Applies a Mixin to Minecraft's `GuiScreen` to fix issues with Chinese character input, especially on non-Windows platforms. It uses a JOptionPane for input on unsupported platforms and then processes the characters. ```java // InputFixMixin.java - Input fix for Chinese characters @Mixin(GuiScreen.class) public abstract class InputFixMixin { @Unique private static final boolean IS_WINDOWS = LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_WINDOWS; @Shadow protected abstract void keyTyped(char typedChar, int keyCode); @Overwrite public void handleKeyboardInput() { char c = Keyboard.getEventCharacter(); int k = Keyboard.getEventKey(); if (Keyboard.getEventKeyState() || (k == 0 && Character.isDefined(c))) { // Non-Windows: handle special input dialog if (!IS_WINDOWS && k == 88) { takoTech$handleInputDialog(); return; } this.keyTyped(c, k); } } @Unique private void takoTech$handleInputDialog() { String input = JOptionPane.showInputDialog(""); if (input != null && !input.isEmpty()) { for (char c1 : input.toCharArray()) { this.keyTyped(c1, 0); } } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.