Skip to content

Commit

Permalink
STOP DOING MIXINS (on Forge)
Browse files Browse the repository at this point in the history
BYTECODE WAS NOT SUPPOSED TO BE REWRITTEN

YEARS OF DEBUGGING REMAPPING FAILURES yet NO ACTUAL SOLUTION FOUND.

Wanted to use Mixins for anyway for a laugh? We had a tool for that: it
was called "FABRIC LOOM".

"Yes, please produce completely broken jars for no discernable reason"
Statements dreamed up by the utterly Deranged.

 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This removes our two mixins used on Forge:

 - Breaking progress for cabled/wired modems.
 - Running client commands from chat click events. We now suggest the
   command on Forge instead.

Occasionally we get issues where the mixin annotation processor doesn't
write its tsrg file in time for the reobfJar/reobfJarJar task. I thought
we'd fixed that cb8e06a, but sometimes
we still produce missing jars - I have a feeling this might be to do
with incremental compilation.

We can maybe re-evaluate this on 1.20.4, where we don't need to worry
about remapping any more.
  • Loading branch information
SquidDev committed Mar 21, 2024
1 parent afe16cc commit 4675583
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ repositories {

val mainMaven = maven("https://squiddev.cc/maven") {
name = "SquidDev"
content {
// Until https://github.com/SpongePowered/Mixin/pull/593 is merged
includeModule("org.spongepowered", "mixin")
}
}

exclusiveContent {
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ illuaminate = "0.1.0-69-gf294ab2"
librarian = "1.+"
lwjgl = "3.3.3"
minotaur = "2.+"
mixinGradle = "0.7.38"
nullAway = "0.9.9"
spotless = "6.23.3"
taskTree = "2.1.1"
Expand Down Expand Up @@ -171,7 +170,6 @@ githubRelease = { id = "com.github.breadmoirai.github-release", version.ref = "g
gradleVersions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersions" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
librarian = { id = "org.parchmentmc.librarian.forgegradle", version.ref = "librarian" }
mixinGradle = { id = "org.spongepowered.mixin", version.ref = "mixinGradle" }
taskTree = { id = "com.dorongold.task-tree", version.ref = "taskTree" }
versionCatalogUpdate = { id = "nl.littlerobots.version-catalog-update", version.ref = "versionCatalogUpdate" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private static Component linkPosition(CommandSourceStack context, ServerComputer
var file = new File(ServerContext.get(source.getServer()).storageDir().toFile(), "computer/" + id);
if (!file.isDirectory()) return null;

return link(
return clientLink(
text("\u270E"),
"/" + CLIENT_OPEN_FOLDER + " " + id,
Component.translatable("commands.computercraft.dump.open_path")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package dan200.computercraft.shared.command.text;

import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.platform.PlatformHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.ClickEvent;
Expand Down Expand Up @@ -54,6 +55,13 @@ public static Component link(MutableComponent component, String command, Compone
return link(component, new ClickEvent(ClickEvent.Action.RUN_COMMAND, command), toolTip);
}

public static Component clientLink(MutableComponent component, String command, Component toolTip) {
var event = PlatformHelper.get().canClickRunClientCommand()
? new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)
: new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return link(component, event, toolTip);
}

public static Component link(Component component, ClickEvent click, Component toolTip) {
var style = component.getStyle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,13 @@ default double getReachDistance(Player player) {
* @see ServerPlayerGameMode#useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult)
*/
InteractionResult useOn(ServerPlayer player, ItemStack stack, BlockHitResult hit, Predicate<BlockState> canUseBlock);

/**
* Whether {@link net.minecraft.network.chat.ClickEvent.Action#RUN_COMMAND} can be used to run client commands.
*
* @return Whether client commands can be triggered from chat components.
*/
default boolean canClickRunClientCommand() {
return true;
}
}
19 changes: 0 additions & 19 deletions projects/forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import net.minecraftforge.gradle.common.util.RunConfig
plugins {
id("cc-tweaked.forge")
id("cc-tweaked.gametest")
alias(libs.plugins.mixinGradle)
id("cc-tweaked.mod-publishing")
}

Expand Down Expand Up @@ -103,12 +102,6 @@ minecraft {
}
}

mixin {
add(sourceSets.client.get(), "client-computercraft.refmap.json")

config("computercraft-client.forge.mixins.json")
}

configurations {
minecraftLibrary { extendsFrom(minecraftEmbed.get()) }

Expand All @@ -121,9 +114,6 @@ configurations {
}

dependencies {
annotationProcessor("org.spongepowered:mixin:0.8.5-SQUID:processor")
clientAnnotationProcessor("org.spongepowered:mixin:0.8.5-SQUID:processor")

compileOnly(libs.jetbrainsAnnotations)
annotationProcessorEverywhere(libs.autoService)

Expand Down Expand Up @@ -246,15 +236,6 @@ modPublishing {
output.set(tasks.jarJar)
}

// Make sure configureReobfTaskForReobfJarJar runs after compilation
// see - https://github.com/SpongePowered/MixinGradle/pull/51
tasks.configureEach {
when (name) {
"configureReobfTaskForReobfJar" -> mustRunAfter(tasks.jar)
"configureReobfTaskForReobfJarJar" -> mustRunAfter(tasks.jarJar)
}
}

// Don't publish the slim jar
for (cfg in listOf(configurations.apiElements, configurations.runtimeElements)) {
cfg.configure { artifacts.removeIf { it.classifier == "slim" } }
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ public InteractionResult useOn(ServerPlayer player, ItemStack stack, BlockHitRes
return event.getUseItem() == Event.Result.DENY ? InteractionResult.PASS : stack.useOn(context);
}

@Override
public boolean canClickRunClientCommand() {
return false;
}

private record RegistryWrapperImpl<T>(
ResourceLocation name, ForgeRegistry<T> registry
) implements RegistryWrappers.RegistryWrapper<T> {
Expand Down

0 comments on commit 4675583

Please sign in to comment.