Skip to content

Commit 1e624f9

Browse files
authored
Merge pull request Weave-MC#4 from xtrm-en/master
Update to Weave 1.0.0-b.1 + minor improvements
2 parents e403baf + 5211bd8 commit 1e624f9

File tree

10 files changed

+121
-95
lines changed

10 files changed

+121
-95
lines changed

.gitignore

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
# Eclipse IDE Files.
2+
eclipse
3+
bin
4+
*.launch
5+
.settings
6+
.metadata
7+
.classpath
8+
.project
9+
10+
# IntelliJ IDEA Output Files.
11+
out
12+
classes
13+
*.ipr
14+
*.iws
15+
*.iml
116
.idea
17+
18+
# VScode Configuration Directory.
19+
.vscode
20+
21+
# Gradle Output Directories.
222
build
3-
.gradle
23+
.gradle
24+
25+
# Netbeans Output Files.
26+
.nb-gradle
27+
.nb-gradle-properties
28+
29+
# Compiled class file
30+
*.class
31+
32+
# Log file
33+
*.log
34+
35+
# Package Files #
36+
*.jar
37+
*.war
38+
*.nar
39+
*.ear
40+
*.zip
41+
*.tar.gz
42+
*.rar
43+
44+
# VM Crash Logs.
45+
hs_err_pid*
46+
replay_pid*
47+
48+
# Other
49+
run
50+
.DS_Store
51+
Thumbs.db

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Weave's Mod Template
2+
3+
This repository shows how to setup a [Gradle](https://gradle.org) project with the [Weave Gradle plugin](https://github.com/Weave-MC/Weave-Gradle) to develop mods for Weave.
4+
5+
## How to start?
6+
7+
To use this repository as a template, click on the green **Use this template** button.
8+
9+
Alternatively, you can simply clone this repository with the following commands:
10+
```bash
11+
# You can change "MyCoolMod" to anything you'd like
12+
git clone https://github.com/Weave-MC/ExampleMod MyCoolMod
13+
cd MyCoolMod
14+
```
15+
16+
## How to build
17+
18+
To build a Weave mod, you can simply run:
19+
20+
```bash
21+
./gradlew build
22+
```
23+
24+
You can find the built jar files in `./build/libs/*.jar`.

build.gradle.kts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
plugins {
2-
java
3-
id("com.github.weave-mc.weave-gradle") version "649dba7468"
2+
id("net.weavemc.gradle") version "1.0.0-PRE"
43
}
54

65
group = "com.example"
7-
version = "1.0"
6+
version = "1.0.0"
87

9-
minecraft.version("1.8.9")
8+
minecraft {
9+
configure {
10+
name = "ExampleMod"
11+
modId = "examplemod"
12+
entryPoints = listOf("com.example.mod.ExampleMod")
13+
mixinConfigs = listOf("examplemod.mixins.json")
14+
mcpMappings()
15+
}
16+
version("1.8.9")
17+
}
1018

1119
repositories {
12-
maven("https://jitpack.io")
20+
maven("https://repo.weavemc.dev/releases")
1321
maven("https://repo.spongepowered.org/maven/")
1422
}
1523

1624
dependencies {
17-
compileOnly("com.github.weave-mc:weave-loader:v0.2.4")
18-
25+
compileOnly("net.weavemc.api:common:1.0.0-b.2")
1926
compileOnly("org.spongepowered:mixin:0.8.5")
2027
}
2128

22-
tasks.compileJava {
23-
options.release.set(11)
24-
}
29+
java {
30+
withSourcesJar()
31+
32+
toolchain {
33+
languageVersion.set(JavaLanguageVersion.of(8))
34+
}
35+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
rootProject.name = "ExampleMod"
2-
31
pluginManagement {
42
repositories {
53
gradlePluginPortal()
6-
maven("https://jitpack.io")
4+
maven("https://repo.weavemc.net/releases")
75
}
8-
}
6+
}
7+
8+
plugins {
9+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.+"
10+
}
11+
12+
rootProject.name = "ExampleMod"
Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
package com.example.mod;
22

3-
import net.weavemc.loader.api.ModInitializer;
4-
import net.weavemc.loader.api.command.CommandBus;
5-
import net.weavemc.loader.api.event.*;
6-
import com.example.mod.command.TestCommand;
7-
import com.example.mod.listener.RenderGameOverlayListener;
8-
import net.minecraft.client.Minecraft;
9-
import net.minecraft.util.ChatComponentText;
10-
import org.lwjgl.input.Keyboard;
3+
import net.weavemc.api.ModInitializer;
4+
import org.apache.logging.log4j.LogManager;
5+
import org.apache.logging.log4j.Logger;
6+
import org.jetbrains.annotations.NotNull;
117

12-
public class ExampleMod implements ModInitializer {
13-
@Override
14-
public void preInit() {
15-
System.out.println("Initializing ExampleMod!");
16-
17-
CommandBus.register(new TestCommand());
8+
import java.lang.instrument.Instrumentation;
189

19-
EventBus.subscribe(KeyboardEvent.class, e -> {
20-
if (Minecraft.getMinecraft().currentScreen == null && e.getKeyState()) {
21-
Minecraft.getMinecraft().thePlayer.addChatMessage(
22-
new ChatComponentText("Key Pressed: " + Keyboard.getKeyName(e.getKeyCode()))
23-
);
24-
}
25-
});
26-
EventBus.subscribe(RenderHandEvent.class, e -> e.setCancelled(true));
10+
public class ExampleMod implements ModInitializer {
11+
private final Logger logger = LogManager.getLogger();
2712

28-
EventBus.subscribe(new RenderGameOverlayListener());
13+
@Override
14+
public void init() {
15+
logger.info("Hello from ExampleMod!");
2916
}
17+
18+
//TODO: This will be removed
19+
@SuppressWarnings({"deprecation", "RedundantSuppression"})
20+
@Override public void preInit(@NotNull Instrumentation instrumentation) {}
3021
}

src/main/java/com/example/mod/command/TestCommand.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main/java/com/example/mod/hook/MinecraftHook.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.mod.hook;
22

3-
import net.weavemc.loader.api.Hook;
3+
import net.weavemc.api.Hook;
44
import org.jetbrains.annotations.NotNull;
55
import org.objectweb.asm.Opcodes;
66
import org.objectweb.asm.Type;
@@ -16,15 +16,15 @@ public MinecraftHook() {
1616
public void transform(@NotNull ClassNode classNode, @NotNull AssemblerConfig assemblerConfig) {
1717
classNode.methods.stream()
1818
.filter(m -> m.name.equals("startGame"))
19-
.findFirst().orElseThrow()
20-
.instructions.insert(
19+
.findFirst()
20+
.ifPresent(m -> m.instructions.insert(
2121
new MethodInsnNode(
2222
Opcodes.INVOKESTATIC,
2323
Type.getInternalName(MinecraftHook.class),
2424
"onStartGame",
2525
"()V"
2626
)
27-
);
27+
));
2828
}
2929

3030
@SuppressWarnings("unused")

src/main/java/com/example/mod/listener/RenderGameOverlayListener.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/resources/weave.mod.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)