Skip to content

Commit

Permalink
Add the activate death protection rule
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 authored and Patbox committed Nov 10, 2024
1 parent e6916f5 commit fceb366
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Leukocyte provides various rules that can be applied within authorities. These r
- `crafting` controls whether players can craft items
- `fall_damage` controls whether players should receive fall damage
- `hunger` controls whether players will become hungry
- `activate_death_protection` controls whether entities should activate death protection items such as totems of undying to avoid dying
- `throw_items` controls whether players can throw items from their inventory
- `pickup_items` controls whether items can be picked up by players or other entities
- `unstable_tnt` controls tnt automatically igniting when placed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public final class ProtectionRule {
public static final ProtectionRule FREEZING_DAMAGE = register("freezing_damage");
public static final ProtectionRule LAVA_DAMAGE = register("lava_damage");
public static final ProtectionRule DAMAGE = register("damage");
public static final ProtectionRule ACTIVATE_DEATH_PROTECTION = register("activate_death_protection");

public static final ProtectionRule THROW_ITEMS = register("throw_items");
public static final ProtectionRule PICKUP_ITEMS = register("pickup_items");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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.EntityActivateDeathProtectionEvent;
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 @@ -96,6 +97,9 @@ public void applyTo(ProtectionRuleMap rules, EventRegistrar events) {
return (player, source, amount) -> !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY) ? rule : EventResult.PASS;
});

this.forRule(events, rules.test(ProtectionRule.ACTIVATE_DEATH_PROTECTION))
.applySimple(EntityActivateDeathProtectionEvent.EVENT, rule -> (player, source, stack) -> rule);

this.forRule(events, rules.test(ProtectionRule.THROW_ITEMS))
.applySimple(ItemThrowEvent.EVENT, rule -> (player, slot, stack) -> rule);
this.forRule(events, rules.test(ProtectionRule.PICKUP_ITEMS))
Expand Down

0 comments on commit fceb366

Please sign in to comment.