Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the block trample rule #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Leukocyte provides various rules that can be applied within authorities. These r
- `break` controls whether players can break blocks
- `place` controls whether players can place blocks
- `block_drops` controls whether blocks drop items when broken
- `block_trample` controls whether blocks like farmland and turtle eggs can be broken
- `interact_blocks` controls whether players can interact with blocks
- `interact_entities` controls whether players can interact with entities
- `interact` controls global interaction over blocks and entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public final class ProtectionRule {
public static final ProtectionRule THROW_PROJECTILES = register("throw_projectiles");
public static final ProtectionRule SHEAR_ENTITIES = register("shear_entities");

public static final ProtectionRule BLOCK_TRAMPLE = register("block_trample");
public static final ProtectionRule EXPLOSION = register("explosion");

public static final ProtectionRule BLOCK_RANDOM_TICK = register("block_random_tick");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import xyz.nucleoid.stimuli.event.block.BlockDropItemsEvent;
import xyz.nucleoid.stimuli.event.block.BlockPlaceEvent;
import xyz.nucleoid.stimuli.event.block.BlockRandomTickEvent;
import xyz.nucleoid.stimuli.event.block.BlockTrampleEvent;
import xyz.nucleoid.stimuli.event.block.BlockUseEvent;
import xyz.nucleoid.stimuli.event.block.CoralDeathEvent;
import xyz.nucleoid.stimuli.event.block.DispenserActivateEvent;
Expand Down Expand Up @@ -148,6 +149,9 @@ private void applyBlockRules(ProtectionRuleMap rules, EventRegistrar events) {
};
});

this.forRule(events, rules.test(ProtectionRule.BLOCK_TRAMPLE))
.applySimple(BlockTrampleEvent.EVENT, rule -> (entity, world, pos, from, to) -> rule);

this.forRule(events, rules.test(ProtectionRule.EXPLOSION))
.applySimple(ExplosionDetonatedEvent.EVENT, rule -> (explosion, blocksToDestroy) -> rule);

Expand Down