Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# Eclipse IDE Files.
eclipse
bin
*.launch
.settings
.metadata
.classpath
.project

# IntelliJ IDEA Output Files.
out
classes
*.ipr
*.iws
*.iml
.idea

# VScode Configuration Directory.
.vscode

# Gradle Output Directories.
build
.gradle
.gradle

# Netbeans Output Files.
.nb-gradle
.nb-gradle-properties

# Compiled class file
*.class

# Log file
*.log

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# VM Crash Logs.
hs_err_pid*
replay_pid*

# Other
run
.DS_Store
Thumbs.db
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Weave's Mod Template

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.

## How to start?

To use this repository as a template, click on the green **Use this template** button.

Alternatively, you can simply clone this repository with the following commands:
```bash
# You can change "MyCoolMod" to anything you'd like
git clone https://github.com/Weave-MC/ExampleMod MyCoolMod
cd MyCoolMod
```

## How to build

To build a Weave mod, you can simply run:

```bash
./gradlew build
```

You can find the built jar files in `./build/libs/*.jar`.
31 changes: 21 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
plugins {
java
id("com.github.weave-mc.weave-gradle") version "649dba7468"
id("net.weavemc.gradle") version "1.0.0-PRE"
}

group = "com.example"
version = "1.0"
version = "1.0.0"

minecraft.version("1.8.9")
minecraft {
configure {
name = "ExampleMod"
modId = "examplemod"
entryPoints = listOf("com.example.mod.ExampleMod")
mixinConfigs = listOf("examplemod.mixins.json")
mcpMappings()
}
version("1.8.9")
}

repositories {
maven("https://jitpack.io")
maven("https://repo.weavemc.dev/releases")
maven("https://repo.spongepowered.org/maven/")
}

dependencies {
compileOnly("com.github.weave-mc:weave-loader:v0.2.4")

compileOnly("net.weavemc.api:common:1.0.0-b.2")
compileOnly("org.spongepowered:mixin:0.8.5")
}

tasks.compileJava {
options.release.set(11)
}
java {
withSourcesJar()

toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
rootProject.name = "ExampleMod"

pluginManagement {
repositories {
gradlePluginPortal()
maven("https://jitpack.io")
maven("https://repo.weavemc.net/releases")
}
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.+"
}

rootProject.name = "ExampleMod"
37 changes: 14 additions & 23 deletions src/main/java/com/example/mod/ExampleMod.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
package com.example.mod;

import net.weavemc.loader.api.ModInitializer;
import net.weavemc.loader.api.command.CommandBus;
import net.weavemc.loader.api.event.*;
import com.example.mod.command.TestCommand;
import com.example.mod.listener.RenderGameOverlayListener;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText;
import org.lwjgl.input.Keyboard;
import net.weavemc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

public class ExampleMod implements ModInitializer {
@Override
public void preInit() {
System.out.println("Initializing ExampleMod!");

CommandBus.register(new TestCommand());
import java.lang.instrument.Instrumentation;

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

EventBus.subscribe(new RenderGameOverlayListener());
@Override
public void init() {
logger.info("Hello from ExampleMod!");
}

//TODO: This will be removed
@SuppressWarnings({"deprecation", "RedundantSuppression"})
@Override public void preInit(@NotNull Instrumentation instrumentation) {}
}
16 changes: 0 additions & 16 deletions src/main/java/com/example/mod/command/TestCommand.java

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/java/com/example/mod/hook/MinecraftHook.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.mod.hook;

import net.weavemc.loader.api.Hook;
import net.weavemc.api.Hook;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
Expand All @@ -16,15 +16,15 @@ public MinecraftHook() {
public void transform(@NotNull ClassNode classNode, @NotNull AssemblerConfig assemblerConfig) {
classNode.methods.stream()
.filter(m -> m.name.equals("startGame"))
.findFirst().orElseThrow()
.instructions.insert(
.findFirst()
.ifPresent(m -> m.instructions.insert(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
Type.getInternalName(MinecraftHook.class),
"onStartGame",
"()V"
)
);
));
}

@SuppressWarnings("unused")
Expand Down

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/resources/weave.mod.json

This file was deleted.