9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-31 21:06:31 +00:00

统一大小写

This commit is contained in:
XiaoMoMi
2025-09-14 02:39:21 +08:00
parent aa893edc5a
commit c273a75871
17 changed files with 50 additions and 57 deletions

View File

@@ -32,7 +32,7 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
public static final Key TOGGLEABLE_LAMP_BLOCK = Key.from("craftengine:toggleable_lamp_block");
public static final Key SOFA_BLOCK = Key.from("craftengine:sofa_block");
public static final Key BOUNCING_BLOCK = Key.from("craftengine:bouncing_block");
public static final Key SURFACE_ATTACHED_BLOCK = Key.from("craftengine:surface_attached_block");
public static final Key DIRECTIONAL_ATTACHED_BLOCK = Key.from("craftengine:directional_attached_block");
public static void init() {
register(EMPTY, (block, args) -> EmptyBlockBehavior.INSTANCE);
@@ -63,6 +63,6 @@ public class BukkitBlockBehaviors extends BlockBehaviors {
register(TOGGLEABLE_LAMP_BLOCK, ToggleableLampBlockBehavior.FACTORY);
register(SOFA_BLOCK, SofaBlockBehavior.FACTORY);
register(BOUNCING_BLOCK, BouncingBlockBehavior.FACTORY);
register(SURFACE_ATTACHED_BLOCK, SurfaceAttachedBlockBehavior.FACTORY);
register(DIRECTIONAL_ATTACHED_BLOCK, DirectionalAttachedBlockBehavior.FACTORY);
}
}

View File

