Skip to content

Commit

Permalink
Merge pull request #16 from matt-159/0.3.1-fixes
Browse files Browse the repository at this point in the history
0.3.1 fixes
  • Loading branch information
matt-159 authored Dec 7, 2022
2 parents 076ff02 + 01ee29d commit 4b425d3
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ public abstract class GuiRaintankMixin {
"drawGuiContainerBackgroundLayer" },
constant = { @Constant(intValue = 53),
@Constant(intValue = 80) },
remap = false,
require = 2)
private int modifyXOffsets(int constant) {
return constant + 81;
}

@ModifyConstant(method = "drawGuiContainerBackgroundLayer",
constant = @Constant(intValue = 176),
remap = false,
require = 1)
private int modifyTextureUVXOffset(int constant) {
return 338;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ public void resetInventory() {
if (this.isReorganizedForFallbackSupport) {
DWSUtil.ReorganizeInventoryForFallbackSupport((EntityPlayer) (Object) this, DWSUtil.Reorganization.Undo);
}

this.isReorganizedForFallbackSupport = false;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,96 @@
package com.github.matt159.dws.mixin.mixins.common.nei;

import codechicken.nei.recipe.TemplateRecipeHandler;
import com.github.matt159.dws.util.ListOfGUIsWithTransferRects;
import net.minecraft.client.gui.inventory.GuiContainer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.awt.*;
import java.util.Collection;
import java.util.List;

@Mixin(TemplateRecipeHandler.class)
public abstract class TemplateRecipeHandlerMixin {
@ModifyConstant(method = "drawBackground",
constant = @Constant(intValue = 5),
remap = false,
require = 1)
private int modifyBackgroundXOffset(int constant) {
return constant + 81;
// @ModifyConstant(method = "drawBackground",
// constant = @Constant(intValue = 5),
// remap = false,
// require = 1)
// private int modifyBackgroundXOffset(int constant) {
// return constant + 81;
// }

private static Class<? extends GuiContainer> clazz = null;

@Inject(method = "transferRect(Lnet/minecraft/client/gui/inventory/GuiContainer;Ljava/util/Collection;IIZ)Z",
at = @At("HEAD"),
remap = false,
require = 1)
private static void injectCaptureGuiContainerClass(GuiContainer gui,
Collection<TemplateRecipeHandler.RecipeTransferRect> transferRects,
int offsetx,
int offsety,
boolean usage,
CallbackInfoReturnable<Boolean> cir) {
clazz = gui.getClass();
}

@Inject(method = "transferRectTooltip",
at = @At("HEAD"),
remap = false,
require = 1)
private static void injectCaptureGuiContainerClass(GuiContainer gui,
Collection<TemplateRecipeHandler.RecipeTransferRect> transferRects,
int offsetx,
int offsety,
List<String> currenttip,
CallbackInfoReturnable<List<String>> cir) {
clazz = gui.getClass();
}

@SuppressWarnings("rawtypes")
@Redirect(method = { "transferRect(Lnet/minecraft/client/gui/inventory/GuiContainer;Ljava/util/Collection;IIZ)Z",
"transferRectTooltip" },
at = @At(value = "INVOKE",
target = "Ljava/awt/Rectangle;contains(Ljava/awt/Point;)Z"),
remap = false,
require = 2)
private static boolean redirectNextRectangle(Rectangle instance, Point point) {
if (ListOfGUIsWithTransferRects.contains(clazz)) {
Rectangle rect = new Rectangle(instance);

rect.x += 81;

return rect.contains(point);
}

return instance.contains(point);
}

@Inject(method = "transferRect(Lnet/minecraft/client/gui/inventory/GuiContainer;Ljava/util/Collection;IIZ)Z",
at = @At("RETURN"),
remap = false,
require = 1)
private static void injectReleaseGuiContainerClass(GuiContainer gui,
Collection<TemplateRecipeHandler.RecipeTransferRect> transferRects,
int offsetx,
int offsety,
boolean usage,
CallbackInfoReturnable<Boolean> cir) {
clazz = null;
}

@Inject(method = "transferRectTooltip",
at = @At("RETURN"),
remap = false,
require = 1)
private static void injectReleaseGuiContainerClass(GuiContainer gui,
Collection<TemplateRecipeHandler.RecipeTransferRect> transferRects,
int offsetx,
int offsety,
List<String> currenttip,
CallbackInfoReturnable<List<String>> cir) {
clazz = null;
}
}
6 changes: 1 addition & 5 deletions src/main/java/com/github/matt159/dws/mixin/plugin/Mixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ public enum Mixin implements IMixin {
NEIServerUtilsMixin (COMMON, require(NOTENOUGHITEMS), "nei.NEIServerUtilsMixin"),
PlayerSaveMixin (COMMON, require(NOTENOUGHITEMS), "nei.PlayerSaveMixin"),

BrewingRecipeHandlerMixin (COMMON, require(NOTENOUGHITEMS), "nei.BrewingRecipeHandlerMixin"),
FurnaceRecipeHandlerMixin (COMMON, require(NOTENOUGHITEMS), "nei.FurnaceRecipeHandlerMixin"),
ShapedRecipeHandlerMixin (COMMON, require(NOTENOUGHITEMS), "nei.ShapedRecipeHandlerMixin"),
// TemplateRecipeHandlerMixin (COMMON, require(NOTENOUGHITEMS), "nei.TemplateRecipeHandlerMixin"),
TemplateRecipeHandlerMixin (COMMON, require(NOTENOUGHITEMS), "nei.TemplateRecipeHandlerMixin"),
//endregion

// region Galacticraft Mixins
Expand Down Expand Up @@ -190,7 +187,6 @@ public enum Mixin implements IMixin {
ContainerUpgradeableMixin (COMMON, require(APPLIEDENERGISTICS2), "appliedenergistics2.ContainerUpgradeableMixin"),
ContainerVibrationChamberMixin (COMMON, require(APPLIEDENERGISTICS2), "appliedenergistics2.ContainerVibrationChamberMixin"),
ContainerWirelessMixin (COMMON, require(APPLIEDENERGISTICS2), "appliedenergistics2.ContainerWirelessMixin"),
NEIAERecipeHandlerMixin (COMMON, require(APPLIEDENERGISTICS2), "appliedenergistics2.NEIAERecipeHandlerMixin"),

AEBaseGuiMixin (CLIENT, require(APPLIEDENERGISTICS2), "appliedenergistics2.AEBaseGuiMixin"),
GuiCellWorkbenchMixin (CLIENT, require(APPLIEDENERGISTICS2), "appliedenergistics2.GuiCellWorkbenchMixin"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.github.matt159.dws.util;

import appeng.client.gui.implementations.GuiGrinder;
import appeng.client.gui.implementations.GuiInscriber;
import forestry.factory.gui.*;
import net.minecraft.client.gui.inventory.GuiBrewingStand;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.client.gui.inventory.GuiFurnace;

import java.util.HashSet;

public final class ListOfGUIsWithTransferRects {
private static final HashSet<Class<? extends GuiContainer>> set = new HashSet<>();

public static boolean contains(Class<? extends GuiContainer> clazz) {
return set.contains(clazz);
}

public static boolean addClassToList(Class<? extends GuiContainer> clazz) {
return set.add(clazz);
}

static {
//region Minecraft
addClassToList(GuiCrafting.class);
addClassToList(GuiBrewingStand.class);
addClassToList(GuiFurnace.class);
//endregion
//region AE2
addClassToList(GuiGrinder.class);
addClassToList(GuiInscriber.class);
//endregion
//region Forestry
addClassToList(GuiBottler.class);
addClassToList(GuiCarpenter.class);
addClassToList(GuiCentrifuge.class);
addClassToList(GuiFabricator.class);
addClassToList(GuiFermenter.class);
addClassToList(GuiMoistener.class);
addClassToList(GuiSqueezer.class);
addClassToList(GuiStill.class);
//endregion
//region Gregtech
//Gregtech's NEI Handler overrides handleToolTip in TemplateRecipeHandler so a list of classes isn't needed here
//endregion
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4b425d3

Please sign in to comment.