Add JEI support for the Marx generator

This commit is contained in:
malte0811 2017-08-29 21:31:22 +02:00
parent 96aa3ec96a
commit bc1ebc9fa5
10 changed files with 316 additions and 103 deletions

View file

@ -30,7 +30,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "14.21.1.2420"
version = "14.22.0.2463"
runDir = "run"
replace '${version}', project.version

View file

@ -64,6 +64,7 @@ import java.util.List;
public class IndustrialWires {
public static final String MODID = "industrialwires";
public static final String VERSION = "${version}";
public static final String MODNAME = "Industrial Wires";
public static final List<BlockIWBase> blocks = new ArrayList<>();
public static final List<Item> items = new ArrayList<>();
@ -165,6 +166,7 @@ public class IndustrialWires {
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
IWPotions.init();
Compat.init();
}
@EventHandler

View file

@ -20,6 +20,7 @@ package malte0811.industrialWires.blocks.hv;
import blusunrize.immersiveengineering.api.IEProperties;
import malte0811.industrialWires.blocks.BlockIWMultiblock;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.blocks.IWProperties;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@ -40,7 +41,7 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockHVMultiblocks extends BlockIWMultiblock {
public class BlockHVMultiblocks extends BlockIWMultiblock implements IMetaEnum {
public static final PropertyEnum<BlockTypes_HVMultiblocks> type = PropertyEnum.create("type", BlockTypes_HVMultiblocks.class);
public BlockHVMultiblocks() {
super(Material.IRON, "hv_multiblock");
@ -97,4 +98,9 @@ public class BlockHVMultiblocks extends BlockIWMultiblock {
IEProperties.CONNECTIONS
});
}
@Override
public Object[] getValues() {
return BlockTypes_HVMultiblocks.values();
}
}

View file

@ -21,6 +21,7 @@ import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.client.ClientUtils;
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.panelmodel.PanelModel;
@ -132,8 +133,7 @@ public class ClientEventHandler {
ModelLoader.setCustomModelResourceLocation(IndustrialWires.key, meta, new ModelResourceLocation(loc, "inventory"));
}
Block[] blocks = {IndustrialWires.ic2conn, IndustrialWires.mechConv, IndustrialWires.jacobsLadder, IndustrialWires.panel};
for (Block b : blocks) {
for (BlockIWBase b : IndustrialWires.blocks) {
if (b != null) {
Item blockItem = Item.getItemFromBlock(b);
final ResourceLocation loc = b.getRegistryName();

View file

@ -1,56 +1,60 @@
package malte0811.industrialWires.compat;
import com.google.common.collect.ImmutableList;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.IAction;
import crafttweaker.api.block.IBlock;
import crafttweaker.api.item.IIngredient;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import crafttweaker.api.oredict.IOreDictEntry;
import malte0811.industrialWires.hv.MarxOreHandler;
import malte0811.industrialWires.hv.MarxOreHandler.OreChecker;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import java.util.function.BiPredicate;
import java.util.function.Supplier;
@ZenClass("mods.industrialwires.MarxGenerator")
public class CTMarxGenerator {
@ZenMethod
public static void addRecipe(IBlock in, double avgRelEnergy, double maxMain, IItemStack outMain, @Optional int smallLargeRatio, @Optional IItemStack outSmall) {
IBlock properIn;
if (in instanceof IItemStack)
properIn = ((IItemStack) in).asBlock();
else
properIn = in;
if (!(properIn instanceof IBlock)) {
throw new IllegalArgumentException("What did you pass to MarxGenerator.addRecipe?"+properIn);
public static void addRecipe(IIngredient in, double avgRelEnergy, double maxMain, IItemStack outMain, @Optional int smallLargeRatio, @Optional IItemStack outSmall) {
Supplier<ItemStack> out = () -> CraftTweakerMC.getItemStack(outMain);
Supplier<ItemStack> supSmall = outSmall!=null?() -> CraftTweakerMC.getItemStack(outSmall):null;
if (in instanceof IItemStack) {
IBlock properIn = ((IItemStack) in).asBlock();
if (properIn!=null) {
CraftTweakerAPI.apply(new Add(new MarxOreHandler.OreInfo((world, pos) -> CraftTweakerMC.getBlock(world, pos.getX(), pos.getY(), pos.getZ()).matches(properIn),
ImmutableList.of(CraftTweakerMC.getItemStack(in)), avgRelEnergy, maxMain, out, supSmall, smallLargeRatio)));
return;
}
} else if (in instanceof IOreDictEntry) {
String oreName = ((IOreDictEntry) in).getName();
CraftTweakerAPI.apply(new Add(new MarxOreHandler.OreInfo(new OreChecker(oreName), OreDictionary.getOres(oreName),
avgRelEnergy, maxMain, out, supSmall, smallLargeRatio)));
return;
}
Supplier<ItemStack> out = ()->CraftTweakerMC.getItemStack(outMain);
Supplier<ItemStack> supSmall = ()->CraftTweakerMC.getItemStack(outSmall);
CraftTweakerAPI.apply(new Add((world, pos)-> CraftTweakerMC.getBlock(world, pos.getX(), pos.getY(), pos.getZ()).matches(properIn),
new MarxOreHandler.OreInfo(avgRelEnergy, maxMain, out, supSmall, smallLargeRatio)));
throw new IllegalArgumentException("Invalid parameter "+in);
}
private static class Add implements IAction {
private final BiPredicate<World, BlockPos> isValid;
private final MarxOreHandler.OreInfo output;
private final MarxOreHandler.OreInfo recipe;
public Add(BiPredicate<World, BlockPos> isValid, MarxOreHandler.OreInfo output) {
this.isValid = isValid;
this.output = output;
public Add(MarxOreHandler.OreInfo recipe) {
this.recipe = recipe;
}
@Override
public void apply() {
MarxOreHandler.put(isValid, output);
MarxOreHandler.put(recipe);
}
@Override
public String describe() {
return "Adding Marx Generator Recipe for "+output.output.get();
return "Adding Marx Generator Recipe for "+ recipe.output.get();
}
}
}

View file

@ -13,14 +13,21 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Compat {
private static final Compat INSTANCE = new Compat();
public static void preInit() {
Method[] methods = Compat.class.getDeclaredMethods();
callAllForClass(PreInit.class);
}
public static void init() {
callAllForClass(Init.class);
}
private static void callAllForClass(Class c) {
Method[] methods = c.getDeclaredMethods();
for (Method m : methods) {
if (m.getReturnType() == void.class && m.getParameterCount() == 0&&!m.getName().equals("preInit")) {
if (m.getReturnType() == void.class && m.getParameterCount() == 0) {
try {
m.invoke(INSTANCE);
m.setAccessible(true);
m.invoke(null);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
@ -28,24 +35,28 @@ public class Compat {
}
}
@Optional.Method(modid = "ic2")
private void initIC2() {
Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem();
ItemStack emptyMug = IC2Items.getItem("mug", "empty");
ToolboxHandler.addFoodType((s) -> s.getItem() == tinnedFood);
ToolboxHandler.addFoodType((s) ->
s.getItem() == emptyMug.getItem() && !ItemStack.areItemStacksEqual(emptyMug, ApiUtils.copyStackWithAmount(s, 1))
);
Item cable = IC2Items.getItem("cable", "type:copper,insulation:0").getItem();
ToolboxHandler.addWiringType((s, w) -> s.getItem() == cable);
ToolboxHandler.addToolType((s) -> {
Item a = s.getItem();
return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s);
});
private static class PreInit {
@Optional.Method(modid = "crafttweaker")
private static void preInitCraftTweaker() {
CraftTweakerAPI.registerClass(CTMarxGenerator.class);
}
}
@Optional.Method(modid = "crafttweaker")
private void initCraftTweaker() {
CraftTweakerAPI.registerClass(CTMarxGenerator.class);
private static class Init {
@Optional.Method(modid = "ic2")
private static void initIC2() {
Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem();
ItemStack emptyMug = IC2Items.getItem("mug", "empty");
ToolboxHandler.addFoodType((s) -> s.getItem() == tinnedFood);
ToolboxHandler.addFoodType((s) ->
s.getItem() == emptyMug.getItem() && !ItemStack.areItemStacksEqual(emptyMug, ApiUtils.copyStackWithAmount(s, 1))
);
Item cable = IC2Items.getItem("cable", "type:copper,insulation:0").getItem();
ToolboxHandler.addWiringType((s, w) -> s.getItem() == cable);
ToolboxHandler.addToolType((s) -> {
Item a = s.getItem();
return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s);
});
}
}
}
}

View file

@ -0,0 +1,135 @@
package malte0811.industrialWires.compat;
import blusunrize.immersiveengineering.common.util.Utils;
import com.google.common.collect.ImmutableList;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.hv.BlockTypes_HVMultiblocks;
import malte0811.industrialWires.hv.MarxOreHandler;
import malte0811.industrialWires.hv.MarxOreHandler.OreInfo;
import mezz.jei.api.*;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@JEIPlugin
public class JEIMarx implements IModPlugin {
public static IJeiHelpers jeiHelpers;
private static JEIMarx.MarxCategory marx;
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
}
@Override
public void registerIngredients(IModIngredientRegistration registry) {
}
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
jeiHelpers = registry.getJeiHelpers();
marx = new MarxCategory();
registry.addRecipeCategories(marx);
}
@Override
public void register(IModRegistry registryIn) {
registryIn.handleRecipes(OreInfo.class, MarxRecipeWrapper::new, IndustrialWires.MODID+".marx");
registryIn.addRecipes(MarxOreHandler.getRecipes(), IndustrialWires.MODID+".marx");
registryIn.addRecipeCatalyst(new ItemStack(IndustrialWires.hvMultiblocks, 1,
BlockTypes_HVMultiblocks.MARX.getMeta()), marx.getUid());
}
@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
}
private class MarxCategory implements IRecipeCategory<MarxRecipeWrapper> {
@Nonnull
@Override
public String getUid() {
return IndustrialWires.MODID + ".marx";
}
@Nonnull
@Override
public String getTitle() {
return I18n.format(IndustrialWires.MODID + ".desc.jei.marx");
}
@Nonnull
@Override
public String getModName() {
return IndustrialWires.MODNAME;
}
@Nonnull
@Override
public IDrawable getBackground() {
IGuiHelper guiHelper = jeiHelpers.getGuiHelper();
return guiHelper.createBlankDrawable(140, 50);
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull MarxRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.init(0, true, 10, 17);
guiItemStacks.init(1, false, 62, 4);
guiItemStacks.init(2, false, 62, 29);
guiItemStacks.set(ingredients);
}
@Nullable
@Override
public IDrawable getIcon() {
return null;
}
}
private class MarxRecipeWrapper implements IRecipeWrapper {
OreInfo recipe;
public MarxRecipeWrapper(OreInfo recipe) {
this.recipe = recipe;
}
@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
ingredients.setInputLists(ItemStack.class, ImmutableList.of(recipe.exampleInput));
if (recipe.outputSmall!=null) {
ingredients.setOutputs(ItemStack.class, ImmutableList.of(
recipe.output.get(),
recipe.outputSmall.get()));
} else {
ingredients.setOutputs(ItemStack.class, ImmutableList.of(recipe.output.get(), ItemStack.EMPTY));//TODO remove second output?
}
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
IDrawable slot = jeiHelpers.getGuiHelper().getSlotDrawable();
slot.draw(minecraft, 10, 17);
slot.draw(minecraft, 62, 4);
if (recipe.outputSmall!=null&&!recipe.outputSmall.get().isEmpty()) {
slot.draw(minecraft, 62, 29);
//TODO Localization
minecraft.fontRenderer.drawString("x"+ recipe.smallMax+I18n.format(IndustrialWires.MODID+".desc.jei.alt"), 85, 33, 0xff000000);
}
//TODO Localization
minecraft.fontRenderer.drawString("x"+ Utils.formatDouble(recipe.maxYield, "0.#") + I18n.format(IndustrialWires.MODID+".desc.jei.max"), 85, 8, 0xff000000);
minecraft.fontRenderer.drawString("~", 0, 3, 0xff000000);
minecraft.fontRenderer.drawString((int) (recipe.avgEnergy*MarxOreHandler.defaultEnergy/1000)+" kJ",
minecraft.fontRenderer.getCharWidth('~'), 0, 0xff000000);
}
}
}

View file

@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.crafting.IngredientStack;
import blusunrize.immersiveengineering.common.util.Utils;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@ -34,54 +35,48 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static net.minecraftforge.oredict.OreDictionary.getOres;
public class MarxOreHandler {
private static final List<Pair<BiPredicate<World, BlockPos>, OreInfo>> oreData = new ArrayList<>();
private static double defaultEnergy = 100_000;
private static final List<OreInfo> oreData = new ArrayList<>();
public static double defaultEnergy = 100_000;
public static double modifier;
public static void init() {
// Vanilla ores
putOre("oreIron", new OreInfo(.5, 4, "dustIron", "nuggetIron"));
putOre("oreGold", new OreInfo(1, 4, "dustGold", "nuggetGold"));
putOre("oreDiamond", new OreInfo(2, 4, "gemDiamond"));
putOre("oreEmerald", new OreInfo(3, 4, "gemEmerald"));
putOre("oreLapis", new OreInfo(.75, 10, "gemLapis"));
putOre("oreCoal", new OreInfo(.75, 8, Items.COAL, 0));
putOre("oreRedstone", new OreInfo(1, 12, "dustRedstone"));
putOre("oreQuartz", new OreInfo(1, 6, "gemQuartz"));
putOre("oreIron", .5, 4, "dustIron", "nuggetIron");
putOre("oreGold", 1, 4, "dustGold", "nuggetGold");
putOre("oreDiamond", 2, 4, "gemDiamond");
putOre("oreEmerald", 3, 4, "gemEmerald");
putOre("oreLapis", .75, 10, "gemLapis");
putOre("oreCoal", .75, 8, Items.COAL, 0);
putOre("oreRedstone", 1, 12, "dustRedstone");
putOre("oreQuartz", 1, 6, "gemQuartz");
// IE ores
String[] ores = {"Copper", "Aluminum", "Lead", "Silver", "Nickel", "Tin"};
for (String ore : ores) {
putOre("ore" + ore, new OreInfo(.75, 4, "ingot" + ore, "nugget" + ore));
putOre("ore" + ore, .75, 4, "dust" + ore, "nugget" + ore);
}
putOre("oreUranium", new OreInfo(1.25, 4, "crushedUranium", "nuggetUranium"));
putOre("oreUranium", 1.25, 4, "crushedUranium", "nuggetUranium");
}
public static void putOre(String oreName, OreInfo info) {
put((world, here)->{
IBlockState state = world.getBlockState(here);
ItemStack input = state.getBlock().getPickBlock(state, null, world, here, null);
int[] ores = OreDictionary.getOreIDs(input);
for (int id : ores) {
String name = OreDictionary.getOreName(id);
if (name.equals(oreName)) {
return true;
}
}
return false;
}, info);
public static void putOre(String oreName, double avgEnergy, double maxYield, String oreOut) {
putOre(oreName, avgEnergy, maxYield, oreOut, null);
}
public static void putOre(String oreName, double avgEnergy, double maxYield, String oreOut, @Nullable String oreSmall) {
put(new OreInfo(new OreChecker(oreName), getOres(oreName), avgEnergy, maxYield, oreOut, oreSmall));
}
public static void putOre(String oreName, double avgEnergy, double maxYield, Item oreOut, int meta) {
put(new OreInfo(new OreChecker(oreName), getOres(oreName), avgEnergy, maxYield, oreOut, meta));
}
public static void put(BiPredicate<World, BlockPos> isValid, MarxOreHandler.OreInfo output) {
oreData.add(new ImmutablePair<>(isValid, output));
public static void put(MarxOreHandler.OreInfo output) {
oreData.add(output);
}
public static void resetModifier() {
@ -93,33 +88,32 @@ public class MarxOreHandler {
IndustrialWires.logger.error("The energy-modifier for Marx generators wasn't loaded correctly. It will be reset.");
resetModifier();
}
for (Pair<BiPredicate<World, BlockPos>, OreInfo> ore:oreData) {
if (ore.getLeft().test(world, pos)) {
OreInfo info = ore.getRight();
double idealE = modifier * info.avgEnergy * defaultEnergy;
for (OreInfo ore:oreData) {
if (ore.isValid.test(world, pos)) {
double idealE = modifier * ore.avgEnergy * defaultEnergy;
if (energy >= .75 * idealE) {
double sigma = idealE / 9;
double dist = getNormalizedNormalDist(energy, sigma, idealE);
double out = dist * info.maxYield;
double out = dist * ore.maxYield;
int yield = (int) Math.floor(out);
out -= yield;
int yieldNuggets = (int) Math.round(out * info.smallMax);
if (yieldNuggets >= info.smallMax || (info.outputSmall == null && yieldNuggets >= info.smallMax/2F)) {
int yieldNuggets = (int) Math.round(out * ore.smallMax);
if (yieldNuggets >= ore.smallMax || (ore.outputSmall == null && yieldNuggets >= ore.smallMax/2F)) {
yield++;
yieldNuggets = 0;
}
if (yield > 0 && yieldNuggets > 0 && info.outputSmall != null) {
if (yield > 0 && yieldNuggets > 0 && ore.outputSmall != null) {
return new ItemStack[]{
ApiUtils.copyStackWithAmount(info.output.get(), yield),
ApiUtils.copyStackWithAmount(info.outputSmall.get(), yieldNuggets)
ApiUtils.copyStackWithAmount(ore.output.get(), yield),
ApiUtils.copyStackWithAmount(ore.outputSmall.get(), yieldNuggets)
};
} else if (yield > 0) {
return new ItemStack[]{
ApiUtils.copyStackWithAmount(info.output.get(), yield)
ApiUtils.copyStackWithAmount(ore.output.get(), yield)
};
} else if (yieldNuggets > 0 && info.outputSmall != null) {
} else if (yieldNuggets > 0 && ore.outputSmall != null) {
return new ItemStack[]{
ApiUtils.copyStackWithAmount(info.outputSmall.get(), yieldNuggets)
ApiUtils.copyStackWithAmount(ore.outputSmall.get(), yieldNuggets)
};
}
}
@ -132,7 +126,15 @@ public class MarxOreHandler {
return Math.exp(-(x - mu) * (x - mu) / (2 * sigma * sigma));
}
public static List<OreInfo> getRecipes() {
return oreData;
}
public static class OreInfo {
//Input
public BiPredicate<World, BlockPos> isValid;
public List<ItemStack> exampleInput;
//Output
public final double avgEnergy;
public final double maxYield;
public final Supplier<ItemStack> output;
@ -140,37 +142,68 @@ public class MarxOreHandler {
public final Supplier<ItemStack> outputSmall;//1/9 of output
public final int smallMax;
public OreInfo(double avg, double maxYield, Supplier<ItemStack> out, @Nullable Supplier<ItemStack> outSmall, int smallCount) {
public OreInfo(BiPredicate<World, BlockPos> isValid, List<ItemStack> exampleInput, double avg, double maxYield,
Supplier<ItemStack> out, @Nullable Supplier<ItemStack> outSmall, int smallCount) {
avgEnergy = avg;
this.maxYield = maxYield;
output = out;
outputSmall = outSmall;
smallMax = smallCount;
this.isValid = isValid;
this.exampleInput = exampleInput;
}
public OreInfo(double avgEnergy, double maxYield, Item iOut, int mOut, @Nullable Item iOutSmall, int mOutSmall) {
public OreInfo(BiPredicate<World, BlockPos> isValid, List<ItemStack> exampleInput, double avgEnergy, double maxYield,
Item iOut, int mOut, @Nullable Item iOutSmall, int mOutSmall) {
this.avgEnergy = avgEnergy;
this.maxYield = maxYield;
this.output = new IngredientStack(new ItemStack(iOut, 1, mOut))::getExampleStack;
this.outputSmall = iOutSmall == null ? null : new IngredientStack(new ItemStack(iOutSmall, 1, mOutSmall))::getExampleStack;
smallMax = 9;
this.isValid = isValid;
this.exampleInput = exampleInput;
}
public OreInfo(double avgEnergy, double maxYield, Item iOut, int mOut) {
this(avgEnergy, maxYield, iOut, mOut, null, 0);
public OreInfo(BiPredicate<World, BlockPos> isValid, List<ItemStack> exampleInput, double avgEnergy,
double maxYield, Item iOut, int mOut) {
this(isValid, exampleInput, avgEnergy, maxYield, iOut, mOut, null, 0);
}
public OreInfo(double avgEnergy, double maxYield, String oreOut, @Nullable String oreSmall) {
public OreInfo(BiPredicate<World, BlockPos> isValid, List<ItemStack> exampleInput, double avgEnergy, double maxYield,
String oreOut, @Nullable String oreSmall) {
this.avgEnergy = avgEnergy;
this.maxYield = maxYield;
this.output = new IngredientStack(oreOut)::getExampleStack;
this.outputSmall = oreSmall == null ? null : new IngredientStack(oreSmall)::getExampleStack;
smallMax = 9;
this.isValid = isValid;
this.exampleInput = exampleInput;
}
public OreInfo(double avgEnergy, double maxYield, String oreOut) {
this(avgEnergy, maxYield, oreOut, null);
public OreInfo(BiPredicate<World, BlockPos> isValid, List<ItemStack> exampleInput, double avgEnergy, double maxYield,
String oreOut) {
this(isValid, exampleInput, avgEnergy, maxYield, oreOut, null);
}
}
public static class OreChecker implements BiPredicate<World, BlockPos> {
String oreName;
public OreChecker(String ore) {
oreName = ore;
}
@Override
public boolean test(World world, BlockPos here) {
IBlockState state = world.getBlockState(here);
ItemStack input = state.getBlock().getPickBlock(state, null, world, here, null);
int[] ores = OreDictionary.getOreIDs(input);
for (int id : ores) {
String name = OreDictionary.getOreName(id);
if (name.equals(oreName)) {
return true;
}
}
return false;
}
}
}

View file

@ -10,9 +10,27 @@
}
},
"variants": {
"inventory,type=marx": [
{
"model": "industrialwires:marx_stage.obj",
"transform": {
"scale": 0.375,
"rotation": [
{
"x": 20
},
{
"y": 135
}
],
"translation": [
0.15, 0, 0
]
}
}
],
"type": {
"marx": {
}
},
"facing": {
@ -62,7 +80,7 @@
"model": "immersiveengineering:smartmodel/conn_empty"
}
},
"boolean0": //Mirror
"boolean0":
{
"false": {},
"true": {
@ -74,4 +92,4 @@
}
}
}
}
}

View file

@ -48,6 +48,10 @@ industrialwires.subtitle.jacobs_ladder=Jacob's ladder hums
industrialwires.subtitle.marx_bang=Marx generator discharges
industrialwires.subtitle.marx_pop=Marx generator misfires
industrialwires.desc.jei.marx=Marx Generator
industrialwires.desc.jei.alt= (alternative)
industrialwires.desc.jei.max= (max.)
industrialwires.desc.wireLength=Wire length: %1s block(s)
industrialwires.desc.recipe=Please check the Engineer's manual for recipe details
industrialwires.desc.remove_all=Remove all components from this panel
@ -60,7 +64,7 @@ industrialwires.desc.latching_info=Does this button stay on indefinitely?
industrialwires.desc.disassemble=Disassemble the panel
industrialwires.desc.rsid_info=The ID of the redstone wire controller to interact with
industrialwires.desc.rschannel_info=The color of the channel to use
industrialwires.desc.rsid_info2=The ID of the redstone wire controller to interact with for the second signal. Set to -1 to disable it.
industrialwires.desc.rsid_info2=The ID of the redstone wire controller for the second signal. -1 to disable.
industrialwires.desc.rschannel_info2=The color of the channel to use for the second signal
industrialwires.desc.label_text=The text in this label
industrialwires.desc.red=Red