Skip to content

Commit d843927

Browse files
committed
fix recipe changing when scrolling to zoom
1 parent 3a6960b commit d843927

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

src/main/java/blockrenderer6343/integration/nei/GuiMultiblockHandler.java

+24-26
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,20 @@ public abstract class GuiMultiblockHandler {
9797
public static final BlockPos MB_PLACE_POS = new BlockPos(0, 64, 0);
9898
protected static final BlockPos SELECTED_BLOCK = new BlockPos().set(NO_SELECTED_BLOCK);
9999

100-
protected static int guiMouseX;
101-
protected static int guiMouseY;
102-
protected static int lastGuiMouseX;
103-
protected static int lastGuiMouseY;
100+
protected static int guiMouseX, guiMouseY, guiLeft, guiTop;
101+
protected static int lastGuiMouseX, lastGuiMouseY;
104102
protected static Vector3f center;
105-
protected static float rotationYaw;
106-
protected static float rotationPitch;
103+
protected static float rotationYaw, rotationPitch;
107104
protected static float zoom;
108105

109106
protected static ItemStack tooltipBlockStack;
110107

111108
protected static int layerIndex = -1;
112-
protected static int guiColorBg;
113-
protected static int guiColorFont;
114-
protected static int buttonColorEnabled;
115-
protected static int buttonColorDisabled;
116-
protected static int buttonColorHovered;
117-
118-
protected static String guiTextLayer;
119-
protected static String guiLayerButtonTitle;
120-
protected static String guiTextTier;
121-
protected static String guiTierButtonTitle;
109+
protected static int guiColorBg, guiColorFont;
110+
protected static int buttonColorEnabled, buttonColorDisabled, buttonColorHovered;
111+
112+
protected static String guiTextLayer, guiLayerButtonTitle;
113+
protected static String guiTextTier, guiTierButtonTitle;
122114
protected static int initialTierButtonTitleWidth;
123115
protected static int initialLayerButtonTitleWidth;
124116
protected static int initialChannelTierButtonTitleWidth;
@@ -131,9 +123,8 @@ public abstract class GuiMultiblockHandler {
131123
protected Consumer<List<ItemStack>> onIngredientChanged;
132124
protected final Map<GuiButton, Runnable> buttons = new HashMap<>();
133125

134-
protected IConstructable renderingController;
126+
protected IConstructable renderingController, lastRenderingController;
135127
protected ItemStack stackForm;
136-
protected IConstructable lastRenderingController;
137128

138129
public static final Long2ObjectMap<IStructureElement<IConstructable>> structureElementMap = new Long2ObjectOpenHashMap<>();
139130
protected Consumer<List<List<ItemStack>>> onCandidateChanged;
@@ -442,8 +433,8 @@ private void resetCenter() {
442433
public void drawMultiblock() {
443434
guiMouseX = GuiDraw.getMousePosition().x;
444435
guiMouseY = GuiDraw.getMousePosition().y;
445-
int guiLeft = NEIClientUtils.getGuiContainer().guiLeft;
446-
int guiTop = NEIClientUtils.getGuiContainer().guiTop;
436+
guiLeft = NEIClientUtils.getGuiContainer().guiLeft;
437+
guiTop = NEIClientUtils.getGuiContainer().guiTop;
447438

448439
int guiHeight = NEIClientUtils.getGuiContainer().height;
449440
if (guiHeight != lastHeight) {
@@ -464,14 +455,11 @@ public void drawMultiblock() {
464455
tooltipBlockStack = null;
465456

466457
MovingObjectPosition rayTraceResult = renderer.getLastTraceResult();
467-
boolean insideView = guiMouseX >= guiLeft + RECIPE_LAYOUT_X && guiMouseY >= guiTop + RECIPE_LAYOUT_Y
468-
&& guiMouseX < guiLeft + RECIPE_LAYOUT_X + RECIPE_WIDTH
469-
&& guiMouseY < guiTop + RECIPE_LAYOUT_Y + sceneHeight;
470458
boolean leftClickHeld = Mouse.isButtonDown(0);
471459
boolean rightClickHeld = Mouse.isButtonDown(1);
472460
boolean middleClickHeld = Mouse.isButtonDown(2);
473461

474-
if (insideView) {
462+
if (isInsideView()) {
475463
if (leftClickHeld) {
476464
rotationPitch += guiMouseX - lastGuiMouseX + 360;
477465
rotationPitch = rotationPitch % 360;
@@ -551,6 +539,12 @@ public void drawMultiblock() {
551539
// RenderHelper.disableStandardItemLighting();
552540
}
553541

542+
private boolean isInsideView() {
543+
return guiMouseX >= guiLeft + RECIPE_LAYOUT_X && guiMouseX <= guiLeft + RECIPE_LAYOUT_X + RECIPE_WIDTH
544+
&& guiMouseY >= guiTop + RECIPE_LAYOUT_Y
545+
&& guiMouseY <= guiTop + RECIPE_LAYOUT_Y + scaledSceneHeight;
546+
}
547+
554548
protected String getMultiblockName() {
555549
return I18n.format(stackForm.getDisplayName());
556550
}
@@ -662,8 +656,12 @@ protected void initializeSceneRenderer(boolean resetCamera) {
662656
}
663657
}
664658

665-
public void handleMouseScrollUp(int scrolled) {
666-
this.scrolled = scrolled;
659+
public boolean handleMouseScrollUp(int scrolled) {
660+
if (isInsideView()) {
661+
this.scrolled = scrolled;
662+
return true;
663+
}
664+
return false;
667665
}
668666

669667
protected String getTierButtonTitle() {

src/main/java/blockrenderer6343/integration/nei/InputHandler.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@ public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {}
7474

7575
@Override
7676
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
77+
if (canHandle(gui)) {
78+
return activeHandler.getGuiHandler().handleMouseScrollUp(scrolled);
79+
}
7780
return false;
7881
}
7982

8083
@Override
81-
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
82-
if (canHandle(gui)) {
83-
activeHandler.getGuiHandler().handleMouseScrollUp(scrolled);
84-
}
85-
}
84+
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {}
8685

8786
@Override
8887
public void onMouseDragged(GuiContainer gui, int amousex, int amousey, int button, long heldTime) {}

0 commit comments

Comments
 (0)