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

refactor(block): 优化方块

This commit is contained in:
jhqwqmc
2025-09-10 09:55:03 +08:00
parent da6acea474
commit 837ac97482
11 changed files with 6 additions and 16 deletions

View File

@@ -7,6 +7,8 @@ import net.momirealms.craftengine.core.block.CustomBlock;
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import net.momirealms.craftengine.core.util.VersionHelper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.Map;
import java.util.concurrent.Callable;

View File

@@ -49,7 +49,7 @@ public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
@Override
public void onPlace(Object thisBlock, Object[] args, Callable<Object> superMethod) {
if (this.canOpenWithHand) return;
if (this.poweredProperty == null) return;
Object state = args[0];
Object level = args[1];
Object pos = args[2];
@@ -63,7 +63,7 @@ public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
@Override
public void neighborChanged(Object thisBlock, Object[] args, Callable<Object> superMethod) {
if (this.canOpenWithHand) return;
if (this.poweredProperty == null) return;
Object blockState = args[0];
Object world = args[1];
if (!CoreReflections.clazz$ServerLevel.isInstance(world)) return;
@@ -91,9 +91,9 @@ public class ToggleableLampBlockBehavior extends BukkitBlockBehavior {
public static class Factory implements BlockBehaviorFactory {
@Override
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.toggleable_lamp.missing_lit");
Property<Boolean> powered = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.toggleable_lamp.missing_powered");
boolean canOpenWithHand = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("can-open-with-hand", false), "can-open-with-hand");
Property<Boolean> lit = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("lit"), "warning.config.block.behavior.toggleable_lamp.missing_lit");
Property<Boolean> powered = (Property<Boolean>) (canOpenWithHand ? block.getProperty("powered") : ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("powered"), "warning.config.block.behavior.toggleable_lamp.missing_powered"));
return new ToggleableLampBlockBehavior(block, lit, powered, canOpenWithHand);
}
}

View File

@@ -1,6 +1,4 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"texture_size": [32, 32],
"textures": {
"0": "item/custom/cap",

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"textures": {
"1": "item/custom/flower_basket",
"particle": "item/custom/flower_basket"

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/flower_basket"
},

View File

@@ -1,6 +1,4 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/flower_basket"
},

View File

@@ -1,6 +1,4 @@
{
"format_version": "1.21.6",
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/sofa",
"particle": "item/custom/sofa"

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/sofa",
"particle": "item/custom/sofa"

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"0": "item/custom/sofa",

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/topaz_trident_3d",
"particle": "item/custom/topaz_trident_3d"

View File

@@ -1,5 +1,4 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "item/custom/topaz_trident_3d",
"particle": "item/custom/topaz_trident_3d"