forked from Clones/Controlify
➕ More recipe book SnapPoints (#178)
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package dev.isxander.controlify.mixins.feature.virtualmouse.snapping;
|
package dev.isxander.controlify.mixins.feature.virtualmouse.snapping;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.components.StateSwitchingButton;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookPage;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookPage;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookTabButton;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookTabButton;
|
||||||
@ -15,4 +16,7 @@ public interface RecipeBookComponentAccessor {
|
|||||||
|
|
||||||
@Accessor
|
@Accessor
|
||||||
List<RecipeBookTabButton> getTabButtons();
|
List<RecipeBookTabButton> getTabButtons();
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
StateSwitchingButton getFilterButton();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.isxander.controlify.mixins.feature.virtualmouse.snapping;
|
package dev.isxander.controlify.mixins.feature.virtualmouse.snapping;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.components.StateSwitchingButton;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookPage;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookPage;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeButton;
|
import net.minecraft.client.gui.screens.recipebook.RecipeButton;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -11,4 +12,10 @@ import java.util.List;
|
|||||||
public interface RecipeBookPageAccessor {
|
public interface RecipeBookPageAccessor {
|
||||||
@Accessor
|
@Accessor
|
||||||
List<RecipeButton> getButtons();
|
List<RecipeButton> getButtons();
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
StateSwitchingButton getForwardButton();
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
StateSwitchingButton getBackButton();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package dev.isxander.controlify.virtualmouse;
|
|||||||
import dev.isxander.controlify.api.vmousesnapping.SnapPoint;
|
import dev.isxander.controlify.api.vmousesnapping.SnapPoint;
|
||||||
import dev.isxander.controlify.mixins.feature.virtualmouse.snapping.RecipeBookComponentAccessor;
|
import dev.isxander.controlify.mixins.feature.virtualmouse.snapping.RecipeBookComponentAccessor;
|
||||||
import dev.isxander.controlify.mixins.feature.virtualmouse.snapping.RecipeBookPageAccessor;
|
import dev.isxander.controlify.mixins.feature.virtualmouse.snapping.RecipeBookPageAccessor;
|
||||||
|
import net.minecraft.client.gui.components.StateSwitchingButton;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
|
|
||||||
@ -21,12 +22,33 @@ public final class SnapUtils {
|
|||||||
points.add(new SnapPoint(new Vector2i(x, y), 20));
|
points.add(new SnapPoint(new Vector2i(x, y), 20));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
StateSwitchingButton filterButton = componentAccessor.getFilterButton();
|
||||||
|
if (filterButton.visible) {
|
||||||
|
int x = filterButton.getX() + filterButton.getWidth() / 2;
|
||||||
|
int y = filterButton.getY() + filterButton.getHeight() / 2;
|
||||||
|
points.add(new SnapPoint(new Vector2i(x, y), 14));
|
||||||
|
}
|
||||||
|
|
||||||
RecipeBookPageAccessor pageAccessor = (RecipeBookPageAccessor) componentAccessor.getRecipeBookPage();
|
RecipeBookPageAccessor pageAccessor = (RecipeBookPageAccessor) componentAccessor.getRecipeBookPage();
|
||||||
pageAccessor.getButtons().forEach(button -> {
|
pageAccessor.getButtons().forEach(button -> {
|
||||||
int x = button.getX() + button.getWidth() / 2;
|
int x = button.getX() + button.getWidth() / 2;
|
||||||
int y = button.getY() + button.getHeight() / 2;
|
int y = button.getY() + button.getHeight() / 2;
|
||||||
points.add(new SnapPoint(new Vector2i(x, y), 21));
|
points.add(new SnapPoint(new Vector2i(x, y), 21));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
StateSwitchingButton forwardButton = pageAccessor.getForwardButton();
|
||||||
|
if (forwardButton.visible) {
|
||||||
|
int x = forwardButton.getX() + forwardButton.getWidth() / 2 - 2;
|
||||||
|
int y = forwardButton.getY() + forwardButton.getHeight() / 2;
|
||||||
|
points.add(new SnapPoint(new Vector2i(x, y), 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
StateSwitchingButton backButton = pageAccessor.getBackButton();
|
||||||
|
if (backButton.visible) {
|
||||||
|
int x = backButton.getX() + backButton.getWidth() / 2 + 2;
|
||||||
|
int y = backButton.getY() + backButton.getHeight() / 2;
|
||||||
|
points.add(new SnapPoint(new Vector2i(x, y), 10));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user