MCPcopy Create free account
hub / github.com/VolmitSoftware/Adapt / isMergable

Method isMergable

src/main/java/com/volmit/adapt/util/Items.java:324–357  ·  view source on GitHub ↗

Can the item a be stacked onto the item b (following max stack size) @param a the item a @param b the item b @return true if they can be merged

(ItemStack a, ItemStack b)

Source from the content-addressed store, hash-verified

322 * @return true if they can be merged
323 */
324 @SuppressWarnings("deprecation")
325 public static boolean isMergable(ItemStack a, ItemStack b) {
326 if (is(a) && is(b)) {
327 if (!a.getType().equals(b.getType())) {
328 return false;
329 }
330
331 if (a.getData().getData() != b.getData().getData()) {
332 return false;
333 }
334
335 if (a.hasItemMeta() != b.hasItemMeta()) {
336 return false;
337 }
338
339 if (a.getDurability() != b.getDurability()) {
340 return false;
341 }
342
343 if (a.hasItemMeta()) {
344 if (!a.getItemMeta().getDisplayName().equals(b.getItemMeta().getDisplayName())) {
345 return false;
346 }
347
348 if (!new ArrayList<String>(a.getItemMeta().getLore()).equals(new ArrayList<>(b.getItemMeta().getLore()))) {
349 return false;
350 }
351 }
352
353 return a.getMaxStackSize() >= a.getAmount() + b.getAmount();
354 }
355
356 return false;
357 }
358}

Callers 1

hasSpaceMethod · 0.95

Calls 9

isMethod · 0.95
getDurabilityMethod · 0.80
getItemMetaMethod · 0.80
getMaxStackSizeMethod · 0.80
getTypeMethod · 0.65
getDataMethod · 0.65
getDisplayNameMethod · 0.65
getLoreMethod · 0.65
equalsMethod · 0.45

Tested by

no test coverage detected