Jump to content

Can't get my NEI addon to display properly


AleXndrTheGr8st

Recommended Posts

I've been working on an NEI addon (long overdue) for my Fusion Furnace, however I can't get it to display properly. The texture is definitely being loaded, as the flames/bubbles work properly. However, the background slots aren't being displayed, giving it an odd appearance. I'm not sure if the slots are being removed because of the items displaying in front of them (even though the items are obviously transparent), or if I have something messed up.

 

Here's a picture of what the Fusion Furnace gui looks like:

 

JVeQPcn.png

 

And here's a picture of what it is showing as in NEI:

 

YR2PVC3.png

 

And here's my FusionRecipeHandler.java:

 

 

package alexndr.plugins.Fusion.nei;

import java.awt.Rectangle;
import java.util.List;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;

import org.lwjgl.opengl.GL11;

import alexndr.plugins.Fusion.FusionFurnaceRecipes;
import alexndr.plugins.Fusion.GuiFusionFurnace;
import alexndr.plugins.Fusion.RecipeEntry;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.API;
import codechicken.nei.recipe.FurnaceRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;

import com.google.common.collect.ImmutableList;

/**
* @author AleXndrTheGr8st
* With help from Zot201
*/
public class FusionRecipeHandler extends TemplateRecipeHandler{

public static final String ID = "fusion";

private static final int X0 = 0;
private static final int Y0 = 15;

private static final int X1 = 5;
private static final int Y1 = 5;

@Override 
public void drawBackground(int i) {
	GL11.glColor4f(1, 1, 1, 1);
}

static {
	API.setGuiOffset(GuiFusionFurnace.class, -x(0), -y(0));
}

protected static int x(int x) {
	return x + X0 - X1;
}
protected static int y(int y) {
	return y + Y0 - Y1;
}

@Override 
public void loadTransferRects() {
	transferRects.add(new RecipeTransferRect(new Rectangle(x(51), y(34), 24, 18), ID));
	transferRects.add(new RecipeTransferRect(new Rectangle(x(100), y(34), 24, 18), ID));
}

@Override 
public void drawExtras(int recipe) {
	drawProgressBar(x(105), y(55), 176, 0, 190 - 176, 14, 48, 7); // Left Flames
	drawProgressBar(x(55), y(55), 176, 0, 190 - 176, 14, 48, 7); // Right Flames
	drawProgressBar(x(51), y(34), 176, 14, 200 - 176, 31 - 14, 48, 0); // Left Arrow
	drawProgressBar(x(100), y(34), 176, 31, 200 - 176, 31 - 14, 48, 2); // Right Arrow
	drawProgressBar(x(64), y(4), 176, 64, 11, 92 - 64, 48, 3); // Left Bubbles
	drawProgressBar(x(98), y(4), 188, 64, 11, 92 - 64, 48, 3); // Right Bubbles
}

protected static PositionedStack convertFuelStack(PositionedStack stack) {
	stack = stack.copy();
	stack.relx = x(79);
	stack.rely = y(62);
	return stack;
}

@Override 
public Class<? extends GuiContainer> getGuiClass() {
	return GuiFusionFurnace.class;
}

@Override 
public String getRecipeName() {
	return "Fusion";
}

@Override 
public String getGuiTexture() {
	return "fusion:textures/gui/fusion_furnace_gui.png";
}

@Override 
public int recipiesPerPage() {
	return 1;
}

@Override 
public String getOverlayIdentifier() {
	return ID;
}

@Override 
public void loadCraftingRecipes(String outputId, Object... results) {
	RecipeEntry entry;
	if (outputId.equals(ID)) {
		for (RecipeEntry e : FusionFurnaceRecipes.getRecipeList())
			if ((entry = e) != null)
				arecipes.add(new CachedFusionRecipe(entry).computeVisuals());
	}
	else
		super.loadCraftingRecipes(outputId, results);
}

@Override 
public void loadCraftingRecipes(ItemStack result) {
	RecipeEntry entry;
	for (RecipeEntry e : FusionFurnaceRecipes.getRecipeList())
		if ((entry = e) != null && FusionFurnaceRecipes.matches(entry.getOutput(), result))
			arecipes.add(new CachedFusionRecipe(entry).computeVisuals());
}

@Override 
public void loadUsageRecipes(ItemStack ingredient) {
	ingredient.stackSize = Integer.MAX_VALUE;
	RecipeEntry entry;
	for(RecipeEntry e : FusionFurnaceRecipes.getRecipeList())
		if ((entry = e) != null && (entry.isItemInput(ingredient) || entry.isItemCatalyst(ingredient)))
			arecipes.add(new CachedFusionRecipe(entry).computeVisuals().setIngredientPermutation(ingredient));
}

public class CachedFusionRecipe extends CachedRecipe {
	private final ImmutableList<PositionedStack> ingredients;
	private final PositionedStack result;

