diff --git a/build.gradle b/build.gradle index b5764d0..dd913d5 100644 --- a/build.gradle +++ b/build.gradle @@ -96,6 +96,9 @@ minecraft { client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id + + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" } server { @@ -138,6 +141,20 @@ repositories { // flatDir { // dir 'libs' // } + maven { + // Shedaniel's maven (Architectury API) + url = "https://maven.architectury.dev" + content { + includeGroup "dev.architectury" + } + } + maven { + // saps.dev Maven (KubeJS and Rhino) + url = "https://maven.saps.dev/releases" + content { + includeGroup "dev.latvian.mods" + } + } } dependencies { @@ -148,6 +165,12 @@ dependencies { // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + + implementation fg.deobf("dev.latvian.mods:kubejs-forge:${kubejs_version}") + +// these two are unfortunately needed since fg.deobf doesn't respect transitive dependencies yet + implementation fg.deobf("dev.latvian.mods:rhino-forge:${rhino_version}") + implementation fg.deobf("dev.architectury:architectury-forge:${architectury_version}") // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") diff --git a/gradle.properties b/gradle.properties index 39c938e..693e4bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false +-Net.minecraftforge.gradle.check.certs=false # The Minecraft version must agree with the Forge version to get a valid artifact @@ -51,3 +52,7 @@ mod_group_id=com.pancake mod_authors= # The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. mod_description= + +kubejs_version=2001.6.3-build.89 +rhino_version=2001.2.2-build.11 +architectury_version=9.1.12 diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/event/AftermathEvent.java b/src/main/java/com/pancake/surviving_the_aftermath/common/event/AftermathEvent.java index fde993d..1034c72 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/event/AftermathEvent.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/event/AftermathEvent.java @@ -5,6 +5,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.util.random.SimpleWeightedRandomList; import net.minecraft.world.item.Item; +import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java index e4d23e0..6eb6077 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/event/subscriber/RaidEventSubscriber.java @@ -54,7 +54,8 @@ public static void onBlock(BlockEvent.PortalSpawnEvent event) { } } @SubscribeEvent - public static void onRaidStart(AftermathEvent.Start event) { + public static void onRaidStart(AftermathEvent.Start event) + { event.getPlayers().forEach(uuid -> { Player player = event.getLevel().getPlayerByUUID(uuid); if (player != null) { diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java index 66ca29d..7a577c7 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/raid/NetherRaid.java @@ -35,6 +35,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Mirror; diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/tracker/RaidPlayerBattleTracker.java b/src/main/java/com/pancake/surviving_the_aftermath/common/tracker/RaidPlayerBattleTracker.java index 58d689d..6691d54 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/tracker/RaidPlayerBattleTracker.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/tracker/RaidPlayerBattleTracker.java @@ -48,7 +48,7 @@ public String getUniqueIdentifier() { @SubscribeEvent public void updatePlayer(AftermathEvent.Ongoing event) { - ServerLevel level = event.getLevel(); + Level level = event.getLevel(); Set uuids = Sets.newHashSet(); Set eventPlayers = event.getPlayers(); for (UUID uuid : players) { diff --git a/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java b/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java index d7449b7..1f1de9e 100644 --- a/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java +++ b/src/main/java/com/pancake/surviving_the_aftermath/common/util/AftermathEventUtil.java @@ -3,9 +3,13 @@ import com.pancake.surviving_the_aftermath.api.AftermathState; import com.pancake.surviving_the_aftermath.api.base.BaseAftermath; import com.pancake.surviving_the_aftermath.common.event.AftermathEvent; +import com.pancake.surviving_the_aftermath.compat.kubejs.event.AftermathEventJS; +import com.pancake.surviving_the_aftermath.compat.kubejs.event.AftermathEvents; +import dev.latvian.mods.kubejs.event.EventResult; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.random.SimpleWeightedRandomList; import net.minecraft.world.item.Item; +import net.minecraft.world.level.Level; import net.minecraftforge.common.MinecraftForge; import java.util.List; @@ -17,37 +21,45 @@ public class AftermathEventUtil { public static void start(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.START); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Start(aftermath,players, level)); + AftermathEvents.START.post(new AftermathEventJS.StartJS(aftermath, players, level)); + } //post ready public static void ready(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.READY); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Ready(aftermath,players, level)); + AftermathEvents.READY.post(new AftermathEventJS.ReadyJS(aftermath, players, level)); } //post ongoing public static void ongoing(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.ONGOING); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Ongoing(aftermath,players, level)); + AftermathEvents.ONGOING.post(new AftermathEventJS.OngoingJS(aftermath, players, level)); } //post victory public static void victory(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.VICTORY); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Victory(aftermath,players, level)); + AftermathEvents.VICTORY.post(new AftermathEventJS.VictoryJS(aftermath, players, level)); } //post celebrating public static void celebrating(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.CELEBRATING); SimpleWeightedRandomList rewardList = aftermath.getModule().getRewardList(); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Celebrating(aftermath,players, level,rewardList)); + AftermathEvents.CELEBRATING.post(new AftermathEventJS.CelebratingJS(aftermath, players, level,rewardList)); } //post lose public static void lose(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.LOSE); MinecraftForge.EVENT_BUS.post(new AftermathEvent.Lose(aftermath,players, level)); + AftermathEvents.LOSE.post(new AftermathEventJS.LoseJS(aftermath, players, level)); } //post end public static void end(BaseAftermath aftermath, Set players, ServerLevel level) { aftermath.setState(AftermathState.END); MinecraftForge.EVENT_BUS.post(new AftermathEvent.End(aftermath,players, level)); + AftermathEvents.END.post(new AftermathEventJS.EndJS(aftermath, players, level)); } } diff --git a/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java new file mode 100644 index 0000000..a52ff6c --- /dev/null +++ b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/ModKubeJSPlugin.java @@ -0,0 +1,12 @@ +package com.pancake.surviving_the_aftermath.compat.kubejs; + +import com.pancake.surviving_the_aftermath.compat.kubejs.event.AftermathEvents; +import dev.latvian.mods.kubejs.KubeJSPlugin; + +public class ModKubeJSPlugin extends KubeJSPlugin { + + @Override + public void registerEvents() { + AftermathEvents.register(); + } +} diff --git a/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEventJS.java b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEventJS.java new file mode 100644 index 0000000..c889e3b --- /dev/null +++ b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEventJS.java @@ -0,0 +1,86 @@ +package com.pancake.surviving_the_aftermath.compat.kubejs.event; + +import com.pancake.surviving_the_aftermath.api.base.BaseAftermath; +import com.pancake.surviving_the_aftermath.api.base.BaseAftermathModule; +import dev.latvian.mods.kubejs.event.EventJS; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.random.SimpleWeightedRandomList; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.Level; +import net.minecraftforge.eventbus.api.Cancelable; + +import java.util.Set; +import java.util.UUID; + +public class AftermathEventJS extends EventJS { + private final BaseAftermath aftermath; + private final Set players; + private final ServerLevel level; + + public Set getPlayers() { + return players; + } + + public ServerLevel getLevel() { + return level; + } + + public AftermathEventJS(BaseAftermath aftermath, Set players, ServerLevel level) { + this.aftermath = aftermath; + this.players = players; + this.level = level; + } + + public static class StartJS extends AftermathEventJS { + public StartJS(BaseAftermath aftermath,Set players, ServerLevel level) { + super(aftermath,players, level); + } + } + public static class EndJS extends AftermathEventJS { + + public EndJS(BaseAftermath aftermath, Set players, ServerLevel level) { + super(aftermath, players, level); + } + } + public static class ReadyJS extends AftermathEventJS { + + public ReadyJS(BaseAftermath aftermath, Set players, ServerLevel level) { + super(aftermath, players, level); + } + } + + public static class OngoingJS extends AftermathEventJS { + + public OngoingJS(BaseAftermath aftermath, Set players, ServerLevel level) { + super(aftermath, players, level); + } + } + public static class VictoryJS extends AftermathEventJS { + + public VictoryJS(BaseAftermath aftermath, Set players, ServerLevel level) { + super(aftermath, players, level); + } + } + public static class LoseJS extends AftermathEventJS { + + public LoseJS(BaseAftermath aftermath, Set players, ServerLevel level) { + super(aftermath, players, level); + } + } + @Cancelable + public static class CelebratingJS extends AftermathEventJS { + private SimpleWeightedRandomList rewardList; + + public CelebratingJS(BaseAftermath aftermath, Set players, ServerLevel level,SimpleWeightedRandomList rewardList) { + super(aftermath, players, level); + this.rewardList = rewardList; + } + public SimpleWeightedRandomList getRewardList() { + return rewardList; + } + + public void setRewardList(SimpleWeightedRandomList rewardList) { + this.rewardList = rewardList; + } + } +} diff --git a/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEvents.java b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEvents.java new file mode 100644 index 0000000..d2daafe --- /dev/null +++ b/src/main/java/com/pancake/surviving_the_aftermath/compat/kubejs/event/AftermathEvents.java @@ -0,0 +1,34 @@ +package com.pancake.surviving_the_aftermath.compat.kubejs.event; + +import dev.latvian.mods.kubejs.event.EventGroup; +import dev.latvian.mods.kubejs.event.EventHandler; + +public interface AftermathEvents { + EventGroup GROUP = EventGroup.of("AftermathEvents"); + + //Start + EventHandler START = GROUP.server("start", () -> AftermathEventJS.StartJS.class); + + //End + EventHandler END = GROUP.server("end", () -> AftermathEventJS.EndJS.class); + + //Ready + EventHandler READY = GROUP.server("ready", () -> AftermathEventJS.ReadyJS.class); + + //Ongoing + EventHandler ONGOING = GROUP.server("ongoing", () -> AftermathEventJS.OngoingJS.class); + + //Victory + EventHandler VICTORY = GROUP.server("victory", () -> AftermathEventJS.VictoryJS.class); + + //Lose + EventHandler LOSE = GROUP.server("lose", () -> AftermathEventJS.LoseJS.class); + + //Celebrating + EventHandler CELEBRATING = GROUP.server("celebrating", () -> AftermathEventJS.CelebratingJS.class); + + static void register() { + GROUP.register(); + } + +} diff --git a/src/main/resources/kubejs.plugins.txt b/src/main/resources/kubejs.plugins.txt new file mode 100644 index 0000000..5c05bbd --- /dev/null +++ b/src/main/resources/kubejs.plugins.txt @@ -0,0 +1 @@ +com.pancake.surviving_the_aftermath.compat.kubejs.ModKubeJSPlugin \ No newline at end of file