Compare commits

..
Author SHA1 Message Date
Jason Mitchell af50881c6e Bugfixes 2021-03-23 23:34:05 -07:00
Jason Mitchell c971199bd1 Fix IOOBE. 2021-03-23 21:59:40 -07:00
Jason Mitchell 146e882229 Angry Boubs 2021-03-22 21:20:48 -07:00
Jason Mitchell baa0a8962b Add option to switch between JEI tab style and Creative tab style 2021-03-22 20:22:00 -07:00
Léa Gris 400f38d919 impr(tab): user creative inventory tab asset and layout
This allow proprely textured GUI without the need to update a resourcepack.
2021-03-22 19:02:42 -07:00
Jason Mitchell 07ec5f67c5 DrawableResource from JEI. Swap out tab & tab icon drawing. 2021-03-21 21:43:37 -07:00
Léa Gris 79b5da1d1a refactor: override draw with correct signature 2021-03-21 19:39:12 -07:00
Jason Mitchell aa13ba7781 Fix crash on bookmark toggle
Fixes #53
2021-03-21 09:32:03 -07:00
16 changed files with 391 additions and 120 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@ mc_version=1.7.10
forge_version=10.13.4.1614-1.7.10
ccl_version=1.1.3.138
ccc_version=1.0.7.+
mod_version=2.1.0-GTNH-beta
mod_version=2.1.0-GTNH-beta2
+3
View File
@@ -114,6 +114,9 @@ nei.options.inventory.bookmarksEnabled.false=Hidden
nei.options.inventory.jei_style_tabs=JEI Style Tabs
nei.options.inventory.jei_style_tabs.true=Yes
nei.options.inventory.jei_style_tabs.false=No [Weirdo]
nei.options.inventory.creative_tab_style=Creative or JEI tab style
nei.options.inventory.creative_tab_style.true=Creative
nei.options.inventory.creative_tab_style.false=JEI
nei.options.inventory.widgetsenabled.true=NEI Enabled
nei.options.inventory.widgetsenabled.false=NEI Disabled
nei.options.inventory.cheatmode.0=Recipe Mode
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+2
View File
@@ -6,6 +6,7 @@ public abstract class ButtonCycled extends Button
public ButtonCycled(int num) {
icons = new Image[num];
init();
}
@Override
public Image getRenderIcon()
@@ -13,6 +14,7 @@ public abstract class ButtonCycled extends Button
return icons[index];
}
public void init() {}
public int index;
public Image[] icons;
}
+26 -4
View File
@@ -8,6 +8,8 @@ import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.api.LayoutStyle;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerDrawHandler;
import codechicken.nei.guihook.IContainerInputHandler;
@@ -258,7 +260,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
@Override
public void postRenderObjects(GuiContainer gui, int mousex, int mousey) {
if (!isHidden() && isEnabled()) {
@@ -335,6 +337,13 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
options = new ButtonCycled(3)
{
@Override
public void init() {
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 32, 0, 16, 16).build();
this.icons[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 48, 0, 16, 16).build();
this.icons[2] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 64, 0, 16, 16).build();
}
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
@@ -371,9 +380,15 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
bookmarksButton = new ButtonCycled(2)
{
@Override
public void init() {
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 0, 16, 16).build();
this.icons[1] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 16, 0, 16, 16).build();
}
@Override
public boolean onButtonPress(boolean rightclick) {
NEIClientConfig.toggleBooleanSetting("bookmarksEnabled");
NEIClientConfig.toggleBooleanSetting("inventory.bookmarksEnabled");
return true;
}
@@ -768,11 +783,18 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
}
public static void drawIcon(int x, int y, Image image) {
changeTexture("nei:textures/nei_sprites.png");
final boolean isDrawableResource = image instanceof DrawableResource;
if (!isDrawableResource)
changeTexture("nei:textures/nei_sprites.png");
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
if(!isDrawableResource)
drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
else
((DrawableResource)image).draw(x, y);
GL11.glDisable(GL11.GL_BLEND);
}
@@ -49,11 +49,6 @@ public class LayoutStyleMinecraft extends LayoutStyle
timeButtons[2].icon = new Image(144, 24, 12, 12);
timeButtons[3].icon = new Image(156, 24, 12, 12);
heal.icon = new Image(168, 24, 12, 12);
bookmarksButton.icons[0] = new Image(0, 36, 16, 16);
bookmarksButton.icons[1] = new Image(16, 36, 16, 16);
options.icons[0] = new Image(32, 36, 16, 16);
options.icons[1] = new Image(48, 36, 16, 16);
options.icons[2] = new Image(64, 36, 16, 16);
}
@Override
@@ -189,6 +184,7 @@ public class LayoutStyleMinecraft extends LayoutStyle
final int iconX = b.x + (b.w - icon.width) / 2;
final int iconY = b.y + (b.h - icon.height) / 2;
LayoutManager.drawIcon(iconX, iconY, icon);
}
}
+7 -1
View File
@@ -78,7 +78,7 @@ public class NEIClientConfig
tag.getTag("inventory.widgetsenabled").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.widgetsenabled"));
tag.getTag("inventory.hidden").getBooleanValue(false);
tag.getTag("inventory.cheatmode").getIntValue(2);
tag.getTag("inventory.lockmode").setComment("For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame").getIntValue(-1);
@@ -130,6 +130,9 @@ public class NEIClientConfig
tag.getTag("inventory.jei_style_tabs").setComment("Enable/disable JEI Style Tabs").getBooleanValue(true);
API.addOption(new OptionToggleButtonBoubs("inventory.jei_style_tabs", true));
tag.getTag("inventory.creative_tab_style").setComment("Creative or JEI style tabs").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.creative_tab_style", true));
setDefaultKeyBindings();
}
@@ -294,6 +297,9 @@ public class NEIClientConfig
public static boolean areJEIStyleTabsVisible() {
return getBooleanSetting("inventory.jei_style_tabs");
}
public static boolean useCreativeTabStyle() {
return getBooleanSetting("inventory.creative_tab_style");
}
public static boolean isEnabled() {
return enabledOverride && getBooleanSetting("inventory.widgetsenabled");
}
@@ -1,18 +1,17 @@
package codechicken.nei.config;
import codechicken.lib.render.CCRenderState;
import codechicken.nei.Image;
import codechicken.nei.LayoutManager;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import org.lwjgl.opengl.GL11;
import java.awt.Rectangle;
import static codechicken.lib.gui.GuiDraw.changeTexture;
import static codechicken.lib.gui.GuiDraw.drawStringC;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
public class OptionToggleButtonBoubs extends OptionButton {
private static final DrawableResource coolBoubs = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 48, 16, 22, 22).build();
private static final DrawableResource angryBoubs = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 70, 16, 22, 22).build();
public class OptionToggleButtonBoubs extends OptionButton
{
public final boolean prefixed;
public OptionToggleButtonBoubs(String name, boolean prefixed) {
@@ -32,19 +31,8 @@ public class OptionToggleButtonBoubs extends OptionButton
public void drawButton(int mx, int my) {
Rectangle b = buttonSize();
LayoutManager.drawButtonBackground(b.x, b.y, b.width, b.height, true, getButtonTex(mx, my));
if(state()) {
changeTexture("nei:textures/nei_sprites.png");
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Image image = new Image(48, 52, 24, 24);
// drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
drawTexturedModalRect(b.x + (b.width/2) - (image.width/2), b.y, image.x, image.y, image.width, image.height);
GL11.glDisable(GL11.GL_BLEND);
}else {
drawStringC(getButtonText(), b.x, b.y, b.width, b.height, getTextColour(mx, my));
}
final Image image = state() ? coolBoubs : angryBoubs;
LayoutManager.drawIcon(b.x + (b.width/2) - (coolBoubs.getWidth()/2), b.y, image);
}
public String getButtonText() {
@@ -0,0 +1,52 @@
package codechicken.nei.drawable;
import net.minecraft.util.ResourceLocation;
public class DrawableBuilder {
private final ResourceLocation resourceLocation;
private int u;
private int v;
private int width;
private int height;
private int textureWidth = 256;
private int textureHeight = 256;
private int paddingTop = 0;
private int paddingBottom = 0;
private int paddingLeft = 0;
private int paddingRight = 0;
public DrawableBuilder(String resourceLocation, int u, int v, int width, int height) {
this.u = u;
this.v = v;
this.width = width;
this.height = height;
this.resourceLocation = new ResourceLocation(resourceLocation);
}
public DrawableBuilder setTextureSize(int width, int height) {
this.textureWidth = width;
this.textureHeight = height;
return this;
}
public DrawableBuilder addPadding(int paddingTop, int paddingBottom, int paddingLeft, int paddingRight) {
this.paddingTop = paddingTop;
this.paddingBottom = paddingBottom;
this.paddingLeft = paddingLeft;
this.paddingRight = paddingRight;
return this;
}
public DrawableBuilder trim(int trimTop, int trimBottom, int trimLeft, int trimRight) {
this.u += trimLeft;
this.v += trimTop;
this.width -= trimLeft + trimRight;
this.height -= trimTop + trimBottom;
return this;
}
public DrawableResource build() {
return new DrawableResource(resourceLocation, u, v, width, height, paddingTop, paddingBottom, paddingLeft, paddingRight, textureWidth, textureHeight);
}
}
@@ -0,0 +1,56 @@
package codechicken.nei.drawable;
import codechicken.nei.Image;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
public class DrawableResource extends Image {
private final ResourceLocation resourceLocation;
private final int textureWidth;
private final int textureHeight;
private final int paddingTop;
private final int paddingBottom;
private final int paddingLeft;
private final int paddingRight;
public DrawableResource(ResourceLocation resourceLocation, int u, int v, int width, int height, int paddingTop, int paddingBottom, int paddingLeft, int paddingRight, int textureWidth, int textureHeight) {
super(u, v, width, height);
this.resourceLocation = resourceLocation;
this.textureWidth = textureWidth;
this.textureHeight = textureHeight;
this.paddingTop = paddingTop;
this.paddingBottom = paddingBottom;
this.paddingLeft = paddingLeft;
this.paddingRight = paddingRight;
}
public int getWidth() {
return width + paddingLeft + paddingRight;
}
public int getHeight() {
return height + paddingTop + paddingBottom;
}
public void draw(int xOffset, int yOffset) {
draw(xOffset, yOffset, 0, 0, 0, 0);
}
public void draw(int xOffset, int yOffset, int maskTop, int maskBottom, int maskLeft, int maskRight) {
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
int x = xOffset + this.paddingLeft + maskLeft;
int y = yOffset + this.paddingTop + maskTop;
int u = this.x + maskLeft;
int v = this.y + maskTop;
int width = this.width - maskRight - maskLeft;
int height = this.height - maskBottom - maskTop;
// drawModalRectWithCustomSizedTexture
Gui.func_146110_a(x, y, u, v, width, height, textureWidth, textureHeight);
}
}
@@ -102,6 +102,8 @@ public class DefaultOverlayHandler implements IOverlayHandler
{
for(IngredientDistribution distrib : assignedIngredients)
{
if(distrib.slots.length == 0) continue;
ItemStack pstack = distrib.permutation;
int transferCap = quantity*pstack.stackSize;
int transferred = 0;
+8 -6
View File
@@ -196,17 +196,19 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
}
private void nextType() {
recipetype++;
if (recipetype >= currenthandlers.size())
recipetype = 0;
page = 0;
recipeTabs.calcPageNumber();
setRecipePage(++recipetype);
}
private void prevType() {
recipetype--;
setRecipePage(--recipetype);
}
public void setRecipePage(int idx) {
recipetype = idx;
if (recipetype < 0)
recipetype = currenthandlers.size() - 1;
else if (recipetype >= currenthandlers.size())
recipetype = 0;
page = 0;
recipeTabs.calcPageNumber();
}
+87 -61
View File
@@ -2,9 +2,9 @@ package codechicken.nei.recipe;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.Button;
import codechicken.nei.Image;
import codechicken.nei.LayoutManager;
import codechicken.nei.Widget;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -18,29 +18,37 @@ import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.List;
public class GuiRecipeTab extends Button {
public static HashMap<String, ImmutablePair<String, Image>> iconMap = new HashMap<>();
public abstract class GuiRecipeTab extends Widget {
public static HashMap<String, ImmutablePair<String, DrawableResource>> imageMap = new HashMap<>();
public static HashMap<String, ImmutablePair<String, ItemStack>> stackMap = new HashMap<>();
public static final int TAB_WIDTH = 24;
public static final int TAB_HEIGHT = 24;
private static final Image selectedIcon = new Image(0, 52, 24, 24);
private static final Image unselectedIcon = new Image(24, 52, 24, 24);
private final GuiRecipe guiRecipe;
private final IRecipeHandler handler;
private final String handlerName;
private final String handlerID;
private boolean selected;
public abstract int getWidth();
public abstract int getHeight();
public abstract DrawableResource getSelectedTabImage();
public abstract DrawableResource getUnselectedTabImage();
protected abstract int getForegroundIconX();
protected abstract int getForegroundIconY();
public GuiRecipeTab(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) {
super();
this.x = x;
this.y = y;
this.w = TAB_WIDTH;
this.h = TAB_HEIGHT;
this.w = getWidth();
this.h = getHeight();
this.handler = handler;
this.handlerName = handler.toString().split("@")[0];
this.guiRecipe = guiRecipe;
this.selected = false;
if(handler instanceof TemplateRecipeHandler) {
handlerID = (((TemplateRecipeHandler)handler).getOverlayIdentifier());
@@ -48,37 +56,37 @@ public class GuiRecipeTab extends Button {
handlerID = null;
}
}
public void draw(boolean selected, int mouseX, int mouseY) {
drawTab(selected, mouseX, mouseY);
drawTabIcon(selected, mouseX, mouseY);
@Override
public void draw(int mouseX, int mouseY) {
drawBackground(mouseX, mouseY);
drawForeground(mouseX, mouseY);
}
public void drawTab(boolean selected, int mouseX, int mouseY) {
public void drawBackground(int mouseX, int mouseY) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor4f(1, 1, 1, 1);
if (selected) icon = selectedIcon;
else icon = unselectedIcon;
final int iconX = x + (w - icon.width) / 2;
final int iconY = y + (h - icon.height) / 2;
LayoutManager.drawIcon(iconX, iconY, icon);
final DrawableResource image;
if (selected) image = getSelectedTabImage();
else image = getUnselectedTabImage();
final int iconX = x + (w - image.getWidth()) / 2;
final int iconY = y + (h - image.getHeight()) / 2;
image.draw(iconX, iconY);
}
public void drawTabIcon(boolean selected, int mouseX, int mouseY) {
final int iconX = x + 4;
final int iconY = y + 4;
public void drawForeground(int mouseX, int mouseY) {
final int iconX = getForegroundIconX();
final int iconY = getForegroundIconY();
final FontRenderer fontRenderer = GuiDraw.fontRenderer;
final Image icon = getIcon(handlerName);
final DrawableResource icon = getImage(handlerName);
final ItemStack itemStack = getItemStack(handlerName, handlerID);
if (icon != null) {
LayoutManager.drawIcon(iconX + 1, iconY + 1, icon);
icon.draw(iconX + 1, iconY + 1);
} else if (itemStack != null) {
GuiContainerManager.drawItems.zLevel += 100;
GuiContainerManager.drawItem(iconX, iconY, itemStack);
@@ -86,15 +94,14 @@ public class GuiRecipeTab extends Button {
} else {
// Text fallback
String text = handler.getRecipeName().substring(0, 2);
int textCenterX = x + (int) (TAB_WIDTH / 2f);
int textCenterY = y + (int) (TAB_HEIGHT / 2f) - 3;
int color = selected ? 16777120 : 14737632;
int textCenterX = x + (int) (getWidth() / 2f);
int textCenterY = y + (int) (getHeight() / 2f) - 3;
int color = selected ? 0xffffa0 : 0xe0e0e0;
fontRenderer.drawStringWithShadow(text, textCenterX - (int) (fontRenderer.getStringWidth(text) / 2f), textCenterY, color);
GL11.glColor4f(1, 1, 1, 1);
}
}
@Override
public void addTooltips(List<String> tooltip) {
tooltip.add(handler.getRecipeName().trim());
@@ -109,18 +116,17 @@ public class GuiRecipeTab extends Button {
}
@Override
public boolean onButtonPress(boolean rightclick) {
int newIdx = guiRecipe.currenthandlers.indexOf(handler);
if (newIdx == -1)
return false;
guiRecipe.recipetype = newIdx;
guiRecipe.setRecipePage(newIdx);
return true;
}
public boolean isSelected(IRecipeHandler current) {
return handler == current;
public void setSelected(IRecipeHandler current) {
selected = handler == current;
}
public static Pair<String, ItemStack> lookupStackMap(String name, String name2) {
@@ -136,7 +142,7 @@ public class GuiRecipeTab extends Button {
if (stackRes != null)
return stackRes.getLeft();
Pair<String, Image> iconRes = iconMap.get(name);
Pair<String, DrawableResource> iconRes = imageMap.get(name);
if (iconRes != null)
return iconRes.getLeft();
@@ -150,8 +156,8 @@ public class GuiRecipeTab extends Button {
return null;
}
public static Image getIcon(String id) {
Pair<String, Image> res = iconMap.get(id);
public static DrawableResource getImage(String id) {
Pair<String, DrawableResource> res = imageMap.get(id);
if (res != null)
return res.getRight();
return null;
@@ -165,8 +171,9 @@ public class GuiRecipeTab extends Button {
addToStackMap("codechicken.nei.recipe.FurnaceRecipeHandler", "minecraft", "minecraft:furnace");
addToStackMap("codechicken.nei.recipe.ShapedRecipeHandler", "minecraft", "minecraft:crafting_table");
addToStackMap("codechicken.nei.recipe.ShapelessRecipeHandler", "minecraft", "minecraft:crafting_table");
addToIconMap("codechicken.nei.recipe.FuelRecipeHandler", "minecraft", new Image(80, 36, 14, 14));
addToIconMap("codechicken.nei.recipe.FuelRecipeHandler", "minecraft",
new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 80, 0, 14, 14).build());
// IC2
if (Loader.isModLoaded("IC2")) {
addToStackMap("ic2.neiIntegration.core.recipehandler.AdvRecipeHandler", "IC2", "IC2:blockreactorvessel");
@@ -186,6 +193,10 @@ public class GuiRecipeTab extends Button {
addToStackMap("ic2.neiIntegration.core.recipehandler.ScrapboxRecipeHandler", "IC2", "IC2:itemScrapbox");
addToStackMap("ic2.neiIntegration.core.recipehandler.SolidCannerRecipeHandler", "IC2", "IC2:blockMachine2:9");
}
if (Loader.isModLoaded("Ic2Nei")) {
addToStackMap("speiger.src.crops.prediction.NEIPlugin", "IC2CropsNEI", "IC2:blockCrop");
}
// Gregtech 5u
if (!Loader.isModLoaded("gregapi_post") && Loader.isModLoaded("gregtech")) {
@@ -261,32 +272,46 @@ public class GuiRecipeTab extends Button {
addToStackMap("gt.recipe.vacuumfreezer", "gregtech", "gregtech:gt.blockmachines:1002"); // gt.blockmachines.multimachine.vacuumfreezer
addToStackMap("gt.recipe.wiremill", "gregtech", "gregtech:gt.blockmachines:351"); // gt.blockmachines.basicmachine.wiremill.tier.01
addToStackMap("ic.recipe.recycler", "gregtech", "gregtech:gt.blockmachines:331"); // gt.blockmachines.basicmachine.recycler.tier.01
// // Maybe acid generator
// //tabItemIcon.put("null", stackDB("gt.blockmachines.acidgeneratormv"));
//
// // Maybe not release
// tabItemIcon.put("gt.recipe.largenaquadahreactor", stackDB("gt.blockmachines.1nr.controller.single"));
// tabItemIcon.put("gt.recipe.fluidnaquadahreactor", stackDB("gt.blockmachines.1nr.controller.single"));
// tabItemIcon.put("gt.recipe.hugenaquadahreactor", stackDB("gt.blockmachines.1nr.controller.single"));
// tabItemIcon.put("gt.recipe.extrahugenaquadahreactor", stackDB("gt.blockmachines.1nr.controller.single"));
addToStackMap("gt.recipe.byproductlist", "gregtech", "");
addToStackMap("gt.recipe.cncmachine", "gregtech", "");
addToStackMap("gt.recipe.uuamplifier", "gregtech", "");
addToStackMap("gt.recipe.extremedieselgeneratorfuel", "gregtech", "gregtech:gt.blockmachines:1171");
addToStackMap("gt.recipe.largenaquadahreactor", "gregtech", "gregtech:gt.blockmachines:97");
addToStackMap("gt.recipe.fluidnaquadahreactor", "gregtech", "gregtech:gt.blockmachines:97");
addToStackMap("gt.recipe.hugenaquadahreactor", "gregtech", "gregtech:gt.blockmachines:97");
addToStackMap("gt.recipe.extrahugenaquadahreactor", "gregtech", "gregtech:gt.blockmachines:97");
addToStackMap("gt.recipe.rocketenginefuel", "gregtech", "GalaxySpace:item.Tier8Rocket");
addToStackMap("gt.recipe.RTGgenerators", "gregtech", "IC2:itemRTGPellet");
addToStackMap("gt.recipe.componentassembler", "gregtech", "gregtech:gt.blockmachines:211");
addToStackMap("bw.fuels.acidgens", "gregtech", "gregtech:gt.blockmachines:12726");
addToStackMap("bw.recipe.cal", "gregtech", "gregtech:gt.blockmachines:12735");
}
if (Loader.isModLoaded("appliedenergistics2")) {
addToStackMap("appeng.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler", "AppliedEnergistics2","appliedenergistics2:item.ItemMultiPart:380");
addToStackMap("appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler","AppliedEnergistics2", "appliedenergistics2:item.ItemMultiPart:380");
addToStackMap("appeng.integration.modules.NEIHelpers.NEIFacadeRecipeHandler", "AppliedEnergistics2", "appliedenergistics2:item.ItemFacade:192");
addToStackMap("appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler", "AppliedEnergistics2","appliedenergistics2:item.ItemMultiMaterial:8");
addToStackMap("appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler", "AppliedEnergistics2", "appliedenergistics2:tile.BlockInscriber");
addToStackMap("appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler", "AppliedEnergistics2", "appliedenergistics2:item.ItemMultiMaterial:9");
}
if (Loader.isModLoaded("OpenComputers")) {
addToStackMap("li.cil.oc.integration.nei.ManualUsageHandler", "OpenComputers", "OpenComputers:item:98");
addToStackMap("li.cil.oc.integration.nei.CallbackDocHandler", "OpenComputers", "");
}
if (Loader.isModLoaded("AdvancedSolarPanel")) {
addToStackMap("advsolar.client.nei.MTRecipeHandler", "AdvancedSolarPanel", "AdvancedSolarPanel:BlockMolecularTransformer");
}
if (Loader.isModLoaded("AromaBackup")) {
addToStackMap("aroma1997.core.recipes.nei.ShapedAromicRecipeHandler", "AromaBackup", "minecraft:crafting_table");
addToStackMap("aroma1997.core.recipes.nei.ShapelessAromicRecipeHandler", "AromaBackup", "minecraft:crafting_table");
}
if (Loader.isModLoaded("WitcheryExtras")) {
addToStackMap("alkalus.main.nei.NEI_Handler_Cauldron", "witchery", "witchery:cauldron");
addToStackMap("alkalus.main.nei.NEI_Handler_Distillery", "witchery", "witchery:distilleryidle");
@@ -304,6 +329,7 @@ public class GuiRecipeTab extends Button {
}
if (Loader.isModLoaded("Thaumcraft")) {
addToStackMap("com.djgiannuzz.thaumcraftneiplugin.nei.recipehandler.ArcaneShapedRecipeHandler", "Thaumcraft", "Thaumcraft:blockTable:15");
addToStackMap("com.djgiannuzz.thaumcraftneiplugin.nei.recipehandler.ArcaneShapelessRecipeHandler", "Thaumcraft", "Thaumcraft:blockTable:15");
addToStackMap("com.djgiannuzz.thaumcraftneiplugin.nei.recipehandler.CrucibleRecipeHandler", "Thaumcraft", "Thaumcraft:blockMetalDevice");
addToStackMap("com.djgiannuzz.thaumcraftneiplugin.nei.recipehandler.InfusionRecipeHandler", "Thaumcraft", "Thaumcraft:blockStoneDevice:2");
@@ -469,7 +495,7 @@ public class GuiRecipeTab extends Button {
addToStackMap("tconstruct.plugins.nei.RecipeHandlerCastingTable", "Tinker's Construct", "TConstruct:SearedBlock");
addToStackMap("tconstruct.plugins.nei.RecipeHandlerDryingRack", "Tinker's Construct", "TConstruct:Armor.DryingRack");
addToStackMap("tconstruct.plugins.nei.RecipeHandlerMelting", "Tinker's Construct", "TConstruct:LavaTank:2");
addToStackMap("tconstruct.plugins.nei.RecipeHandlerToolMaterials", "Tinker's Construct", "TConstruct:pickaxe");
addToStackMap("tconstruct.plugins.nei.RecipeHandlerToolMaterials", "Tinker's Construct", "TConstruct:ToolStationBlock");
}
if (Loader.isModLoaded("chisel")) {
addToStackMap("team.chisel.compat.nei.RecipeHandlerChisel", "Chisel", "chisel:chisel");
@@ -487,7 +513,7 @@ public class GuiRecipeTab extends Button {
addToStackMap("tonius.neiintegration.mods.mcforge.RecipeHandlerOreDictionary", "Minecraft", "minecraft:iron_ore");
}
if (Loader.isModLoaded("GalacticraftCoRailcraftre")) {
if (Loader.isModLoaded("Railcraft")) {
addToStackMap("tonius.neiintegration.mods.railcraft.RecipeHandlerBlastFurnace", "Railcraft", "Railcraft:machine.alpha:12");
addToStackMap("tonius.neiintegration.mods.railcraft.RecipeHandlerCokeOven", "Railcraft", "Railcraft:machine.alpha:7");
addToStackMap("tonius.neiintegration.mods.railcraft.RecipeHandlerRockCrusher", "Railcraft", "Railcraft:machine.alpha:15");
@@ -557,7 +583,7 @@ public class GuiRecipeTab extends Button {
else
System.out.println("Couldn't find " + modname + " - " + item_id);
}
private static void addToIconMap(String handler, String modid, Image image) {
iconMap.put(handler, new ImmutablePair<>(modid, image));
private static void addToIconMap(String handler, String modname, DrawableResource image) {
imageMap.put(handler, new ImmutablePair<>(modname, image));
}
}
@@ -0,0 +1,47 @@
package codechicken.nei.recipe;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
public class GuiRecipeTabCreative extends GuiRecipeTab {
public static final int TAB_WIDTH = 28;
public static final int TAB_HEIGHT = 31;
private static final DrawableResource selectedTabImage = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 32, 28, 32).build();
private static final DrawableResource unselectedTabImage = new DrawableBuilder("minecraft:textures/gui/container/creative_inventory/tabs.png", 28, 0, 28, 30).build();
public GuiRecipeTabCreative(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) {
super(guiRecipe, handler, x, y);
}
@Override
public int getWidth() {
return TAB_WIDTH;
}
@Override
public int getHeight() {
return TAB_HEIGHT;
}
@Override
protected int getForegroundIconX() {
return x + (w - 16) / 2;
}
@Override
protected int getForegroundIconY() {
return y + h - 22;
}
@Override
public DrawableResource getSelectedTabImage() {
return selectedTabImage;
}
@Override
public DrawableResource getUnselectedTabImage() {
return unselectedTabImage;
}
}
@@ -0,0 +1,47 @@
package codechicken.nei.recipe;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
public class GuiRecipeTabJEI extends GuiRecipeTab {
public static final int TAB_WIDTH = 24;
public static final int TAB_HEIGHT = 24;
private static final DrawableResource selectedTabImage = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 16, 24, 24).build();
private static final DrawableResource unselectedTabImage = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 24, 16, 24, 24).build();
public GuiRecipeTabJEI(GuiRecipe guiRecipe, IRecipeHandler handler, int x, int y) {
super(guiRecipe, handler, x, y);
}
@Override
public int getWidth() {
return TAB_WIDTH;
}
@Override
public int getHeight() {
return TAB_HEIGHT;
}
@Override
protected int getForegroundIconX() {
return x + 4;
}
@Override
protected int getForegroundIconY() {
return y + 4;
}
@Override
public DrawableResource getSelectedTabImage() {
return selectedTabImage;
}
@Override
public DrawableResource getUnselectedTabImage() {
return unselectedTabImage;
}
}
+45 -23
View File
@@ -2,8 +2,9 @@ package codechicken.nei.recipe;
import codechicken.nei.Button;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import java.awt.Rectangle;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -13,23 +14,37 @@ public class GuiRecipeTabs {
private final List<Button> buttons = new ArrayList<>();
private final Rectangle area = new Rectangle();
private boolean creative_tab_style;
private int pageCount = 1;
private int pageNumber = 0;
private int categoriesPerPage = 1;
private int numHandlers = 1;
private int tabWidth;
private int tabHeight;
public GuiRecipeTabs(GuiRecipe guiRecipe) {
this.guiRecipe = guiRecipe;
}
public void initLayout() {
creative_tab_style = NEIClientConfig.useCreativeTabStyle();
if(creative_tab_style) {
tabWidth = GuiRecipeTabCreative.TAB_WIDTH;
tabHeight = GuiRecipeTabCreative.TAB_HEIGHT;
} else {
tabWidth = GuiRecipeTabJEI.TAB_WIDTH;
tabHeight = GuiRecipeTabJEI.TAB_HEIGHT;
}
int totalWidth = 0;
categoriesPerPage = 0;
numHandlers = guiRecipe.currenthandlers.size();
for (IRecipeHandler handler : guiRecipe.currenthandlers) {
if (totalWidth + GuiRecipeTab.TAB_WIDTH < (guiRecipe.xSize - 4)) {
totalWidth += GuiRecipeTab.TAB_WIDTH;
if (totalWidth + tabWidth < (guiRecipe.xSize - 4)) {
totalWidth += tabWidth;
categoriesPerPage++;
} else {
break;
@@ -37,9 +52,9 @@ public class GuiRecipeTabs {
}
area.width = totalWidth;
area.height = GuiRecipeTab.TAB_HEIGHT;
area.x = guiRecipe.guiLeft + 2;
area.y = guiRecipe.guiTop - GuiRecipeTab.TAB_HEIGHT + 3;
area.height = tabHeight;
area.x = guiRecipe.guiLeft + 4;
area.y = guiRecipe.guiTop - tabHeight + 3;
pageCount = (int) Math.ceil((float) numHandlers / categoriesPerPage);
calcPageNumber();
@@ -56,51 +71,58 @@ public class GuiRecipeTabs {
tabs.clear();
buttons.clear();
int tabX = area.x;
final int startIndex = pageNumber * categoriesPerPage;
for (int i = 0 ; i < categoriesPerPage ; i++) {
final int index = i + startIndex;
if (index >= numHandlers) break;
IRecipeHandler handler = guiRecipe.currenthandlers.get(index);
tabs.add(new GuiRecipeTab(guiRecipe, handler, tabX, area.y));
tabX += GuiRecipeTab.TAB_WIDTH;
int tabX = area.x + (i * tabWidth);
if(NEIClientConfig.useCreativeTabStyle())
tabs.add(new GuiRecipeTabCreative(guiRecipe, handler, tabX, area.y));
else
tabs.add(new GuiRecipeTabJEI(guiRecipe, handler, tabX, area.y));
}
// Maybe add buttons
if (numHandlers > categoriesPerPage) {
Button prevTab = new Button("prevTab") {
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) return previousPage();
else return false;
public boolean onButtonPress(boolean rightClick) {
if (!rightClick) {
NEIClientUtils.playClickSound();
return previousPage();
} else
return false;
}
@Override
public String getRenderLabel() {
return "<";
}
};
prevTab.x = area.x - 7;
prevTab.y = area.y + 2;
prevTab.h = 20;
prevTab.w = 8;
prevTab.h = tabHeight - 4;
prevTab.x = area.x - prevTab.w;
prevTab.y = area.y + 2;
buttons.add(prevTab);
Button nextTab = new Button("nextTab") {
@Override
public boolean onButtonPress(boolean rightclick) {
if(!rightclick) return nextPage();
else return false;
if (!rightclick) {
NEIClientUtils.playClickSound();
return nextPage();
} else return false;
}
@Override
public String getRenderLabel() {
return ">";
}
};
nextTab.w = prevTab.w;
nextTab.h = prevTab.h;
nextTab.x = area.x + area.width;
nextTab.y = area.y + 2;
nextTab.h = 20;
nextTab.w = 8;
nextTab.y = prevTab.y;
buttons.add(nextTab);
}
}
@@ -133,8 +155,8 @@ public class GuiRecipeTabs {
public void draw(int mouseX, int mouseY) {
IRecipeHandler current = guiRecipe.currenthandlers.get(guiRecipe.recipetype);
for (GuiRecipeTab tab : tabs) {
boolean selected = tab.isSelected(current);
tab.draw(selected, mouseX, mouseY);
tab.setSelected(current);
tab.draw(mouseX, mouseY);
}
for (Button button : buttons) {
button.draw(mouseX, mouseY);