Skip to content

Commit

Permalink
feat: FFS/KubeJS integration
Browse files Browse the repository at this point in the history
Fire a KJS event for the FFS CustomFilterEvent.MATCH_ITEM event
  • Loading branch information
desht committed Dec 1, 2023
1 parent 730f9db commit 1e58cc7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs;

import dev.latvian.mods.kubejs.event.EventJS;
import net.minecraft.world.item.ItemStack;

public class CustomFilterEventJS extends EventJS {
private final ItemStack stack;
private final String data;

public CustomFilterEventJS(ItemStack stack, String data) {
this.stack = stack;
this.data = data;
}

public ItemStack getStack() {
return stack;
}

public String getData() {
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs;

import dev.latvian.mods.kubejs.event.EventGroup;
import dev.latvian.mods.kubejs.event.EventHandler;
import dev.latvian.mods.kubejs.event.Extra;

public interface FFSEvents {
EventGroup EVENT_GROUP = EventGroup.of("FTBFilterSystemEvents");

EventHandler CUSTOM_FILTER = EVENT_GROUP.server("customFilter", () -> CustomFilterEventJS.class).extra(Extra.STRING).hasResult();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs;

import dev.architectury.event.EventResult;
import dev.ftb.mods.ftbfiltersystem.api.event.CustomFilterEvent;
import dev.latvian.mods.kubejs.KubeJSPlugin;
import dev.latvian.mods.kubejs.script.ScriptType;
import net.minecraft.world.item.ItemStack;

public class FFSKubeJSPlugin extends KubeJSPlugin {
@Override
public void init() {
CustomFilterEvent.MATCH_ITEM.register(FFSKubeJSPlugin::onCustomFilter);
}

@Override
public void registerEvents() {
FFSEvents.EVENT_GROUP.register();
}

private static EventResult onCustomFilter(ItemStack stack, String eventId, String extraData) {
return FFSEvents.CUSTOM_FILTER.post(ScriptType.SERVER, eventId, new CustomFilterEventJS(stack, extraData)).arch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.entity.player.Player;

public class KubeJSIntegration extends KubeJSPlugin {
@Override
public void init() {
CustomTaskEvent.EVENT.register(KubeJSIntegration::onCustomTask);
CustomRewardEvent.EVENT.register(KubeJSIntegration::onCustomReward);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
import dev.ftb.mods.ftbxmodcompat.FTBXModCompat;
import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedLootCrate;
import dev.ftb.mods.ftbxmodcompat.ftbquests.recipemod_common.WrappedQuest;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.entry.filtering.base.BasicFilteringRule;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.category.CategoryRegistry;
import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider;
import me.shedaniel.rei.api.client.view.ViewSearchBuilder;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.type.EntryDefinition;
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.world.item.ItemStack;

import java.util.Collection;

public class FTBQuestsREIIntegration implements REIClientPlugin {
private static BasicFilteringRule.MarkDirty cratesChanged;

Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/kubejs.plugins.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dev.ftb.mods.ftbxmodcompat.ftbquests.kubejs.KubeJSIntegration ftbquests
dev.ftb.mods.ftbxmodcompat.ftbchunks.kubejs.FTBChunksKubeJSPlugin ftbchunks
dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams
dev.ftb.mods.ftbxmodcompat.ftbteams.kubejs.FTBTeamsKubeJSPlugin ftbteams
dev.ftb.mods.ftbxmodcompat.ftbfiltersystem.kubejs.FFSKubeJSPlugin ftbfiltersystem
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ftb_chunks_version=2001.2.0
ftb_ranks_version=2001.1.3
ftb_essentials_version=2001.2.0
ftb_teams_version=2001.1.4
ftb_filter_system_version=1.0.1-SNAPSHOT
ftb_filter_system_version=1.0.2-SNAPSHOT
itemfilters_version=2001.1.0-build.55

kubejs_version=2001.6.3-build.18
Expand Down

0 comments on commit 1e58cc7

Please sign in to comment.