Skip to content

Commit

Permalink
Update to KubeJS 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Jul 18, 2023
1 parent 720a5b3 commit 2042aba
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -45,6 +48,7 @@
- Added `morejs.player.start_trading` event.

<!-- Versions -->
[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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,7 +8,7 @@ mixinVersion = 0.8.5
minecraftVersion = 1.19.2

# Forge
forgeVersion = 43.1.32
forgeVersion = 43.2.0
forgeMinVersion = 43

# Fabric
Expand All @@ -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+

Expand Down

0 comments on commit 2042aba

Please sign in to comment.