Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
be067fea11
Exposes a mutable array on items a player should keep on death. This allows a cleaner method to implement "Keep certain items on death" than how plugins currently do it in that it never removes them in first place, so its safe if the player logs out/server is shutdown before respawn. Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4
24 Zeilen
914 B
Diff
24 Zeilen
914 B
Diff
From 127e1e338fa2acd16ab6a7ca19ae1e504dd65bac Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 21 Dec 2016 03:48:29 -0500
|
|
Subject: [PATCH] Optimize ItemStack.isEmpty()
|
|
|
|
Remove hashMap lookup every check, simplify code to remove ternary
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
|
index e0f782acc..865ff2ee1 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
|
@@ -151,7 +151,7 @@ public final class ItemStack {
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
- return this == ItemStack.a ? true : (this.getItem() != null && this.getItem() != Items.AIR ? this.count <= 0 : true);
|
|
+ return this == ItemStack.a || this.item == null || this.item == Items.AIR || this.count <= 0; // Paper
|
|
}
|
|
|
|
public ItemStack cloneAndSubtract(int i) {
|
|
--
|
|
2.21.0
|
|
|