Mark @Unique methods/fields with viaFabricPlus$ prefix

This commit is contained in:
FlorianMichael 2023-11-28 00:16:29 +01:00
parent ae6e117698
commit 1611d96da3
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
4 changed files with 22 additions and 22 deletions

View File

@ -82,7 +82,7 @@ public abstract class MixinClientWorld extends World {
entity.tick();
this.getProfiler().pop();
}
this.checkChunk(entity);
this.viaFabricPlus$checkChunk(entity);
if (mixinEntity.viaFabricPlus$isInLoadedChunkAndShouldTick()) {
for (Entity entity2 : entity.getPassengerList()) {
@ -105,7 +105,7 @@ public abstract class MixinClientWorld extends World {
passenger.age++;
passenger.tickRiding();
}
this.checkChunk(passenger);
this.viaFabricPlus$checkChunk(passenger);
if (mixinPassenger.viaFabricPlus$isInLoadedChunkAndShouldTick()) {
for (Entity entity2 : passenger.getPassengerList()) {
@ -119,7 +119,7 @@ public abstract class MixinClientWorld extends World {
}
@Unique
private void checkChunk(Entity entity) {
private void viaFabricPlus$checkChunk(Entity entity) {
this.getProfiler().push("chunkCheck");
final IEntity mixinEntity = (IEntity) entity;
final int chunkX = MathHelper.floor(entity.getX() / 16.0D);

View File

@ -22,15 +22,12 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;
import com.llamalad7.mixinextras.sugar.Local;
import de.florianmichael.viafabricplus.fixes.data.RenderableGlyphDiff;
import de.florianmichael.viafabricplus.fixes.replacement.BuiltinEmptyGlyph1_12_2;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import de.florianmichael.viafabricplus.settings.impl.DebugSettings;
import de.florianmichael.viafabricplus.settings.impl.VisualSettings;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.*;
import net.minecraft.util.Identifier;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -57,28 +54,28 @@ public abstract class MixinFontStorage {
private Identifier id;
@Unique
private GlyphRenderer blankGlyphRenderer1_12_2;
private GlyphRenderer viaFabricPlus$blankGlyphRenderer1_12_2;
@Unique
private Object2IntMap<Font> providedGlyphsCache;
private Object2IntMap<Font> viaFabricPlus$providedGlyphsCache;
@Inject(method = "setFonts", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BuiltinEmptyGlyph;bake(Ljava/util/function/Function;)Lnet/minecraft/client/font/GlyphRenderer;", ordinal = 0))
private void bakeBlankGlyph1_12_2(List<Font> fonts, CallbackInfo ci) {
this.blankGlyphRenderer1_12_2 = BuiltinEmptyGlyph1_12_2.INSTANCE.bake(this::getGlyphRenderer);
this.providedGlyphsCache = new Object2IntOpenHashMap<>();
this.viaFabricPlus$blankGlyphRenderer1_12_2 = BuiltinEmptyGlyph1_12_2.INSTANCE.bake(this::getGlyphRenderer);
this.viaFabricPlus$providedGlyphsCache = new Object2IntOpenHashMap<>();
}
@Inject(method = "findGlyph", at = @At("RETURN"), cancellable = true)
private void filterGlyphs1(int codePoint, CallbackInfoReturnable<FontStorage.GlyphPair> cir, @Local Font font) {
if (this.shouldBeInvisible(cir.getReturnValue().equals(FontStorage.GlyphPair.MISSING) ? null : font, codePoint)) {
cir.setReturnValue(this.getBlankGlyphPair());
if (this.viaFabricPlus$shouldBeInvisible(cir.getReturnValue().equals(FontStorage.GlyphPair.MISSING) ? null : font, codePoint)) {
cir.setReturnValue(this.viaFabricPlus$getBlankGlyphPair());
}
}
@Inject(method = "findGlyphRenderer", at = @At("RETURN"), cancellable = true)
private void filterGlyphs2(int codePoint, CallbackInfoReturnable<GlyphRenderer> cir, @Local Font font) {
if (this.shouldBeInvisible(cir.getReturnValue().equals(this.blankGlyphRenderer) ? null : font, codePoint)) {
cir.setReturnValue(this.getBlankGlyphRenderer());
if (this.viaFabricPlus$shouldBeInvisible(cir.getReturnValue().equals(this.blankGlyphRenderer) ? null : font, codePoint)) {
cir.setReturnValue(this.viaFabricPlus$getBlankGlyphRenderer());
}
}
@ -94,12 +91,12 @@ public abstract class MixinFontStorage {
@Redirect(method = "findGlyphRenderer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/font/FontStorage;blankGlyphRenderer:Lnet/minecraft/client/font/GlyphRenderer;"))
private GlyphRenderer fixBlankGlyphRenderer1_12_2(FontStorage instance) {
return this.getBlankGlyphRenderer();
return this.viaFabricPlus$getBlankGlyphRenderer();
}
@Unique
private boolean shouldBeInvisible(final Font font, final int codePoint) {
if (font != null && this.providedGlyphsCache.computeIfAbsent(font, f -> ((Font) f).getProvidedGlyphs().size()) == 1) {
private boolean viaFabricPlus$shouldBeInvisible(final Font font, final int codePoint) {
if (font != null && this.viaFabricPlus$providedGlyphsCache.computeIfAbsent(font, f -> ((Font) f).getProvidedGlyphs().size()) == 1) {
return false; // Probably a custom icon character from a resource pack
}
@ -107,7 +104,7 @@ public abstract class MixinFontStorage {
}
@Unique
private FontStorage.GlyphPair getBlankGlyphPair() {
private FontStorage.GlyphPair viaFabricPlus$getBlankGlyphPair() {
if (VisualSettings.global().changeFontRendererBehaviour.isEnabled()) {
return new FontStorage.GlyphPair(BuiltinEmptyGlyph1_12_2.INSTANCE, BuiltinEmptyGlyph1_12_2.INSTANCE);
}
@ -115,9 +112,9 @@ public abstract class MixinFontStorage {
}
@Unique
private GlyphRenderer getBlankGlyphRenderer() {
private GlyphRenderer viaFabricPlus$getBlankGlyphRenderer() {
if (VisualSettings.global().changeFontRendererBehaviour.isEnabled()) {
return this.blankGlyphRenderer1_12_2;
return this.viaFabricPlus$blankGlyphRenderer1_12_2;
}
return this.blankGlyphRenderer;
}

View File

@ -47,7 +47,7 @@ public abstract class MixinGameRenderer {
if (ProtocolHack.getTargetVersion().equals(VersionEnum.bedrockLatest)) {
final Entity entity = this.client.getCameraEntity();
if (hitResult.getType() != HitResult.Type.MISS) return hitResult;
if (!this.canReachAround(entity)) return hitResult;
if (!this.viaFabricPlus$canReachAround(entity)) return hitResult;
final int x = MathHelper.floor(entity.getX());
final int y = MathHelper.floor(entity.getY() - 0.2F);
@ -61,7 +61,7 @@ public abstract class MixinGameRenderer {
}
@Unique
private boolean canReachAround(final Entity entity) {
private boolean viaFabricPlus$canReachAround(final Entity entity) {
return entity.isOnGround() && entity.getVehicle() == null && entity.getPitch() >= 45;
}

View File

@ -76,6 +76,9 @@ public abstract class MixinMinecraftClient {
}
}
/**
* Never happens in Vanilla, this is only for {@link ItemRegistryDiff} to work
*/
@Redirect(method = "doItemPick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;clickCreativeStack(Lnet/minecraft/item/ItemStack;I)V"))
private void dontSendEmptyItem(ClientPlayerInteractionManager instance, ItemStack stack, int slotId) {
if (!stack.isEmpty()) {