-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JIJ output location, add CoreMod to testproject for testing (#18)
- Loading branch information
Showing
14 changed files
with
223 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
jar { | ||
manifest { | ||
attributes([ | ||
"FMLModType": "LIBRARY" | ||
]) | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
url = "https://libraries.minecraft.net" | ||
metadataSources{ | ||
mavenPom() | ||
} | ||
} | ||
maven { | ||
url = "https://maven.neoforged.net/releases" | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly 'net.neoforged.fancymodloader:loader:4.0.4' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package coremod; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import cpw.mods.modlauncher.api.ITransformerVotingContext; | ||
import cpw.mods.modlauncher.api.TargetType; | ||
import cpw.mods.modlauncher.api.TransformerVoteResult; | ||
import net.neoforged.neoforgespi.coremod.ICoreMod; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CoreMod implements ICoreMod { | ||
@Override | ||
public Iterable<? extends cpw.mods.modlauncher.api.ITransformer<?>> getTransformers() { | ||
return List.of( | ||
new ITransformer<ClassNode>() { | ||
@Override | ||
public ClassNode transform(ClassNode classNode, ITransformerVotingContext context) { | ||
classNode.visitField( | ||
Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL, | ||
"CORE_MOD_MARKER", | ||
"Z", | ||
null, | ||
true | ||
); | ||
return classNode; | ||
} | ||
|
||
@Override | ||
public TransformerVoteResult castVote(ITransformerVotingContext context) { | ||
return TransformerVoteResult.YES; | ||
} | ||
|
||
@Override | ||
public Set<Target<ClassNode>> targets() { | ||
return Set.of(Target.targetClass("net.minecraft.world.item.ItemStack")); | ||
} | ||
|
||
@Override | ||
public TargetType<ClassNode> getTargetType() { | ||
return TargetType.CLASS; | ||
} | ||
} | ||
); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...t/coremod/src/main/resources/META-INF/services/net.neoforged.neoforgespi.coremod.ICoreMod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coremod.CoreMod |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
plugins { | ||
id 'net.neoforged.moddev' | ||
} | ||
|
||
dependencies { | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
jarJar project(":coremod") | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
neoForge { | ||
version = project.neoforge_version | ||
|
||
runs { | ||
data { | ||
data() | ||
} | ||
} | ||
|
||
mods { | ||
jijtest { | ||
sourceSet sourceSets.main | ||
} | ||
coremod { | ||
dependency project(":coremod") | ||
} | ||
} | ||
|
||
unitTest { | ||
enable() | ||
testedMod = mods.jijtest | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
testproject/jijtest/src/main/resources/META-INF/neoforge.mods.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
modLoader = "javafml" | ||
loaderVersion = "[4,)" | ||
license = "CC0" | ||
[[mods]] | ||
modId = "jijtest" | ||
version = "0.0.0" | ||
displayName = "JIJ Test" | ||
description = '''JIJ Test''' |
16 changes: 16 additions & 0 deletions
16
testproject/jijtest/src/test/java/jijtest/CoreModTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package jijtest; | ||
|
||
import net.minecraft.world.item.ItemStack; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class CoreModTest { | ||
@Test | ||
void testPresenceOfCoreMod() throws Exception { | ||
var field = assertDoesNotThrow(() -> ItemStack.class.getField("CORE_MOD_MARKER")); | ||
assertTrue(field.getBoolean(null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters