From 2042aba51f58c885718faefaebf33d3f85c6f8cc Mon Sep 17 00:00:00 2001 From: LLytho Date: Tue, 18 Jul 2023 11:40:58 +0200 Subject: [PATCH] Update to KubeJS 6.1 --- CHANGELOG.md | 4 ++++ .../main/java/com/almostreliable/morejs/core/Events.java | 6 +++--- .../features/enchantment/EnchantmentTableChangedJS.java | 3 ++- .../morejs/mixin/enchanting/EnchantmentMenuMixin.java | 2 +- .../morejs/mixin/enchanting/EnchantmentScreenMixin.java | 4 ++-- .../java/com/almostreliable/morejs/mixin/PlayerMixin.java | 3 ++- .../morejs/mixin/teleport/ChorusFruitItemMixin.java | 2 +- .../morejs/mixin/teleport/ThrownEnderPearlMixin.java | 2 +- .../java/com/almostreliable/morejs/ForgeEventLoaders.java | 6 +++--- gradle.properties | 8 ++++---- 10 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62eeb17..4e2177d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [0.2.0] - 2023-07-18 +- Update to KubeJS 6.1 + ## [0.1.1] - 2023-05-26 - Add `TradeItem` to allow price ranges for trades - Add custom potion removing for forge @@ -45,6 +48,7 @@ - Added `morejs.player.start_trading` event. +[0.2.0]: https://github.com/AlmostReliable/morejs/releases/tag/v1.19-0.2.0-beta [0.0.8]: https://github.com/AlmostReliable/morejs/releases/tag/v1.19-0.0.8-beta [0.0.7]: https://github.com/AlmostReliable/morejs/releases/tag/v1.19-0.0.7-beta [0.0.6]: https://github.com/AlmostReliable/morejs/releases/tag/v1.19-0.0.6-beta diff --git a/Common/src/main/java/com/almostreliable/morejs/core/Events.java b/Common/src/main/java/com/almostreliable/morejs/core/Events.java index 1963080..2b0f0bf 100644 --- a/Common/src/main/java/com/almostreliable/morejs/core/Events.java +++ b/Common/src/main/java/com/almostreliable/morejs/core/Events.java @@ -24,11 +24,11 @@ public interface Events { EventHandler UPDATE_WANDERER_OFFERS = GROUP.server("updateWandererOffers", () -> UpdateAbstractVillagerOffersEventJS.class); EventHandler ENCHANTMENT_TABLE_IS_ENCHANTABLE = GROUP.server("enchantmentTableIsEnchantable", () -> EnchantmentTableServerEventJS.class); EventHandler ENCHANTMENT_TABLE_CHANGED = GROUP.server("enchantmentTableChanged", () -> EnchantmentTableServerEventJS.class); - EventHandler ENCHANTMENT_TABLE_ENCHANT = GROUP.server("enchantmentTableEnchant", () -> EnchantmentTableServerEventJS.class).cancelable(); + EventHandler ENCHANTMENT_TABLE_ENCHANT = GROUP.server("enchantmentTableEnchant", () -> EnchantmentTableServerEventJS.class).hasResult(); EventHandler ENCHANTMENT_TABLE_TOOLTIP = GROUP.client("enchantmentTableTooltip", () -> EnchantmentTableTooltipEventJS.class); - EventHandler TELEPORT = GROUP.server("teleport", () -> EntityTeleportsEventJS.class).cancelable(); + EventHandler TELEPORT = GROUP.server("teleport", () -> EntityTeleportsEventJS.class).hasResult(); EventHandler STRUCTURE_LOAD = GROUP.server("structureLoad", () -> StructureLoadEventJS.class); - EventHandler XP_CHANGE = GROUP.server("playerXpChange", () -> ExperiencePlayerEventJS.class).cancelable(); + EventHandler XP_CHANGE = GROUP.server("playerXpChange", () -> ExperiencePlayerEventJS.class).hasResult(); EventHandler PIGLIN_PLAYER_BEHAVIOR = GROUP.server("piglinPlayerBehavior", () -> PiglinPlayerBehaviorEventJS.class); EventHandler POTION_BREWING_REGISTER = GROUP.startup("registerPotionBrewing", () -> PotionBrewingRegisterEvent.class); diff --git a/Common/src/main/java/com/almostreliable/morejs/features/enchantment/EnchantmentTableChangedJS.java b/Common/src/main/java/com/almostreliable/morejs/features/enchantment/EnchantmentTableChangedJS.java index 5d31e69..f262b34 100644 --- a/Common/src/main/java/com/almostreliable/morejs/features/enchantment/EnchantmentTableChangedJS.java +++ b/Common/src/main/java/com/almostreliable/morejs/features/enchantment/EnchantmentTableChangedJS.java @@ -1,6 +1,7 @@ package com.almostreliable.morejs.features.enchantment; import com.google.common.base.Preconditions; +import dev.latvian.mods.kubejs.event.EventResult; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.util.RandomSource; @@ -21,7 +22,7 @@ public EnchantmentTableChangedJS(ItemStack item, ItemStack secondItem, Level lev } @Override - protected void afterPosted(boolean result) { + protected void afterPosted(EventResult result) { super.afterPosted(result); // If the enchantments are cleared we want also to clear the required level. diff --git a/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentMenuMixin.java b/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentMenuMixin.java index 4764e9f..f6992bb 100644 --- a/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentMenuMixin.java +++ b/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentMenuMixin.java @@ -137,7 +137,7 @@ private void handleEnchantmentGetter(ItemStack itemStack, int index, int powerLe ItemStack item = this.enchantSlots.getItem(0); ItemStack secondItem = this.enchantSlots.getItem(1); var e = new EnchantmentTableServerEventJS(item, secondItem, level, pos, player, this.morejs$process); - if (Events.ENCHANTMENT_TABLE_ENCHANT.post(e)) { + if (Events.ENCHANTMENT_TABLE_ENCHANT.post(e).interruptFalse()) { cir.setReturnValue(false); } diff --git a/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentScreenMixin.java b/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentScreenMixin.java index f865c95..846a010 100644 --- a/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentScreenMixin.java +++ b/Common/src/main/java/com/almostreliable/morejs/mixin/enchanting/EnchantmentScreenMixin.java @@ -4,7 +4,7 @@ import com.almostreliable.morejs.features.enchantment.EnchantmentMenuExtension; import com.almostreliable.morejs.features.enchantment.EnchantmentTableTooltipEventJS; import com.mojang.blaze3d.vertex.PoseStack; -import dev.latvian.mods.kubejs.bindings.ComponentWrapper; +import dev.latvian.mods.kubejs.bindings.TextWrapper; import dev.latvian.mods.kubejs.script.ScriptType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -52,7 +52,7 @@ public EnchantmentScreenMixin(EnchantmentMenu abstractContainerMenu, Inventory i currentComponents.clear(); components.forEach(o -> { - MutableComponent of = ComponentWrapper.of(o); + MutableComponent of = TextWrapper.of(o); currentComponents.add(of); }); } diff --git a/Fabric/src/main/java/com/almostreliable/morejs/mixin/PlayerMixin.java b/Fabric/src/main/java/com/almostreliable/morejs/mixin/PlayerMixin.java index 00fa40f..f854150 100644 --- a/Fabric/src/main/java/com/almostreliable/morejs/mixin/PlayerMixin.java +++ b/Fabric/src/main/java/com/almostreliable/morejs/mixin/PlayerMixin.java @@ -2,6 +2,7 @@ import com.almostreliable.morejs.core.Events; import com.almostreliable.morejs.features.misc.ExperiencePlayerEventJS; +import dev.latvian.mods.kubejs.script.ScriptType; import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,7 +16,7 @@ public class PlayerMixin { @ModifyVariable(method = "giveExperiencePoints", at = @At("HEAD"), argsOnly = true) private int morejs$invokeExperienceEvent(int amount) { var e = new ExperiencePlayerEventJS((Player) (Object) this, amount); - if (Events.XP_CHANGE.post(e)) { + if (Events.XP_CHANGE.post(e).interruptFalse()) { return Integer.MIN_VALUE; } return e.getAmount(); diff --git a/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ChorusFruitItemMixin.java b/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ChorusFruitItemMixin.java index 9fe15a8..0cc15ad 100644 --- a/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ChorusFruitItemMixin.java +++ b/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ChorusFruitItemMixin.java @@ -26,7 +26,7 @@ public class ChorusFruitItemMixin { return; } var e = new EntityTeleportsEventJS(entity, args.get(0), args.get(1), args.get(2), TeleportType.CHORUS_FRUIT); - if (Events.TELEPORT.post(e)) { + if (Events.TELEPORT.post(e).interruptFalse()) { morejs$cancelTeleport = true; return; } diff --git a/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ThrownEnderPearlMixin.java b/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ThrownEnderPearlMixin.java index dcd9c36..dc641d9 100644 --- a/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ThrownEnderPearlMixin.java +++ b/Fabric/src/main/java/com/almostreliable/morejs/mixin/teleport/ThrownEnderPearlMixin.java @@ -23,7 +23,7 @@ public class ThrownEnderPearlMixin { self.getY(), self.getZ(), TeleportType.ENDER_PEARL); - if (Events.TELEPORT.post(event)) { + if (Events.TELEPORT.post(event).interruptFalse()) { ci.cancel(); self.discard(); return; diff --git a/Forge/src/main/java/com/almostreliable/morejs/ForgeEventLoaders.java b/Forge/src/main/java/com/almostreliable/morejs/ForgeEventLoaders.java index f338a5f..db16227 100644 --- a/Forge/src/main/java/com/almostreliable/morejs/ForgeEventLoaders.java +++ b/Forge/src/main/java/com/almostreliable/morejs/ForgeEventLoaders.java @@ -22,9 +22,9 @@ public static void load(IEventBus bus) { private static void onExperienceChange(PlayerXpEvent.XpChange event) { var e = new ExperiencePlayerEventJS(event.getEntity(), event.getAmount()); - boolean cancelled = Events.XP_CHANGE.post(e); + var result = Events.XP_CHANGE.post(e); event.setAmount(e.getAmount()); - if (cancelled) { + if (result.interruptFalse()) { event.setCanceled(true); } } @@ -39,7 +39,7 @@ private static void enderPearlTeleport(EntityTeleportEvent.EnderPearl e) { private static void handleEvent(EntityTeleportEvent e, TeleportType type) { var event = new EntityTeleportsEventJS(e.getEntity(), e.getTargetX(), e.getTargetY(), e.getTargetZ(), type); - if (Events.TELEPORT.post(event)) { + if (Events.TELEPORT.post(event).interruptFalse()) { e.setCanceled(true); return; } diff --git a/gradle.properties b/gradle.properties index 37487f7..d1a8b22 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project -version = 0.1.1 +version = 0.2.0 group = com.almostreliable.morejs license = GNU Lesser General Public License v3.0 mixinVersion = 0.8.5 @@ -8,7 +8,7 @@ mixinVersion = 0.8.5 minecraftVersion = 1.19.2 # Forge -forgeVersion = 43.1.32 +forgeVersion = 43.2.0 forgeMinVersion = 43 # Fabric @@ -17,8 +17,8 @@ fabricLoaderVersion = 0.14.9 # Dependencies extraModsDirectory = extra-mods -kubejsVersion = 1902.6.0-build.119 -rhinoVersion = 1902.2.2-build.263 +kubejsVersion = 1902.6.1-build.300 +rhinoVersion = 1902.2.2-build.269 architecturyVersion = 6.2.46 reiVersion = 9+