use of org.lanternpowered.server.behavior.BehaviorResult in project LanternServer by LanternPowered.
the class SimpleBreakBehavior method tryBreak.
@Override
public BehaviorResult tryBreak(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
final BlockSnapshotBuilder builder = BlockSnapshotBuilder.create();
// Apply the creator and notifier to the block
context.populateBlockSnapshot(builder, BehaviorContext.PopulationFlags.CREATOR_AND_NOTIFIER);
builder.location(context.requireContext(ContextKeys.BLOCK_LOCATION));
// The block should be replaced with air
builder.blockState(BlockTypes.AIR.getDefaultState());
// Add the block change
context.addBlockChange(builder.build());
context.getContext(EventContextKeys.PLAYER).ifPresent(p -> p.get(Keys.EXHAUSTION).ifPresent(value -> p.offer(Keys.EXHAUSTION, value + 0.005)));
context.process(pipeline.pipeline(BlockDropsProviderBehavior.class), (ctx, behavior) -> {
behavior.tryAddDrops(pipeline, context);
return BehaviorResult.CONTINUE;
});
return BehaviorResult.CONTINUE;
}
Aggregations