9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

fix SurfaceSpreadingBlockBehavior.java

Improved compatibility with Snowy Block
This commit is contained in:
MrPanda8
2025-11-14 00:38:55 +03:00
committed by GitHub
parent f549438a75
commit 96a92221b2

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);
}
}
}