diff --git a/build.gradle b/build.gradle index d5865b1..095ccdf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.7.+' + id 'fabric-loom' version '1.8.+' id "com.modrinth.minotaur" version "2.+" } import com.modrinth.minotaur.TaskModrinthUpload @@ -21,10 +21,10 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation include('xyz.nucleoid:stimuli:0.4.12+1.21') + modImplementation include('xyz.nucleoid:stimuli:0.5.0+1.21.3') - modCompileOnly "dev.gegy:player-roles-api:1.6.11" - modCompileOnly "me.lucko:fabric-permissions-api:0.3.1" + modCompileOnly "dev.gegy:player-roles-api:1.6.13" + modCompileOnly "me.lucko:fabric-permissions-api:0.3.2" } processResources { diff --git a/gradle.properties b/gradle.properties index ef767e7..f3cf2df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.2 -loader_version=0.15.11 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 #Dependencies -fabric_version=0.100.3+1.21 +fabric_version=0.107.0+1.21.3 # Mod Properties mod_version=0.3.9 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e644113..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..df97d72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf1..f5feea6 100644 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e..9b42019 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/RuleResult.java b/src/main/java/xyz/nucleoid/leukocyte/rule/RuleResult.java index 5207fbd..886e141 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/RuleResult.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/RuleResult.java @@ -5,11 +5,11 @@ import net.minecraft.text.ClickEvent; import net.minecraft.text.Text; import net.minecraft.text.MutableText; -import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import xyz.nucleoid.leukocyte.authority.Authority; +import xyz.nucleoid.stimuli.event.EventResult; import java.util.Map; import java.util.Set; @@ -77,11 +77,11 @@ public RuleResult orElse(RuleResult other) { return this.isDefinitive() ? this : other; } - public ActionResult asActionResult() { + public EventResult asEventResult() { return switch (this) { - case ALLOW -> ActionResult.SUCCESS; - case DENY -> ActionResult.FAIL; - default -> ActionResult.PASS; + case ALLOW -> EventResult.ALLOW; + case DENY -> EventResult.DENY; + default -> EventResult.PASS; }; } diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java index 026bcda..af7336a 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/LeukocyteRuleEnforcer.java @@ -11,10 +11,11 @@ import net.minecraft.item.Items; import net.minecraft.registry.tag.DamageTypeTags; import net.minecraft.util.ActionResult; -import net.minecraft.util.TypedActionResult; import xyz.nucleoid.leukocyte.rule.ProtectionRule; import xyz.nucleoid.leukocyte.rule.ProtectionRuleMap; +import xyz.nucleoid.stimuli.event.DroppedItemsResult; import xyz.nucleoid.stimuli.event.EventRegistrar; +import xyz.nucleoid.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.block.BlockBreakEvent; import xyz.nucleoid.stimuli.event.block.BlockDropItemsEvent; import xyz.nucleoid.stimuli.event.block.BlockPlaceEvent; @@ -55,7 +56,7 @@ public void applyTo(ProtectionRuleMap rules, EventRegistrar events) { this.forRule(events, rules.test(ProtectionRule.PVP)) .applySimple(PlayerAttackEntityEvent.EVENT, rule -> (attacker, hand, attacked, hitResult) -> { - return attacked instanceof PlayerEntity ? rule : ActionResult.PASS; + return attacked instanceof PlayerEntity ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.SPECTATE_ENTITIES)) @@ -72,27 +73,27 @@ public void applyTo(ProtectionRuleMap rules, EventRegistrar events) { this.forRule(events, rules.test(ProtectionRule.FALL_DAMAGE)) .applySimple(PlayerDamageEvent.EVENT, rule -> { - return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FALL) ? rule : ActionResult.PASS; + return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FALL) ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.FIRE_DAMAGE)) .applySimple(PlayerDamageEvent.EVENT, rule -> { - return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FIRE) && !source.isOf(DamageTypes.LAVA) ? rule : ActionResult.PASS; + return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FIRE) && !source.isOf(DamageTypes.LAVA) ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.FREEZING_DAMAGE)) .applySimple(PlayerDamageEvent.EVENT, rule -> { - return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FREEZING) ? rule : ActionResult.PASS; + return (player, source, amount) -> source.isIn(DamageTypeTags.IS_FREEZING) ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.LAVA_DAMAGE)) .applySimple(PlayerDamageEvent.EVENT, rule -> { - return (player, source, amount) -> source.isOf(DamageTypes.LAVA) ? rule : ActionResult.PASS; + return (player, source, amount) -> source.isOf(DamageTypes.LAVA) ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.DAMAGE)) .applySimple(PlayerDamageEvent.EVENT, rule -> { - return (player, source, amount) -> !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY) ? rule : ActionResult.PASS; + return (player, source, amount) -> !source.isIn(DamageTypeTags.BYPASSES_INVULNERABILITY) ? rule : EventResult.PASS; }); this.forRule(events, rules.test(ProtectionRule.THROW_ITEMS)) @@ -101,20 +102,20 @@ public void applyTo(ProtectionRuleMap rules, EventRegistrar events) { .applySimple(ItemPickupEvent.EVENT, rule -> (player, entity, stack) -> rule); this.forRule(events, rules.test(ProtectionRule.SPAWN_MONSTERS)) - .applySimple(EntitySpawnEvent.EVENT, rule -> entity -> entity instanceof Monster ? rule : ActionResult.PASS); + .applySimple(EntitySpawnEvent.EVENT, rule -> entity -> entity instanceof Monster ? rule : EventResult.PASS); this.forRule(events, rules.test(ProtectionRule.SPAWN_ANIMALS)) - .applySimple(EntitySpawnEvent.EVENT, rule -> entity -> entity instanceof AnimalEntity ? rule : ActionResult.PASS); + .applySimple(EntitySpawnEvent.EVENT, rule -> entity -> entity instanceof AnimalEntity ? rule : EventResult.PASS); this.forRule(events, rules.test(ProtectionRule.THROW_PROJECTILES)) .applySimple(ItemUseEvent.EVENT, rule -> { return (player, hand) -> { ItemStack stack = player.getStackInHand(hand); if (stack.isOf(Items.EGG) || stack.isOf(Items.SNOWBALL) || stack.isOf(Items.TRIDENT)) { - return TypedActionResult.fail(stack); + return ActionResult.FAIL; } - return TypedActionResult.pass(stack); + return ActionResult.PASS; }; }); @@ -134,16 +135,16 @@ private void applyBlockRules(ProtectionRuleMap rules, EventRegistrar events) { this.forRule(events, rules.test(ProtectionRule.BLOCK_DROPS)) .applySimple(BlockDropItemsEvent.EVENT, rule -> { return (breaker, world, pos, state, dropStacks) -> { - if (rule == ActionResult.FAIL) { - return new TypedActionResult<>(rule, new ArrayList<>()); - } else { - return new TypedActionResult<>(rule, dropStacks); - } + return switch (rule) { + case ALLOW -> DroppedItemsResult.allow(dropStacks); + case DENY -> DroppedItemsResult.deny(); + default -> DroppedItemsResult.pass(dropStacks); + }; }; }); this.forRule(events, rules.test(ProtectionRule.EXPLOSION)) - .applySimple(ExplosionDetonatedEvent.EVENT, rule -> (explosion, particles) -> explosion.clearAffectedBlocks()); + .applySimple(ExplosionDetonatedEvent.EVENT, rule -> (explosion, blocksToDestroy) -> rule); this.forRule(events, rules.test(ProtectionRule.BLOCK_RANDOM_TICK)) .applySimple(BlockRandomTickEvent.EVENT, rule -> (world, pos, state) -> rule); @@ -159,19 +160,19 @@ private void applyInteractionRules(ProtectionRuleMap rules, EventRegistrar event var interactItems = rules.test(ProtectionRule.INTERACT_ITEMS).orElse(interact); this.forRule(events, interactBlocks) - .applySimple(BlockUseEvent.EVENT, rule -> (player, hand, hitResult) -> rule); + .applySimple(BlockUseEvent.EVENT, rule -> (player, hand, hitResult) -> rule.asActionResult()); this.forRule(events, interactEntities) .applySimple(EntityUseEvent.EVENT, rule -> (player, entity, hand, hitResult) -> rule); this.forRule(events, interactItems) - .applySimple(ItemUseEvent.EVENT, rule -> (player, hand) -> new TypedActionResult<>(rule, ItemStack.EMPTY)); + .applySimple(ItemUseEvent.EVENT, rule -> (player, hand) -> rule.asActionResult()); } private void applyWorldRules(ProtectionRuleMap rules, EventRegistrar events) { this.forRule(events, rules.test(ProtectionRule.UNSTABLE_TNT)) .applySimple(BlockPlaceEvent.AFTER, rule -> (player, world, pos, state) -> { - if (rule == ActionResult.SUCCESS && state.getBlock() == Blocks.TNT) { + if (rule == EventResult.ALLOW && state.getBlock() == Blocks.TNT) { TntBlock.primeTnt(player.getWorld(), pos); player.getWorld().setBlockState(pos, Blocks.AIR.getDefaultState()); } diff --git a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/ProtectionRuleEnforcer.java b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/ProtectionRuleEnforcer.java index c81e965..b112ace 100644 --- a/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/ProtectionRuleEnforcer.java +++ b/src/main/java/xyz/nucleoid/leukocyte/rule/enforcer/ProtectionRuleEnforcer.java @@ -1,9 +1,9 @@ package xyz.nucleoid.leukocyte.rule.enforcer; -import net.minecraft.util.ActionResult; import xyz.nucleoid.leukocyte.rule.ProtectionRuleMap; import xyz.nucleoid.leukocyte.rule.RuleResult; import xyz.nucleoid.stimuli.event.EventRegistrar; +import xyz.nucleoid.stimuli.event.EventResult; import xyz.nucleoid.stimuli.event.StimulusEvent; public interface ProtectionRuleEnforcer { @@ -14,13 +14,13 @@ default ForRule forRule(EventRegistrar events, RuleResult result) { } interface ListenerFactory { - T createListener(ActionResult rule); + T createListener(EventResult rule); } record ForRule(EventRegistrar events, RuleResult result) { public void applySimple(StimulusEvent event, ListenerFactory factory) { if (this.result.isDefinitive()) { - this.events.listen(event, factory.createListener(this.result.asActionResult())); + this.events.listen(event, factory.createListener(this.result.asEventResult())); } } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d6fbd8f..1e5fc3b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -14,7 +14,7 @@ "depends": { "fabricloader": ">=0.12", "fabric": "*", - "minecraft": ">=1.21-", + "minecraft": ">=1.21.2-", "stimuli": ">=0.4.3", "java": ">=21" }