Skip to content

Commit

Permalink
some commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ToCraft committed Jun 19, 2024
1 parent a6dd410 commit 424ec22
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 66 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
craftedcore 4.3.1
================

- fix mixins on forge not working properly anymore

craftedcore 4.3
================

Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ loom {

dependencies {
// mixin extras
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.6"))
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.mixinextras_version}"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import tocraft.craftedcore.platform.PlatformData;
import tocraft.craftedcore.util.TraceUtils;

// based on code by comp500 (licensed as MIT, take a look https://github.com/comp500/mixintrace for details)
Expand All @@ -17,8 +16,6 @@ public abstract class CrashReportCategoryMixin {

@Inject(method = "getDetails", at = @At("TAIL"))
private void onGetDetails(StringBuilder crashReportBuilder, CallbackInfo ci) {
if (!PlatformData.isModLoaded("mixintrace")) {
TraceUtils.printMixinTrace(stackTrace, crashReportBuilder);
}
TraceUtils.printMixinTrace(stackTrace, crashReportBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import tocraft.craftedcore.platform.PlatformData;
import tocraft.craftedcore.util.TraceUtils;

// based on code by comp500 (licensed as MIT, take a look https://github.com/comp500/mixintrace for details)
@Mixin(CrashReport.class)
public abstract class CrashReportMixin {
@Shadow
Expand All @@ -18,19 +16,17 @@ public abstract class CrashReportMixin {
@Inject(method = "getDetails(Ljava/lang/StringBuilder;)V",
at = @At(value = "FIELD", target = "Lnet/minecraft/CrashReport;details:Ljava/util/List;"))
private void onGetDetails(StringBuilder crashReportBuilder, CallbackInfo ci) {
if (!PlatformData.isModLoaded("mixintrace")) {
int trailingNewlineCount = 0;
// Remove trailing \n
if (crashReportBuilder.charAt(crashReportBuilder.length() - 1) == '\n') {
crashReportBuilder.deleteCharAt(crashReportBuilder.length() - 1);
trailingNewlineCount++;
}
if (crashReportBuilder.charAt(crashReportBuilder.length() - 1) == '\n') {
crashReportBuilder.deleteCharAt(crashReportBuilder.length() - 1);
trailingNewlineCount++;
}
TraceUtils.printMixinTrace(uncategorizedStackTrace, crashReportBuilder);
crashReportBuilder.append("\n".repeat(trailingNewlineCount));
int trailingNewlineCount = 0;
// Remove trailing \n
if (crashReportBuilder.charAt(crashReportBuilder.length() - 1) == '\n') {
crashReportBuilder.deleteCharAt(crashReportBuilder.length() - 1);
trailingNewlineCount++;
}
if (crashReportBuilder.charAt(crashReportBuilder.length() - 1) == '\n') {
crashReportBuilder.deleteCharAt(crashReportBuilder.length() - 1);
trailingNewlineCount++;
}
TraceUtils.printMixinTrace(uncategorizedStackTrace, crashReportBuilder);
crashReportBuilder.append("\n".repeat(trailingNewlineCount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import tocraft.craftedcore.platform.PlatformData;
import tocraft.craftedcore.util.TraceUtils;

// based on code by comp500
@Mixin(MinecraftServer.class)
public abstract class MinecraftServerMixin {
@Inject(method = "onServerCrash", at = @At("HEAD"))
private void onOnServerCrash(CrashReport report, CallbackInfo ci) {
if (!PlatformData.isModLoaded("mixintrace")) {
StringBuilder crashReportBuilder = new StringBuilder();
TraceUtils.printMixinTrace(report.getException().getStackTrace(), crashReportBuilder);
System.out.println(crashReportBuilder);
}
StringBuilder crashReportBuilder = new StringBuilder();
TraceUtils.printMixinTrace(report.getException().getStackTrace(), crashReportBuilder);
System.out.println(crashReportBuilder);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import tocraft.craftedcore.platform.PlatformData;
import tocraft.craftedcore.util.TraceUtils;

import java.io.File;
Expand All @@ -19,10 +18,8 @@
public abstract class MinecraftMixin {
@Inject(method = "crash", at = @At("HEAD"))
private static void onCrash(Minecraft minecraft, File gameDirectory, CrashReport report, CallbackInfo ci) {
if (!PlatformData.isModLoaded("mixintrace")) {
StringBuilder crashReportBuilder = new StringBuilder();
TraceUtils.printMixinTrace(report.getException().getStackTrace(), crashReportBuilder);
System.out.println(crashReportBuilder);
}
StringBuilder crashReportBuilder = new StringBuilder();
TraceUtils.printMixinTrace(report.getException().getStackTrace(), crashReportBuilder);
System.out.println(crashReportBuilder);
}
}
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ loom {

dependencies {
// mixin extras
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.3.6")))
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${rootProject.mixinextras_version}")))
}
4 changes: 2 additions & 2 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ loom {

dependencies {
// mixin extras
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.6"))
implementation(include("io.github.llamalad7:mixinextras-forge:0.3.6"))
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.mixinextras_version}"))
implementation(include("io.github.llamalad7:mixinextras-forge:${rootProject.mixinextras_version}"))
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package tocraft.craftedcore.forge.client;

import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import tocraft.craftedcore.event.client.ClientPlayerEvents;
import tocraft.craftedcore.event.client.ClientTickEvents;
import tocraft.craftedcore.event.client.RenderEvents;
import tocraft.craftedcore.registration.forge.KeyBindingRegistryImpl;

@SuppressWarnings("unused")
@OnlyIn(Dist.CLIENT)
public class CraftedCoreForgeEventHandlerClient {
// FIXME: Where is RenderGuiEvent.Post ???
@SubscribeEvent
public void eventRenderGameOverlayEvent(CustomizeGuiOverlayEvent event) {
public void event(CustomizeGuiOverlayEvent event) {
RenderEvents.HUD_RENDERING.invoke().render(event.getGuiGraphics(), event.getPartialTick());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.network.ChannelBuilder;
import net.minecraftforge.network.EventNetworkChannel;
Expand Down Expand Up @@ -43,7 +42,7 @@ public Player getPlayer() {

@Override
public ModernNetworking.Env getEnv() {
return event.getSource().getDirection().getReceptionSide() == LogicalSide.CLIENT ? ModernNetworking.Env.CLIENT : ModernNetworking.Env.SERVER;
return event.getSource().isClientSide() ? ModernNetworking.Env.CLIENT : ModernNetworking.Env.SERVER;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package tocraft.craftedcore.registration.forge;

import com.mojang.logging.LogUtils;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.commons.lang3.ArrayUtils;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("unused")
@OnlyIn(Dist.CLIENT)
public final class KeyBindingRegistryImpl {
Expand Down
14 changes: 0 additions & 14 deletions forge/src/main/resources/craftedcore-forge.mixins.json

This file was deleted.

3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G
minecraft_version=1.20.6
supported_versions=1.20.6
archives_base_name=craftedcore
mod_version=4.3
mod_version=4.3.1
artifact_type=release
maven_group=dev.tocraft
# Loader Versions
Expand All @@ -18,6 +18,7 @@ modrinth_id=Dg7PHdkJ
required_dependencies=
optional_dependencies=
# Platforms
mixinextras_version=0.4.0-beta.2
enabled_platforms=fabric,neoforge
java_version=21
# Discord Webhook
Expand Down
4 changes: 2 additions & 2 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ loom {

dependencies {
// mixin extras
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.6"))
implementation(include("io.github.llamalad7:mixinextras-neoforge:0.3.6"))
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${rootProject.mixinextras_version}"))
implementation(include("io.github.llamalad7:mixinextras-neoforge:${rootProject.mixinextras_version}"))
}

0 comments on commit 424ec22

Please sign in to comment.