!MMOItems no longer fulfill vanilla item requirements in crafting

This commit is contained in:
Gunging 2021-03-27 00:03:10 -05:00
parent 2ed5c9896c
commit 3b9a068314
3 changed files with 38 additions and 3 deletions

View File

@ -194,7 +194,7 @@ public class MMOItemTemplate extends PostLoadObject implements ItemReference {
* <p></p>
* Default is <b>1</b> obviously.
*
* @deprecated Dont use this method, the Crafted Amount Stat will be deleted in the near future.
* @deprecated Don't use this method, the Crafted Amount Stat will be deleted in the near future.
*/
@Deprecated
public int getCraftedAmount() {
@ -205,8 +205,10 @@ public class MMOItemTemplate extends PostLoadObject implements ItemReference {
// Found?
if (ofAmount != null) {
int s = SilentNumbers.ceil(ofAmount.calculate(0));
// Well what does it read
return SilentNumbers.ceil(ofAmount.calculate(0));
return s;
}
// No

View File

@ -199,7 +199,9 @@ public class MMOItemUIFilter implements UIFilter {
*/
public static void register() {
global = new MMOItemUIFilter();
UIFilterManager.registerUIFilter(global); }
UIFilterManager.registerUIFilter(global);
VanillaMMOItemCountermatch.enable();
}
/**
* @return The general instance of this MMOItem UIFilter.

View File

@ -0,0 +1,31 @@
package net.Indyuce.mmoitems.api.recipe;
import io.lumine.mythic.lib.api.crafting.uifilters.VanillaUIFilter;
import io.lumine.mythic.lib.api.crafting.uimanager.UIFilterCountermatch;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* To make MMOItems not match as vanilla items (bruh)
*/
public class VanillaMMOItemCountermatch implements UIFilterCountermatch {
/**
* Activates this Counter Match, to prevent MMOItems from matching as vanilla items.
*/
public static void enable() {
// Activate
VanillaUIFilter.get().addMatchOverride(new VanillaMMOItemCountermatch());
}
@Override
public boolean preventsMatching(@NotNull ItemStack itemStack, @Nullable FriendlyFeedbackProvider friendlyFeedbackProvider) {
// Does it have type? Then cancel lma0
return NBTItem.get(itemStack).hasType();
}
}