mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-04-15 07:13:13 +00:00
STOP DOING MIXINS (on Forge)
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 cb8e06af2aefd931b1f6743849a7afb2a25ea0bd, 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.
This commit is contained in:
parent
afe16cc593
commit
4675583e1c
@ -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 {
|
||||
|
@ -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"
|
||||
@ -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" }
|
||||
|
||||
|
@ -385,7 +385,7 @@ public final class CommandComputerCraft {
|
||||
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")
|
||||
|
@ -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;
|
||||
@ -54,6 +55,13 @@ public final class ChatHelpers {
|
||||
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();
|
||||
|
||||
|
@ -389,4 +389,13 @@ public interface PlatformHelper extends dan200.computercraft.impl.PlatformHelper
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
@ -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()) }
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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" } }
|
||||
|
@ -1,66 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.mixin.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import dan200.computercraft.client.ClientHooks;
|
||||
import net.minecraft.client.renderer.block.BlockModelShaper;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.renderer.block.ModelBlockRenderer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
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.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Provides custom block breaking progress for modems, so it only applies to the current part.
|
||||
*
|
||||
* @see BlockRenderDispatcher#renderBreakingTexture(BlockState, BlockPos, BlockAndTintGetter, PoseStack, VertexConsumer, ModelData)
|
||||
*/
|
||||
@Mixin(BlockRenderDispatcher.class)
|
||||
public class BlockRenderDispatcherMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private RandomSource random;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private BlockModelShaper blockModelShaper;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ModelBlockRenderer modelRenderer;
|
||||
|
||||
@Inject(
|
||||
method = "name=/^renderBreakingTexture/ desc=/ModelData;\\)V$/",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true,
|
||||
require = 0 // This isn't critical functionality, so don't worry if we can't apply it.
|
||||
)
|
||||
public void renderBlockDamage(
|
||||
BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack pose, VertexConsumer buffers, ModelData modelData,
|
||||
CallbackInfo info
|
||||
) {
|
||||
var newState = ClientHooks.getBlockBreakingState(state, pos);
|
||||
if (newState != null) {
|
||||
info.cancel();
|
||||
|
||||
var model = blockModelShaper.getBlockModel(newState);
|
||||
modelRenderer.tesselateBlock(
|
||||
world, model, newState, pos, pose, buffers, true, random, newState.getSeed(pos),
|
||||
OverlayTexture.NO_OVERLAY, modelData, null
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.mixin.client;
|
||||
|
||||
import dan200.computercraft.shared.command.CommandComputerCraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* Allows triggering ComputerCraft's client commands from chat components events.
|
||||
*/
|
||||
@Mixin(ClientPacketListener.class)
|
||||
class ClientPacketListenerMixin {
|
||||
@Inject(method = "sendUnsignedCommand", at = @At("HEAD"), cancellable = true)
|
||||
void commandUnsigned(String command, CallbackInfoReturnable<Boolean> ci) {
|
||||
if (command.startsWith(CommandComputerCraft.CLIENT_OPEN_FOLDER) && ClientCommandHandler.runCommand(command)) {
|
||||
ci.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "dan200.computercraft.mixin.client",
|
||||
"minVersion": "0.8",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"client": [
|
||||
"BlockRenderDispatcherMixin",
|
||||
"ClientPacketListenerMixin"
|
||||
],
|
||||
"refmap": "client-computercraft.refmap.json"
|
||||
}
|
@ -345,6 +345,11 @@ public class PlatformHelperImpl implements PlatformHelper {
|
||||
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> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user