Add crafting calculator v2 compat for newer AE2-GTNH versions

This commit is contained in:
Raven Szewczyk committed 2023-01-14 18:04:23 +00:00
1 parent f203c24551
commit 18630c9618
3 files changed
+33 -1

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.20-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-137-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-137-GTNH-10-g625c054:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
@@ -7,6 +7,7 @@ import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.loader.CalculatorV2PluginLoader;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
@@ -90,6 +91,16 @@ public class FluidCraft {
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
}
try {
Class<?> calculatorV2 = Class.forName("appeng.crafting.v2.CraftingCalculations");
if (calculatorV2 != null) {
// Only run this if GTNH AE2 is installed
CalculatorV2PluginLoader.installCalculatorV2Plugins();
}
} catch (ClassNotFoundException e) {
// no-op
}
proxy.postInit(event);
}
@@ -0,0 +1,21 @@
package com.glodblock.github.loader;
import appeng.api.storage.data.IAEItemStack;
import appeng.crafting.v2.CraftingCalculations;
import appeng.crafting.v2.CraftingRequest;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
public class CalculatorV2PluginLoader {
private static long adjustByteCost(CraftingRequest<IAEItemStack> request, Long originalAmount) {
if (request.stack.getItem() instanceof ItemFluidDrop) {
return Platform.ceilDiv(originalAmount, 1000L);
} else {
return originalAmount;
}
}
public static void installCalculatorV2Plugins() {
CraftingCalculations.registerByteAmountAdjuster(CalculatorV2PluginLoader::adjustByteCost, IAEItemStack.class);
}
}