Implement support for JEI R and U keys, fixes #484
This commit is contained in:
@@ -66,6 +66,10 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
this.ySize = height;
|
this.ySize = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Scrollbar getScrollbar() {
|
||||||
|
return scrollbar;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
return slotNumber >= 0;
|
return slotNumber >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverSlotArea(int mouseX, int mouseY) {
|
public boolean isOverSlotArea(int mouseX, int mouseY) {
|
||||||
return inBounds(7, 19, 162, 18 * getVisibleRows(), mouseX, mouseY);
|
return inBounds(7, 19, 162, 18 * getVisibleRows(), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ public class ClientStackFluid implements IClientStack {
|
|||||||
gui.drawQuantity(x, y, RSUtils.QUANTITY_FORMATTER.format((float) stack.amount / 1000F));
|
gui.drawQuantity(x, y, RSUtils.QUANTITY_FORMATTER.format((float) stack.amount / 1000F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getIngredient() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof ClientStackFluid && ((ClientStackFluid) obj).getStack().isFluidEqual(stack);
|
return obj instanceof ClientStackFluid && ((ClientStackFluid) obj).getStack().isFluidEqual(stack);
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ public class ClientStackItem implements IClientStack {
|
|||||||
gui.drawItem(x, y, stack, true, getQuantityForDisplay(isOverWithShift));
|
gui.drawItem(x, y, stack, true, getQuantityForDisplay(isOverWithShift));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getIngredient() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof IClientStack && ((ClientStackItem) obj).getHash() == hash;
|
return obj instanceof IClientStack && ((ClientStackItem) obj).getHash() == hash;
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ public interface IClientStack {
|
|||||||
int getQuantity();
|
int getQuantity();
|
||||||
|
|
||||||
void draw(GuiBase gui, int x, int y, boolean isOverWithShift);
|
void draw(GuiBase gui, int x, int y, boolean isOverWithShift);
|
||||||
|
|
||||||
|
Object getIngredient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.integration.jei;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||||
|
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GuiHandlerGrid implements IAdvancedGuiHandler<GuiGrid> {
|
||||||
|
@Override
|
||||||
|
public Class<GuiGrid> getGuiContainerClass() {
|
||||||
|
return GuiGrid.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public List<Rectangle> getGuiExtraAreas(GuiGrid guiContainer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Object getIngredientUnderMouse(GuiGrid guiContainer, int mouseX, int mouseY) {
|
||||||
|
mouseX -= guiContainer.getGuiLeft();
|
||||||
|
mouseY -= guiContainer.getGuiTop();
|
||||||
|
|
||||||
|
if (guiContainer.isOverSlotArea(mouseX, mouseY)) {
|
||||||
|
mouseX -= 7;
|
||||||
|
mouseY -= 19;
|
||||||
|
|
||||||
|
int x = mouseX / 18;
|
||||||
|
int y = mouseY / 18;
|
||||||
|
|
||||||
|
y += guiContainer.getScrollbar().getOffset();
|
||||||
|
|
||||||
|
int slot = y * 9 + x;
|
||||||
|
|
||||||
|
return slot >= 0 && slot < GuiGrid.STACKS.size() ? GuiGrid.STACKS.get(slot).getIngredient() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,8 @@ public class RSJEIPlugin extends BlankModPlugin {
|
|||||||
registry.addRecipes(RecipeMakerSolderer.getRecipes());
|
registry.addRecipes(RecipeMakerSolderer.getRecipes());
|
||||||
|
|
||||||
registry.addRecipeCategoryCraftingItem(new ItemStack(RSBlocks.SOLDERER), RecipeCategorySolderer.ID);
|
registry.addRecipeCategoryCraftingItem(new ItemStack(RSBlocks.SOLDERER), RecipeCategorySolderer.ID);
|
||||||
|
|
||||||
|
registry.addAdvancedGuiHandlers(new GuiHandlerGrid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user