This commit is contained in:
FlorianMichael 2024-12-29 23:11:51 +01:00
parent 147b425bcd
commit 82c7ec2e88
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
13 changed files with 58 additions and 58 deletions

View File

@ -23,6 +23,6 @@ package com.viaversion.viafabricplus.visuals.injection.access.r1_7_tab_list_tyle
public interface IPlayerListEntry {
int viaFabricPlus$getIndex();
int viaFabricPlusVisuals$getIndex();
}

View File

@ -23,6 +23,6 @@ package com.viaversion.viafabricplus.visuals.injection.access.r1_7_tab_list_tyle
public interface IPlayerListHud {
void viaFabricPlus$setMaxPlayers(final int maxPlayers);
void viaFabricPlusVisuals$setMaxPlayers(final int maxPlayers);
}

View File

@ -46,7 +46,7 @@ public abstract class MixinGameModeSelectionScreen extends Screen {
private static int UI_WIDTH;
@Unique
private GameModeSelectionScreen.GameModeSelection[] viaFabricPlus$unwrappedGameModes;
private GameModeSelectionScreen.GameModeSelection[] viaFabricPlusVisuals$unwrappedGameModes;
public MixinGameModeSelectionScreen(Text title) {
super(title);
@ -62,15 +62,15 @@ public abstract class MixinGameModeSelectionScreen extends Screen {
selections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE);
}
viaFabricPlus$unwrappedGameModes = selections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5;
viaFabricPlusVisuals$unwrappedGameModes = selections.toArray(GameModeSelectionScreen.GameModeSelection[]::new);
UI_WIDTH = viaFabricPlusVisuals$unwrappedGameModes.length * 31 - 5;
}
}
@Redirect(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;VALUES:[Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;"))
private GameModeSelectionScreen.GameModeSelection[] removeNewerGameModes() {
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
return viaFabricPlus$unwrappedGameModes;
return viaFabricPlusVisuals$unwrappedGameModes;
} else {
return GameModeSelectionScreen.GameModeSelection.values();
}

View File

@ -63,20 +63,20 @@ public abstract class MixinFontStorage {
@Inject(method = "findGlyph", at = @At("RETURN"), cancellable = true)
private void filterGlyphs(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir) {
if (this.viaFabricPlus$shouldBeInvisible(codePoint)) {
if (this.viaFabricPlusVisuals$shouldBeInvisible(codePoint)) {
cir.setReturnValue(this.viaFabricPlusVisuals$getBlankGlyphPair());
}
}
@Inject(method = "bake(I)Lnet/minecraft/client/font/BakedGlyph;", at = @At("RETURN"), cancellable = true)
private void filterBakedGlyph(int codePoint, CallbackInfoReturnable<BakedGlyph> cir) {
if (this.viaFabricPlus$shouldBeInvisible(codePoint)) {
if (this.viaFabricPlusVisuals$shouldBeInvisible(codePoint)) {
cir.setReturnValue(this.viaFabricPlusVisuals$getBlankBakedGlyph());
}
}
@Unique
private boolean viaFabricPlus$shouldBeInvisible(final int codePoint) {
private boolean viaFabricPlusVisuals$shouldBeInvisible(final int codePoint) {
if (VisualSettings.INSTANCE.filterNonExistingGlyphs.getValue()) {
return (this.id.equals(MinecraftClient.DEFAULT_FONT_ID) || this.id.equals(MinecraftClient.UNICODE_FONT_ID)) && !RenderableGlyphDiff.isGlyphRenderable(codePoint);
} else {

View File

@ -51,7 +51,7 @@ import java.util.function.Function;
public abstract class MixinInGameHud {
@Unique
private static final int viaFabricPlus$ARMOR_ICON_WIDTH = 8;
private static final int viaFabricPlusVisuals$ARMOR_ICON_WIDTH = 8;
@Inject(method = "playBurstSound", at = @At("HEAD"), cancellable = true)
private void disableBubblePopSound(int bubble, PlayerEntity player, int burstBubbles, CallbackInfo ci) {
@ -105,8 +105,8 @@ public abstract class MixinInGameHud {
final MinecraftClient client = MinecraftClient.getInstance();
final int armorWidth = 10 * viaFabricPlus$ARMOR_ICON_WIDTH;
final int offset = n * viaFabricPlus$ARMOR_ICON_WIDTH;
final int armorWidth = 10 * viaFabricPlusVisuals$ARMOR_ICON_WIDTH;
final int offset = n * viaFabricPlusVisuals$ARMOR_ICON_WIDTH;
args.set(1, client.getWindow().getScaledWidth() - x - armorWidth + offset - 1);
args.set(2, (int) args.get(2) + client.textRenderer.fontHeight + 1);

View File

@ -36,12 +36,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public abstract class MixinPlayerEntity {
@Unique
private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(Identifier.of("viafabricplus-visuals", "oof.hurt"));
private static final SoundEvent viaFabricPlusVisuals$oof_hurt = SoundEvent.of(Identifier.of("viafabricplus-visuals", "oof.hurt"));
@Inject(method = "getHurtSound", at = @At("HEAD"), cancellable = true)
private void replaceSound(DamageSource source, CallbackInfoReturnable<SoundEvent> cir) {
if (VisualSettings.INSTANCE.replaceHurtSoundWithOOFSound.isEnabled()) {
cir.setReturnValue(viaFabricPlus$oof_hurt);
cir.setReturnValue(viaFabricPlusVisuals$oof_hurt);
}
}

View File

@ -36,13 +36,13 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public abstract class MixinItemRenderer {
@Unique
private static final Identifier viaFabricPlus$missingIdentifier = Identifier.of(String.valueOf(System.currentTimeMillis()));
private static final Identifier viaFabricPlusVisuals$missingIdentifier = Identifier.of(String.valueOf(System.currentTimeMillis()));
@Redirect(method = "update(Lnet/minecraft/client/render/item/ItemRenderState;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;I)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;get(Lnet/minecraft/component/ComponentType;)Ljava/lang/Object;"))
private Object removeModel(ItemStack instance, ComponentType componentType) {
if (VisualSettings.INSTANCE.replacePetrifiedOakSlab.isEnabled() && instance.isOf(Items.PETRIFIED_OAK_SLAB)) {
return viaFabricPlus$missingIdentifier;
return viaFabricPlusVisuals$missingIdentifier;
} else {
return instance.get(componentType);
}

View File

@ -47,19 +47,19 @@ public abstract class MixinHeldItemRenderer {
@Inject(method = "renderFirstPersonItem",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 2, shift = At.Shift.AFTER))
private void applyFoodSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices);
viaFabricPlusVisuals$applySwingOffset(player, hand, swingProgress, matrices);
}
@Inject(method = "renderFirstPersonItem",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 3, shift = At.Shift.AFTER))
private void applyBlockingSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices);
viaFabricPlusVisuals$applySwingOffset(player, hand, swingProgress, matrices);
}
@Inject(method = "renderFirstPersonItem",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 4, shift = At.Shift.AFTER))
private void applyBowSwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
viaFabricPlus$applySwingOffset(player, hand, swingProgress, matrices);
viaFabricPlusVisuals$applySwingOffset(player, hand, swingProgress, matrices);
}
@Inject(method = "renderFirstPersonItem",
@ -77,7 +77,7 @@ public abstract class MixinHeldItemRenderer {
}
@Unique
private void viaFabricPlus$applySwingOffset(AbstractClientPlayerEntity player, Hand hand, float swingProgress, MatrixStack matrices) {
private void viaFabricPlusVisuals$applySwingOffset(AbstractClientPlayerEntity player, Hand hand, float swingProgress, MatrixStack matrices) {
if (VisualSettings.INSTANCE.swingHandOnItemUse.isEnabled()) {
final Arm arm = hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite();
applySwingOffset(matrices, arm, swingProgress);

View File

@ -37,7 +37,7 @@ public abstract class MixinClientPlayNetworkHandler {
@Inject(method = "onGameJoin", at = @At("RETURN"))
private void initPlayerListFix(GameJoinS2CPacket packet, CallbackInfo ci) {
LegacyTabList.globalTablistIndex = 0;
((IPlayerListHud) MinecraftClient.getInstance().inGameHud.getPlayerListHud()).viaFabricPlus$setMaxPlayers(packet.maxPlayers());
((IPlayerListHud) MinecraftClient.getInstance().inGameHud.getPlayerListHud()).viaFabricPlusVisuals$setMaxPlayers(packet.maxPlayers());
}
}

View File

@ -31,10 +31,10 @@ import org.spongepowered.asm.mixin.Unique;
public abstract class MixinPlayerListEntry implements IPlayerListEntry {
@Unique
private final int viaFabricPlus$index = LegacyTabList.globalTablistIndex++;
private final int viaFabricPlusVisuals$index = LegacyTabList.globalTablistIndex++;
@Override
public int viaFabricPlus$getIndex() {
return viaFabricPlus$index;
public int viaFabricPlusVisuals$getIndex() {
return viaFabricPlusVisuals$index;
}
}

View File

@ -49,57 +49,57 @@ public abstract class MixinPlayerListHud implements IPlayerListHud {
private MinecraftClient client;
@Unique
private static final Comparator<PlayerListEntry> viaFabricPlus$FIFO_COMPARATOR = Comparator.comparingInt(e -> ((IPlayerListEntry) e).viaFabricPlus$getIndex());
private static final Comparator<PlayerListEntry> viaFabricPlusVisuals$FIFO_COMPARATOR = Comparator.comparingInt(e -> ((IPlayerListEntry) e).viaFabricPlusVisuals$getIndex());
@Unique
private int viaFabricPlus$maxSlots;
private int viaFabricPlusVisuals$maxSlots;
@Unique
private boolean viaFabricPlus$hideSkins = true;
private boolean viaFabricPlusVisuals$hideSkins = true;
@Inject(method = "collectPlayerEntries", at = @At("HEAD"), cancellable = true)
private void collectPlayerEntries(CallbackInfoReturnable<List<PlayerListEntry>> result) {
if (VisualSettings.INSTANCE.enableLegacyTablist.isEnabled()) {
result.setReturnValue(this.client.player.networkHandler.getListedPlayerListEntries().stream()
.sorted(viaFabricPlus$FIFO_COMPARATOR)
.limit(viaFabricPlus$maxSlots)
.collect(Collectors.collectingAndThen(Collectors.toList(), this::viaFabricPlus$transpose)));
.sorted(viaFabricPlusVisuals$FIFO_COMPARATOR)
.limit(viaFabricPlusVisuals$maxSlots)
.collect(Collectors.collectingAndThen(Collectors.toList(), this::viaFabricPlusVisuals$transpose)));
} else {
viaFabricPlus$hideSkins = false;
viaFabricPlusVisuals$hideSkins = false;
}
}
@ModifyExpressionValue(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;isEncrypted()Z"))
private boolean hideSkins(boolean original) {
return original && !viaFabricPlus$hideSkins;
return original && !viaFabricPlusVisuals$hideSkins;
}
@Unique
private List<PlayerListEntry> viaFabricPlus$transpose(final List<PlayerListEntry> list) {
private List<PlayerListEntry> viaFabricPlusVisuals$transpose(final List<PlayerListEntry> list) {
// Only bother transposing if we know the list is full
if (list.size() != viaFabricPlus$maxSlots) {
viaFabricPlus$hideSkins = list.stream().noneMatch(e -> e.getProfile().getProperties().containsKey("textures"));
if (list.size() != viaFabricPlusVisuals$maxSlots) {
viaFabricPlusVisuals$hideSkins = list.stream().noneMatch(e -> e.getProfile().getProperties().containsKey("textures"));
return list;
}
final List<PlayerListEntry> result = new ArrayList<>(list.size());
final int columns = viaFabricPlus$maxSlots / PlayerListHud.MAX_ROWS;
final int columns = viaFabricPlusVisuals$maxSlots / PlayerListHud.MAX_ROWS;
boolean anyHasSkinData = false;
for (int i = 0; i < viaFabricPlus$maxSlots; i++) {
for (int i = 0; i < viaFabricPlusVisuals$maxSlots; i++) {
final int row = i % PlayerListHud.MAX_ROWS;
final int col = i / PlayerListHud.MAX_ROWS;
final PlayerListEntry current = list.get(row * columns + col);
result.add(current);
anyHasSkinData = anyHasSkinData || current.getProfile().getProperties().containsKey("textures");
}
viaFabricPlus$hideSkins = !anyHasSkinData;
viaFabricPlusVisuals$hideSkins = !anyHasSkinData;
return result;
}
@Override
public void viaFabricPlus$setMaxPlayers(int maxPlayers) {
this.viaFabricPlus$maxSlots = Math.min(200, Math.max(20, ((maxPlayers + PlayerListHud.MAX_ROWS - 1) / PlayerListHud.MAX_ROWS) * PlayerListHud.MAX_ROWS));
public void viaFabricPlusVisuals$setMaxPlayers(int maxPlayers) {
this.viaFabricPlusVisuals$maxSlots = Math.min(200, Math.max(20, ((maxPlayers + PlayerListHud.MAX_ROWS - 1) / PlayerListHud.MAX_ROWS) * PlayerListHud.MAX_ROWS));
}
}

View File

@ -84,10 +84,10 @@ public abstract class MixinGameMenuScreen extends Screen {
private static int NORMAL_BUTTON_WIDTH;
@Unique
private int viaFabricPlus$disconnectButtonWidth;
private int viaFabricPlusVisuals$disconnectButtonWidth;
@Unique
private ButtonWidget.PressAction viaFabricPlus$disconnectSupplier;
private ButtonWidget.PressAction viaFabricPlusVisuals$disconnectSupplier;
protected MixinGameMenuScreen(Text title) {
super(title);
@ -104,7 +104,7 @@ public abstract class MixinGameMenuScreen extends Screen {
}
// Advancements -> disconnect
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1) && text.equals(ADVANCEMENTS_TEXT)) {
return ButtonWidget.builder(ScreenTexts.DISCONNECT, viaFabricPlus$disconnectSupplier).width(viaFabricPlus$disconnectButtonWidth).build();
return ButtonWidget.builder(ScreenTexts.DISCONNECT, viaFabricPlusVisuals$disconnectSupplier).width(viaFabricPlusVisuals$disconnectButtonWidth).build();
}
} else if (VisualSettings.INSTANCE.changeGameMenuScreenLayout.getIndex() == 1) {
// Player reporting -> Social interactions
@ -130,20 +130,20 @@ public abstract class MixinGameMenuScreen extends Screen {
// Move all buttons below feebdack/bug down since they are removed
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
viaFabricPlus$applyTo(OPTIONS_TEXT, moveDown);
viaFabricPlus$applyTo(SHARE_TO_LAN_TEXT, moveDown);
viaFabricPlus$applyTo(ScreenTexts.DISCONNECT, moveDown);
viaFabricPlusVisuals$applyTo(OPTIONS_TEXT, moveDown);
viaFabricPlusVisuals$applyTo(SHARE_TO_LAN_TEXT, moveDown);
viaFabricPlusVisuals$applyTo(ScreenTexts.DISCONNECT, moveDown);
}
// Tracked for dimensions in case some mod changes them
final ButtonWidget returnToGame = viaFabricPlus$getButton(RETURN_TO_GAME_TEXT);
final ButtonWidget returnToGame = viaFabricPlusVisuals$getButton(RETURN_TO_GAME_TEXT);
if (returnToGame == null) {
return;
}
// Make options button wider since lan is removed
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) {
viaFabricPlus$applyTo(OPTIONS_TEXT, buttonWidget -> {
viaFabricPlusVisuals$applyTo(OPTIONS_TEXT, buttonWidget -> {
buttonWidget.setX(returnToGame.getX());
buttonWidget.setWidth(returnToGame.getWidth());
});
@ -151,8 +151,8 @@ public abstract class MixinGameMenuScreen extends Screen {
// Make space between return to game and options, put disconnect button below options
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_4tob1_4_1)) {
viaFabricPlus$applyTo(OPTIONS_TEXT, moveDown);
viaFabricPlus$applyTo(ScreenTexts.DISCONNECT, buttonWidget -> {
viaFabricPlusVisuals$applyTo(OPTIONS_TEXT, moveDown);
viaFabricPlusVisuals$applyTo(ScreenTexts.DISCONNECT, buttonWidget -> {
// Magical offset which would be calculated by the grid system, nothing we can do about it
buttonWidget.setY(returnToGame.getY() + ButtonWidget.DEFAULT_HEIGHT + 3);
});
@ -176,8 +176,8 @@ public abstract class MixinGameMenuScreen extends Screen {
if (button.getMessage().equals(STATS_TEXT)) {
return false;
} else if (button.getMessage().equals(ScreenTexts.DISCONNECT)) {
viaFabricPlus$disconnectSupplier = buttonWidget -> button.onPress();
viaFabricPlus$disconnectButtonWidth = button.getWidth();
viaFabricPlusVisuals$disconnectSupplier = buttonWidget -> button.onPress();
viaFabricPlusVisuals$disconnectButtonWidth = button.getWidth();
return false;
}
}
@ -186,15 +186,15 @@ public abstract class MixinGameMenuScreen extends Screen {
}
@Unique
private void viaFabricPlus$applyTo(final Text text, final Consumer<ButtonWidget> action) {
final ButtonWidget button = viaFabricPlus$getButton(text);
private void viaFabricPlusVisuals$applyTo(final Text text, final Consumer<ButtonWidget> action) {
final ButtonWidget button = viaFabricPlusVisuals$getButton(text);
if (button != null) {
action.accept(button);
}
}
@Unique
private ButtonWidget viaFabricPlus$getButton(final Text text) {
private ButtonWidget viaFabricPlusVisuals$getButton(final Text text) {
for (Element child : children()) {
if (child instanceof ButtonWidget buttonWidget) {
if (buttonWidget.getMessage().equals(text)) {

View File

@ -33,12 +33,12 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
public abstract class MixinTextRenderer_Drawer {
@Unique
private static final float viaFabricPlus$offset = 0.5F; // Magical offset to revert the changes done in 1.13 pre6->1.13 pre7
private static final float viaFabricPlusVisuals$offset = 0.5F; // Magical offset to revert the changes done in 1.13 pre6->1.13 pre7
@ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 1)
private float fixStrikethroughMinY(float value) {
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset;
return value - viaFabricPlusVisuals$offset;
} else {
return value;
}
@ -47,7 +47,7 @@ public abstract class MixinTextRenderer_Drawer {
@ModifyArg(method = "accept", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BakedGlyph$Rectangle;<init>(FFFFFIIF)V", ordinal = 0), index = 3)
private float fixStrikethroughMaxY(float value) {
if (ViaFabricPlus.getImpl().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
return value - viaFabricPlus$offset;
return value - viaFabricPlusVisuals$offset;
} else {
return value;
}