Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package eu.oskar3123.fabric.test;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class ExampleMod implements ModInitializer
|
||||
{
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
System.out.println("Hello Fabric world!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package eu.oskar3123.fabric.test;
|
||||
|
||||
public class TapemouseCommand
|
||||
{
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
public static boolean isEnabled()
|
||||
{
|
||||
return TapemouseCommand.enabled;
|
||||
}
|
||||
|
||||
public static void toggle()
|
||||
{
|
||||
TapemouseCommand.enabled = !TapemouseCommand.enabled;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package eu.oskar3123.fabric.test.mixin;
|
||||
|
||||
import eu.oskar3123.fabric.test.TapemouseCommand;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class MixinClientPlayerEntity
|
||||
{
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable = true)
|
||||
public void onSendChatMessage(String string, CallbackInfo info)
|
||||
{
|
||||
if (string == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String str = string + " ";
|
||||
if (str.toLowerCase().startsWith(".tapemouse "))
|
||||
{
|
||||
TapemouseCommand.toggle();
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
client.player.addChatMessage(new StringTextComponent("Tapemouse enabled: " + TapemouseCommand.isEnabled()), false);
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package eu.oskar3123.fabric.test.mixin;
|
||||
|
||||
import eu.oskar3123.fabric.test.TapemouseCommand;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(KeyBinding.class)
|
||||
public class MixinKeyBinding
|
||||
{
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "isPressed()Z", cancellable = true)
|
||||
public void onIsPressed(CallbackInfoReturnable<Boolean> info)
|
||||
{
|
||||
if (this.id == null || !this.id.equals("key.use"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!TapemouseCommand.isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
info.setReturnValue(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
||||
public class ExampleMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
System.out.println("Hello Fabric world!");
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package net.fabricmc.example.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class ExampleMixin {
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
System.out.println("This line is printed by an example mod mixin!");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"net.fabricmc.example.ExampleMod"
|
||||
"eu.oskar3123.fabric.test.ExampleMod"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "net.fabricmc.example.mixin",
|
||||
"package": "eu.oskar3123.fabric.test.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ExampleMixin"
|
||||
"MixinClientPlayerEntity",
|
||||
"MixinKeyBinding"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user