Skip to content

Commit

Permalink
修复 itemStack == ItemStack.EMPTY 的判定
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed May 12, 2024
1 parent f37b683 commit 93fed25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

public class FakePlayerAutoReplaceTool {

public static void autoReplaceTool(Player fakePlayer) {
public static void autoReplaceTool(@NotNull Player fakePlayer) {
ItemStack mainHand = fakePlayer.getMainHandItem();
ItemStack offHand = fakePlayer.getOffhandItem();
if (!mainHand.isEmpty() && (mainHand.getMaxDamage() - mainHand.getDamageValue()) <= 10)
Expand All @@ -15,11 +16,11 @@ public static void autoReplaceTool(Player fakePlayer) {
replaceTool(EquipmentSlot.OFFHAND, fakePlayer);
}

public static void replaceTool(EquipmentSlot slot, Player fakePlayer) {
public static void replaceTool(EquipmentSlot slot, @NotNull Player fakePlayer) {
ItemStack itemStack = fakePlayer.getItemBySlot(slot);
for (int i = 0; i < 36; i++) {
ItemStack itemStack1 = fakePlayer.getInventory().getItem(i);
if (itemStack1 == ItemStack.EMPTY || itemStack1 == itemStack) continue;
if (itemStack1.isEmpty() || itemStack1 == itemStack) continue;
if (itemStack1.getItem().getClass() == itemStack.getItem().getClass() && (itemStack1.getMaxDamage() - itemStack1.getDamageValue()) > 10) {
ItemStack itemStack2 = itemStack1.copy();
fakePlayer.getInventory().setItem(i, itemStack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void replenishment(@NotNull ItemStack itemStack, NonNullList<ItemS
if (count <= rs) return;
global:
for (ItemStack itemStack1 : itemStackList) {
if (itemStack1 == ItemStack.EMPTY || itemStack1 == itemStack) continue;
if (itemStack1.isEmpty() || itemStack1 == itemStack) continue;
if (ItemStack.isSameItemSameTags(itemStack1, itemStack)) {
if (itemStack1.getCount() > count) {
itemStack.setCount(itemStack.getCount() + count);
Expand Down

0 comments on commit 93fed25

Please sign in to comment.