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

准备压力板

This commit is contained in:
XiaoMoMi
2025-06-22 02:07:12 +08:00
parent bf190b30f1
commit 5ce430e596
11 changed files with 115 additions and 15 deletions

View File

@@ -25,6 +25,7 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
public static final Key FENCE_GATE_BLOCK = Key.from("craftengine:fence_gate_block");
public static final Key SLAB_BLOCK = Key.from("craftengine:slab_block");
public static final Key STAIRS_BLOCK = Key.from("craftengine:stairs_block");
public static final Key PRESSURE_PLATE_BLOCK = Key.from("craftengine:pressure_plate_block");
public static void init() {
register(EMPTY, (block, args) -> EmptyBlockBehavior.INSTANCE);
@@ -48,5 +49,6 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
register(FENCE_GATE_BLOCK, FenceGateBlockBehavior.FACTORY);
register(SLAB_BLOCK, SlabBlockBehavior.FACTORY);
register(STAIRS_BLOCK, StairsBlockBehavior.FACTORY);
register(PRESSURE_PLATE_BLOCK, PressurePlateBlockBehavior.FACTORY);
}
}

View File

@@ -0,0 +1,29 @@
package net.momirealms.craftengine.bukkit.block.behavior;
import net.momirealms.craftengine.core.block.BlockBehavior;
import net.momirealms.craftengine.core.block.CustomBlock;
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
import net.momirealms.craftengine.core.block.properties.Property;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import java.util.Map;
public class PressurePlateBlockBehavior extends BukkitBlockBehavior {
public static final Factory FACTORY = new Factory();
private final Property<Boolean> poweredProperty;
public PressurePlateBlockBehavior(CustomBlock block, Property<Boolean> poweredProperty) {
super(block);
this.poweredProperty = poweredProperty;
}
public static class Factory implements BlockBehaviorFactory {
@SuppressWarnings("unchecked")
@Override
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
Property<Boolean> powered = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.pressure_plate.missing_powered");
return new PressurePlateBlockBehavior(block, powered);
}
}
}

View File

@@ -1,9 +1,7 @@
package net.momirealms.craftengine.bukkit.plugin.command.feature;
import net.kyori.adventure.text.Component;
import net.momirealms.craftengine.bukkit.nms.FastNMS;
import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
import net.momirealms.craftengine.bukkit.plugin.injector.WorldStorageInjector;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
import net.momirealms.craftengine.core.plugin.command.sender.Sender;

View File

@@ -7,7 +7,6 @@ import com.mojang.serialization.DynamicOps;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.momirealms.craftengine.bukkit.block.behavior.BukkitBlockBehavior;
import net.momirealms.craftengine.bukkit.plugin.reflection.ReflectionInitException;
import net.momirealms.craftengine.bukkit.util.BukkitReflectionUtils;
import net.momirealms.craftengine.core.util.ReflectionUtils;

View File

@@ -62,14 +62,14 @@ resource-pack:
max: LATEST
# Remove 1.21.5+ tinted_leaves particles
remove-tinted-leaves-particle: true
# Remove all shaders
remove-all-shaders: false
merge-external-folders:
- ModelEngine/resource pack
- BetterModel/build
merge-external-zip-files:
- CustomNameplates/resourcepack.zip
exclude-file-extensions: ["md", "psd", "bbmodel", "db", "ini"]
# Exclude the shaders when generating the resource pack
exclude-shaders: false
delivery:
# Send the resource pack on joining the server
send-on-join: true

View File

@@ -567,7 +567,54 @@ items:
parent: minecraft:block/stairs
textures: *textures
default:palm_pressure_plate:
material: nether_brick
custom-model-data: 1014
model:
type: minecraft:model
path: minecraft:item/custom/palm_pressure_plate
generation:
parent: minecraft:block/custom/palm_pressure_plate
data:
item-name: <!i><i18n:item.palm_pressure_plate>
settings:
fuel-time: 300
behavior:
type: block_item
block:
loot:
template: default:loot_table/self
settings:
template:
- default:sound/wood
- default:hardness/planks
overrides:
burnable: true
map-color: 2
instrument: bass
tags:
- minecraft:mineable/axe
- minecraft:wall_post_override
- minecraft:wooden_pressure_plates
- minecraft:pressure_plates
behaviors:
type: pressure_plate_block
states:
template: default:block_state/pressure_plate
arguments:
normal_state: light_weighted_pressure_plate:0
powered_state: light_weighted_pressure_plate:1
normal_id: 0
powered_id: 1
model_normal_path: minecraft:block/custom/palm_pressure_plate
model_normal_generation:
parent: minecraft:block/pressure_plate_up
textures:
texture: minecraft:block/custom/palm_planks
model_powered_path: minecraft:block/custom/palm_pressure_plate_down
model_powered_generation:
parent: minecraft:block/pressure_plate_down
textures:
texture: minecraft:block/custom/palm_planks
recipes:
default:palm_planks:
template: default:recipe/planks

