mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge pull request #3275 from Sfiguz7/fix/itemsadder_cargo_stacking
Fixes #3133
This commit is contained in:
commit
e02eedd940
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -52,6 +53,7 @@ import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
|||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
* @author Walshy
|
* @author Walshy
|
||||||
|
* @author Sfiguz7
|
||||||
*/
|
*/
|
||||||
public final class SlimefunUtils {
|
public final class SlimefunUtils {
|
||||||
|
|
||||||
@ -159,7 +161,7 @@ public final class SlimefunUtils {
|
|||||||
* @param item
|
* @param item
|
||||||
* The {@link ItemStack} you want to add/remove Soulbound from.
|
* The {@link ItemStack} you want to add/remove Soulbound from.
|
||||||
* @param makeSoulbound
|
* @param makeSoulbound
|
||||||
* If they item should be soulbound.
|
* If the item should be soulbound.
|
||||||
*
|
*
|
||||||
* @see #isSoulbound(ItemStack)
|
* @see #isSoulbound(ItemStack)
|
||||||
*/
|
*/
|
||||||
@ -321,24 +323,30 @@ public final class SlimefunUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMetaSnapshot meta, boolean checkLore) {
|
private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMetaSnapshot itemMetaSnapshot, boolean checkLore) {
|
||||||
Optional<String> displayName = meta.getDisplayName();
|
Optional<String> displayName = itemMetaSnapshot.getDisplayName();
|
||||||
|
|
||||||
if (itemMeta.hasDisplayName() != displayName.isPresent()) {
|
if (itemMeta.hasDisplayName() != displayName.isPresent()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (itemMeta.hasDisplayName() && displayName.isPresent() && !itemMeta.getDisplayName().equals(displayName.get())) {
|
} else if (itemMeta.hasDisplayName() && displayName.isPresent() && !itemMeta.getDisplayName().equals(displayName.get())) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!checkLore) {
|
} else if (checkLore) {
|
||||||
return true;
|
Optional<List<String>> itemLore = itemMetaSnapshot.getLore();
|
||||||
} else {
|
|
||||||
Optional<List<String>> itemLore = meta.getLore();
|
|
||||||
|
|
||||||
if (itemMeta.hasLore() && itemLore.isPresent()) {
|
if (itemMeta.hasLore() && itemLore.isPresent() && !equalsLore(itemMeta.getLore(), itemLore.get())) {
|
||||||
return equalsLore(itemMeta.getLore(), itemLore.get());
|
return false;
|
||||||
} else {
|
} else if (itemMeta.hasLore() != itemLore.isPresent()) {
|
||||||
return !itemMeta.hasLore() && !itemLore.isPresent();
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes #3133: name and lore are not enough
|
||||||
|
OptionalInt itemCustomModelData = itemMetaSnapshot.getCustomModelData();
|
||||||
|
if (itemMeta.hasCustomModelData() && itemCustomModelData.isPresent() && itemMeta.getCustomModelData() != itemCustomModelData.getAsInt()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return itemMeta.hasCustomModelData() == itemCustomModelData.isPresent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMeta sfitemMeta, boolean checkLore) {
|
private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMeta sfitemMeta, boolean checkLore) {
|
||||||
@ -359,6 +367,15 @@ public final class SlimefunUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixes #3133: name and lore are not enough
|
||||||
|
boolean hasItemMetaCustomModelData = itemMeta.hasCustomModelData();
|
||||||
|
boolean hasSfItemMetaCustomModelData = sfitemMeta.hasCustomModelData();
|
||||||
|
if (hasItemMetaCustomModelData && hasSfItemMetaCustomModelData && itemMeta.getCustomModelData() != sfitemMeta.getCustomModelData()) {
|
||||||
|
return false;
|
||||||
|
} else if (hasItemMetaCustomModelData != hasSfItemMetaCustomModelData) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (itemMeta instanceof PotionMeta && sfitemMeta instanceof PotionMeta) {
|
if (itemMeta instanceof PotionMeta && sfitemMeta instanceof PotionMeta) {
|
||||||
return ((PotionMeta) itemMeta).getBasePotionData().equals(((PotionMeta) sfitemMeta).getBasePotionData());
|
return ((PotionMeta) itemMeta).getBasePotionData().equals(((PotionMeta) sfitemMeta).getBasePotionData());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user