Compare commits

...
Author SHA1 Message Date
D-Cysteine 58117fa368 Some changes to NEI that are needed by NEI Custom Diagram (#163)
* Add IRecipeHandler support for handling mouse scrollwheel
* Add accessors for handler and recipe indices
* Make Shift+R not be handled as U
* Clean up redundant code
2021-09-30 21:17:14 -07:00
Prometheus0000 db339e94f4 Add yshifts 2021-09-30 21:14:57 -07:00
6 changed files with 59 additions and 31 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.12-GTNH
mod_version=2.1.13-GTNH
+6 -6
View File
@@ -22,14 +22,14 @@ WayofTime.alchemicalWizardry.client.nei.NEIAltarRecipeHandler,Blood Magic,AWWayo
WayofTime.alchemicalWizardry.client.nei.NEIBindingRitualHandler,Blood Magic,AWWayofTime:sacrificialKnife,,AWWayofTime,TRUE,,,50,,6,,,,,,
WayofTime.alchemicalWizardry.client.nei.NEIBloodOrbShapedHandler,Blood Magic,AWWayofTime:AlchemicalWizardrybloodRune:3,,AWWayofTime,TRUE,,,65,,5,,,,,,
WayofTime.alchemicalWizardry.client.nei.NEIBloodOrbShapelessHandler,Blood Magic,AWWayofTime:AlchemicalWizardrybloodRune:4,,AWWayofTime,TRUE,,,65,,5,,,,,,
bw.fuels.acidgens,BartWorks,gregtech:gt.blockmachines:12726,,bartworks,TRUE,,,145,,2,,,,,,
bw.recipe.cal,BartWorks,gregtech:gt.blockmachines:12735,,bartworks,TRUE,,,135,,2,,,,,,
bw.fuels.acidgens,BartWorks,gregtech:gt.blockmachines:12726,,bartworks,TRUE,,6,145,,2,,,,,,
bw.recipe.cal,BartWorks,gregtech:gt.blockmachines:12735,,bartworks,TRUE,,6,135,,2,,,,,,
gg.recipe.naquadah_reactor,Good Generator,gregtech:gt.blockmachines:12732,,GoodGenerator,TRUE,,,145,,1,,,,,,
gg.recipe.naquadah_fuel_refine_factory,Good Generator,gregtech:gt.blockmachines:16999,,GoodGenerator,TRUE,,,145,,1,,,,,,
com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioLabHandler,BartWorks,gregtech:gt.blockmachines:12699,,bartworks,TRUE,,,145,,2,,,,,,
com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioVatHandler,BartWorks,gregtech:gt.blockmachines:12712,,bartworks,TRUE,,,140,,2,,,,,,
com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioLabHandler,BartWorks,gregtech:gt.blockmachines:12699,,bartworks,TRUE,,6,145,,2,,,,,,
com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioVatHandler,BartWorks,gregtech:gt.blockmachines:12712,,bartworks,TRUE,,6,140,,2,,,,,,
com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_OreHandler,BartWorks,bartworks:bw.blockores.01:89,,bartworks,TRUE,,,135,,2,,,,,,
gt.recipe.electricimplosioncompressor,BartWorks,gregtech:gt.blockmachines:12734,,bartworks,TRUE,,,135,,2,,,,,,
gt.recipe.electricimplosioncompressor,BartWorks,gregtech:gt.blockmachines:12734,,bartworks,TRUE,,6,135,,2,,,,,,
net.bdew.neiaddons.botany.flowers.FlowerBreedingHandler,Botany,Botany:flower,,Botany,TRUE,,,65,,5,,,,,,
buildcraft.compat.nei.RecipeHandlerRefinery,BuildCraft,BuildCraft|Factory:refineryBlock,,BuildCraft|Factory,TRUE,,,60,,5,,,,,,There's only 2 recipes though
buildcraft.compat.nei.RecipeHandlerAssemblyTable,BuildCraft,BuildCraft|Silicon:laserTableBlock,,BuildCraft|Silicon,TRUE,,,100,,3,,,,,,
@@ -448,4 +448,4 @@ neresources.nei.NEIDungeonHandler,Not Enough Resources,minecraft:chest,,neresour
neresources.nei.NEIEnchantmentHandler,Not Enough Resources,minecraft:anvil,,neresources,TRUE,,,130,166,2,,,,,,
neresources.nei.NEIMobHandler,Not Enough Resources,minecraft:skull:4,,neresources,TRUE,,,130,166,2,,,,,,
neresources.nei.NEIOreHandler,Not Enough Resources,minecraft:diamond_ore,,neresources,TRUE,,,65,166,5,,,,,,
neresources.nei.NEIPlantHandler,Not Enough Resources,minecraft:wheat,,neresources,TRUE,,,130,166,2,,,,,,
neresources.nei.NEIPlantHandler,Not Enough Resources,minecraft:wheat,,neresources,TRUE,,,130,166,2,,,,,,
1 handler modName itemName nbtInfo modId modRequired excludedModId yShift handlerHeight handlerWidth maxRecipesPerPage imageResource imageX imageY imageWidth imageHeight itemNotes
22 WayofTime.alchemicalWizardry.client.nei.NEIBindingRitualHandler Blood Magic AWWayofTime:sacrificialKnife AWWayofTime TRUE 50 6
23 WayofTime.alchemicalWizardry.client.nei.NEIBloodOrbShapedHandler Blood Magic AWWayofTime:AlchemicalWizardrybloodRune:3 AWWayofTime TRUE 65 5
24 WayofTime.alchemicalWizardry.client.nei.NEIBloodOrbShapelessHandler Blood Magic AWWayofTime:AlchemicalWizardrybloodRune:4 AWWayofTime TRUE 65 5
25 bw.fuels.acidgens BartWorks gregtech:gt.blockmachines:12726 bartworks TRUE 6 145 2
26 bw.recipe.cal BartWorks gregtech:gt.blockmachines:12735 bartworks TRUE 6 135 2
27 gg.recipe.naquadah_reactor Good Generator gregtech:gt.blockmachines:12732 GoodGenerator TRUE 145 1
28 gg.recipe.naquadah_fuel_refine_factory Good Generator gregtech:gt.blockmachines:16999 GoodGenerator TRUE 145 1
29 com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioLabHandler BartWorks gregtech:gt.blockmachines:12699 bartworks TRUE 6 145 2
30 com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_BioVatHandler BartWorks gregtech:gt.blockmachines:12712 bartworks TRUE 6 140 2
31 com.github.bartimaeusnek.bartworks.neiHandler.BW_NEI_OreHandler BartWorks bartworks:bw.blockores.01:89 bartworks TRUE 135 2
32 gt.recipe.electricimplosioncompressor BartWorks gregtech:gt.blockmachines:12734 bartworks TRUE 6 135 2
33 net.bdew.neiaddons.botany.flowers.FlowerBreedingHandler Botany Botany:flower Botany TRUE 65 5
34 buildcraft.compat.nei.RecipeHandlerRefinery BuildCraft BuildCraft|Factory:refineryBlock BuildCraft|Factory TRUE 60 5 There's only 2 recipes though
35 buildcraft.compat.nei.RecipeHandlerAssemblyTable BuildCraft BuildCraft|Silicon:laserTableBlock BuildCraft|Silicon TRUE 100 3
448 neresources.nei.NEIEnchantmentHandler Not Enough Resources minecraft:anvil neresources TRUE 130 166 2
449 neresources.nei.NEIMobHandler Not Enough Resources minecraft:skull:4 neresources TRUE 130 166 2
450 neresources.nei.NEIOreHandler Not Enough Resources minecraft:diamond_ore neresources TRUE 65 166 5
451 neresources.nei.NEIPlantHandler Not Enough Resources minecraft:wheat neresources TRUE 130 166 2
+31 -20
View File
@@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOverlay, IGuiClientSide, IGuiHandleMouseWheel, IContainerTooltipHandler, INEIGuiHandler {
// Background image calculations
@@ -172,6 +173,18 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
initOverlayButtons();
}
public IRecipeHandler getHandler() {
return handler;
}
public List<Integer> getRecipeIndices() {
final int recipesPerPage = getRecipesPerPage();
int minIndex = page * recipesPerPage;
int maxIndex = Math.min(handler.numRecipes(), (page + 1) * recipesPerPage);
return IntStream.range(minIndex, maxIndex).boxed().collect(Collectors.toList());
}
@Override
public void keyTyped(char c, int i) {
@@ -183,8 +196,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
if (GuiContainerManager.getManager(this).lastKeyTyped(i, c))
return;
final int recipesPerPage = getRecipesPerPage();
for (int recipe = page * recipesPerPage; recipe < handler.numRecipes() && recipe < (page + 1) * recipesPerPage; recipe++)
for (int recipe : getRecipeIndices())
if (handler.keyTyped(this, c, i, recipe))
return;
@@ -205,8 +217,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
@Override
protected void mouseClicked(int x, int y, int button) {
final int recipesPerPage = getRecipesPerPage();
for (int recipe = page * recipesPerPage; recipe < handler.numRecipes() && recipe < (page + 1) * recipesPerPage; recipe++)
for (int recipe : getRecipeIndices())
if (handler.mouseClicked(this, button, recipe))
return;
if (recipeTabs.mouseClicked(x, y, button))
@@ -214,10 +225,21 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
super.mouseClicked(x, y, button);
}
@Override
public void mouseScrolled(int i) {
for (int recipe : getRecipeIndices())
if (handler.mouseScrolled(this, i, recipe))
return;
if (new Rectangle(guiLeft, guiTop, xSize, ySize).contains(GuiDraw.getMousePosition())) {
if (i > 0) prevPage();
else nextPage();
}
}
@Override
protected void actionPerformed(GuiButton guibutton) {
super.actionPerformed(guibutton);
final int recipesPerPage = getRecipesPerPage();
switch (guibutton.id) {
case 0:
prevType();
@@ -233,7 +255,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
return;
}
if (overlayButtons != null && guibutton.id >= OVERLAY_BUTTON_ID_START && guibutton.id < OVERLAY_BUTTON_ID_START + overlayButtons.length) {
overlayRecipe(page * recipesPerPage + guibutton.id - OVERLAY_BUTTON_ID_START);
overlayRecipe(page * getRecipesPerPage() + guibutton.id - OVERLAY_BUTTON_ID_START);
}
}
@@ -246,8 +268,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
@Override
public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) {
final int recipesPerPage = getRecipesPerPage();
/*
/*
* Several mods try to figure out the relative mouse position for fluid tooltips. This worked fine
* when it was a static 166.. however now that we're scaling it this no longer works. Rather than
* patching the individual mods (so that we can be as compatible as possible), we'll just fake
@@ -257,9 +278,8 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
// Begin Hax
final int oldHeight = this.height;
this.height = 166 + handlerInfo.getHeight() + 18 + (guiTop - 44) * 2;
for (int i = page * recipesPerPage; i < handler.numRecipes() && i < (page + 1) * recipesPerPage; i++) {
for (int i : getRecipeIndices())
currenttip = handler.handleTooltip(this, currenttip, i);
}
recipeTabs.handleTooltip(mousex, mousey, currenttip);
this.height = oldHeight;
// End Hax
@@ -269,8 +289,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
@Override
public List<String> handleItemTooltip(GuiContainer gui, ItemStack stack, int mousex, int mousey, List<String> currenttip) {
final int recipesPerPage = getRecipesPerPage();
for (int i = page * recipesPerPage; i < handler.numRecipes() && i < (page + 1) * recipesPerPage; i++)
for (int i : getRecipeIndices())
currenttip = handler.handleItemTooltip(this, stack, currenttip, i);
return currenttip;
@@ -532,14 +551,6 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
return new Point(5, 32 + yShift + ((recipe % getRecipesPerPage()) * handlerInfo.getHeight()));
}
@Override
public void mouseScrolled(int i) {
if (new Rectangle(guiLeft, guiTop, xSize, ySize).contains(GuiDraw.getMousePosition())) {
if (i > 0) prevPage();
else nextPage();
}
}
public abstract ArrayList<? extends IRecipeHandler> getCurrentRecipeHandlers();
@Override
@@ -120,6 +120,7 @@ public interface IRecipeHandler
* @return true to terminate further processing of this event.
*/
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe);
/**
*
* @param gui An instance of the currentscreen
@@ -127,4 +128,15 @@ public interface IRecipeHandler
* @return true to terminate further processing of this event.
*/
public boolean mouseClicked(GuiRecipe gui, int button, int recipe);
/**
* For legacy compatibility reasons, this method has a do-nothing default implementation.
*
* @param gui An instance of the currentscreen
* @param scroll The scroll direction, {> 0 = Up, < 0 = Down}
* @return true to terminate further processing of this event.
*/
default boolean mouseScrolled(GuiRecipe gui, int scroll, int recipe) {
return false;
}
}
@@ -16,13 +16,13 @@ public class RecipeItemInputHandler implements IContainerInputHandler
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if(stackover == null)
return false;
if(keyCode == NEIClientConfig.getKeyBinding("gui.usage") || (keyCode == NEIClientConfig.getKeyBinding("gui.recipe") && NEIClientUtils.shiftKey()))
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
if(keyCode == NEIClientConfig.getKeyBinding("gui.bookmark")) {
NEIClientConfig.logger.debug("Adding or removing {} from bookmarks", stackover.getDisplayName());
ItemPanels.bookmarkPanel.addOrRemoveItem(stackover.copy());
@@ -639,6 +639,11 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
return false;
}
@Override
public boolean mouseScrolled(GuiRecipe gui, int scroll, int recipe) {
return false;
}
private boolean transferRect(GuiRecipe gui, int recipe, boolean usage) {
Point offset = gui.getRecipePosition(recipe);
return transferRect(gui, transferRects, offset.x, offset.y, usage);