mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
fix(bukkit): 修复错误的方块实体
This commit is contained in:
@@ -849,9 +849,19 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
return states.get(0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void deceiveBukkit(Object newBlock, Key replacedBlock, boolean isNoteBlock) throws IllegalAccessException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Object, Material> magicMap = (Map<Object, Material>) Reflections.field$CraftMagicNumbers$BLOCK_MATERIAL.get(null);
|
||||
magicMap.put(newBlock, isNoteBlock ? Material.STONE : org.bukkit.Registry.MATERIAL.get(new NamespacedKey(replacedBlock.namespace(), replacedBlock.value())));
|
||||
Map<Material, Object> factories = (Map<Material, Object>) Reflections.field$CraftBlockStates$FACTORIES.get(null);
|
||||
if (isNoteBlock) {
|
||||
magicMap.put(newBlock, Material.STONE);
|
||||
} else {
|
||||
Material material = org.bukkit.Registry.MATERIAL.get(new NamespacedKey(replacedBlock.namespace(), replacedBlock.value()));
|
||||
if (Reflections.clazz$CraftBlockStates$BlockEntityStateFactory.isInstance(factories.get(material))) {
|
||||
magicMap.put(newBlock, Material.STONE);
|
||||
} else {
|
||||
magicMap.put(newBlock, material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6591,4 +6591,16 @@ public class Reflections {
|
||||
clazz$ServerboundResourcePackPacket, clazz$ServerboundResourcePackPacket$Action, 0
|
||||
)
|
||||
);
|
||||
|
||||
public static final Field field$CraftBlockStates$FACTORIES = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$CraftBlockStates, "FACTORIES"
|
||||
)
|
||||
);
|
||||
|
||||
public static final Class<?> clazz$CraftBlockStates$BlockEntityStateFactory = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
BukkitReflectionUtils.assembleCBClass("block.CraftBlockStates$BlockEntityStateFactory")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user