mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-14 01:04:23 +00:00
Finally got GT6 fluids to work properly as far as I can test. Can pu… (#84)
Co-authored-by: slprime <[email protected]>
This commit is contained in:
1 parent
7d41385a79
commit
af46bd7dce
3 files changed
+88
-16
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package com.github.vfyjxf.nee.nei;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.api.IStackStringifyHandler;
|
||||
import gregapi.data.FL;
|
||||
import gregapi.item.ItemFluidDisplay;
|
||||
|
||||
public class GT6StackStringifyHandler implements IStackStringifyHandler {
|
||||
|
||||
@Override
|
||||
public boolean isFluidDisplayItem(ItemStack stack) {
|
||||
return stack != null && stack.getItem() instanceof ItemFluidDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||
if (stack != null && stack.getItem() instanceof ItemFluidDisplay) {
|
||||
FluidStack fluid = getFluid(stack);
|
||||
if (fluid != null && fluid.getFluid() != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("gt6FluidName", fluid.getFluid().getName());
|
||||
tag.setInteger("Count", saveStackSize ? fluid.amount : 1000);
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack convertNBTToItemStack(NBTTagCompound nbtTag) {
|
||||
if (nbtTag != null && nbtTag.hasKey("gt6FluidName")) {
|
||||
String fluidName = nbtTag.getString("gt6FluidName");
|
||||
Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
int amount = nbtTag.getInteger("Count");
|
||||
if (fluid != null) {
|
||||
return FL.display(new FluidStack(fluid, amount), false, false);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack stack) {
|
||||
if (stack != null && stack.getItem() instanceof ItemFluidDisplay) {
|
||||
return FL.getFluid(stack, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack normalizeRecipeQueryStack(ItemStack stack) {
|
||||
if (stack != null && stack.getItem() instanceof ItemFluidDisplay) {
|
||||
FluidStack fluid = getFluid(stack);
|
||||
if (fluid != null) {
|
||||
return codechicken.nei.item.ItemFluidDisplay.createStack(fluid);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import gregapi.NEI_RecipeMap;
|
||||
import gregapi.NEI_RecipeMap.FixedPositionedStack;
|
||||
import gregapi.data.FL;
|
||||
import gregapi.recipes.Recipe;
|
||||
|
||||
/**
|
||||
@@ -54,11 +53,9 @@ public class GregTech6RecipeProcessor implements IRecipeProcessor {
|
||||
positionedStack.item.stackSize = 1;
|
||||
}
|
||||
}
|
||||
// remove fluid
|
||||
recipeInputs.removeIf(
|
||||
positionedStack -> FL.getFluid(positionedStack.item, true) != null
|
||||
|| (positionedStack.item.stackSize == 0 && !NEEConfig.includeNonConsumableIngredients));
|
||||
// try to remove machine
|
||||
positionedStack -> positionedStack.item.stackSize == 0
|
||||
&& !NEEConfig.includeNonConsumableIngredients);
|
||||
if (recipe instanceof NEI_RecipeMap) {
|
||||
Field mRecipeMapField = ReflectionHelper.findField(NEI_RecipeMap.class, "mRecipeMap");
|
||||
Recipe.RecipeMap mRecipeMap = null;
|
||||
@@ -67,14 +64,21 @@ public class GregTech6RecipeProcessor implements IRecipeProcessor {
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (mRecipeMap != null) {
|
||||
ItemStack lastItem = (recipeInputs.get(recipeInputs.size() - 1)).items[0];
|
||||
for (ItemStack stack : mRecipeMap.mRecipeMachineList) {
|
||||
if (ItemStack.areItemStackTagsEqual(lastItem, stack)) {
|
||||
recipeInputs.remove(recipeInputs.size() - 1);
|
||||
break;
|
||||
final List<ItemStack> machineList = mRecipeMap != null ? mRecipeMap.mRecipeMachineList : null;
|
||||
if (machineList != null && !machineList.isEmpty()) {
|
||||
recipeInputs.removeIf(positionedStack -> {
|
||||
if (positionedStack == null || positionedStack.items == null) return false;
|
||||
for (ItemStack item : positionedStack.items) {
|
||||
if (item == null) continue;
|
||||
for (ItemStack machine : machineList) {
|
||||
if (machine == null) continue;
|
||||
if (item.isItemEqual(machine) && ItemStack.areItemStackTagsEqual(item, machine)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
return recipeInputs;
|
||||
@@ -88,10 +92,7 @@ public class GregTech6RecipeProcessor implements IRecipeProcessor {
|
||||
List<PositionedStack> recipeOutput = new ArrayList<>();
|
||||
if (this.getAllOverlayIdentifier().contains(identifier)) {
|
||||
recipeOutput.addAll(recipe.getOtherStacks(recipeIndex));
|
||||
recipeOutput.removeIf(
|
||||
positionedStack -> FL.getFluid(positionedStack.item, true) != null
|
||||
|| positionedStack.item.stackSize == 0);
|
||||
// try to remove item output if it's chance != 100%
|
||||
recipeOutput.removeIf(positionedStack -> positionedStack.item.stackSize == 0);
|
||||
recipeOutput.removeIf(
|
||||
positionedStack -> positionedStack instanceof FixedPositionedStack
|
||||
&& ((FixedPositionedStack) positionedStack).mChance > 0
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
import com.github.vfyjxf.nee.block.BlockPatternInterface;
|
||||
import com.github.vfyjxf.nee.block.tile.TilePatternInterface;
|
||||
import com.github.vfyjxf.nee.nei.GT6StackStringifyHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
@@ -18,6 +19,8 @@ import appeng.api.util.AEColor;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.BlockStackSrc;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import codechicken.nei.api.API;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -29,6 +32,9 @@ public class CommonProxy {
|
||||
TilePatternInterface.class,
|
||||
new BlockStackSrc(BLOCK_INSTANCE, 0, ActivityState.Enabled));
|
||||
registerRecipe();
|
||||
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) {
|
||||
API.registerStackStringifyHandler(new GT6StackStringifyHandler());
|
||||
}
|
||||
}
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
Reference in new issue
Block a user