mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 21:06:31 +00:00
添加1.20.1 mod
This commit is contained in:
@@ -342,25 +342,21 @@ public class BlockEventListener implements Listener {
|
||||
if (!this.enableNoteBlockCheck) return;
|
||||
// for vanilla blocks
|
||||
if (event.getChangedType() == Material.NOTE_BLOCK) {
|
||||
try {
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
Location location = block.getLocation();
|
||||
Block sourceBlock = event.getSourceBlock();
|
||||
BlockFace direction = sourceBlock.getFace(block);
|
||||
if (direction == BlockFace.UP || direction == BlockFace.DOWN) {
|
||||
Object serverLevel = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(world);
|
||||
Object chunkSource = FastNMS.INSTANCE.method$ServerLevel$getChunkSource(serverLevel);
|
||||
Object blockPos = LocationUtils.toBlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
FastNMS.INSTANCE.method$ServerChunkCache$blockChanged(chunkSource, blockPos);
|
||||
if (direction == BlockFace.UP) {
|
||||
NoteBlockChainUpdateUtils.noteBlockChainUpdate(serverLevel, chunkSource, Reflections.instance$Direction$UP, blockPos, 0);
|
||||
} else {
|
||||
NoteBlockChainUpdateUtils.noteBlockChainUpdate(serverLevel, chunkSource, Reflections.instance$Direction$DOWN, blockPos, 0);
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
Location location = block.getLocation();
|
||||
Block sourceBlock = event.getSourceBlock();
|
||||
BlockFace direction = sourceBlock.getFace(block);
|
||||
if (direction == BlockFace.UP || direction == BlockFace.DOWN) {
|
||||
Object serverLevel = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(world);
|
||||
Object chunkSource = FastNMS.INSTANCE.method$ServerLevel$getChunkSource(serverLevel);
|
||||
Object blockPos = LocationUtils.toBlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
FastNMS.INSTANCE.method$ServerChunkCache$blockChanged(chunkSource, blockPos);
|
||||
if (direction == BlockFace.UP) {
|
||||
NoteBlockChainUpdateUtils.noteBlockChainUpdate(serverLevel, chunkSource, Reflections.instance$Direction$UP, blockPos, 0);
|
||||
} else {
|
||||
NoteBlockChainUpdateUtils.noteBlockChainUpdate(serverLevel, chunkSource, Reflections.instance$Direction$DOWN, blockPos, 0);
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
plugin.logger().warn("Failed to sync note block states", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
newBlockState = getOnlyBlockState(newRealBlock);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Optional<Object> optionalHolder = (Optional<Object>) Reflections.method$Registry$getHolder0.invoke(Reflections.instance$BuiltInRegistries$BLOCK, resourceLocation);
|
||||
Optional<Object> optionalHolder = (Optional<Object>) Reflections.method$Registry$getHolder1.invoke(Reflections.instance$BuiltInRegistries$BLOCK, Reflections.method$ResourceKey$create.invoke(null, Reflections.instance$Registries$BLOCK, resourceLocation));
|
||||
blockHolder = optionalHolder.get();
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ConcretePowderBlockBehavior extends FallingBlockBehavior {
|
||||
if (direction != Reflections.instance$Direction$DOWN || canSolidify(blockState)) {
|
||||
Reflections.method$MutableBlockPos$setWithOffset.invoke(mutablePos, pos, direction);
|
||||
blockState = FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, mutablePos);
|
||||
if (canSolidify(blockState) && !(boolean) Reflections.method$BlockStateBase$isFaceSturdy.invoke(blockState, level, pos, Reflections.getOppositeDirection(direction), Reflections.instance$SupportType$FULL)) {
|
||||
if (canSolidify(blockState) && !(boolean) Reflections.method$BlockStateBase$isFaceSturdy.invoke(blockState, level, pos, FastNMS.INSTANCE.method$Direction$getOpposite(direction), Reflections.instance$SupportType$FULL)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
this.debugStickListener = new DebugStickListener(plugin);
|
||||
this.itemParser = new ItemParser();
|
||||
this.registerAllVanillaItems();
|
||||
if (plugin.hasMod() && VersionHelper.isVersionNewerThan1_20_5()) {
|
||||
if (plugin.hasMod()) {
|
||||
Class<?> clazz$CustomStreamCodec = ReflectionUtils.getClazz("net.momirealms.craftengine.mod.item.CustomStreamCodec");
|
||||
if (clazz$CustomStreamCodec != null) {
|
||||
Field s2cProcessor = ReflectionUtils.getDeclaredField(clazz$CustomStreamCodec, Function.class, 0);
|
||||
|
||||
@@ -7,9 +7,9 @@ public class NoteBlockChainUpdateUtils {
|
||||
|
||||
private NoteBlockChainUpdateUtils() {}
|
||||
|
||||
public static void noteBlockChainUpdate(Object level, Object chunkSource, Object direction, Object blockPos, int times) throws ReflectiveOperationException {
|
||||
public static void noteBlockChainUpdate(Object level, Object chunkSource, Object direction, Object blockPos, int times) {
|
||||
if (times >= Config.maxChainUpdate()) return;
|
||||
Object relativePos = Reflections.method$BlockPos$relative.invoke(blockPos, direction);
|
||||
Object relativePos = FastNMS.INSTANCE.method$BlockPos$relative(blockPos, direction);
|
||||
Object state = FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, relativePos);
|
||||
if (BlockStateUtils.isClientSideNoteBlock(state)) {
|
||||
FastNMS.INSTANCE.method$ServerChunkCache$blockChanged(chunkSource, relativePos);
|
||||
|
||||
@@ -1522,7 +1522,6 @@ public class Reflections {
|
||||
public static final Object instance$Direction$WEST;
|
||||
public static final Object instance$Direction$EAST;
|
||||
public static final Object[] instance$Directions;
|
||||
private static final Map<Object, Object> oppositeDirections = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -1533,20 +1532,14 @@ public class Reflections {
|
||||
instance$Direction$SOUTH = instance$Directions[3];
|
||||
instance$Direction$WEST = instance$Directions[4];
|
||||
instance$Direction$EAST = instance$Directions[5];
|
||||
oppositeDirections.put(instance$Direction$DOWN, instance$Direction$UP);
|
||||
oppositeDirections.put(instance$Direction$UP, instance$Direction$DOWN);
|
||||
oppositeDirections.put(instance$Direction$NORTH, instance$Direction$SOUTH);
|
||||
oppositeDirections.put(instance$Direction$SOUTH, instance$Direction$NORTH);
|
||||
oppositeDirections.put(instance$Direction$WEST, instance$Direction$EAST);
|
||||
oppositeDirections.put(instance$Direction$EAST, instance$Direction$WEST);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getOppositeDirection(Object direction) {
|
||||
return oppositeDirections.get(direction);
|
||||
}
|
||||
// public static Object getOppositeDirection(Object direction) {
|
||||
// return oppositeDirections.get(direction);
|
||||
// }
|
||||
|
||||
public static final Class<?> clazz$CraftBlock = requireNonNull(
|
||||
ReflectionUtils.getClazz(
|
||||
|
||||
Reference in New Issue
Block a user