View File

@@ -3014,7 +3014,30 @@ templates#block_states:
resistance: 1200.0
burnable: false
fluid-state: water
# pressure plate block
default:block_state/pressure_plate:
properties:
powered:
type: boolean
default: false
appearances:
normal:
state: ${normal_state}
model:
path: ${model_normal_path}
generation: ${model_normal_generation}
powered:
state: ${powered_state}
model:
path: ${model_powered_path}
generation: ${model_powered_generation}
variants:
powered=false:
appearance: normal
id: ${normal_id}
powered=true:
appearance: powered
id: ${powered_id}
# recipes
templates#recipes:
default:recipe/planks:

View File

@@ -263,9 +263,10 @@ warning.config.block.behavior.fence_gate.missing_in_wall: "<yellow>Issue found i
warning.config.block.behavior.fence_gate.missing_open: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'powered' argument for 'fence_gate_block' behavior.</yellow>"
warning.config.block.behavior.fence_gate.missing_powered: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'open' argument for 'fence_gate_block' behavior.</yellow>"
warning.config.block.behavior.trapdoor.missing_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'type' property for 'slab_block' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_facing: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'facing' property for 'stairs' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_half: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'half' property for 'stairs' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_shape: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'shape' property for 'stairs' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_facing: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'facing' property for 'stairs_block' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_half: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'half' property for 'stairs_block' behavior.</yellow>"
warning.config.block.behavior.stairs.missing_shape: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'shape' property for 'stairs_block' behavior.</yellow>"
warning.config.block.behavior.pressure_plate.missing_powered: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'powered' property for 'pressure_plate_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.invalid_display_position: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid display position '<arg:2>' in 'generation.display' section. Allowed display positions: [<arg:3>]</yellow>"
warning.config.model.generation.invalid_gui_light: "<yellow>Issue found in file <arg:0> - The config '<arg:1>' is using an invalid gui-light option '<arg:2>' in 'generation' section. Allowed gui light options: [<arg:3>]</yellow>"

View File

@@ -266,6 +266,7 @@ warning.config.block.behavior.slab.missing_type: "<yellow>在文件 <arg:0> 发
warning.config.block.behavior.stairs.missing_facing: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'stairs_block' 行为缺少必需的 'facing' 属性</yellow>"
warning.config.block.behavior.stairs.missing_half: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'stairs_block' 行为缺少必需的 'half' 属性</yellow>"
warning.config.block.behavior.stairs.missing_shape: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'stairs_block' 行为缺少必需的 'shape' 属性</yellow>"
warning.config.block.behavior.pressure_plate.missing_powered: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'pressure_plate_block' 行为缺少必需的 'powered' 属性</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>"
warning.config.model.generation.invalid_display_position: "<yellow>在文件 <arg:0> 发现问题 - 配置项 '<arg:1>' 在 'generation.display' 区域使用了无效的 display 位置类型 '<arg:2>'. 可用展示类型: [<arg:3>]</yellow>"

View File

@@ -615,7 +615,7 @@ public abstract class AbstractPackManager implements PackManager {
this.generateClientLang(generatedPackPath);
this.generateEquipments(generatedPackPath);
this.generateParticle(generatedPackPath);
if (Config.removeAllShaders()) {
if (Config.excludeShaders()) {
this.removeAllShaders(generatedPackPath);
}
if (Config.validateResourcePack()) {

View File

@@ -60,7 +60,7 @@ public class Config {
protected boolean resource_pack$protection$crash_tools$method_3;
protected boolean resource_pack$validate$enable;
protected boolean resource_pack$remove_all_shaders;
protected boolean resource_pack$exclude_shaders;
protected boolean resource_pack$protection$obfuscation$enable;
protected long resource_pack$protection$obfuscation$seed;
@@ -263,7 +263,7 @@ public class Config {
resource_pack$protection$obfuscation$resource_location$bypass_sounds = config.getStringList("resource-pack.protection.obfuscation.resource-location.bypass-sounds");
resource_pack$protection$obfuscation$resource_location$bypass_equipments = config.getStringList("resource-pack.protection.obfuscation.resource-location.bypass-equipments");
resource_pack$validate$enable = config.getBoolean("resource-pack.validate.enable", true);
resource_pack$remove_all_shaders = config.getBoolean("resource-pack.remove-all-shaders", false);
resource_pack$exclude_shaders = config.getBoolean("resource-pack.exclude-shaders", false);
try {
resource_pack$duplicated_files_handler = config.getMapList("resource-pack.duplicated-files-handler").stream().map(it -> {
@@ -738,8 +738,8 @@ public class Config {
return instance.resource_pack$validate$enable;
}
public static boolean removeAllShaders() {
return instance.resource_pack$remove_all_shaders;
public static boolean excludeShaders() {
return instance.resource_pack$exclude_shaders;
}
public YamlDocument loadOrCreateYamlData(String fileName) {