mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 20:09:13 +00:00
完善修复物品
This commit is contained in:
@@ -261,7 +261,6 @@ public class RecipeEventListener implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onAnvilEvent(PrepareAnvilEvent event) {
|
||||
if (event.getResult() == null) return;
|
||||
preProcess(event);
|
||||
processRepairable(event);
|
||||
processRename(event);
|
||||
@@ -271,6 +270,7 @@ public class RecipeEventListener implements Listener {
|
||||
预处理会阻止一些不合理的原版材质造成的合并问题
|
||||
*/
|
||||
private void preProcess(PrepareAnvilEvent event) {
|
||||
if (event.getResult() == null) return;
|
||||
AnvilInventory inventory = event.getInventory();
|
||||
ItemStack first = inventory.getFirstItem();
|
||||
ItemStack second = inventory.getSecondItem();
|
||||
@@ -320,7 +320,7 @@ public class RecipeEventListener implements Listener {
|
||||
|
||||
if (firstCustom.isPresent()) {
|
||||
CustomItem<ItemStack> firstCustomItem = firstCustom.get();
|
||||
if (firstCustomItem.settings().canRepair() == Tristate.FALSE) {
|
||||
if (firstCustomItem.settings().repairable().anvilCombine() == Tristate.FALSE) {
|
||||
event.setResult(null);
|
||||
return;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public class RecipeEventListener implements Listener {
|
||||
Key firstId = wrappedFirst.id();
|
||||
Optional<CustomItem<ItemStack>> optionalCustomTool = wrappedFirst.getCustomItem();
|
||||
// 物品无法被修复
|
||||
if (optionalCustomTool.isPresent() && optionalCustomTool.get().settings().canRepair() == Tristate.FALSE) {
|
||||
if (optionalCustomTool.isPresent() && optionalCustomTool.get().settings().repairable().anvilRepair() == Tristate.FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -493,6 +493,7 @@ public class RecipeEventListener implements Listener {
|
||||
*/
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
private void processRename(PrepareAnvilEvent event) {
|
||||
if (event.getResult() == null) return;
|
||||
AnvilInventory inventory = event.getInventory();
|
||||
ItemStack first = inventory.getFirstItem();
|
||||
if (ItemStackUtils.isEmpty(first)) {
|
||||
|
||||
@@ -89,11 +89,13 @@ public class BukkitCraftEngine extends CraftEngine {
|
||||
super.logger = logger;
|
||||
super.platform = new BukkitPlatform();
|
||||
super.scheduler = new BukkitSchedulerAdapter(this);
|
||||
Class<?> compatibilityClass = Objects.requireNonNull(ReflectionUtils.getClazz(COMPATIBILITY_CLASS), "Compatibility class not found");
|
||||
try {
|
||||
super.compatibilityManager = (CompatibilityManager) Objects.requireNonNull(ReflectionUtils.getConstructor(compatibilityClass, 0)).newInstance(this);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
logger().warn("Compatibility class could not be instantiated: " + compatibilityClass.getName());
|
||||
Class<?> compatibilityClass = ReflectionUtils.getClazz(COMPATIBILITY_CLASS);
|
||||
if (compatibilityClass != null) {
|
||||
try {
|
||||
super.compatibilityManager = (CompatibilityManager) Objects.requireNonNull(ReflectionUtils.getConstructor(compatibilityClass, 0)).newInstance(this);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
logger().warn("Compatibility class could not be instantiated: " + compatibilityClass.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ public final class RecipeInjector {
|
||||
if (input2.count() != 1 || !isDamageableItem(input2)) return false;
|
||||
if (!input1.id().equals(input2.id())) return false;
|
||||
Optional<CustomItem<ItemStack>> customItem = input1.getCustomItem();
|
||||
return customItem.isEmpty() || customItem.get().settings().canRepair() != Tristate.FALSE;
|
||||
return customItem.isEmpty() || customItem.get().settings().repairable().craftingTable() != Tristate.FALSE;
|
||||
}
|
||||
|
||||
private static boolean isDamageableItem(Item<ItemStack> item) {
|
||||
|
||||
Reference in New Issue
Block a user