9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +00:00
This commit is contained in:
jhqwqmc
2025-09-20 02:32:12 +08:00
parent 3218d91707
commit 862203ca2a
2 changed files with 8 additions and 12 deletions

View File

@@ -20,7 +20,6 @@ import net.momirealms.craftengine.bukkit.compatibility.worldedit.WorldEditBlockR
import net.momirealms.craftengine.bukkit.font.BukkitFontManager; import net.momirealms.craftengine.bukkit.font.BukkitFontManager;
import net.momirealms.craftengine.bukkit.item.BukkitItemManager; import net.momirealms.craftengine.bukkit.item.BukkitItemManager;
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine; import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
import net.momirealms.craftengine.bukkit.util.KeyUtils;
import net.momirealms.craftengine.core.entity.furniture.ExternalModel; import net.momirealms.craftengine.core.entity.furniture.ExternalModel;
import net.momirealms.craftengine.core.entity.player.Player; import net.momirealms.craftengine.core.entity.player.Player;
import net.momirealms.craftengine.core.loot.LootConditions; import net.momirealms.craftengine.core.loot.LootConditions;
@@ -33,7 +32,6 @@ import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.VersionHelper; import net.momirealms.craftengine.core.util.VersionHelper;
import net.momirealms.craftengine.core.world.WorldManager; import net.momirealms.craftengine.core.world.WorldManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Registry;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.*; import java.util.*;
@@ -252,8 +250,6 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
weBlockRegister.register(newBlockId); weBlockRegister.register(newBlockId);
} }
} catch (Exception e) { } catch (Exception e) {
// 检查是不是有插件干预了注册表
if (Registry.MATERIAL.get(KeyUtils.toNamespacedKey(BukkitBlockManager.instance().blockRegisterOrder().getFirst())) != null) return;
this.plugin.logger().warn("Failed to initialize world edit hook", e); this.plugin.logger().warn("Failed to initialize world edit hook", e);
} }
} }

View File

@@ -243,14 +243,14 @@ public final class BlockStateGenerator {
@RuntimeType @RuntimeType
public boolean intercept(@This Object thisObj, @AllArguments Object[] args) { public boolean intercept(@This Object thisObj, @AllArguments Object[] args) {
DelegatingBlockState customState = (DelegatingBlockState) thisObj;
ImmutableBlockState thisState = customState.blockState();
if (thisState == null) return false;
CustomBlock thisBlock = thisState.owner().value();
Object block = FastNMS.INSTANCE.method$Holder$value(args[0]); Object block = FastNMS.INSTANCE.method$Holder$value(args[0]);
if (!(block instanceof DelegatingBlock delegatingBlock)) return false; if (!(block instanceof DelegatingBlock delegatingBlock)) return false;
BlockBehavior behavior = delegatingBlock.behaviorDelegate().value(); BlockBehavior behavior = delegatingBlock.behaviorDelegate().value();
if (behavior == null) return false; if (behavior == null) return false;
DelegatingBlockState customState = (DelegatingBlockState) thisObj;
ImmutableBlockState thisState = customState.blockState();
if (thisState == null) return false;
CustomBlock thisBlock = thisState.owner().value();
return behavior.block().equals(thisBlock); return behavior.block().equals(thisBlock);
} }
} }
@@ -260,16 +260,16 @@ public final class BlockStateGenerator {
@RuntimeType @RuntimeType
public boolean intercept(@This Object thisObj, @AllArguments Object[] args) { public boolean intercept(@This Object thisObj, @AllArguments Object[] args) {
DelegatingBlockState customState = (DelegatingBlockState) thisObj;
ImmutableBlockState thisState = customState.blockState();
if (thisState == null) return false;
CustomBlock thisBlock = thisState.owner().value();
Object block = FastNMS.INSTANCE.method$HolderGetter$getResourceKey(MBuiltInRegistries.BLOCK, args[0]) Object block = FastNMS.INSTANCE.method$HolderGetter$getResourceKey(MBuiltInRegistries.BLOCK, args[0])
.map(FastNMS.INSTANCE::method$Holder$value) .map(FastNMS.INSTANCE::method$Holder$value)
.orElse(null); .orElse(null);
if (!(block instanceof DelegatingBlock delegatingBlock)) return false; if (!(block instanceof DelegatingBlock delegatingBlock)) return false;
BlockBehavior behavior = delegatingBlock.behaviorDelegate().value(); BlockBehavior behavior = delegatingBlock.behaviorDelegate().value();
if (behavior == null) return false; if (behavior == null) return false;
DelegatingBlockState customState = (DelegatingBlockState) thisObj;
ImmutableBlockState thisState = customState.blockState();
if (thisState == null) return false;
CustomBlock thisBlock = thisState.owner().value();
return behavior.block().equals(thisBlock); return behavior.block().equals(thisBlock);
} }
} }