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

Merge pull request #457 from MrPanda8/dev

fix Snowy Block and Surface Spreading Block
This commit is contained in:
XiaoMoMi
2025-11-14 14:58:23 +08:00
committed by GitHub
2 changed files with 28 additions and 6 deletions

View File

@@ -30,7 +30,8 @@ public class SnowyBlockBehavior extends BukkitBlockBehavior {
if (args[updateShape$direction] != CoreReflections.instance$Direction$UP) return superMethod.call();
ImmutableBlockState state = BlockStateUtils.getOptionalCustomBlockState(args[0]).orElse(null);
if (state == null || state.isEmpty()) return superMethod.call();
return state.with(this.snowyProperty, isSnowySetting(args[updateShape$neighborState]));
ImmutableBlockState newState = state.with(this.snowyProperty, isSnowySetting(args[updateShape$neighborState]));
return newState.customBlockState().literalObject();
}
@Override

View File

@@ -40,13 +40,34 @@ public class SurfaceSpreadingBlockBehavior extends BukkitBlockBehavior {
return;
}
if (FastNMS.INSTANCE.method$LevelReader$getMaxLocalRawBrightness(level, FastNMS.INSTANCE.method$BlockPos$relative(pos, CoreReflections.instance$Direction$UP)) < this.requiredLight) return;
ImmutableBlockState blockState = this.block().defaultState();
BooleanProperty snowy = (BooleanProperty) this.block().getProperty("snowy");
for (int i = 0; i < 4; i++) {
Object blockPos = FastNMS.INSTANCE.method$BlockPos$offset(pos, RandomUtils.generateRandomInt(-1, 2), RandomUtils.generateRandomInt(-3, 2), RandomUtils.generateRandomInt(-1, 2));
if (FastNMS.INSTANCE.method$BlockStateBase$isBlock(FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, blockPos), FastNMS.INSTANCE.method$BlockState$getBlock(this.baseBlock.get())) && canPropagate(state, level, blockPos)) {
if (snowy != null) blockState = blockState.with(snowy, FastNMS.INSTANCE.method$BlockStateBase$isBlock(FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, FastNMS.INSTANCE.method$BlockPos$relative(pos, CoreReflections.instance$Direction$UP)), MBlocks.SNOW));
FastNMS.INSTANCE.method$LevelWriter$setBlock(level, blockPos, blockState.customBlockState().literalObject(), 3);
Object blockPos = FastNMS.INSTANCE.method$BlockPos$offset(
pos,
RandomUtils.generateRandomInt(-1, 2),
RandomUtils.generateRandomInt(-3, 2),
RandomUtils.generateRandomInt(-1, 2)
);
if (FastNMS.INSTANCE.method$BlockStateBase$isBlock(
FastNMS.INSTANCE.method$BlockGetter$getBlockState(level, blockPos),
FastNMS.INSTANCE.method$BlockState$getBlock(this.baseBlock.get())
) && canPropagate(state, level, blockPos)) {
ImmutableBlockState newState = this.block().defaultState();
if (snowy != null) {
boolean hasSnow = FastNMS.INSTANCE.method$BlockStateBase$isBlock(
FastNMS.INSTANCE.method$BlockGetter$getBlockState(level,
FastNMS.INSTANCE.method$BlockPos$relative(blockPos, CoreReflections.instance$Direction$UP)),
MBlocks.SNOW
);
newState = newState.with(snowy, hasSnow);
}
FastNMS.INSTANCE.method$LevelWriter$setBlock(level, blockPos, newState.customBlockState().literalObject(), 3);
}
}
}