mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 01:14:21 +00:00
Add NEI support for ExtraTrees
This commit is contained in:
1 parent
4aaa092db9
commit
4ffe81967d
6 files changed
+203
-1
No files matched your search
@@ -18,6 +18,7 @@ import binnie.extratrees.core.ModuleCore;
|
||||
import binnie.extratrees.genetics.ModuleGenetics;
|
||||
import binnie.extratrees.item.ModuleItems;
|
||||
import binnie.extratrees.machines.ModuleMachine;
|
||||
import binnie.extratrees.nei.IMCForNEI;
|
||||
import binnie.extratrees.proxy.Proxy;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
@@ -82,6 +83,7 @@ public class ExtraTrees extends AbstractMod {
|
||||
addModule(new ModuleCarpentry());
|
||||
addModule(new ModuleMachine());
|
||||
addModule(new ModuleCore());
|
||||
IMCForNEI.IMCSender();
|
||||
preInit();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Lumbermill {
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static void calculateLumbermillProducts() {
|
||||
public static void calculateLumbermillProducts() {
|
||||
for (IPlankType type : WoodManager.getAllPlankTypes()) {
|
||||
for (ItemStack wood : getRecipeResult(type.getStack())) {
|
||||
Lumbermill.recipes.put(wood, type.getStack());
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package binnie.extratrees.nei;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class IMCForNEI {
|
||||
public static void IMCSender() {
|
||||
sendHandler("binnie.extratrees.nei.NEIHandlerLumbermill", "ExtraTrees:machine:0");
|
||||
|
||||
sendCatalyst("extratrees.lumbermill", "ExtraTrees:machine:0");
|
||||
}
|
||||
|
||||
private static void sendHandler(String aName, String aBlock) {
|
||||
NBTTagCompound aNBT = new NBTTagCompound();
|
||||
aNBT.setString("handler", aName);
|
||||
aNBT.setString("modName", "Extra Trees");
|
||||
aNBT.setString("modId", "ExtraTrees");
|
||||
aNBT.setBoolean("modRequired", true);
|
||||
aNBT.setString("itemName", aBlock);
|
||||
aNBT.setInteger("handlerHeight", 76);
|
||||
aNBT.setInteger("handlerWidth", 166);
|
||||
aNBT.setInteger("maxRecipesPerPage", 4);
|
||||
aNBT.setInteger("yShift", 6);
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT);
|
||||
}
|
||||
|
||||
private static void sendCatalyst(String aName, String aStack, int aPriority) {
|
||||
NBTTagCompound aNBT = new NBTTagCompound();
|
||||
aNBT.setString("handlerID", aName);
|
||||
aNBT.setString("itemName", aStack);
|
||||
aNBT.setInteger("priority", aPriority);
|
||||
FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT);
|
||||
}
|
||||
|
||||
private static void sendCatalyst(String aName, String aStack) {
|
||||
sendCatalyst(aName, aStack, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package binnie.extratrees.nei;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
|
||||
public class NEIExtraTreesConfig implements IConfigureNEI {
|
||||
protected static void registerHandler(RecipeHandlerBase handler) {
|
||||
handler.prepare();
|
||||
API.registerRecipeHandler(handler);
|
||||
API.registerUsageHandler(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfig() {
|
||||
registerHandler(new NEIHandlerLumbermill());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Extra Trees NEI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return BinnieCore.VERSION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package binnie.extratrees.nei;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.nei.NEIUtils;
|
||||
import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import binnie.extratrees.machines.lumbermill.Lumbermill;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NEIHandlerLumbermill extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
if (Lumbermill.recipes.isEmpty()) Lumbermill.calculateLumbermillProducts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverlayIdentifier() {
|
||||
return "extratrees.lumbermill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "extratrees:textures/gui/nei/lumbermill.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("extratrees.machine.machine.lumbermill");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.addTransferRect(75, 27, 24, 17);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int recipe) {
|
||||
changeToGuiTexture();
|
||||
GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 74);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 27, 176, 0, 24, 17, 40, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAllRecipes() {
|
||||
Lumbermill.recipes.forEach((wood, plank) -> this.arecipes.add(new CachedLumbermillRecipe(wood, Lumbermill.getPlankProduct(wood))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCraftingRecipes(ItemStack result) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(ExtraTreeItems.Sawdust.get(1), result) || (NEIServerUtils.areStacksSameTypeCrafting(ExtraTreeItems.Bark.get(1), result))) {
|
||||
this.loadAllRecipes();
|
||||
} else {
|
||||
for (Map.Entry<ItemStack, ItemStack> entry : Lumbermill.recipes.entrySet()) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(entry.getValue(), result)) {
|
||||
this.arecipes.add(new CachedLumbermillRecipe(entry.getKey(), Lumbermill.getPlankProduct(entry.getKey())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(FluidStack ingredient) {
|
||||
if (NEIUtils.areFluidsSameType(Binnie.Liquid.getLiquidStack("water", 0), ingredient)) {
|
||||
this.loadAllRecipes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUsageRecipes(ItemStack ingredient) {
|
||||
for (Map.Entry<ItemStack, ItemStack> entry : Lumbermill.recipes.entrySet()) {
|
||||
if (NEIServerUtils.areStacksSameTypeCrafting(entry.getKey(), ingredient)) {
|
||||
this.arecipes.add(new CachedLumbermillRecipe(entry.getKey(), Lumbermill.getPlankProduct(entry.getKey())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class CachedLumbermillRecipe extends CachedBaseRecipe {
|
||||
|
||||
public PositionedFluidTank waterTank = new PositionedFluidTank(Binnie.Liquid.getLiquidStack("water", 300), 1000, new Rectangle(28, 6, 16, 58));
|
||||
public PositionedStack bark = new PositionedStack(ExtraTreeItems.Sawdust.get(1), 123, 6);
|
||||
public PositionedStack sawDust = new PositionedStack(ExtraTreeItems.Bark.get(1), 123, 48);
|
||||
public PositionedStack wood;
|
||||
public PositionedStack plank;
|
||||
public List<PositionedStack> results = new ArrayList<>();
|
||||
|
||||
|
||||
public CachedLumbermillRecipe(ItemStack wood, ItemStack plank) {
|
||||
this.plank = new PositionedStack(plank, 105, 27);
|
||||
this.wood = new PositionedStack(wood, 53, 27);
|
||||
|
||||
this.results.add(this.plank);
|
||||
this.results.add(this.bark);
|
||||
this.results.add(this.sawDust);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedFluidTank getFluidTank() {
|
||||
return this.waterTank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getIngredient() {
|
||||
return this.wood;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getOtherStacks() {
|
||||
return this.results;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionedStack getResult() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user