mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
重命名成表面扩散方块行为
This commit is contained in:
@@ -44,7 +44,7 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
|
||||
public static final Key CHIME_BLOCK = Key.from("craftengine:chime_block");
|
||||
public static final Key BUDDING_BLOCK = Key.from("craftengine:budding_block");
|
||||
public static final Key SEAT_BLOCK = Key.from("craftengine:seat_block");
|
||||
public static final Key SPREADING_BLOCK = Key.from("craftengine:spreading_block");
|
||||
public static final Key SURFACE_SPREADING_BLOCK = Key.from("craftengine:surface_spreading_block");
|
||||
public static final Key SNOWY_BLOCK = Key.from("craftengine:snowy_block");
|
||||
|
||||
public static void init() {
|
||||
@@ -88,7 +88,7 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
|
||||
register(CHIME_BLOCK, ChimeBlockBehavior.FACTORY);
|
||||
register(BUDDING_BLOCK, BuddingBlockBehavior.FACTORY);
|
||||
register(SEAT_BLOCK, SeatBlockBehavior.FACTORY);
|
||||
register(SPREADING_BLOCK, SpreadingBlockBehavior.FACTORY);
|
||||
register(SURFACE_SPREADING_BLOCK, SurfaceSpreadingBlockBehavior.FACTORY);
|
||||
register(SNOWY_BLOCK, SnowyBlockBehavior.FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||
public class SurfaceSpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||
public static final Factory FACTORY = new Factory();
|
||||
private final int spreadLight;
|
||||
private final LazyReference<Object> spreadBlock;
|
||||
private final int requiredLight;
|
||||
private final LazyReference<Object> baseBlock;
|
||||
|
||||
public SpreadingBlockBehavior(CustomBlock customBlock, int spreadLight, String spreadBlock) {
|
||||
public SurfaceSpreadingBlockBehavior(CustomBlock customBlock, int requiredLight, String baseBlock) {
|
||||
super(customBlock);
|
||||
this.spreadLight = spreadLight;
|
||||
this.spreadBlock = LazyReference.lazyReference(() -> Objects.requireNonNull(BukkitBlockManager.instance().createBlockState(spreadBlock)).literalObject());
|
||||
this.requiredLight = requiredLight;
|
||||
this.baseBlock = LazyReference.lazyReference(() -> Objects.requireNonNull(BukkitBlockManager.instance().createBlockState(baseBlock)).literalObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,15 +36,15 @@ public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||
Object level = args[1];
|
||||
Object pos = args[2];
|
||||
if (!canBeGrass(state, level, pos)) {
|
||||
FastNMS.INSTANCE.method$LevelWriter$setBlock(level, pos, this.spreadBlock.get(), 3);
|
||||
FastNMS.INSTANCE.method$LevelWriter$setBlock(level, pos, this.baseBlock.get(), 3);
|
||||
return;
|
||||
}
|
||||
if (FastNMS.INSTANCE.method$LevelReader$getMaxLocalRawBrightness(level, FastNMS.INSTANCE.method$BlockPos$relative(pos, CoreReflections.instance$Direction$UP)) < this.spreadLight) 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.spreadBlock.get())) && canPropagate(state, level, blockPos)) {
|
||||
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);
|
||||
}
|
||||
@@ -82,9 +82,9 @@ public class SpreadingBlockBehavior extends BukkitBlockBehavior {
|
||||
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
int spreadLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("spread-light", 9), "spread-light");
|
||||
String spreadBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("spread-block", "minecraft:dirt"), "warning.config.block.behavior.spreading.missing_spread_block");
|
||||
return new SpreadingBlockBehavior(block, spreadLight, spreadBlock);
|
||||
int requiredLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("required-light", 9), "required-light");
|
||||
String baseBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.getOrDefault("base-block", "minecraft:dirt"), "warning.config.block.behavior.surface_spreading.missing_base_block");
|
||||
return new SurfaceSpreadingBlockBehavior(block, requiredLight, baseBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,7 +353,7 @@ warning.config.block.behavior.attached_stem.missing_facing: "<yellow>Issue found
|
||||
warning.config.block.behavior.attached_stem.missing_fruit: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'fruit' argument for 'attached_stem_block' behavior.</yellow>"
|
||||
warning.config.block.behavior.attached_stem.missing_stem: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'stem' argument for 'attached_stem_block' behavior.</yellow>"
|
||||
warning.config.block.behavior.chime.missing_sounds_projectile_hit: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'sounds.projectile-hit' argument for 'chime_block' behavior.</yellow>"
|
||||
warning.config.block.behavior.spreading.missing_spread_block: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'spread-block' argument for 'spreading_block' behavior.</yellow>"
|
||||
warning.config.block.behavior.surface_spreading.missing_base_block: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'base-block' argument for 'surface_spreading_block' behavior.</yellow>"
|
||||
warning.config.block.behavior.snowy.missing_snowy: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'snowy' property for 'snowy_block' behavior.</yellow>"
|
||||
warning.config.model.generation.missing_parent: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is missing the required 'parent' argument in 'generation' section.</yellow>"
|
||||
warning.config.model.generation.conflict: "<yellow>Issue found in file <arg:0> - Failed to generate model for '<arg:1>' as two or more configurations attempt to generate different json models with the same path: '<arg:2>'.</yellow>"
|
||||
|
||||
@@ -353,7 +353,7 @@ warning.config.block.behavior.attached_stem.missing_facing: "<yellow>在文件 <
|
||||
warning.config.block.behavior.attached_stem.missing_fruit: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'attached_stem_block' 行为缺少必需的 'fruit' 选项</yellow>"
|
||||
warning.config.block.behavior.attached_stem.missing_stem: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'attached_stem_block' 行为缺少必需的 'stem' 选项</yellow>"
|
||||
warning.config.block.behavior.chime.missing_sounds_projectile_hit: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'chime_block' 行为缺少必需的 'sounds.projectile-hit' 选项</yellow>"
|
||||
warning.config.block.behavior.spreading.missing_spread_block: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'spreading_block' 行为缺少必需的 'spread-block' 选项</yellow>"
|
||||
warning.config.block.behavior.surface_spreading.missing_base_block: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'surface_spreading_block' 行为缺少必需的 'base-block' 选项</yellow>"
|
||||
warning.config.block.behavior.snowy.missing_snowy: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'snowy_block' 行为缺少必需的 'snowy' 属性</yellow>"
|
||||
warning.config.model.generation.missing_parent: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 的 'generation' 段落缺少必需的 'parent' 参数</yellow>"
|
||||
warning.config.model.generation.conflict: "<yellow>在文件 <arg:0> 发现问题 - 无法为 '<arg:1>' 生成模型 存在多个配置尝试使用相同路径 '<arg:2>' 生成不同的 JSON 模型</yellow>"
|
||||
|
||||
Reference in New Issue
Block a user