114 lines
5.1 KiB
Java
114 lines
5.1 KiB
Java
package dev.pfaff.recipe_nope.mixin;
|
|
|
|
import dev.pfaff.recipe_nope.injector.UnconstrainedRedirect;
|
|
import net.minecraft.client.MinecraftClient;
|
|
import net.minecraft.client.gui.screen.ingame.CraftingScreen;
|
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
|
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
|
|
import net.minecraft.client.util.math.MatrixStack;
|
|
import net.minecraft.screen.AbstractRecipeScreenHandler;
|
|
import net.minecraft.screen.slot.Slot;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Overwrite;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
@Mixin(CraftingScreen.class)
|
|
public abstract class CraftingScreenMixin extends HandledScreen {
|
|
public CraftingScreenMixin() {
|
|
super(null, null, null);
|
|
throw new AssertionError();
|
|
}
|
|
|
|
@UnconstrainedRedirect(method = "<init>", at = @At(value = "NEW", target = "()Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;"))
|
|
private RecipeBookWidget constructor$skipNewRecipeBook() {
|
|
return null;
|
|
}
|
|
|
|
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;initialize(IILnet/minecraft/client/MinecraftClient;ZLnet/minecraft/screen/AbstractRecipeScreenHandler;)V"))
|
|
private void init$skipRecipeBookInit(RecipeBookWidget instance,
|
|
int parentWidth,
|
|
int parentHeight,
|
|
MinecraftClient client,
|
|
boolean narrow,
|
|
AbstractRecipeScreenHandler<?> craftingScreenHandler) {}
|
|
|
|
@Redirect(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;findLeftEdge(II)I"))
|
|
private int init$findLeftEdgeWithoutRecipeBook(RecipeBookWidget instance, int width, int backgroundWidth) {
|
|
return (width - backgroundWidth) / 2;
|
|
}
|
|
|
|
@Inject(method = "init", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;findLeftEdge(II)I"), cancellable = true)
|
|
private void init$cancelRest(CallbackInfo ci) {
|
|
if (((Object) this) instanceof CraftingScreen) {
|
|
this.titleX = 29;
|
|
}
|
|
ci.cancel();
|
|
}
|
|
|
|
@Redirect(method = "handledScreenTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;update()V"))
|
|
private void init$skipRecipeBookUpdate(RecipeBookWidget instance) {}
|
|
|
|
@Overwrite
|
|
public void refreshRecipeBook() {
|
|
}
|
|
|
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;isOpen()Z"))
|
|
private boolean render$recipeBookNeverOpen(RecipeBookWidget instance) {
|
|
return false;
|
|
}
|
|
|
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V"))
|
|
private void render$skipRecipeBookRender(RecipeBookWidget instance,
|
|
MatrixStack matrices,
|
|
int mouseX,
|
|
int mouseY,
|
|
float delta) {
|
|
}
|
|
|
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;drawGhostSlots(Lnet/minecraft/client/util/math/MatrixStack;IIZF)V"))
|
|
private void render$skipRecipeBookDrawGhostSlots(RecipeBookWidget instance,
|
|
MatrixStack matrices,
|
|
int x,
|
|
int y,
|
|
boolean bl,
|
|
float delta) {
|
|
}
|
|
|
|
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;drawTooltip(Lnet/minecraft/client/util/math/MatrixStack;IIII)V"))
|
|
private void render$skipRecipeBookDrawTooltip(RecipeBookWidget instance,
|
|
MatrixStack matrices,
|
|
int x,
|
|
int y,
|
|
int mouseX,
|
|
int mouseY) {
|
|
}
|
|
|
|
@Redirect(method = "mouseClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;mouseClicked(DDI)Z"))
|
|
private boolean mouseClicked$skipRecipeBook(RecipeBookWidget instance, double mouseX, double mouseY, int button) {
|
|
return false;
|
|
}
|
|
|
|
@Redirect(method = "isClickOutsideBounds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;isClickOutsideBounds(DDIIIII)Z"))
|
|
private boolean isClickOutsideBounds$skipRecipeBook(RecipeBookWidget instance,
|
|
double mouseX,
|
|
double mouseY,
|
|
int x,
|
|
int y,
|
|
int backgroundWidth,
|
|
int backgroundHeight,
|
|
int button) {
|
|
return true;
|
|
}
|
|
|
|
@Redirect(method = "onMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;slotClicked(Lnet/minecraft/screen/slot/Slot;)V"))
|
|
private void onMouseClick$skipRecipeBook(RecipeBookWidget instance, Slot slot) {
|
|
}
|
|
|
|
@Redirect(method = "removed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeBookWidget;close()V"))
|
|
private void removed$skipRecipeBook(RecipeBookWidget instance) {
|
|
}
|
|
}
|