Skip to content

Commit

Permalink
Mark @unique methods/fields with viaFabricPlus$ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 27, 2023
1 parent ae6e117 commit 1611d96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void tickEntity(Entity entity) {
entity.tick();
this.getProfiler().pop();
}
this.checkChunk(entity);
this.viaFabricPlus$checkChunk(entity);

if (mixinEntity.viaFabricPlus$isInLoadedChunkAndShouldTick()) {
for (Entity entity2 : entity.getPassengerList()) {
Expand All @@ -105,7 +105,7 @@ private void tickPassenger(Entity entity, Entity passenger) {
passenger.age++;
passenger.tickRiding();
}
this.checkChunk(passenger);
this.viaFabricPlus$checkChunk(passenger);

if (mixinPassenger.viaFabricPlus$isInLoadedChunkAndShouldTick()) {
for (Entity entity2 : passenger.getPassengerList()) {
Expand All @@ -119,7 +119,7 @@ private void tickPassenger(Entity entity, Entity passenger) {
}

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

Expand All @@ -94,30 +91,30 @@ private void fixBlankGlyph1_12_2(int codePoint, CallbackInfoReturnable<FontStora

@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
}

return (this.id.equals(MinecraftClient.DEFAULT_FONT_ID) || this.id.equals(MinecraftClient.UNICODE_FONT_ID)) && !RenderableGlyphDiff.isGlyphRenderable(codePoint);
}

@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);
}
return FontStorage.GlyphPair.MISSING;
}

@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private HitResult bedrockReachAroundRaycast(HitResult hitResult) {
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);
Expand All @@ -61,7 +61,7 @@ private HitResult bedrockReachAroundRaycast(HitResult hitResult) {
}

@Unique
private boolean canReachAround(final Entity entity) {
private boolean viaFabricPlus$canReachAround(final Entity entity) {
return entity.isOnGround() && entity.getVehicle() == null && entity.getPitch() >= 45;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ private void filterItem(PlayerInventory instance, ItemStack stack) {
}
}

/**
* 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()) {
Expand Down

0 comments on commit 1611d96

Please sign in to comment.