Skip to content

Commit

Permalink
Namings
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 29, 2024
1 parent 147b425 commit 82c7ec2
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

public interface IPlayerListEntry {

int viaFabricPlus$getIndex();
int viaFabricPlusVisuals$getIndex();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

public interface IPlayerListHud {

void viaFabricPlus$setMaxPlayers(final int maxPlayers);
void viaFabricPlusVisuals$setMaxPlayers(final int maxPlayers);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -62,15 +62,15 @@ private void fixUIWidth(CallbackInfo ci) {
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ private void bakeBlankGlyph1_12_2(CallbackInfo ci) {

@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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
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) {
Expand Down Expand Up @@ -105,8 +105,8 @@ private static void moveArmorPositions(Args args, @Local(ordinal = 3, argsOnly =

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -77,7 +77,7 @@ private void slightlyTiltItemPosition(AbstractClientPlayerEntity player, float t
}

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -104,7 +104,7 @@ private ButtonWidget replaceButtons(GameMenuScreen instance, Text text, Supplier
}
// 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
Expand All @@ -130,29 +130,29 @@ private void moveButtonPositions(CallbackInfo ci) {

// 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());
});
}

// 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);
});
Expand All @@ -176,8 +176,8 @@ private boolean removeButtons(GridWidget.Adder instance, Widget widget) {
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;
}
}
Expand All @@ -186,15 +186,15 @@ private boolean removeButtons(GridWidget.Adder instance, Widget widget) {
}

@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)) {
Expand Down
Loading

0 comments on commit 82c7ec2

Please sign in to comment.