Merge branch 'master' into fix/same-network-multiple-extract-only-storage-bus

This commit is contained in:
Martin Robertz authored and GitHub committed 2025-01-12 12:29:00 +01:00
commit fc165a7f6f
4 files changed
+150 -4

No files matched your search

+4 -4
View File
@@ -34,7 +34,7 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.7.15-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.7.18-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-518-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.8.2:dev')
@@ -49,15 +49,15 @@ dependencies {
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.1:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.9.2:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.61:dev') {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.67:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.3-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.2-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.4-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.4-GTNH:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.13:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.3.4:dev")
@@ -81,6 +81,7 @@ public class FluidCraft {
RecipeLoader.addInfiniteWaterCell();
}
RecipeLoader.runTerminalRecipe();
RecipeLoader.addDisassembleRecipe();
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
@@ -71,6 +71,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.loader.recipe.DisassembleRecipe;
import com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe;
import com.glodblock.github.loader.recipe.WirelessTerminalQuantumBridgeRecipe;
import com.glodblock.github.loader.recipe.WirelessTerminalRecipe;
@@ -757,4 +758,8 @@ public class RecipeLoader implements Runnable {
Arrays.stream(term).filter(Objects::nonNull).toArray());
}
public static void addDisassembleRecipe() {
GameRegistry.addRecipe(new DisassembleRecipe());
}
}
@@ -0,0 +1,140 @@
package com.glodblock.github.loader.recipe;
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.util.IterationCounter;
import appeng.util.Platform;
public class DisassembleRecipe implements IRecipe {
private final Map<ItemStack, ItemStack> cellMappings;
private final Map<ItemStack, ItemStack> nonCellMappings;
public DisassembleRecipe() {
this.cellMappings = new HashMap<>(16);
this.nonCellMappings = new HashMap<>(1);
this.cellMappings.put(new ItemStack(CELL1K), new ItemStack(CELL_PART, 1, 0));
this.cellMappings.put(new ItemStack(CELL4K), new ItemStack(CELL_PART, 1, 1));
this.cellMappings.put(new ItemStack(CELL16K), new ItemStack(CELL_PART, 1, 2));
this.cellMappings.put(new ItemStack(CELL64K), new ItemStack(CELL_PART, 1, 3));
this.cellMappings.put(new ItemStack(CELL256K), new ItemStack(CELL_PART, 1, 4));
this.cellMappings.put(new ItemStack(CELL1024K), new ItemStack(CELL_PART, 1, 5));
this.cellMappings.put(new ItemStack(CELL4096K), new ItemStack(CELL_PART, 1, 6));
this.cellMappings.put(new ItemStack(CELL16384K), new ItemStack(CELL_PART, 1, 7));
this.cellMappings.put(new ItemStack(CELL1KM), new ItemStack(CELL_PART, 1, 0));
this.cellMappings.put(new ItemStack(CELL4KM), new ItemStack(CELL_PART, 1, 1));
this.cellMappings.put(new ItemStack(CELL16KM), new ItemStack(CELL_PART, 1, 2));
this.cellMappings.put(new ItemStack(CELL64KM), new ItemStack(CELL_PART, 1, 3));
this.cellMappings.put(new ItemStack(CELL256KM), new ItemStack(CELL_PART, 1, 4));
this.cellMappings.put(new ItemStack(CELL1024KM), new ItemStack(CELL_PART, 1, 5));
this.cellMappings.put(new ItemStack(CELL4096KM), new ItemStack(CELL_PART, 1, 6));
this.cellMappings.put(new ItemStack(CELL16384KM), new ItemStack(CELL_PART, 1, 7));
this.nonCellMappings.put(
new ItemStack(PATTERN),
AEApi.instance().definitions().materials().blankPattern().maybeStack(1).get());
}
@Override
public boolean matches(final InventoryCrafting inv, final World w) {
return this.getOutput(inv) != null;
}
@SuppressWarnings("unchecked")
private ItemStack getOutput(final IInventory inventory) {
int itemCount = 0;
ItemStack output = null;
for (int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++) {
final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex);
if (stackInSlot != null) {
// needs a single input in the recipe
itemCount++;
if (itemCount > 1) {
return null;
}
// handle storage cells
final ItemStack storageCellStack = this.getCellOutput(stackInSlot);
if (storageCellStack != null) {
// make sure the storage cell stackInSlot empty...
final IMEInventory<IAEFluidStack> cellInv = AEApi.instance().registries().cell()
.getCellInventory(stackInSlot, null, StorageChannel.FLUIDS);
if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv
.getAvailableItems(StorageChannel.FLUIDS.createList(), IterationCounter.fetchNewId());
if (!list.isEmpty()) {
return null;
}
}
output = storageCellStack;
}
// handle crafting storage blocks
final ItemStack craftingStorageStack = this.getNonCellOutput(stackInSlot);
if (craftingStorageStack != null) {
output = craftingStorageStack;
}
}
}
return output;
}
private ItemStack getCellOutput(final ItemStack compared) {
for (final Map.Entry<ItemStack, ItemStack> entry : this.cellMappings.entrySet()) {
if (Platform.isSameItemType(compared, entry.getKey())) {
return entry.getValue().copy();
}
}
return null;
}
private ItemStack getNonCellOutput(final ItemStack compared) {
for (final Map.Entry<ItemStack, ItemStack> entry : this.nonCellMappings.entrySet()) {
if (Platform.isSameItemType(compared, entry.getKey())) {
return entry.getValue().copy();
}
}
return null;
}
@Nullable
@Override
public ItemStack getCraftingResult(final InventoryCrafting inv) {
return this.getOutput(inv);
}
@Override
public int getRecipeSize() {
return 1;
}
@Nullable
@Override
public ItemStack getRecipeOutput() // no default output..
{
return null;
}
}