Skip to content

Commit

Permalink
Try fix #2805
Browse files Browse the repository at this point in the history
  • Loading branch information
dnk1234567 committed Feb 1, 2025
1 parent cbff31b commit 663572c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.utils.Position;

import cpw.mods.fml.relauncher.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import appeng.api.stacks.GenericStack;
import lombok.Getter;
import net.minecraftforge.fml.LogicalSide;
import org.jetbrains.annotations.NotNull;

import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawStringSized;
Expand All @@ -38,11 +41,16 @@ public AmountSetWidget(int x, int y, ConfigWidget widget) {
.setMaxStringLength(10);
}

public void setSlotIndex(int slotIndex) {
@OnlyIn(Dist.CLIENT)
public void setSlotIndexClient(int slotIndex) {
this.index = slotIndex;
writeClientAction(0, buf -> buf.writeVarInt(this.index));
}

public void setSlotIndex(int slotIndex){
this.index = slotIndex;
}

public String getAmountStr() {
if (this.index < 0) {
return "0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,27 @@ public ConfigWidget(int x, int y, IConfigurableSlot[] config, boolean isStocking
this.amountSetWidget.getAmountText().setVisible(false);
}

public void enableAmount(int slotIndex) {
@OnlyIn(Dist.CLIENT)
public void enableAmountClient(int slotIndex) {
this.amountSetWidget.setSlotIndexClient(slotIndex);
this.amountSetWidget.setVisible(true);
this.amountSetWidget.getAmountText().setVisible(true);
}

@OnlyIn(Dist.CLIENT)
public void disableAmountClient() {
this.amountSetWidget.setSlotIndexClient(-1);
this.amountSetWidget.setVisible(false);
this.amountSetWidget.getAmountText().setVisible(false);
}

public void enableAmount(int slotIndex){
this.amountSetWidget.setSlotIndex(slotIndex);
this.amountSetWidget.setVisible(true);
this.amountSetWidget.getAmountText().setVisible(true);
}

public void disableAmount() {
public void disableAmount(){
this.amountSetWidget.setSlotIndex(-1);
this.amountSetWidget.setVisible(false);
this.amountSetWidget.getAmountText().setVisible(false);
Expand All @@ -66,7 +80,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
slot.setSelect(false);
}
}
this.disableAmount();
this.disableAmountClient();
return super.mouseClicked(mouseX, mouseY, button);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
writeClientAction(REMOVE_ID, buf -> {});

if (!parentWidget.isStocking()) {
this.parentWidget.disableAmount();
this.parentWidget.disableAmountClient();
}
} else if (button == 0) {
// Left click to set/select
ItemStack hold = this.gui.getModularUIContainer().getCarried();
FluidUtil.getFluidContained(hold).ifPresent(f -> writeClientAction(UPDATE_ID, f::writeToPacket));

if (!parentWidget.isStocking()) {
this.parentWidget.enableAmount(this.index);
this.parentWidget.enableAmountClient(this.index);
this.select = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
writeClientAction(REMOVE_ID, buf -> {});

if (!parentWidget.isStocking()) {
this.parentWidget.disableAmount();
this.parentWidget.disableAmountClient();
}
} else if (button == 0) {
// Left click to set/select
Expand All @@ -108,7 +108,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}

if (!parentWidget.isStocking()) {
this.parentWidget.enableAmount(this.index);
this.parentWidget.enableAmountClient(this.index);
this.select = true;
}
}
Expand Down

0 comments on commit 663572c

Please sign in to comment.