mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 16:27:40 +00:00
8 files changed
+161
-17
No files matched your search
@@ -22,5 +22,6 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.29:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:GTplusplus:1.7.49:dev") {transitive = false}
|
||||
|
||||
|
||||
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
|
||||
}
|
||||
@@ -389,19 +389,19 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
if( this.canHoldNewFluid() ) // room for new type, and for at least one item!
|
||||
{
|
||||
final int remainingItemCount = (int) this.getRemainingFluidCount() - this.getBytesPerType() * 8;
|
||||
final long remainingItemCount = this.getRemainingFluidCount() - this.getBytesPerType() * 8;
|
||||
|
||||
if( remainingItemCount > 0 )
|
||||
{
|
||||
if( input.getStackSize() > remainingItemCount )
|
||||
{
|
||||
final FluidStack toReturn = Util.cloneFluidStack(sharedFluidStack);
|
||||
toReturn.amount = sharedFluidStack.amount - remainingItemCount;
|
||||
toReturn.amount = (int) (sharedFluidStack.amount - remainingItemCount);
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
final FluidStack toWrite = Util.cloneFluidStack( sharedFluidStack );
|
||||
toWrite.amount = remainingItemCount;
|
||||
toWrite.amount = (int) remainingItemCount;
|
||||
|
||||
this.cellItems.add( AEFluidStack.create( toWrite ) );
|
||||
this.updateFluidCount( toWrite.amount );
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
@@ -19,7 +20,6 @@ import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -48,8 +48,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel) {
|
||||
/*conflict = !checkDiscreatizer();
|
||||
if (conflict) return Collections.emptyList();*/
|
||||
if (getProxy().isActive()) {
|
||||
if (channel == StorageChannel.ITEMS) {
|
||||
return Collections.singletonList(fluidDropInv.invHandler);
|
||||
@@ -131,6 +129,25 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onBootUp(MENetworkBootingStatusChange event) {
|
||||
try {
|
||||
IMEInventory<IAEItemStack> inventory = this.getProxy().getStorage().getItemInventory();
|
||||
IItemList<IAEItemStack> items = inventory.getAvailableItems(AEApi.instance().storage().createItemList());
|
||||
IItemList<IAEItemStack> drops = AEApi.instance().storage().createItemList();
|
||||
for (IAEItemStack item : items) {
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
drops.add(item);
|
||||
}
|
||||
}
|
||||
for (IAEItemStack drop : drops) {
|
||||
inventory.extractItems(drop, Actionable.MODULATE, ownActionSource);
|
||||
inventory.injectItems(drop, Actionable.MODULATE, ownActionSource);
|
||||
}
|
||||
} catch (GridAccessException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private class FluidDiscretizingInventory implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
|
||||
@@ -142,7 +159,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack request, Actionable type, BaseActionSource src) {
|
||||
/*if (conflict) return request;*/
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return request;
|
||||
@@ -165,7 +181,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) {
|
||||
/*if (conflict) return null;*/
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
@@ -188,7 +203,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
|
||||
/*if (conflict) return out;*/
|
||||
if (itemCache == null) {
|
||||
itemCache = new ArrayList<>();
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
@@ -253,7 +267,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
|
||||
/*if (conflict) return null;*/
|
||||
ICraftingGrid craftingGrid;
|
||||
try {
|
||||
craftingGrid = getProxy().getGrid().getCache(ICraftingGrid.class);
|
||||
|
||||
@@ -2,18 +2,12 @@ package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
|
||||
@@ -67,6 +67,19 @@ public class DefaultExtractorLoader implements Runnable {
|
||||
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerStill()));
|
||||
}
|
||||
|
||||
if (ModAndClassUtil.IC2) {
|
||||
FluidRecipe.addRecipeMap("blastfurnace", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("BlockCutter", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("centrifuge", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("compressor", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("extractor", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("fluidcanner", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("macerator", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("metalformer", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("oreWashing", new IndustrialCraftRecipeExtractor());
|
||||
FluidRecipe.addRecipeMap("solidcanner", new IndustrialCraftRecipeExtractor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package com.glodblock.github.nei.recipes.extractor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import com.glodblock.github.nei.object.IRecipeExtractor;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import ic2.neiIntegration.core.recipehandler.FluidCannerRecipeHandler;
|
||||
import ic2.neiIntegration.core.recipehandler.OreWashingRecipeHandler;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IndustrialCraftRecipeExtractor implements IRecipeExtractor {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i ++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
tmp.add(OrderStack.pack(rawInputs.get(i), i));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i ++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
tmp.add(OrderStack.pack(rawOutputs.get(i), i));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
|
||||
List<OrderStack<?>> stacks = new LinkedList<>();
|
||||
|
||||
if (recipe instanceof FluidCannerRecipeHandler) {
|
||||
FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes.get(index);
|
||||
FluidStack input = ReflectIC2.getInputFluid(cachedRecipe);
|
||||
PositionedStack add = rawInputs.size() > 1 ? rawInputs.get(1) : null;
|
||||
stacks.add(OrderStack.pack(add, 0));
|
||||
stacks.add(new OrderStack<>(input, 1));
|
||||
}
|
||||
else if (recipe instanceof OreWashingRecipeHandler) {
|
||||
stacks = getInputIngredients(rawInputs);
|
||||
int water = ReflectIC2.getOreWasherWater((OreWashingRecipeHandler) recipe, index);
|
||||
stacks.add(new OrderStack<>(new FluidStack(FluidRegistry.WATER, water), stacks.size()));
|
||||
} else {
|
||||
stacks = getInputIngredients(rawInputs);
|
||||
}
|
||||
|
||||
return stacks.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe, int index) {
|
||||
List<OrderStack<?>> stacks = new LinkedList<>();
|
||||
|
||||
if (recipe instanceof FluidCannerRecipeHandler) {
|
||||
FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes.get(index);
|
||||
FluidStack output = ReflectIC2.getOutputFluid(cachedRecipe);
|
||||
stacks.add(new OrderStack<>(output, 0));
|
||||
} else {
|
||||
stacks = getOutputIngredients(rawOutputs);
|
||||
}
|
||||
|
||||
return stacks.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static class ReflectIC2 {
|
||||
|
||||
private final static Field inputsF;
|
||||
private final static Field resultF;
|
||||
|
||||
private final static Method oreWasherWater;
|
||||
|
||||
static {
|
||||
try {
|
||||
inputsF = Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidInput");
|
||||
resultF = Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidOutput");
|
||||
oreWasherWater = Ae2Reflect.reflectMethod(OreWashingRecipeHandler.class, "getreqWater", int.class);
|
||||
} catch (NoSuchFieldException | NoSuchMethodException e) {
|
||||
throw new IllegalStateException("Failed to initialize IC2 reflection hacks!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static FluidStack getInputFluid(FluidCannerRecipeHandler.CachedFluidCannerRecipe recipe) {
|
||||
return Ae2Reflect.readField(recipe, inputsF);
|
||||
}
|
||||
|
||||
private static FluidStack getOutputFluid(FluidCannerRecipeHandler.CachedFluidCannerRecipe recipe) {
|
||||
return Ae2Reflect.readField(recipe, resultF);
|
||||
}
|
||||
|
||||
private static int getOreWasherWater(OreWashingRecipeHandler recipeHandler, int index) {
|
||||
try {
|
||||
return (int) oreWasherWater.invoke(recipeHandler, index);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to invoke method: " + oreWasherWater, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.glodblock.github.proxy;
|
||||
import com.glodblock.github.loader.ListenerLoader;
|
||||
import com.glodblock.github.loader.RenderLoader;
|
||||
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -24,6 +25,8 @@ public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event){
|
||||
super.postInit(event);
|
||||
(new DefaultExtractorLoader()).run();
|
||||
if (ModAndClassUtil.NEI) {
|
||||
(new DefaultExtractorLoader()).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public final class ModAndClassUtil {
|
||||
public static boolean OC = false;
|
||||
public static boolean ThE = false;
|
||||
public static boolean WCT = false;
|
||||
public static boolean IC2 = false;
|
||||
public static boolean NEI = false;
|
||||
public static boolean GTPP = false;
|
||||
|
||||
public static boolean isDoubleButton;
|
||||
@@ -113,6 +115,10 @@ public final class ModAndClassUtil {
|
||||
ThE = true;
|
||||
if (Loader.isModLoaded("ae2wct"))
|
||||
WCT = true;
|
||||
if (Loader.isModLoaded("IC2"))
|
||||
IC2 = true;
|
||||
if (Loader.isModLoaded("NotEnoughItems"))
|
||||
NEI = true;
|
||||
if (Loader.isModLoaded("miscutils"))
|
||||
GTPP = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user