@@ -22,43 +22,42 @@ import net.momirealms.craftengine.core.world.World;
import java.util.Map;
import java.util.concurrent.Callable;
public class SurfaceAttachedBlockBehavior extends BukkitBlockBehavior {
public class DirectionalAttachedBlockBehavior extends BukkitBlockBehavior {
public static final Factory FACTORY = new Factory();
private final Property<?> facingProperty;
private final boolean isDirection;
private final boolean isSixDirection;
public SurfaceAttachedBlockBehavior(CustomBlock customBlock, Property<?> facingProperty, boolean isDirection) {
public DirectionalAttachedBlockBehavior(CustomBlock customBlock, Property<?> facingProperty, boolean isSixDirection) {
super(customBlock);
this.facingProperty = facingProperty;
this.isDirection = isDirection;
this.isSixDirection = isSixDirection;
}
@Override
public Object updateShape(Object thisBlock, Object[] args, Callable<Object> superMethod) throws Exception {
ImmutableBlockState state = BlockStateUtils.getOptionalCustomBlockState(args[0]).orElse(null);
if (state == null) return args[0];
SurfaceAttachedBlockBehavior behavior = state.behavior().getAs(SurfaceAttachedBlockBehavior.class).orElse(null);
DirectionalAttachedBlockBehavior behavior = state.behavior().getAs(DirectionalAttachedBlockBehavior.class).orElse(null);
if (behavior == null) return state;
boolean flag;
if (isDirection) {
if (isSixDirection) {
Direction direction = DirectionUtils.fromNMSDirection(args[updateShape$direction]).opposite();
flag = direction == state.get(behavior.facingProperty);
} else {
HorizontalDirection direction = DirectionUtils.fromNMSDirection(args[updateShape$direction]).opposite().toHorizontalDirection();
flag = direction == state.get(behavior.facingProperty);
}
return flag && !FastNMS.INSTANCE.method$BlockStateBase$canSurvive(args[0], args[updateShape$level], args[updateShape$blockPos])
? MBlocks.AIR$defaultState : args[0];
return flag && !FastNMS.INSTANCE.method$BlockStateBase$canSurvive(args[0], args[updateShape$level], args[updateShape$blockPos]) ? MBlocks.AIR$defaultState : args[0];
}
@Override
public boolean canSurvive(Object thisBlock, Object[] args, Callable<Object> superMethod) throws Exception {
ImmutableBlockState state = BlockStateUtils.getOptionalCustomBlockState(args[0]).orElse(null);
if (state == null) return false;
SurfaceAttachedBlockBehavior behavior = state.behavior().getAs(SurfaceAttachedBlockBehavior.class).orElse(null);
DirectionalAttachedBlockBehavior behavior = state.behavior().getAs(DirectionalAttachedBlockBehavior.class).orElse(null);
if (behavior == null) return false;
Direction direction;
if (isDirection) {
if (isSixDirection) {
direction = ((Direction) state.get(behavior.facingProperty)).opposite();
} else {
direction = ((HorizontalDirection) state.get(behavior.facingProperty)).opposite().toDirection();
@@ -72,12 +71,12 @@ public class SurfaceAttachedBlockBehavior extends BukkitBlockBehavior {
@SuppressWarnings("unchecked")
@Override
public ImmutableBlockState updateStateForPlacement(BlockPlaceContext context, ImmutableBlockState state) {
SurfaceAttachedBlockBehavior behavior = state.behavior().getAs(SurfaceAttachedBlockBehavior.class).orElse(null);
DirectionalAttachedBlockBehavior behavior = state.behavior().getAs(DirectionalAttachedBlockBehavior.class).orElse(null);
if (behavior == null) return null;
World level = context.getLevel();
BlockPos clickedPos = context.getClickedPos();
for (Direction direction : context.getNearestLookingDirections()) {
if (isDirection) {
if (isSixDirection) {
state = state.with((Property<Direction>) behavior.facingProperty, direction.opposite());
if (FastNMS.INSTANCE.method$BlockStateBase$canSurvive(state.customBlockState().literalObject(), level.serverWorld(), LocationUtils.toBlockPos(clickedPos))) {
return state;
@@ -102,7 +101,7 @@ public class SurfaceAttachedBlockBehavior extends BukkitBlockBehavior {
if (!(isHorizontalDirection || isDirection)) {
throw new LocalizedResourceConfigException("warning.config.block.behavior.surface_attached.missing_facing");
}
return new SurfaceAttachedBlockBehavior(block, facing, isDirection);
return new DirectionalAttachedBlockBehavior(block, facing, isDirection);
}
}
}

View File

@@ -204,13 +204,8 @@ public class SimpleStorageBlockBehavior extends BukkitBlockBehavior implements E
openSound = Optional.ofNullable(sounds.get("open")).map(obj -> SoundData.create(obj, SoundData.SoundValue.FIXED_0_5, SoundData.SoundValue.ranged(0.9f, 1f))).orElse(null);
closeSound = Optional.ofNullable(sounds.get("close")).map(obj -> SoundData.create(obj, SoundData.SoundValue.FIXED_0_5, SoundData.SoundValue.ranged(0.9f, 1f))).orElse(null);
}
Map<String, Object> hopperBehavior = (Map<String, Object>) arguments.get("hopper-behavior");
boolean canPlaceItem = true;
boolean canTakeItem = true;
if (hopperBehavior != null) {
canPlaceItem = ResourceConfigUtils.getAsBoolean(hopperBehavior.getOrDefault("allow-input", true), "allow-input");
canTakeItem = ResourceConfigUtils.getAsBoolean(hopperBehavior.getOrDefault("allow-output", true), "allow-output");
}
boolean canPlaceItem = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("allow-input", true), "allow-input");
boolean canTakeItem = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("allow-output", true), "allow-output");
Property<Boolean> property = (Property<Boolean>) block.getProperty("open");
return new SimpleStorageBlockBehavior(block, title, rows, openSound, closeSound, hasAnalogOutputSignal, canPlaceItem, canTakeItem, property);
}

View File

@@ -19,8 +19,8 @@ items:
resistance: 1.4
is-suffocating: true
is-redstone-conductor: true
push-reaction: PUSH_ONLY
instrument: BASEDRUM
push-reaction: push_only
instrument: basedrum
map-color: 36
sounds:
break: minecraft:block.stone.break

View File

@@ -21,8 +21,8 @@ items:
- default:sound/wood
- default:settings/solid_1x1x1
overrides:
push-reaction: NORMAL
instrument: HARP
push-reaction: normal
instrument: harp
luminance: 15
map-color: 36
state:

View File

@@ -24,7 +24,7 @@ items:
replaceable: false
is-redstone-conductor: true
is-suffocating: true
instrument: BASEDRUM
instrument: basedrum
map-color: 15
behavior:
type: lamp_block

View File

@@ -19,7 +19,7 @@ blocks:
- default:sound/grass
overrides:
item: default:ender_pearl_flower_seeds
push-reaction: DESTROY
push-reaction: destroy
map-color: 24
is-randomly-ticking: true
behaviors:

View File

@@ -17,7 +17,7 @@ items:
- default:sound/grass
overrides:
item: default:fairy_flower
push-reaction: DESTROY
push-reaction: destroy
map-color: 19
behavior:
type: bush_block

View File

@@ -16,7 +16,7 @@ items:
- default:hardness/none
- default:sound/grass
overrides:
push-reaction: DESTROY
push-reaction: destroy
map-color: 15
is-randomly-ticking: true
behaviors:

View File

@@ -25,7 +25,7 @@ items:
overrides:
hardness: 0.5
resistance: 0.5
instrument: SNARE
instrument: snare
map-color: 45
state:
id: 16
@@ -59,7 +59,7 @@ items:
overrides:
hardness: 1.8
resistance: 1.8
instrument: BASEDRUM
instrument: basedrum
map-color: 45
state:
id: 17

View File

@@ -44,7 +44,7 @@ items:
map-color: 29
hardness: 10.0
resistance: 1200
push-reaction: BLOCK
push-reaction: block
states:
properties:
facing_clockwise:

View File

@@ -363,7 +363,7 @@ items:
template:
- default:sound/wood
overrides:
push-reaction: DESTROY
push-reaction: destroy
map-color: 2
instrument: bass
hardness: 3.0
@@ -588,7 +588,7 @@ items:
- default:hardness/planks
overrides:
burnable: true
push-reaction: DESTROY
push-reaction: destroy
map-color: 2
instrument: bass
tags:

View File

@@ -17,7 +17,7 @@ items:
- default:hardness/none
overrides:
map-color: 11
push-reaction: DESTROY
push-reaction: destroy
behaviors:
- type: sturdy_base_block
direction: down

View File

@@ -16,7 +16,7 @@ items:
- default:hardness/none
- default:sound/grass
overrides:
push-reaction: DESTROY
push-reaction: destroy
map-color: 60
behavior:
type: on_liquid_block

View File

@@ -19,8 +19,8 @@ items:
resistance: 1200
is-suffocating: true
is-redstone-conductor: true
push-reaction: BLOCK
instrument: BASEDRUM
push-reaction: block
instrument: basedrum
map-color: 6
sounds:
break: minecraft:block.stone.break
@@ -35,9 +35,8 @@ items:
sounds:
open: minecraft:block.iron_trapdoor.open
close: minecraft:block.iron_trapdoor.close
hopper-behavior:
allow-input: true
allow-output: false
allow-input: true
allow-output: false
states:
properties:
facing:

View File

@@ -21,8 +21,8 @@ items:
burnable: true
is-suffocating: false
is-redstone-conductor: false
push-reaction: BLOCK
instrument: BASS
push-reaction: block
instrument: bass
sounds:
break: minecraft:block.wood.break
fall: minecraft:block.wood.fall
@@ -68,8 +68,8 @@ items:
burnable: true
is-suffocating: false
is-redstone-conductor: false
push-reaction: BLOCK
instrument: BASS
push-reaction: block
instrument: bass
sounds:
break: minecraft:block.wood.break
fall: minecraft:block.wood.fall

View File

@@ -747,7 +747,7 @@ templates#settings#blocks:
- default:hardness/none
- default:sound/grass
overrides:
push-reaction: DESTROY
push-reaction: destroy
is-randomly-ticking: true
map-color: 7
tags:
@@ -763,11 +763,11 @@ templates#settings#blocks:
overrides:
hardness: 0.2
resistance: 0.2
push-reaction: DESTROY
push-reaction: destroy
replaceable: false
is-redstone-conductor: false
is-suffocating: false
instrument: HARP
instrument: harp
tags:
- minecraft:mineable/hoe
- minecraft:sword_efficient
@@ -780,11 +780,11 @@ templates#settings#blocks:
- default:burn_data/wood
- default:hardness/wood
overrides:
push-reaction: NORMAL
push-reaction: normal
replaceable: false
is-redstone-conductor: true
is-suffocating: true
instrument: BASS
instrument: bass
can-occlude: true
tags:
- minecraft:mineable/axe
@@ -798,11 +798,11 @@ templates#settings#blocks:
- default:burn_data/planks
- default:hardness/planks
overrides:
push-reaction: NORMAL
push-reaction: normal
replaceable: false
is-redstone-conductor: true
is-suffocating: true
instrument: BASS
instrument: bass
can-occlude: true
tags:
- minecraft:mineable/axe
@@ -814,10 +814,10 @@ templates#settings#blocks:
overrides:
hardness: 3.0
resistance: 3.0
push-reaction: NORMAL
push-reaction: normal
is-redstone-conductor: true
is-suffocating: true
instrument: BASEDRUM
instrument: basedrum
can-occlude: true
map-color: 11
tags:
@@ -830,10 +830,10 @@ templates#settings#blocks:
overrides:
hardness: 4.5
resistance: 3.0
push-reaction: NORMAL
push-reaction: normal
is-redstone-conductor: true
is-suffocating: true
instrument: BASEDRUM
instrument: basedrum
can-occlude: true
map-color: 59
tags: