mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-09-06 01:07:59 +02:00
Re-add Debug Hud information list
This commit is contained in:
parent
a19c7085e9
commit
55e9c024cf
@ -48,7 +48,6 @@ import java.io.File;
|
||||
* TODO | Migration v3
|
||||
* - Rename all methods
|
||||
* - Use ViaProxy config patch for some clientside fixes options (Remove ViaFabricPlusVLViaConfig and MixinViaLegacyConfig)
|
||||
* - Re-add Debug Hud information list
|
||||
* - Fix auto detect to not be a huge mess
|
||||
* - Fix MixinAbstractDonkeyEntity
|
||||
* - Boats are probably broken. Check entity height offset fix
|
||||
|
@ -33,6 +33,8 @@ public class ViaFabricPlusMixinPlugin implements IMixinConfigPlugin {
|
||||
private static final String MC_FIXES_PACKAGE = "fixes.minecraft.";
|
||||
private static final String COMPAT_PACKAGE = "compat.";
|
||||
|
||||
public static String VFP_VERSION;
|
||||
|
||||
public static boolean DASH_LOADER_PRESENT;
|
||||
public static boolean ARMOR_SKIN_PRESENT;
|
||||
public static boolean IPNEXT_PRESENT;
|
||||
@ -41,6 +43,8 @@ public class ViaFabricPlusMixinPlugin implements IMixinConfigPlugin {
|
||||
public void onLoad(String mixinPackage) {
|
||||
final FabricLoader loader = FabricLoader.getInstance();
|
||||
|
||||
VFP_VERSION = loader.getModContainer("viafabricplus").get().getMetadata().getVersion().getFriendlyString();
|
||||
|
||||
DASH_LOADER_PRESENT = loader.isModLoaded("dashloader");
|
||||
ARMOR_SKIN_PRESENT = loader.isModLoaded("armorskin");
|
||||
IPNEXT_PRESENT = loader.isModLoaded("inventoryprofilesnext");
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.access;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface IBlobCache {
|
||||
|
||||
Map<Long, CompletableFuture<byte[]>> viaFabricPlus$getPending();
|
||||
}
|
@ -19,9 +19,28 @@
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.base.integration;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.fixes.tracker.JoinGameTracker;
|
||||
import de.florianmichael.viafabricplus.injection.ViaFabricPlusMixinPlugin;
|
||||
import de.florianmichael.viafabricplus.injection.access.IBlobCache;
|
||||
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
|
||||
import de.florianmichael.viafabricplus.protocolhack.provider.viabedrock.ViaFabricPlusBlobCacheProvider;
|
||||
import de.florianmichael.viafabricplus.settings.impl.GeneralSettings;
|
||||
import de.florianmichael.viafabricplus.util.ChatUtil;
|
||||
import de.florianmichael.viafabricplus.util.StringUtil;
|
||||
import net.lenni0451.reflect.stream.RStream;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.DebugHud;
|
||||
import net.raphimc.viabedrock.protocol.data.enums.bedrock.ServerMovementModes;
|
||||
import net.raphimc.viabedrock.protocol.providers.BlobCacheProvider;
|
||||
import net.raphimc.viabedrock.protocol.storage.BlobCache;
|
||||
import net.raphimc.viabedrock.protocol.storage.GameSessionStorage;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.storage.ExtensionProtocolMetadataStorage;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.storage.SeedStorage;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.EntityTracker;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -29,15 +48,88 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@SuppressWarnings("DataFlowIssue")
|
||||
@Mixin(DebugHud.class)
|
||||
public abstract class MixinDebugHud {
|
||||
|
||||
@Inject(method = "getLeftText", at = @At("RETURN"))
|
||||
public void addViaFabricPlusInformation(CallbackInfoReturnable<List<String>> cir) {
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() || !GeneralSettings.global().showExtraInformationInDebugHud.getValue()) return;
|
||||
if (!GeneralSettings.global().showExtraInformationInDebugHud.getValue()) {
|
||||
return;
|
||||
}
|
||||
if (MinecraftClient.getInstance().isInSingleplayer() || ProtocolHack.getTargetVersion() == ProtocolHack.NATIVE_VERSION) {
|
||||
return;
|
||||
}
|
||||
final UserConnection userConnection = ProtocolHack.getPlayNetworkUserConnection();
|
||||
|
||||
final List<String> information = new ArrayList<>();
|
||||
information.add("");
|
||||
|
||||
// Title
|
||||
information.add(ChatUtil.PREFIX + " " + ViaFabricPlusMixinPlugin.VFP_VERSION);
|
||||
|
||||
// common
|
||||
final ProtocolInfo info = userConnection.getProtocolInfo();
|
||||
information.add(
|
||||
"P: " + info.getPipeline().pipes().size() +
|
||||
" / C: " + ProtocolVersion.getProtocol(info.getProtocolVersion()) +
|
||||
" / S: " + ProtocolVersion.getProtocol(info.getServerProtocolVersion())
|
||||
);
|
||||
|
||||
// bedrock
|
||||
final JoinGameTracker joinGameTracker = userConnection.get(JoinGameTracker.class);
|
||||
|
||||
if (joinGameTracker != null) {
|
||||
final int movementMode = userConnection.get(GameSessionStorage.class).getMovementMode();
|
||||
String movement = "Server with rewind";
|
||||
if (movementMode == ServerMovementModes.CLIENT) {
|
||||
movement = "Client";
|
||||
} else if (movementMode == ServerMovementModes.SERVER) {
|
||||
movement = "Server";
|
||||
}
|
||||
|
||||
information.add("Bedrock Level: " + joinGameTracker.getLevelId() + " / Enchantment Seed: " + joinGameTracker.getEnchantmentSeed() + " / Movement: " + movement);
|
||||
}
|
||||
final BlobCache blobCache = userConnection.get(BlobCache.class);
|
||||
if (blobCache != null) {
|
||||
final var blobCacheProvider = (ViaFabricPlusBlobCacheProvider) Via.getManager().getProviders().get(BlobCacheProvider.class);
|
||||
|
||||
final long totalSize = blobCacheProvider.getSize();
|
||||
final int blobCount = blobCacheProvider.getBlobs().size();
|
||||
final int pendingCount = ((IBlobCache) blobCache).viaFabricPlus$getPending().size();
|
||||
|
||||
if (totalSize != 0 || blobCount != 0 || pendingCount != 0) {
|
||||
information.add("Blob Cache: S: " + StringUtil.formatBytes(totalSize) + " / C: " + blobCount + " / Pending: " + pendingCount);
|
||||
}
|
||||
}
|
||||
|
||||
// r1_7_10
|
||||
final EntityTracker entityTracker1_7_10 = userConnection.get(EntityTracker.class);
|
||||
if (entityTracker1_7_10 != null) {
|
||||
information.add(
|
||||
"1.7 Entities: " + entityTracker1_7_10.getTrackedEntities().size() +
|
||||
" / Virtual holograms: " + entityTracker1_7_10.getVirtualHolograms().size()
|
||||
);
|
||||
}
|
||||
|
||||
// r1_1 and bedrock
|
||||
final SeedStorage seedStorage = userConnection.get(SeedStorage.class);
|
||||
if (seedStorage != null) {
|
||||
information.add("World Seed: " + seedStorage.seed);
|
||||
} else if (joinGameTracker != null) {
|
||||
information.add("World Seed: " + joinGameTracker.getSeed());
|
||||
}
|
||||
|
||||
// c0.30cpe
|
||||
final ExtensionProtocolMetadataStorage extensionProtocolMetadataStorage = userConnection.get(ExtensionProtocolMetadataStorage.class);
|
||||
if (extensionProtocolMetadataStorage != null) {
|
||||
information.add("CPE extensions: " + extensionProtocolMetadataStorage.getExtensionCount());
|
||||
}
|
||||
|
||||
information.add("");
|
||||
|
||||
cir.getReturnValue().addAll(information);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viabedrock;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.viabedrock;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import de.florianmichael.viafabricplus.fixes.tracker.JoinGameTracker;
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.viabedrock;
|
||||
|
||||
import de.florianmichael.viafabricplus.injection.access.IBlobCache;
|
||||
import net.raphimc.viabedrock.protocol.storage.BlobCache;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(value = BlobCache.class, remap = false)
|
||||
public class MixinBlobCache implements IBlobCache {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Map<Long, CompletableFuture<byte[]>> pending;
|
||||
|
||||
@Override
|
||||
public Map<Long, CompletableFuture<byte[]>> viaFabricPlus$getPending() {
|
||||
return pending;
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viabedrock;
|
||||
package de.florianmichael.viafabricplus.injection.mixin.viabedrock;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@ -40,7 +40,7 @@ public abstract class MixinJoinPackets {
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Redirect(method = "lambda$register$2", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 56))
|
||||
@Redirect(method = "lambda$register$2", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 55))
|
||||
private static Object trackLevelId(PacketWrapper instance, Type<StringType> tType) throws Exception {
|
||||
final Object levelId = instance.read(tType);
|
||||
instance.user().get(JoinGameTracker.class).setLevelId((String) levelId);
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.florianmichael.viafabricplus.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
// Stolen from https://github.com/FlorianMichael/RClasses/blob/main/common/src/main/java/de/florianmichael/rclasses/common/StringUtils.java
|
||||
public class StringUtil {
|
||||
|
||||
/**
|
||||
* Convention: IEC 60027-2
|
||||
*/
|
||||
private final static String[] BYTES_UNIT = {"B", "KiB", "MiB", "GiB", "TiB"};
|
||||
private final static DecimalFormat OPTIONAL_FORMAT = new DecimalFormat("#.##");
|
||||
|
||||
/**
|
||||
* Formats a value in bytes to a human-readable format
|
||||
*
|
||||
* @param value The raw value in bytes
|
||||
* @return The formatted value in bytes
|
||||
*/
|
||||
public static String formatBytes(final long value) {
|
||||
int index = (int) (Math.log(value) / Math.log(1024.0));
|
||||
double data = value / Math.pow(1024.0, index);
|
||||
if (index < 0) index = 0;
|
||||
if (Double.isNaN(data)) data = 0;
|
||||
|
||||
return OPTIONAL_FORMAT.format(data) + " " + BYTES_UNIT[index];
|
||||
}
|
||||
|
||||
}
|
@ -134,8 +134,8 @@
|
||||
"fixes.minecraft.screen.screenhandler.MixinCraftingScreenHandler",
|
||||
"fixes.minecraft.screen.screenhandler.MixinPlayerScreenHandler",
|
||||
"fixes.minecraft.screen.screenhandler.MixinScreenHandler",
|
||||
"fixes.viabedrock.MixinBedrockProtocol",
|
||||
"fixes.viabedrock.MixinJoinPackets",
|
||||
"viabedrock.MixinBedrockProtocol",
|
||||
"viabedrock.MixinJoinPackets",
|
||||
"fixes.vialegacy.MixinClassicProtocolExtension",
|
||||
"fixes.vialegacy.MixinClientboundPacketsc0_30cpe",
|
||||
"fixes.vialegacy.MixinExtensionProtocolMetadataStorage",
|
||||
@ -173,6 +173,7 @@
|
||||
"fixes.minecraft.entity.MixinSkeletonHorseEntity",
|
||||
"fixes.minecraft.item.MixinArmorItem",
|
||||
"fixes.minecraft.item.MixinBowItem",
|
||||
"fixes.minecraft.item.MixinShearsItem"
|
||||
"fixes.minecraft.item.MixinShearsItem",
|
||||
"viabedrock.MixinBlobCache"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user