Skip to content

Commit

Permalink
Frankenstein some deprecated methods back into EventHandler
Browse files Browse the repository at this point in the history
(KubeJS is too powerful to let this API break!)
  • Loading branch information
MaxNeedsSnacks committed Jul 17, 2023
1 parent 1c16825 commit 38c8f89
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ subprojects {
apply plugin: "java"
apply plugin: "dev.architectury.loom"
apply plugin: 'architectury-plugin'
apply plugin: "io.github.juuxel.loom-quiltflower"
apply plugin: "io.github.juuxel.loom-vineflower"
apply plugin: "maven-publish"
apply from: "https://files.latvian.dev/public/markdown-git-changelog.gradle"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dev.latvian.mods.kubejs.core.mixin.common;

import dev.latvian.mods.kubejs.event.EventHandler;
import dev.latvian.mods.kubejs.event.EventJS;
import org.spongepowered.asm.mixin.Mixin;

@SuppressWarnings("ReferenceToMixin")
@Mixin(value = EventHandler.class, remap = false)
public abstract class EventHandlerBridgeMixin {
public EventHandler cancelable() {
return ((EventHandlerInvoker) this).callHasResult();
}

public boolean post(Object extraId, EventJS event) {
return ((EventHandlerInvoker) this).callPost(event, extraId).interruptFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.latvian.mods.kubejs.core.mixin.common;

import dev.latvian.mods.kubejs.event.EventHandler;
import dev.latvian.mods.kubejs.event.EventJS;
import dev.latvian.mods.kubejs.event.EventResult;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(value = EventHandler.class, remap = false)
public interface EventHandlerInvoker {

@Invoker(remap = false)
EventHandler callHasResult();

@Invoker(remap = false)
EventResult callPost(EventJS event, @Nullable Object extraId);
}
2 changes: 2 additions & 0 deletions common/src/main/resources/kubejs-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"ContainerMixin",
"DamageSourceMixin",
"EntityMixin",
"EventHandlerBridgeMixin",
"EventHandlerInvoker",
"FireworkRocketEntityMixin",
"GameRulesMixin",
"IngredientMixin",
Expand Down

0 comments on commit 38c8f89

Please sign in to comment.