Skip to content

Commit

Permalink
feat: added kubejs support back in for Neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed May 9, 2024
1 parent 2284fff commit e203d51
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 83 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 6.0.0
## 6.0.1

### Changed
### Added

- Updated to 1.20.4
- Added kubejs support back in for NeoForge as KubeJS no longer supports Forge or Fabric
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ allprojects {
group = rootProject.maven_group

repositories {
maven {
url "https://maven.latvian.dev/releases"
content {
includeGroup "dev.latvian.mods"
}
}
maven {
url "https://maven.saps.dev/releases"
content {
Expand Down
3 changes: 0 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ dependencies {
modApi("me.shedaniel.cloth:cloth-config:${rootProject.cloth_config_version}")

modApi "dev.architectury:architectury:${rootProject.architectury_version}"

// modImplementation "dev.latvian.mods:kubejs:${rootProject.kubejs_version}"
// modImplementation "dev.latvian.mods:rhino:${rootProject.rhino_version}"
}

def ENV = System.getenv()
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ dependencies {

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }

// modImplementation "dev.latvian.mods:kubejs-fabric:${rootProject.kubejs_version}"
// modImplementation "dev.latvian.mods:rhino-fabric:${rootProject.rhino_version}"
}

processResources {
Expand Down
3 changes: 0 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ dependencies {

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }

// modImplementation "dev.latvian.mods:kubejs-forge:${rootProject.kubejs_version}"
// modImplementation "dev.latvian.mods:rhino-forge:${rootProject.rhino_version}"
}

processResources {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ minecraft_version=1.20.4
enabled_platforms=fabric,forge,neoforge

archives_base_name=SimpleDiscordRichPresence
mod_version=6.0.0
mod_version=6.0.1
maven_group=com.sunekaer.mods

curseforge_id=334853
modrinth_id=SCAopByd
maven_url=https://maven.nanite.dev/

architectury_version=11.0.8
architectury_version=11.1.17

fabric_loader_version=0.15.2
fabric_api_version=0.91.3+1.20.4

forge_version=49.0.9
neoforge_version=20.4.43-beta
neoforge_version=20.4.234

#kubejs_version=2001.6.4-build.114
#rhino_version=1902.2.3-build.284
kubejs_version=2004.7.0-build.16
rhino_version=2004.2.3-build.4

cloth_config_version=13.0.114
cloth_config_version=13.0.121
4 changes: 2 additions & 2 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ dependencies {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }

// modImplementation "dev.latvian.mods:kubejs-forge:${rootProject.kubejs_version}"
// modImplementation "dev.latvian.mods:rhino-forge:${rootProject.rhino_version}"
modImplementation("dev.latvian.mods:kubejs-neoforge:${rootProject.kubejs_version}") { transitive = false }
modImplementation("dev.latvian.mods:rhino-neoforge:${rootProject.rhino_version}") { transitive = false }
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.sunekaer.sdrp.integration.kubejs;


import com.sunekaer.sdrp.neoforge.kubejs.SDRPKubeJSWrapper;
import dev.architectury.event.EventResult;
import dev.architectury.event.events.common.EntityEvent;
import dev.latvian.mods.kubejs.KubeJSPlugin;
import dev.latvian.mods.kubejs.event.EventGroup;
import dev.latvian.mods.kubejs.event.EventHandler;
import dev.latvian.mods.kubejs.event.EventJS;
import dev.latvian.mods.kubejs.script.BindingsEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.dimension.DimensionType;

public class SDRPKubeJSIntegration extends KubeJSPlugin {
static EventGroup GROUP = EventGroup.of("sdrp");
static EventHandler DIMENSION_CHANGE = GROUP.client("dimension_change", () -> ClientDimensionChangeEvent.class);

public static void setup() {
EntityEvent.ADD.register(SDRPKubeJSIntegration::clientJoinEvent);
}

@Override
public void registerBindings(BindingsEvent event) {
event.add("SDRP", SDRPKubeJSWrapper.class);
}

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

private static EventResult clientJoinEvent(Entity entity, Level level) {
if (!(entity instanceof Player player)) {
return EventResult.pass();
}

if (!level.isClientSide) {
return EventResult.pass();
}

DIMENSION_CHANGE.post(new ClientDimensionChangeEvent(level.dimensionType(), player, level));
return EventResult.pass();
}

public static class ClientDimensionChangeEvent extends EventJS {
public DimensionType dimensionType;
public Player player;
public Level level;

public ClientDimensionChangeEvent(DimensionType dimensionType, Player player, Level level) {
this.dimensionType = dimensionType;
this.player = player;
this.level = level;
}

public void updateSDRPState(String message, String imageName, String imageKey) {
SDRPKubeJSWrapper.setState(message, imageName, imageKey);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sunekaer.sdrp.integration.kubejs;
package com.sunekaer.sdrp.neoforge.kubejs;

import com.jagrosh.discordipc.entities.RichPresence;
import com.sunekaer.sdrp.discord.State;
Expand Down

0 comments on commit e203d51

Please sign in to comment.