Skip to content
Merged

Dev #424

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
48 changes: 32 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
plugins {
id("fabric-loom") version "1.15-SNAPSHOT"
id("maven-publish")
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
id("dev.kikugie.loom-back-compat")
}

version = "${project.property("mod_version")}+${stonecutter.current.version}"
group = project.property("maven_group")!!

val lastTask: Task = (if (sc.current.parsed.matches("<26.1")) tasks.named<Task>("remapJar") else tasks.jar).get()

base {
archivesName.set(project.property("archives_base_name") as String)
}
Expand All @@ -23,15 +25,15 @@ loom {
}

stonecutter {
swaps["mouse_clicked_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "Click click, boolean doubleClick" // mouseClicked
swaps["mouse_clicked_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "MouseButtonEvent click, boolean doubleClick" // mouseClicked
swaps["mouse_clicked_args"] = if (current.parsed < "1.21.10") "mouseX, mouseY, button" else "click, doubleClick"
swaps["on_mouse_clicked_args"] = if (current.parsed < "1.21.10") "(int) mouseX, (int) mouseY, button" else "click, doubleClick" // onMouseClicked
swaps["dragged_released_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "Click click" // mouseDragged, mouseReleased
swaps["dragged_released_params"] = if (current.parsed < "1.21.10") "double mouseX, double mouseY, int button" else "MouseButtonEvent click" // mouseDragged, mouseReleased
swaps["dragged_released_args"] = if (current.parsed < "1.21.10") "mouseX, mouseY, button" else "click"
swaps["on_released_args"] = if (current.parsed < "1.21.10") "(int) mouseX, (int) mouseY, button" else "click" // onMouseReleased
swaps["keyinput_params"] = if (current.parsed < "1.21.10") "int keyCode, int scanCode, int modifiers" else "KeyInput input" // keyPressed, keyReleased
swaps["keyinput_params"] = if (current.parsed < "1.21.10") "int keyCode, int scanCode, int modifiers" else "KeyEvent input" // keyPressed, keyReleased
swaps["keyinput_args"] = if (current.parsed < "1.21.10") "keyCode, scanCode, modifiers" else "input"
swaps["charinput_params"] = if (current.parsed < "1.21.10") "char chr, int modifiers" else "CharInput input" // charTyped
swaps["charinput_params"] = if (current.parsed < "1.21.10") "char chr, int modifiers" else "CharacterEvent input" // charTyped
swaps["charinput_args"] = if (current.parsed < "1.21.10") "chr, modifiers" else "input"
swaps["click_and_inputs_imports"] = if (current.parsed < "1.21.10") "" else
"//\nimport net.minecraft.client.gui.Click;\nimport net.minecraft.client.input.KeyInput;\nimport net.minecraft.client.input.CharInput;"
Expand Down Expand Up @@ -71,13 +73,21 @@ repositories {

dependencies {
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")
modImplementation("com.sk89q.worldedit:worldedit-fabric-mc${project.property("worldedit_version")}")
modImplementation("fi.dy.masa.malilib:malilib-fabric-${project.property("malilib_version")}")
modImplementation("net.kr1v:malilib-api:${project.property("malilib_api_version")}") {
exclude(group = "net.fabricmc.fabric-api") // prevent 1.21.5 fabric api modules used by malilib from leaking into 1.21.4
if (sc.current.parsed.matches("<26.1")) {
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")
modImplementation("com.sk89q.worldedit:worldedit-fabric-mc${project.property("worldedit_version")}")
modImplementation("fi.dy.masa.malilib:malilib-fabric-${project.property("malilib_version")}")
modImplementation("net.kr1v:malilib-api:${project.property("malilib_api_version")}") {
exclude(group = "net.fabricmc.fabric-api") // prevent 1.21.5 fabric api modules used by malilib from leaking into 1.21.4
}
} else {
implementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
implementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")
implementation("com.sk89q.worldedit:worldedit-fabric-mc${project.property("worldedit_version")}")
implementation("fi.dy.masa.malilib:malilib-fabric-${project.property("malilib_version")}")
implementation("net.kr1v:malilib-api:${project.property("malilib_api_version")}")
}
annotationProcessor("net.kr1v:malilib-api-processor:1.0.0")
}
Expand Down Expand Up @@ -118,7 +128,7 @@ tasks.processResources {
tasks.register<Copy>("collectFile") {
group = "build"

from(tasks.remapJar)
from(lastTask)
into(rootProject.layout.buildDirectory.dir("libs/${project.property("mod_version")}"))
}

Expand All @@ -129,11 +139,17 @@ tasks.register<DefaultTask>("buildAndCollect") {

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release = 21
if (sc.current.parsed.matches("<26.1"))
options.release = 21
else
options.release = 25
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
if (sc.current.parsed.matches("<26.1"))
toolchain.languageVersion = JavaLanguageVersion.of(21)
else
toolchain.languageVersion = JavaLanguageVersion.of(25)
withSourcesJar()
}

Expand All @@ -156,7 +172,7 @@ publishing {
}

publishMods {
file.set(tasks.remapJar.get().archiveFile)
file.set((lastTask as AbstractArchiveTask).archiveFile)
type.set(STABLE)
modLoaders.add("fabric")

Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ maven_group = tools.redstone
archives_base_name = redstonetools

loader_version=0.18.4
mod_version = 3.3.0
mod_version = 3.4.0

loomx.loom_version = 1.16-SNAPSHOT
loomx.loom_remap_plugin = net.fabricmc.fabric-loom-remap
loomx.loom_unobf_plugin = net.fabricmc.fabric-loom
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-9.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
pluginManagement {
repositories {
maven {
url = uri("https://maven.fabricmc.net/")
}
mavenCentral()
gradlePluginPortal()

maven {
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "KikuGie Snapshots"
url = uri("https://maven.kikugie.dev/snapshots")
}

maven {
name = "KikuGie Releases"
url = uri("https://maven.kikugie.dev/releases")
}
}
}

plugins {
id("dev.kikugie.stonecutter") version "0.8.3"
id("dev.kikugie.loom-back-compat") version "0.3"
}

rootProject.name = "redstonetools-mod"

include("1.21.4")
include("1.21.5")
include("1.21.8")
include("1.21.10")
include("1.21.11")

stonecutter {
centralScript = "build.gradle.kts"

create(rootProject) {
versions("1.21.4", "1.21.5", "1.21.8", "1.21.10", "1.21.11")
versions("1.21.4", "1.21.5", "1.21.8", "1.21.10", "1.21.11", "26.1.2")
vcsVersion = "1.21.11"
}
}
14 changes: 7 additions & 7 deletions src/client/java/tools/redstone/redstonetools/ClientCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.mojang.brigadier.CommandDispatcher;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.commands.CommandBuildContext;
//? if >=1.21.11 {
import net.minecraft.command.DefaultPermissions;
import net.minecraft.command.permission.PermissionCheck;
import net.minecraft.server.command.CommandManager;
import net.minecraft.commands.Commands;
import net.minecraft.server.permissions.PermissionCheck;
import net.minecraft.server.permissions.Permissions;
//?}
import tools.redstone.redstonetools.features.commands.*;
import tools.redstone.redstonetools.features.toggleable.AirPlaceFeature;
Expand All @@ -18,12 +18,12 @@
public class ClientCommands {
public static final Predicate<FabricClientCommandSource> PERMISSION_LEVEL_2 =
//? if <=1.21.10 {
/*source -> source.getPlayer().hasPermissionLevel(2);
/*source -> source.getPlayer().hasPermissions(2);
*///?} else {
CommandManager.requirePermissionLevel(new PermissionCheck.Require(DefaultPermissions.GAMEMASTERS));
Commands.hasPermission(new PermissionCheck.Require(Permissions.COMMANDS_GAMEMASTER));
//?}

public static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
public static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandBuildContext registryAccess) {
if (!DependencyLookup.REDSTONE_TOOLS_SERVER_PRESENT) {
BaseConvertClient.INSTANCE.registerCommand(dispatcher, registryAccess);
ReachClient.INSTANCE.registerCommand(dispatcher, registryAccess);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import kr1v.malilibApi.MalilibApi;
import net.fabricmc.api.ClientModInitializer;
//? if >=26.1 {
/*import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLevelEvents;
*///? } else {
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientWorldEvents;
//? }
import tools.redstone.redstonetools.config.ClientData;
import tools.redstone.redstonetools.packets.RedstoneToolsClientPackets;

Expand All @@ -16,28 +20,32 @@ public void onInitializeClient() {
LOGGER.info("Initializing Redstone Tools");
MalilibApi.registerMod(MOD_ID, MOD_NAME);

//? if >=26.1 {
/*ClientLevelEvents.AFTER_CLIENT_LEVEL_CHANGE.register((client, clientWorld) -> {
*///? } else {
ClientWorldEvents.AFTER_CLIENT_WORLD_CHANGE.register((client, clientWorld) -> {
if (client.getNetworkHandler() != null) { // dimension change
//? }
if (client.getConnection() != null) { // dimension change
String dimensionChange = ClientData.AUTORUN_DIMENSION_CHANGE.getStringValue();
if (dimensionChange.startsWith("/")) {
client.getNetworkHandler().sendChatCommand(dimensionChange.substring(1));
client.getConnection().sendCommand(dimensionChange.substring(1));
} else if (!dimensionChange.isEmpty()){
client.getNetworkHandler().sendChatMessage(dimensionChange);
client.getConnection().sendChat(dimensionChange);
}
} else { // world entry
String worldEntry = ClientData.AUTORUN_WORLD_ENTRY.getStringValue();
if (worldEntry.startsWith("/")) {
client.send(() -> client.getNetworkHandler().sendChatCommand(worldEntry.substring(1)));
client.execute(() -> client.getConnection().sendCommand(worldEntry.substring(1)));
} else if (!worldEntry.isEmpty()){
client.send(() -> client.getNetworkHandler().sendChatMessage(worldEntry));
client.execute(() -> client.getConnection().sendChat(worldEntry));
}
if (hasRanCommands) return;
hasRanCommands = true;
String firstWorldEntry = ClientData.AUTORUN_FIRST_WORLD_ENTRY.getStringValue();
if (firstWorldEntry.startsWith("/")) {
client.send(() -> client.getNetworkHandler().sendChatCommand(firstWorldEntry.substring(1)));
client.execute(() -> client.getConnection().sendCommand(firstWorldEntry.substring(1)));
} else if (!firstWorldEntry.isEmpty()) {
client.send(() -> client.getNetworkHandler().sendChatMessage(firstWorldEntry));
client.execute(() -> client.getConnection().sendChat(firstWorldEntry));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import kr1v.malilibApi.annotation.Config;
import tools.redstone.redstonetools.RedstoneTools;

@Config(RedstoneTools.MOD_ID)
@Config(value = RedstoneTools.MOD_ID, name = "Chat")
public class ClientData {
public static final ConfigBoolean ENABLE_MATH_VARIABLES = new ConfigBoolean("Enable math and variables for the chat input suggester", true,
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import kr1v.malilibApi.MalilibApi;
import kr1v.malilibApi.config._new.CustomConfigBase;
import kr1v.malilibApi.interfaces.IHotkeyContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import tools.redstone.redstonetools.config.MacroManager;
import tools.redstone.redstonetools.macros.actions.Action;
import tools.redstone.redstonetools.macros.actions.CommandAction;
Expand Down Expand Up @@ -114,9 +114,9 @@ public void resetToDefault() {
static {
MalilibApi.registerButtonBasedConfigType(ConfigMacro.class, (widgetConfigOption, configMacro, x, y, configWidth, configHeight) -> new ButtonGeneric(x, y, configWidth, configHeight, configMacro.getMacroName()) {
@Override
protected boolean onMouseClickedImpl(/*? if >=1.21.10 {*/net.minecraft.client.gui.Click click, boolean doubleClick/*? } else {*//*int mouseX, int mouseY, int mouseButton*//*? }*/) {
protected boolean onMouseClickedImpl(/*? if >=1.21.10 {*/net.minecraft.client.input.MouseButtonEvent click, boolean doubleClick/*? } else {*//*int mouseX, int mouseY, int mouseButton*//*? }*/) {
super.onMouseClickedImpl(/*? if >=1.21.10 {*/click, doubleClick/*? } else {*//*mouseX, mouseY, mouseButton*//*? }*/);
GuiBase.openGui(new GuiMacroEditor(Text.of(configMacro.macroName), configMacro, MinecraftClient.getInstance().currentScreen));
GuiBase.openGui(new GuiMacroEditor(Component.nullToEmpty(configMacro.macroName), configMacro, Minecraft.getInstance().screen));
return true;
}
});
Expand Down Expand Up @@ -181,8 +181,11 @@ public void run() {
if (muted) MacroManager.shouldMute = true;
if (!enabled) return;
if (layers.getAndSet(layers.get() + 1) > 100) {
assert MinecraftClient.getInstance().player != null;
MinecraftClient.getInstance().player.sendMessage(Text.of("Please don't cause a stackoverflow :("), false);
assert Minecraft.getInstance().player != null;
//? if <26.1 {
Minecraft.getInstance().player.displayClientMessage(Component.literal("Please don't cause a stackoverflow :("), false);
//? } else
//Minecraft.getInstance().player.sendSystemMessage(Component.literal("Please don't cause a stackoverflow :("));
return;
}
try {
Expand All @@ -191,8 +194,11 @@ public void run() {
}
} catch (StackOverflowError ignored) {
try {
assert MinecraftClient.getInstance().player != null;
MinecraftClient.getInstance().player.sendMessage(Text.of("Please don't cause a stackoverflow :("), false);
assert Minecraft.getInstance().player != null;
//? if <26.1 {
Minecraft.getInstance().player.displayClientMessage(Component.literal("Please don't cause a stackoverflow :("), false);
//? } else
//Minecraft.getInstance().player.sendSystemMessage(Component.literal("Please don't cause a stackoverflow :("));
} catch (NoClassDefFoundError e) {
// yeah we are absolutely cooked, there is no way to recover from this. I'm not even sure this can happen
// actually there's probably a better throwable to be thrown here. whatever.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.commands.CommandBuildContext;

//? if >=26.1 {
/*import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.literal;
*///? } else {
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
//? }

public class BaseConvertClient {
public static final BaseConvertClient INSTANCE = new BaseConvertClient();

protected BaseConvertClient() {
}
public void registerCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
public void registerCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandBuildContext registryAccess) {
dispatcher.register(
ClientCommandManager.literal("base")
.then(ClientCommandManager.argument("inputNum", StringArgumentType.word())
.then(ClientCommandManager.argument("toBase", IntegerArgumentType.integer(2, 16))
literal("base")
.then(argument("inputNum", StringArgumentType.word())
.then(argument("toBase", IntegerArgumentType.integer(2, 16))
.executes(context -> BaseConvertFeature.INSTANCE.execute(
StringArgumentType.getString(context, "inputNum"),
IntegerArgumentType.getInteger(context, "toBase"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.text.Text;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.network.chat.Component;

import java.util.HashMap;
import java.util.Map;

//? if >=26.1 {
/*import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.literal;
*///? } else {
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
//? }

public class ClientDataFeature {
public Map<String, String> variables = new HashMap<>();
public static final ClientDataFeature INSTANCE = new ClientDataFeature();

public void registerCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
public void registerCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandBuildContext registryAccess) {
dispatcher.register(literal("clientdata")
.then(literal("set")
.then(argument("name", StringArgumentType.word())
Expand All @@ -25,7 +30,7 @@ public void registerCommand(CommandDispatcher<FabricClientCommandSource> dispatc
String name = StringArgumentType.getString(context, "name");
String value = StringArgumentType.getString(context, "value");
variables.put(name, value);
context.getSource().sendFeedback(Text.of("Set " + name + " to \"" + value + "\""));
context.getSource().sendFeedback(Component.literal("Set " + name + " to \"" + value + "\""));
return 1;
}
)
Expand Down
Loading
Loading