mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
Merge branch 'Xiao-MoMi:dev' into dev
This commit is contained in:
@@ -20,7 +20,6 @@ import net.momirealms.craftengine.core.world.BlockPos;
|
||||
import net.momirealms.craftengine.core.world.Vec3d;
|
||||
import net.momirealms.sparrow.nbt.CompoundTag;
|
||||
import net.momirealms.sparrow.nbt.ListTag;
|
||||
import net.momirealms.sparrow.nbt.Tag;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameEvent;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -31,7 +30,6 @@ import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SimpleStorageBlockEntity extends BlockEntity {
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.momirealms.craftengine.core.entity.furniture.*;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkRefl
|
||||
import net.momirealms.craftengine.core.entity.furniture.*;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityType
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkReflections;
|
||||
import net.momirealms.craftengine.core.entity.furniture.*;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflect
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
|
||||
import net.momirealms.craftengine.core.entity.furniture.*;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.world.Vec3d;
|
||||
import net.momirealms.craftengine.core.world.WorldPosition;
|
||||
|
||||
@@ -190,7 +190,6 @@ public class UniversalItemFactory extends BukkitItemFactory<LegacyItemWrapper> {
|
||||
|
||||
@Override
|
||||
protected void maxDamage(LegacyItemWrapper item, Integer damage) {
|
||||
throw new UnsupportedOperationException("This feature is only available on 1.20.5+");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
@@ -318,10 +318,9 @@ public class RecipeEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -373,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;
|
||||
}
|
||||
|
||||
@@ -494,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