Skip to content

Commit

Permalink
zrytx∂
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Jan 15, 2025
1 parent c3aca13 commit 7f13ea6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import xyz.violaflower.legacy_tweaks.util.common.sound.SoundUtil;
import xyz.violaflower.legacy_tweaks.util.common.sound.Sounds;

/// @see InventoryScreen
public class LegacyInventoryScreen extends LegacyEffectRenderingInventoryScreen<InventoryMenu> implements RecipeUpdateListener {
/**
* The old x position of the mouse pointer
Expand Down Expand Up @@ -96,11 +97,11 @@ protected void init() {
int fje = (width - (this.imageWidth)) / 2;
this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth-39);
if (this.leftPos == fjd) this.leftPos = fje;
this.addRenderableWidget(new ImageButton(this.leftPos + 10, this.topPos + 30, 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, button -> {
this.addRenderableWidget(new ImageButton(this.leftPos + 15, this.topPos + 70, 20, 18, RecipeBookComponent.RECIPE_BUTTON_SPRITES, button -> {
this.recipeBookComponent.toggleVisibility();
this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth-39);
if (this.leftPos == fjd) this.leftPos = fje;
button.setPosition(this.leftPos + 104, this.height / 2 - 22);
button.setPosition(this.leftPos + 15, this.topPos + 70);
this.buttonClicked = true;
}));
this.addWidget(this.recipeBookComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xyz.violaflower.legacy_tweaks.client.gui.extention.SlotExtension;
import xyz.violaflower.legacy_tweaks.client.gui.screen.legacy.screens.inventory.LegacyAbstractContainerScreen;
import xyz.violaflower.legacy_tweaks.util.client.GraphicsUtil;
Expand Down Expand Up @@ -62,6 +64,8 @@ private void renderFloatingItem(GuiGraphics guiGraphics, ItemStack stack, int x,

@Shadow protected int imageWidth;

@Shadow protected abstract void renderSlot(GuiGraphics guiGraphics, Slot slot);

@Unique
private boolean shouldApply() {
return (Object) this instanceof LegacyAbstractContainerScreen<?>;
Expand Down Expand Up @@ -179,16 +183,23 @@ private void changeSlotSizeItem(AbstractContainerScreen instance, GuiGraphics gu

@WrapOperation(method = "isHovering(Lnet/minecraft/world/inventory/Slot;DD)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;isHovering(IIIIDD)Z"))
private boolean isHovering(AbstractContainerScreen instance, int x, int y, int width, int height, double mouseX, double mouseY, Operation<Boolean> original, @Local(argsOnly = true) Slot slot) {

if (!shouldApply()) original.call(instance, x, y, width, height, mouseX, mouseY);
return original.call(instance, (int) (slot instanceof SlotExtension extension ? extension.lt$getVisualX() : slot.x), (int) (slot instanceof SlotExtension extension ? extension.lt$getVisualY() : slot.y), slot instanceof SlotExtension extension ? extension.lt$getSize() : width, slot instanceof SlotExtension extension ? extension.lt$getSize() : height, mouseX, mouseY);
}

@Inject(method = "renderSlot", at = @At("HEAD"), cancellable = true)
private void renderSlot(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) {
if (shouldApply()) {
renderSlot2(guiGraphics, slot);
ci.cancel();
}
}
/**
* @author Jab125
* @reason TODO FIX THIS LATER
*/
@Overwrite
public void renderSlot(GuiGraphics guiGraphics, Slot slot) {
@Unique
public void renderSlot2(GuiGraphics guiGraphics, Slot slot) {
float i = slot instanceof SlotExtension extension ? extension.lt$getVisualX() : slot.x;
float j = slot instanceof SlotExtension extension ? extension.lt$getVisualY() : slot.y;
ItemStack itemStack = slot.getItem();
Expand Down

0 comments on commit 7f13ea6

Please sign in to comment.