	public CachedFusionRecipe(RecipeEntry entry) {
		ingredients = ImmutableList.of(
				new PositionedStack(entry.input1.itemsList(), x(33), y(35)),
				new PositionedStack(entry.input2.itemsList(), x(126), y(34)),
				new PositionedStack(entry.catalyst.itemsList(), x(79), y(7)));
		result = new PositionedStack(entry.getOutput(), x(79), y(34));
	}

	@Override 
	public List<PositionedStack> getIngredients() {
		return getCycledIngredients(cycleticks / 20, ingredients);
	}

	@Override 
	public PositionedStack getResult() {
		return result;
	}

	@Override 
	public PositionedStack getOtherStack()  {
		return convertFuelStack(FurnaceRecipeHandler.afuels.get((cycleticks / 48) % FurnaceRecipeHandler.afuels.size()).stack);
	}

	public CachedFusionRecipe computeVisuals() {
		for(PositionedStack stack : ingredients)
			stack.generatePermutations();
		result.generatePermutations();
		return this;
	}

	public CachedFusionRecipe setIngredientPermutation(ItemStack ingredient) {
		setIngredientPermutation(ingredients, ingredient);
		return this;
	}
}
}

 

 

 

So if anyone here has created an NEI plugin successfully before, help would be appreciated. This is driving me crazy :(

 

Thanks :)

 

EDIT: And yes, I've tried looking at neiaddons and logisticspipes source, I still can't figure this out. I'm a fairly competent modder, I just hate GUI stuff haha

Link to comment
Share on other sites

  • 2 weeks later...

It looks like it should be working. I compared it to my code and it looks fine.

 

Hmmm, maybe try getting rid/commenting out these:

 

private static final int X0 = 0;
private static final int Y0 = 15;

private static final int X1 = 5;
private static final int Y1 = 5;

@Override 
public void drawBackground(int i) {
	GL11.glColor4f(1, 1, 1, 1);
}

static {
	API.setGuiOffset(GuiFusionFurnace.class, -x(0), -y(0));
}

protected static int x(int x) {
	return x + X0 - X1;
}
protected static int y(int y) {
	return y + Y0 - Y1;
}

 

and see what happens. If anything, I think it *might* be the offset but I don't know. The code seems fine to me.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Link to comment
Share on other sites

Yeah, the problem was overriding the setBackground method, as the old way of setting the background is gone now (I was basing mine off old code). So I can get it to display the textures now, except I can't get the offset to work, as the image displays too high up and cuts parts of the texture. For some reason, setGuiOffset isn't working.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ. Dumping it directly into the thread often triggers the anti-spam and makes it hard to read due to word wrapping
    • Hi all, I'm running a 1.20.1 Minecraft Forge server with a hosting website and something seems to have gone wrong. It started as an occasional crash that has now become extremely frequent and I don't know what exactly is causing it. I already tried disabling watchdog but the server crashes anyway. Oddly it only occasionally generates a crash report after a crash occurs. Based on viewing the server console's research usage it seems that the CPU spikes astronomically high (100% usage), especially when chunks are being loaded or when a new person joins the server. I downloaded Spark to create a profile (https://spark.lucko.me/bBlWe7ou29) but I lack experience with this mod and don't understand what I'm looking at/how this should help me diagnose the issue. I am using a lot of mods so I'm guessing there is some sort of issue there or a corrupted chunk (although MCRF found no chunk errors). We actually don't experience any lag until the crash occurs, so it's some sort of sudden spike in resource usage. Based on the crash report I've already tried removing Canary and Modernfix but there was no change. Thanks for any help you can provide. Specs:  4 cores x 4200MHz AMD Ryzen 9 5950X 4GB RAM Crash report:  
    • will test that once i get home, thanks
    • I am getting this exception (I am new and just trying to create an item) Caused by: java.io.FileNotFoundException: abrasmagics:models/item/ingot_test.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]   However the directory is set up correctly and the file does exist   idk how to upload images so here is a treeview of the directories:   src ├───main │ ├───java │ │ └───net │ │ └───abrasmods │ │ └───abrasmagics │ │ ├───init │ │ ├───items │ │ └───utils │ │ ├───handlers │ │ ├───misc │ │ └───proxy │ └───resources │ └───assets │ └───abrasmagics │ ├───models │ │ ├───block │ │ └───item │ └───textures └───test ├───java └───resources   the file ingot_test.json is under models/item. The directory seems fine and the file does exist so anyone plz help.   i am using intellij and is coding for 1.12.2
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.