Skip to content

Commit

Permalink
Updated Rhino, fixed registry object type wrapping if they are a record
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Jul 22, 2024
1 parent eedddfb commit eb779b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
19 changes: 7 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ plugins {
id 'java'
id 'maven-publish'
id 'net.neoforged.moddev' version "1.0.14"
id "me.shedaniel.unified-publishing" version "0.1.+"
// https://maven.architectury.dev/me/shedaniel/unified-publishing/maven-metadata.xml
id "me.shedaniel.unified-publishing" version "0.1.13"
}

ext.ENV = System.getenv()
Expand All @@ -23,24 +24,18 @@ neoForge {
configureEach {
logLevel = org.slf4j.event.Level.INFO
}

client {
client()
if (ENV.MC_CLIENT_ARGS) {
programArguments.addAll(ENV.MC_CLIENT_ARGS.split(' '))
}

jvmArguments.addAll("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
gameDirectory = file 'run'
}
client2 {
client()
programArguments.addAll('--username', 'Dev2')
if (ENV.MC_CLIENT_ARGS) {
programArguments.addAll(ENV.MC_CLIENT_ARGS.split(' '))
}

jvmArguments.addAll("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
gameDirectory = file 'run'
}

server {
server()
programArgument("--nogui")
Expand Down Expand Up @@ -116,7 +111,7 @@ repositories {
}

dependencies {
api ("dev.latvian.mods:rhino:$rhino_version") { transitive(false) }
api("dev.latvian.mods:rhino:$rhino_version") { transitive(false) }

compileOnly("dev.architectury:architectury-neoforge:$architectury_version")
compileOnly("mezz.jei:jei-1.21-neoforge:$jei_version")
Expand Down Expand Up @@ -190,7 +185,7 @@ unifiedPublishing {
publishing {
publications {
mavenNeoForge(MavenPublication) {
artifactId = "$archives_base_name-neoforge"
artifactId = archives_base_name
from components.java
}
}
Expand Down
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# loom.platform=neoforge

mod_id=kubejs
archives_base_name=kubejs
archives_base_name=kubejs-neoforge
mod_name=KubeJS
maven_group=dev.latvian.mods
mod_author=latvian.dev
Expand All @@ -13,11 +12,11 @@ modrinth_id=umyGl7zF
minecraft_version=1.21
mod_version=2100.7.0

neoforge_version=21.0.106-beta
neoforge_version=21.0.114-beta
parchment_version=2024.07.07
rhino_version=2100.2.5-build.41
architectury_version=13.0.4
rhino_version=2100.2.5-build.44

rei_version=16.0.729
jei_version=19.5.0.31
architectury_version=13.0.6
rei_version=16.0.744
jei_version=19.5.0.47
emi_version=1.1.10+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;

import java.lang.reflect.AccessibleObject;
Expand Down Expand Up @@ -75,6 +76,10 @@ public Scriptable wrapAsJavaObject(Scriptable scope, Object javaObject, TypeInfo
return super.wrapAsJavaObject(scope, javaObject, target);
}

private static boolean isKey(Object from) {
return from instanceof CharSequence || from instanceof ResourceLocation || from instanceof ResourceKey<?>;
}

@Override
public int internalConversionWeightLast(Object fromObj, TypeInfo target) {
var c = target.asClass();
Expand Down Expand Up @@ -149,7 +154,7 @@ protected Object internalJsToJavaLast(Object from, TypeInfo target) {
throw throwAsScriptRuntimeEx(new IllegalAccessException("Reflection access denied"), this);
} else if (from instanceof Holder<?> holder && c.isInstance(holder.value())) {
return holder.value();
} else {
} else if (isKey(from)) {
var reg = RegistryType.lookup(target);

if (reg != null) {
Expand Down

0 comments on commit eb779b3

Please sign in to comment.