Skip to content

Commit

Permalink
trinkets
Browse files Browse the repository at this point in the history
  • Loading branch information
NGSpace committed Aug 24, 2024
1 parent d9a2db5 commit 2015735
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
#Wed May 01 18:14:19 IDT 2024
#Sat Aug 24 20:33:42 IDT 2024
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
Expand Down
20 changes: 12 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {
maven {
name = "TerraformersMC"
url = uri("https://maven.terraformersmc.com/releases/")

content {
includeGroup("com.terraformersmc")
}
url = uri("https://maven.terraformersmc.com/")
}

maven {
Expand All @@ -33,6 +29,11 @@ repositories {
includeGroup("me.shedaniel.cloth")
}
}

maven {
name = "Ladysnake Libs"
url = 'https://maven.ladysnake.org/releases'
}
}
configurations {
provided
Expand All @@ -52,7 +53,10 @@ dependencies {
//provided group: 'com.github.oshi', name: 'oshi-core', version: '6.5.0'

modImplementation("com.terraformersmc:modmenu:7.2.2")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:11.0.99")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:11.1.106")

modImplementation "dev.emi:trinkets:3.7.2"

}

processResources {
Expand Down Expand Up @@ -100,4 +104,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ maven_group=io.github.ngspace.hudder
archives_base_name=hudder

# Dependencies
fabric_version=0.92.1+1.20.1
fabric_version=0.92.2+1.20.1
17 changes: 17 additions & 0 deletions hudder_1.20.1_client.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/hudder_1.20.1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.fabricmc.devlaunchinjector.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hudder_1.20.1"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dfabric.dli.config=/mnt/datassd/Projects/minecraft/hudder_1.20.1/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:hudder_1.20.1}/run"/>
</launchConfiguration>
17 changes: 17 additions & 0 deletions hudder_1.20.1_server.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/hudder_1.20.1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.fabricmc.devlaunchinjector.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="nogui"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="hudder_1.20.1"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dfabric.dli.config=/mnt/datassd/Projects/minecraft/hudder_1.20.1/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=server -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotServer"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:hudder_1.20.1}/run"/>
</launchConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public MetaCompiler() {

//Inventory Rendering
register(new ItemStackMethods(),"slot", "item", "hand", "selectedslot", "hat", "helmet", "chestplate", "leggings",
"pants", "boots", "offhand");
"pants", "boots", "offhand", "slot_trinkets");

//Text and compiling
register((i,m,c,type,args)->m.setTextLocation(type,(float) (args.length>0?args[0].asDouble():i.scale)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static io.github.ngspace.hudder.Hudder.ins;

import dev.emi.trinkets.api.TrinketsApi;
import io.github.ngspace.hudder.compilers.ATextCompiler;
import io.github.ngspace.hudder.compilers.CompileException;
import io.github.ngspace.hudder.config.ConfigInfo;
Expand All @@ -16,7 +17,7 @@
public class ItemStackMethods implements IMethod {
@Override
public void invoke(ConfigInfo ci, Meta meta, ATextCompiler comp, String type, Value... args) throws CompileException {
int offset = "slot".equals(type)||"item".equals(type) ? 1:0;
int offset = "slot".equals(type)||"item".equals(type)||"slot_trinkets".equals(type) ? 1:0;
if (args.length<2+offset) {
throw new CompileException("\""+type+"\" only accepts \""+type
+("slot".equals(type)?",[slot]":"")
Expand All @@ -38,6 +39,17 @@ public void invoke(ConfigInfo ci, Meta meta, ATextCompiler comp, String type, Va
case "offhand": yield inv.offHand.get(0);
case "slot": yield inv.getStack(args[0].asInt());
case "item": yield new ItemStack(Registries.ITEM.get(Identifier.tryParse(args[1].asString())));
case "slot_trinkets": {
try {
var op = TrinketsApi.getTrinketComponent(ins.player);
if (op.isEmpty()) throw new CompileException("Optional is empty");
var all = op.get().getAllEquipped();
yield all.get(args[0].asInt()).getRight();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
default: throw new IllegalArgumentException("Unexpected value: " + type);
};
meta.elements.add(new ItemElement(x, y, stack, scale, showcount));
Expand Down

0 comments on commit 2015735

Please sign in to comment.