mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
@@ -77,23 +77,15 @@ public class FallingBlockBehavior extends BukkitBlockBehavior {
|
|||||||
public void onBrokenAfterFall(Object thisBlock, Object[] args) throws Exception {
|
public void onBrokenAfterFall(Object thisBlock, Object[] args) throws Exception {
|
||||||
Object level = args[0];
|
Object level = args[0];
|
||||||
Object fallingBlockEntity = args[2];
|
Object fallingBlockEntity = args[2];
|
||||||
boolean cancelDrop = (boolean) CoreReflections.field$FallingBlockEntity$cancelDrop.get(fallingBlockEntity);
|
|
||||||
if (cancelDrop) return;
|
|
||||||
Object blockState = CoreReflections.field$FallingBlockEntity$blockState.get(fallingBlockEntity);
|
|
||||||
Optional<ImmutableBlockState> optionalCustomState = BlockStateUtils.getOptionalCustomBlockState(blockState);
|
|
||||||
if (optionalCustomState.isEmpty()) return;
|
|
||||||
ImmutableBlockState customState = optionalCustomState.get();
|
|
||||||
net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
|
|
||||||
WorldPosition position = new WorldPosition(world, CoreReflections.field$Entity$xo.getDouble(fallingBlockEntity), CoreReflections.field$Entity$yo.getDouble(fallingBlockEntity), CoreReflections.field$Entity$zo.getDouble(fallingBlockEntity));
|
|
||||||
ContextHolder.Builder builder = ContextHolder.builder()
|
|
||||||
.withParameter(DirectContextParameters.FALLING_BLOCK, true)
|
|
||||||
.withParameter(DirectContextParameters.POSITION, position);
|
|
||||||
for (Item<Object> item : customState.getDrops(builder, world, null)) {
|
|
||||||
world.dropItemNaturally(position, item);
|
|
||||||
}
|
|
||||||
Object entityData = CoreReflections.field$Entity$entityData.get(fallingBlockEntity);
|
Object entityData = CoreReflections.field$Entity$entityData.get(fallingBlockEntity);
|
||||||
boolean isSilent = (boolean) CoreReflections.method$SynchedEntityData$get.invoke(entityData, CoreReflections.instance$Entity$DATA_SILENT);
|
boolean isSilent = (boolean) CoreReflections.method$SynchedEntityData$get.invoke(entityData, CoreReflections.instance$Entity$DATA_SILENT);
|
||||||
if (!isSilent) {
|
if (!isSilent) {
|
||||||
|
Object blockState = CoreReflections.field$FallingBlockEntity$blockState.get(fallingBlockEntity);
|
||||||
|
Optional<ImmutableBlockState> optionalCustomState = BlockStateUtils.getOptionalCustomBlockState(blockState);
|
||||||
|
if (optionalCustomState.isEmpty()) return;
|
||||||
|
ImmutableBlockState customState = optionalCustomState.get();
|
||||||
|
net.momirealms.craftengine.core.world.World world = new BukkitWorld(FastNMS.INSTANCE.method$Level$getCraftWorld(level));
|
||||||
|
WorldPosition position = new WorldPosition(world, CoreReflections.field$Entity$xo.getDouble(fallingBlockEntity), CoreReflections.field$Entity$yo.getDouble(fallingBlockEntity), CoreReflections.field$Entity$zo.getDouble(fallingBlockEntity));
|
||||||
world.playBlockSound(position, customState.settings().sounds().destroySound());
|
world.playBlockSound(position, customState.settings().sounds().destroySound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ byte_buddy_version=1.17.5
|
|||||||
ahocorasick_version=0.6.3
|
ahocorasick_version=0.6.3
|
||||||
snake_yaml_version=2.5
|
snake_yaml_version=2.5
|
||||||
anti_grief_version=0.20
|
anti_grief_version=0.20
|
||||||
nms_helper_version=1.0.84
|
nms_helper_version=1.0.85
|
||||||
evalex_version=3.5.0
|
evalex_version=3.5.0
|
||||||
reactive_streams_version=1.0.4
|
reactive_streams_version=1.0.4
|
||||||
amazon_awssdk_version=2.33.1
|
amazon_awssdk_version=2.33.1
|
||||||
|
|||||||
Reference in New Issue
Block a user