浏览代码

Clicking the item again in cheat mode will increment the stack

Signed-off-by: shedaniel <daniel@shedaniel.me>
shedaniel 4 年之前
父节点
当前提交
cbc95b642e

+ 16 - 1
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryListWidget.java

@@ -60,7 +60,6 @@ import org.apache.commons.lang3.mutable.MutableInt;
 import org.apache.commons.lang3.mutable.MutableLong;
 import org.jetbrains.annotations.ApiStatus;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 import java.util.Collections;
 import java.util.Comparator;
@@ -557,7 +556,23 @@ public class EntryListWidget extends WidgetWithBounds {
     public boolean mouseReleased(double mouseX, double mouseY, int button) {
         if (containsMouse(mouseX, mouseY)) {
             LocalPlayer player = minecraft.player;
+            cancelDelete:
             if (ClientHelper.getInstance().isCheating() && player != null && player.inventory != null && !player.inventory.getCarried().isEmpty() && RoughlyEnoughItemsCore.canDeleteItems()) {
+                EntryStack stack = EntryStack.create(minecraft.player.inventory.getCarried().copy());
+                if (stack.getType() == EntryStack.Type.FLUID) {
+                    Item bucketItem = stack.getFluid().getBucket();
+                    if (bucketItem != null) {
+                        stack = EntryStack.create(bucketItem);
+                    }
+                }
+                for (Widget child : children()) {
+                    if (child.containsMouse(mouseX, mouseY) && child instanceof EntryWidget) {
+                        if (((EntryWidget) child).cancelDeleteItems(stack)) {
+                            break cancelDelete;
+                        }
+                    }
+                }
+                
                 ClientHelper.getInstance().sendDeletePacket();
                 return true;
             }

+ 3 - 1
RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/ClientHelperImpl.java

@@ -150,7 +150,9 @@ public class ClientHelperImpl implements ClientHelper, ClientModInitializer {
         } else if (RoughlyEnoughItemsCore.canUsePackets()) {
             Inventory inventory = Minecraft.getInstance().player.inventory;
             EntryStack stack = entry.copy();
-            if (!inventory.getCarried().isEmpty() && !EntryStack.create(inventory.getCarried()).equalsIgnoreAmount(stack)) {
+            if (!inventory.getCarried().isEmpty() && EntryStack.create(inventory.getCarried()).equalsIgnoreAmount(stack)) {
+                stack.setAmount(Mth.clamp(stack.getAmount() + inventory.getCarried().getCount(), 1, stack.getItemStack().getMaxStackSize()));
+            } else if (!inventory.getCarried().isEmpty()) {
                 return false;
             }
             try {

+ 1 - 1
gradle.properties

@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx3G
-mod_version=5.8.11
+mod_version=5.8.12
 supported_version=1.16.2/3/4/5
 minecraft_version=1.16.4
 fabricloader_version=0.10.6+build.214