### Implement ME Network Storage Provider (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt This Java code snippet shows the TileKitchenStation tile entity, which implements IKitchenStorageProvider. It manages the connection to an AE2 ME network using a security key and provides access to the network's inventory via the getInventory method. It also includes NBT persistence for the security key and a tick handler for connection state monitoring. ```java public class TileKitchenStation extends AEBaseTile implements IKitchenStorageProvider, IPowerChannelState { private long securityKey; private final WirelessObject wirelessObject; private boolean isPowered; public TileKitchenStation() { this.wirelessObject = new WirelessObject(this); } // Set the security terminal key to establish network connection public void setKey(long key) { this.securityKey = key; } // Returns the ME network inventory if connected, empty inventory otherwise @Override public IInventory getInventory() { if (this.wirelessObject.reCheckIsConnect()) { return this.wirelessObject.getInventory(); } return Util.EmptyInventory; } // NBT persistence for the security key @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { this.setKey(data.getLong("key")); } @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { data.setLong("key", this.getKey()); return data; } // Tick handler to monitor connection state @TileEvent(TileEventType.TICK) public void update() { if (Platform.isClient()) return; this.updatePowerState(); } @Override public boolean isPowered() { return isPowered; } } ``` -------------------------------- ### Register and Configure Kitchen Station Block (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt This Java code snippet demonstrates the registration and basic configuration of the Kitchen Station block. It extends a base container block and implements an IRegister interface. The onBlockActivated method handles linking the station to an AE2 ME network using a Wireless Terminal. ```java public class BlockKitchenStation extends BaseBlockContainer implements IRegister { public BlockKitchenStation() { super(Material.iron); this.setBlockName(NameConst.BLOCK_KITCHEN_STATION); this.setHardness(2.0f); this.setResistance(10.0f); } @Override public BlockKitchenStation register() { GameRegistry.registerBlock(this, ItemKitchenStation.class, NameConst.BLOCK_KITCHEN_STATION); GameRegistry.registerTileEntity(TileKitchenStation.class, NameConst.BLOCK_KITCHEN_STATION); setCreativeTab(CookingForBlockheads.creativeTab); return this; } // Link the station to an ME network by right-clicking with a linked Wireless Terminal @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { TileKitchenStation tile = (TileKitchenStation) getTileEntity(world, x, y, z); ItemStack is = player.getCurrentEquippedItem(); if (is != null && is.getItem() instanceof ToolWirelessTerminal) { IWirelessTermHandler handler = AEApi.instance().registries().wireless() .getWirelessTerminalHandler(is); String unparsedKey = handler.getEncryptionKey(is); long parsedKey = Long.parseLong(unparsedKey); // Link the kitchen station to the security terminal tile.setKey(parsedKey); return true; } return false; } } ``` -------------------------------- ### AppEngInternalInventoryBridge: Adapt ME Network to IInventory (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt The AppEngInternalInventoryBridge class extends AppEngInternalInventory to provide an adapter, allowing the Kitchen Station to interact with the AE2 ME network as if it were a standard IInventory. It holds a reference to the WirelessObject for ME operations but delegates slot content management to the ME network itself. ```java // AppEngInternalInventoryBridge adapts ME network storage to IInventory interface public class AppEngInternalInventoryBridge extends AppEngInternalInventory { private final WirelessObject obj; public AppEngInternalInventoryBridge(WirelessObject obj) { super(obj, 0, 64, true); this.obj = obj; } // Provides access to the underlying WirelessObject for ME operations public WirelessObject getWirelessObject() { return this.obj; } // Slot contents are managed by ME network, not local storage @Override public void setInventorySlotContents(final int slot, final ItemStack newItemStack) {} @Override public ItemStack getStackInSlot(int slot) { return null; } } ``` -------------------------------- ### Register Kitchen Station Crafting Recipe (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt Registers the crafting recipe for the Kitchen Station, which combines items from Cooking For Blockheads and Applied Energistics 2. It defines the required items and their arrangement in the crafting grid. ```java // RecipeLoader registers the Kitchen Station crafting recipe public class RecipeLoader implements Runnable { public static final ItemStack TOASTER = new ItemStack(blockToaster, 1); public static final ItemStack OVEN = new ItemStack(blockOven, 1); public static final ItemStack BOOK_TIER1 = new ItemStack(itemRecipeBook, 1); public static final ItemStack BOOK_TIER2 = new ItemStack(itemRecipeBook, 1, 1); public static final ItemStack AE2_ME_CHEST = GameRegistry .findItemStack("appliedenergistics2", "tile.BlockChest", 1); public static final ItemStack AE2_GLASS_CABLE = new ItemStack( GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 16); public static final ItemStack AE2_PROCESS_ENG = new ItemStack( GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 24); public static final ItemStack AE2_CELL_16K = new ItemStack( GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 37); @Override public void run() { // Crafting recipe: // T C O (Toaster, ME Chest, Oven) // G K G (Glass Cable, 16K Cell, Glass Cable) // B P N (Recipe Book Tier1, Engineering Processor, Recipe Book Tier2) GameRegistry.addRecipe(new ShapedOreRecipe( KITCHEN_STATION.stack(), "TCO", "GKG", "BPN", 'T', TOASTER, 'C', AE2_ME_CHEST, 'O', OVEN, 'G', AE2_GLASS_CABLE, 'K', AE2_CELL_16K, 'B', BOOK_TIER1, 'P', AE2_PROCESS_ENG, 'N', BOOK_TIER2)); } } ``` -------------------------------- ### Crafting with ME Network Items (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt This mixin intercepts crafting operations to facilitate the extraction of ingredients directly from the ME network and the injection of container items back into it. It provides helper methods for interacting with the ME network's storage. ```java // MixinInventoryCraftBook handles crafting operations with ME network items @Mixin(InventoryCraftBook.class) public abstract class MixinInventoryCraftBook extends InventoryCrafting { @Shadow(remap = false) private List inventories; // Extract item from ME network for crafting private boolean extractItemStackFromAE(ItemStack what) { for (IInventory inv : inventories) { if (inv instanceof AppEngInternalInventoryBridge aeInv) { ItemStack extractItem = what.copy(); extractItem.stackSize = 1; IAEItemStack extracted = aeInv.getWirelessObject().extractItems( AEItemStack.create(extractItem), Actionable.MODULATE, aeInv.getWirelessObject().getSource()); if (extracted != null) return true; } } return false; } // Inject container items back into ME network after crafting private boolean tryInjectContainerItemToAE(ItemStack what) { for (IInventory inv : inventories) { if (inv instanceof AppEngInternalInventoryBridge aeInv) { IAEItemStack injected = aeInv.getWirelessObject().injectItems( AEItemStack.create(what), Actionable.MODULATE, aeInv.getWirelessObject().getSource()); // null return means all items were successfully injected if (injected == null) return true; } } return false; } } ``` -------------------------------- ### Check Ingredient Availability with ME Network Items (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt This mixin intercepts ingredient availability checks, extending them to include items available in the ME network. It iterates through crafting ingredients and checks against inventories, specifically looking for AppEngInternalInventoryBridge instances to query the ME network. Returns true if all ingredients are found, false otherwise. ```java // MixinCookingRegistry extends ingredient checking to include ME network items @Mixin(CookingRegistry.class) public abstract class MixinCookingRegistry { @Inject(method = "areIngredientsAvailableFor", at = @At("HEAD"), remap = false, cancellable = true) private static void onMatrixLoopCompletion(List craftMatrix, List inventories, List itemProviders, CallbackInfoReturnable cir) { IItemList usedStacks = AEApi.instance().storage().createItemList(); boolean[] itemFound = new boolean[craftMatrix.size()]; // Check each ingredient against ME network storage for (int i = 0; i < craftMatrix.size(); i++) { if (craftMatrix.get(i) == null || craftMatrix.get(i).isToolItem()) { itemFound[i] = true; continue; } for (int j = 0; j < inventories.size(); j++) { if (inventories.get(j) instanceof AppEngInternalInventoryBridge aeInv) { // Search ME network for matching ingredients for (ItemStack item : craftMatrix.get(i).getItemStacks()) { IAEItemStack requestItem = AEItemStack.create(item); Collection results = aeInv.getWirelessObject() .getStorageList().findFuzzy(requestItem, FuzzyMode.IGNORE_ALL); for (IAEItemStack result : results) { if (craftMatrix.get(i).isValidItem(result.getItemStack())) { usedStacks.add(requestItem); if (checkHasEnoughItem(usedStacks, aeInv.getWirelessObject().getStorageList())) { itemFound[i] = true; } } } } } } } // Return true only if all ingredients are available for (boolean found : itemFound) { if (!found) { cir.setReturnValue(false); return; } } cir.setReturnValue(true); } } ``` -------------------------------- ### WirelessObject: Manage AE2 ME Network Connection and Storage (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt The WirelessObject class establishes and maintains a connection to the AE2 ME network, enabling item injection, extraction, and querying of available storage. It requires a TileKitchenStation instance and handles reinitialization if the network security key changes. It implements IWirelessObject for direct interaction with ME network storage caches. ```java // WirelessObject bridges the Kitchen Station to AE2 ME network storage public class WirelessObject implements IWirelessObject { private IStorageGrid sg; private IGrid targetGrid; private IMEMonitor itemStorage; private final TileKitchenStation tile; private final MachineSource source; public WirelessObject(TileKitchenStation tile) { this.tile = tile; this.source = new MachineSource(this); this.reinitialize(); } // Check and reinitialize connection if security key changed public boolean reCheckIsConnect() { if (lastKey != tile.getKey()) { this.reinitialize(); } ILocatable obj = AEApi.instance().registries().locatable() .getLocatableBy(tile.getKey()); if (obj instanceof IGridHost ig) { IGridNode n = ig.getGridNode(ForgeDirection.UNKNOWN); return n.isActive(); } return false; } // Initialize connection to the ME network via security terminal public void reinitialize() { ILocatable obj = AEApi.instance().registries().locatable() .getLocatableBy(tile.getKey()); if (obj instanceof IGridHost) { IGridNode n = ((IGridHost) obj).getGridNode(ForgeDirection.UNKNOWN); if (n != null) { this.targetGrid = n.getGrid(); this.sg = targetGrid.getCache(IStorageGrid.class); if (this.sg != null) { this.itemStorage = this.sg.getItemInventory(); } } } } // Extract items from ME network for crafting @Override public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) { if (this.itemStorage != null) { return this.itemStorage.extractItems(request, mode, src); } return null; } // Inject items into ME network (e.g., container items after crafting) @Override public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src) { if (this.itemStorage != null) { return this.itemStorage.injectItems(input, type, src); } return input; } // Get all available items for recipe matching @Override public IItemList getStorageList() { if (this.itemStorage != null) { return this.itemStorage.getStorageList(); } return null; } } ``` -------------------------------- ### Locate Security Terminal (Java) Source: https://context7.com/asdflj/appliedcooking/llms.txt Provides utility methods for Applied Energistics 2 integration, including locating security terminals by their encryption key. It returns an empty inventory when not connected to the ME network. ```java // Util provides helper methods for AE2 integration public class Util { // Empty inventory returned when not connected to ME network public static IInventory EmptyInventory = new AppEngInternalInventory(null, 0); // Locate a security terminal by its encryption key public static ILocatable getSecurityStation(long key) { return AEApi.instance() .registries() .locatable() .getLocatableBy(key); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.