Skip to content

Commit

Permalink
Fix that the clicked slot is not determined correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroscho committed Nov 7, 2024
1 parent 12ebe0b commit 06ed79a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.glodblock.github.client.gui.container.ContainerLevelMaintainer.createLevelValues;

import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -354,18 +353,21 @@ public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
return null;
}

private Rectangle getSlotArea(SlotFake slot) {
return new Rectangle(guiLeft + slot.getX(), guiTop + slot.getY(), 16, 16);
}

@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (draggedStack != null) {
draggedStack.stackSize = 0;
if (draggedStack == null) {
return false;
}

draggedStack.stackSize = 0;
Slot slotAtPosition = this.getSlotAtPosition(mouseX, mouseY);
if (slotAtPosition == null) {
return false;
}

for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
if (slotAtPosition.equals(slot)) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/ae2fc_at.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ public net.minecraft.client.gui.inventory.GuiContainer field_147009_r # guiTop
public net.minecraft.client.gui.inventory.GuiContainer field_147006_u #theSlot

public net.minecraft.client.renderer.texture.TextureMap field_110574_e # mapRegisteredSprites

protected net.minecraft.client.gui.inventory.GuiContainer func_146975_c(II)Lnet.minecraft.inventory.Slot; # getSlotAtPosition

0 comments on commit 06ed79a

Please sign in to comment.