9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

修正低版本onPlace onRemove

This commit is contained in:
XiaoMoMi
2025-08-24 17:41:25 +08:00
parent 42f890a6bf
commit 8fd9a739ef
3 changed files with 10 additions and 15 deletions

View File

@@ -105,7 +105,6 @@ public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
if (signalForState == 0) {
this.checkPressed(args[3], args[1], args[2], state, signalForState, thisBlock);
} else {
// todo 为什么
FastNMS.INSTANCE.method$ScheduledTickAccess$scheduleBlockTick(args[1], args[2], thisBlock, this.pressedTime);
}
}

View File

@@ -106,14 +106,7 @@ public final class BlockGenerator {
.method(ElementMatchers.is(CoreReflections.method$BlockBehaviour$randomTick))
.intercept(MethodDelegation.to(RandomTickInterceptor.INSTANCE))
// onPlace
.method(ElementMatchers.takesArguments(5)
.and(ElementMatchers.takesArgument(0, CoreReflections.clazz$BlockState))
.and(ElementMatchers.takesArgument(1, CoreReflections.clazz$Level))
.and(ElementMatchers.takesArgument(2, CoreReflections.clazz$BlockPos))
.and(ElementMatchers.takesArgument(3, CoreReflections.clazz$BlockState))
.and(ElementMatchers.takesArgument(4, boolean.class))
.and(ElementMatchers.named("onPlace").or(ElementMatchers.named("a")))
)
.method(ElementMatchers.is(CoreReflections.method$BlockBehaviour$onPlace))
.intercept(MethodDelegation.to(OnPlaceInterceptor.INSTANCE))
// onBrokenAfterFall
.method(ElementMatchers.takesArguments(3)

View File

@@ -3458,6 +3458,11 @@ public final class CoreReflections {
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, void.class, new String[]{"randomTick", "b"}, clazz$BlockState, clazz$ServerLevel, clazz$BlockPos, clazz$RandomSource)
);
public static final Method method$BlockBehaviour$onPlace = requireNonNull(
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, void.class, new String[]{"onPlace", VersionHelper.isOrAbove1_21_5() ? "a" : "b"},
clazz$BlockState, clazz$Level, clazz$BlockPos, clazz$BlockState, boolean.class)
);
public static final Class<?> clazz$InsideBlockEffectApplier = BukkitReflectionUtils.findReobfOrMojmapClass(
"world.entity.InsideBlockEffectApplier",
"world.entity.InsideBlockEffectApplier"
@@ -4005,15 +4010,13 @@ public final class CoreReflections {
ReflectionUtils.getStaticMethod(clazz$ArmorTrim, Optional.class, clazz$RegistryAccess, clazz$ItemStack);
public static final Method method$BlockBehaviour$spawnAfterBreak = requireNonNull(
ReflectionUtils.getDeclaredMethod(
clazz$BlockBehaviour, void.class, clazz$BlockState, clazz$ServerLevel, clazz$BlockPos, clazz$ItemStack, boolean.class
)
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, void.class, clazz$BlockState, clazz$ServerLevel, clazz$BlockPos, clazz$ItemStack, boolean.class)
);
// 1.20~1.21.4
public static final Method method$BlockBehaviour$onRemove = VersionHelper.isOrAbove1_21_5() ? null :
ReflectionUtils.getDeclaredMethod(
clazz$BlockBehaviour, void.class, clazz$BlockState, clazz$Level, clazz$BlockPos, clazz$BlockState, boolean.class
public static final Method method$BlockBehaviour$onRemove = MiscUtils.requireNonNullIf(
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, void.class, new String[]{"a", "onRemove"}, clazz$BlockState, clazz$Level, clazz$BlockPos, clazz$BlockState, boolean.class),
!VersionHelper.isOrAbove1_21_5()
);
public static final Object instance$CollisionContext$empty;