mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-18 11:19:30 +00:00
feat: convert gt fluid from nei item panel
This commit is contained in:
1 parent
e5767d75ab
commit
21eb93ea01
9 files changed
+36
-10
No files matched your search
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 3.6.3
|
||||
|
||||
- Feat: add support of `GT++`, `EnderIO`, `Thaumcraft`
|
||||
- Feat: convert gt fluid item into Fluid which picked from NEI item panel
|
||||
|
||||
## 3.6.2
|
||||
|
||||
- Fix: crash when nei version is not number.
|
||||
|
||||
@@ -65,7 +65,7 @@ Tutorial links:
|
||||
|
||||
## Development
|
||||
|
||||
For run `gradle runClient`, you need copy the mods from `dev-mods/` to `run/mods`.
|
||||
~~For run `gradle runClient`, you need copy the mods from `dev-mods/` to `run/mods`.~~
|
||||
|
||||
[1]: http://cf.way2muchnoise.eu/full_just-enough-calculation_downloads.svg
|
||||
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ This mod is focused on calculation, so you might find it powerful and high perfo
|
||||
- [x] gregtech
|
||||
- [x] Forestry (`?` 按钮可能与流体重叠,不是很好点到)
|
||||
- [x] Avaritia (`?` 按钮可能会被NEI搜索栏遮盖)
|
||||
- [x] GT++ (支持 GT++ 1.7.05.68 版本(GTNH 2.1.0.0),老版本没有测试过)
|
||||
- [x] GT++ (支持 GT++ 1.7.05.68 (GTNH 2.1.0.0),老版本没有测试过)
|
||||
- [x] Thaumcraft (不包括要素)
|
||||
- [ ] AE2(目前没办法,需要 AE2 作者支持
|
||||
- [ ] 其它
|
||||
@@ -63,7 +63,7 @@ This mod is focused on calculation, so you might find it powerful and high perfo
|
||||
|
||||
## 开发
|
||||
|
||||
如果要运行 `gradle runClient`, 需要将 `dev-mods/` 文件夹中的全部模组复制到 `run/mods`(运行一次 `runClient` 后生成)文件夹中.
|
||||
~~如果要运行 `gradle runClient`, 需要将 `dev-mods/` 文件夹中的全部模组复制到 `run/mods`(运行一次 `runClient` 后生成)文件夹中.~~
|
||||
|
||||
[1]: http://cf.way2muchnoise.eu/full_just-enough-calculation_downloads.svg
|
||||
|
||||
|
||||
Binary file not shown.
+2
-2
@@ -3,5 +3,5 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
# suppress inspection "UnusedProperty" for whole file
|
||||
mc_version=1.7.10
|
||||
nei_version=2.1.2-GTNH
|
||||
proj_version=3.6.2
|
||||
nei_version=2.1.5-GTNH
|
||||
proj_version=3.6.3
|
||||
@@ -5,6 +5,8 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import me.towdium.jecalculation.nei.adapter.*;
|
||||
import me.towdium.jecalculation.utils.Utilities;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -12,6 +14,16 @@ import java.util.List;
|
||||
public class Adapter {
|
||||
public static List<IAdapter> adapters = new ArrayList<>();
|
||||
|
||||
public static Object convertFluid(ItemStack itemStack) {
|
||||
String name = Utilities.getName(itemStack);
|
||||
String modId = name.substring(0, name.indexOf(":"));
|
||||
String itemId = name.substring(name.indexOf(":") + 1);
|
||||
if (Loader.isModLoaded("gregtech")) {
|
||||
return GregTech.convertFluid(itemStack);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
JustEnoughCalculation.logger.info("=====Just Enough Calculation Init Start=====");
|
||||
if (Loader.isModLoaded("Forestry")) {
|
||||
|
||||
@@ -39,7 +39,8 @@ public class NEIPlugin {
|
||||
public static ILabel getLabelUnderMouse() {
|
||||
if (NEIPlugin.currentItemStack == null)
|
||||
return ILabel.EMPTY;
|
||||
return ILabel.Converter.from(NEIPlugin.currentItemStack);
|
||||
Object stack = Adapter.convertFluid(NEIPlugin.currentItemStack);
|
||||
return ILabel.Converter.from(stack);
|
||||
}
|
||||
|
||||
public static void setLabelUnderMouse(ItemStack itemStack) {
|
||||
|
||||
@@ -67,17 +67,17 @@ public class GregTech implements IAdapter {
|
||||
|
||||
protected void handleDefault(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
Object[] objects = Arrays.stream(inputs.get(i)).map(o -> this.convertFluid((ItemStack) o)).toArray();
|
||||
Object[] objects = Arrays.stream(inputs.get(i)).map(o -> GregTech.convertFluid((ItemStack) o)).toArray();
|
||||
inputs.set(i, objects);
|
||||
}
|
||||
List<PositionedStack> otherStacks = recipe.getOtherStacks(index);
|
||||
outputs.addAll(otherStacks.stream()
|
||||
.map(positionedStack -> positionedStack.items)
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(this::convertFluid).toArray())
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(GregTech::convertFluid).toArray())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
protected Object convertFluid(ItemStack itemStack) {
|
||||
public static Object convertFluid(ItemStack itemStack) {
|
||||
FluidStack fluidStack = getFluidFromDisplayStack(itemStack);
|
||||
return fluidStack == null ? itemStack : fluidStack;
|
||||
}
|
||||
|
||||
@@ -88,11 +88,19 @@ public class Utilities {
|
||||
// MOD NAME
|
||||
@Nullable
|
||||
public static String getModName(Item item) {
|
||||
String name = GameData.getItemRegistry().getNameForObject(item);
|
||||
String name = getName(item);
|
||||
String id = name.substring(0, name.indexOf(":"));
|
||||
return id.equals("minecraft") ? "Minecraft" : Loader.instance().getIndexedModList().get(id).getName();
|
||||
}
|
||||
|
||||
public static String getName(Item item) {
|
||||
return GameData.getItemRegistry().getNameForObject(item);
|
||||
}
|
||||
|
||||
public static String getName(ItemStack itemStack) {
|
||||
return getName(itemStack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* If fluid is lava or water, return 'Minecraft'.
|
||||
* If has still icon or flowing icon, get the icon name, or return 'unknown';
|
||||
|
||||
Reference in new issue
Block a user