Skip to content

Commit

Permalink
Add rules relating to random ticks (#53)
Browse files Browse the repository at this point in the history
* Add the block random tick rule

* Add the fluid random tick rule
  • Loading branch information
haykam821 authored Mar 12, 2023
1 parent 16af1f2 commit 15e1e83
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Leukocyte provides various rules that can be applied within authorities. These r
- `coral_death` controls whether coral and coral fan blocks can die
- `throw_projectiles` controls whether players can throw eggs, snowballs, or tridents
- `shear_entities` controls whether entities such as sheep and mooshrooms can be sheared by players and dispensers
- `block_random_tick` controls whether random ticks will apply to blocks
- `fluid_random_tick` controls whether random ticks will apply to fluids

To set a rule as `allow` or `deny` on an authority, use `/protect set rule <authority> <rule> <result>`.

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/xyz/nucleoid/leukocyte/rule/ProtectionRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public final class ProtectionRule {

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

public static final ProtectionRule BLOCK_RANDOM_TICK = register("block_random_tick");
public static final ProtectionRule FLUID_RANDOM_TICK = register("fluid_random_tick");

private final String key;

ProtectionRule(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import xyz.nucleoid.stimuli.event.block.BlockBreakEvent;
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.BlockUseEvent;
import xyz.nucleoid.stimuli.event.block.CoralDeathEvent;
import xyz.nucleoid.stimuli.event.block.DispenserActivateEvent;
import xyz.nucleoid.stimuli.event.block.FluidRandomTickEvent;
import xyz.nucleoid.stimuli.event.entity.EntityShearEvent;
import xyz.nucleoid.stimuli.event.entity.EntitySpawnEvent;
import xyz.nucleoid.stimuli.event.entity.EntityUseEvent;
Expand Down Expand Up @@ -142,6 +144,12 @@ private void applyBlockRules(ProtectionRuleMap rules, EventRegistrar events) {

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

this.forRule(events, rules.test(ProtectionRule.BLOCK_RANDOM_TICK))
.applySimple(BlockRandomTickEvent.EVENT, rule -> (world, pos, state) -> rule);

this.forRule(events, rules.test(ProtectionRule.FLUID_RANDOM_TICK))
.applySimple(FluidRandomTickEvent.EVENT, rule -> (world, pos, state) -> rule);
}

private void applyInteractionRules(ProtectionRuleMap rules, EventRegistrar events) {
Expand Down

0 comments on commit 15e1e83

Please sign in to comment.