mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
add fabric mod information to crash reports
This commit is contained in:
parent
92768d765a
commit
d3e6e9ca73
3 changed files with 76 additions and 0 deletions
|
@ -28,9 +28,16 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Facing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FabricAPI implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
List<String> ss = null;
|
||||
for (String s : ss) {
|
||||
s.length();
|
||||
}
|
||||
|
||||
PlayerInteractionEvent.BREAK_BLOCK.register((player, world, hand, pos, facing) -> {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state instanceof BreakInteractable) {
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.misc;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.fabricmc.loader.FabricLoader;
|
||||
import net.fabricmc.loader.ModContainer;
|
||||
import net.fabricmc.loader.ModInfo;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashReportElement;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Mixin(CrashReport.class)
|
||||
public abstract class MixinCrashReport {
|
||||
@Shadow
|
||||
public abstract CrashReportElement getElement();
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "generateWittyComment", cancellable = true)
|
||||
private static void generateWittyComment(CallbackInfoReturnable<String> info) {
|
||||
if (SystemUtil.getMeasuringTimeNano() % 14723 == 0) {
|
||||
info.setReturnValue("OOPSIE WOOPSIE!! Uwu We made a fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!");
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "method_559")
|
||||
private void method_559(CallbackInfo info) {
|
||||
getElement().add("Fabric Mods", () -> {
|
||||
Map<String, String> mods = new TreeMap<>();
|
||||
for (ModContainer container : FabricLoader.INSTANCE.getMods()) {
|
||||
mods.put(container.getInfo().getName(), container.getInfo().getVersionString() + " (" + container.getOriginFile().getName() + ")");
|
||||
}
|
||||
|
||||
StringBuilder modString = new StringBuilder();
|
||||
|
||||
for (String id : mods.keySet()) {
|
||||
modString.append("\n\t\t");
|
||||
modString.append(id);
|
||||
modString.append(": ");
|
||||
modString.append(mods.get(id));
|
||||
}
|
||||
|
||||
return modString.toString();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
"events.server.MixinMinecraftServer",
|
||||
"events.tick.MixinMinecraftServer",
|
||||
"events.tick.MixinWorld",
|
||||
"misc.MixinCrashReport",
|
||||
"networking.MixinServerPlayNetworkHandler",
|
||||
"networking.MixinSPacketCustomPayload",
|
||||
"registry.MixinBootstrap",
|
||||
|
|
Loading…
Reference in a new issue