Merge pull request #6796 from IThundxr/mc1.20.1/override-fix

Fix potential issue caused by soft override
This commit is contained in:
simibubi 2024-08-09 09:55:54 +02:00 committed by GitHub
commit b8a329d021
Failed to generate hash of commit
3 changed files with 25 additions and 10 deletions

View file

@ -2,6 +2,8 @@ package com.simibubi.create.content.trains.station;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.mixin.accessor.FontAccessor;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import net.minecraft.client.StringSplitter; import net.minecraft.client.StringSplitter;
@ -18,21 +20,17 @@ public class NoShadowFontWrapper extends Font {
private Font wrapped; private Font wrapped;
public NoShadowFontWrapper(Font wrapped) { public NoShadowFontWrapper(Font wrapped) {
super(null, false); super(((FontAccessor) wrapped).create$getFonts(), false);
this.wrapped = wrapped; this.wrapped = wrapped;
} }
public FontSet getFontSet(ResourceLocation pFontLocation) {
return wrapped.getFontSet(pFontLocation);
}
@Override @Override
public int drawInBatch(Component pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix, public int drawInBatch(Component pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix,
MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords) { MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords) {
return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor, return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor,
pPackedLightCoords); pPackedLightCoords);
} }
@Override @Override
public int drawInBatch(FormattedCharSequence pText, float pX, float pY, int pColor, boolean pDropShadow, public int drawInBatch(FormattedCharSequence pText, float pX, float pY, int pColor, boolean pDropShadow,
Matrix4f pMatrix, MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, Matrix4f pMatrix, MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor,
@ -40,14 +38,14 @@ public class NoShadowFontWrapper extends Font {
return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor, return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor,
pPackedLightCoords); pPackedLightCoords);
} }
@Override @Override
public int drawInBatch(String pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix, public int drawInBatch(String pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix,
MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords) { MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords) {
return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor, return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor,
pPackedLightCoords); pPackedLightCoords);
} }
@Override @Override
public int drawInBatch(String pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix, public int drawInBatch(String pText, float pX, float pY, int pColor, boolean pDropShadow, Matrix4f pMatrix,
MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords, MultiBufferSource pBuffer, DisplayMode pDisplayMode, int pBackgroundColor, int pPackedLightCoords,
@ -55,12 +53,12 @@ public class NoShadowFontWrapper extends Font {
return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor, return wrapped.drawInBatch(pText, pX, pY, pColor, false, pMatrix, pBuffer, pDisplayMode, pBackgroundColor,
pPackedLightCoords, pBidirectional); pPackedLightCoords, pBidirectional);
} }
@Override @Override
public FormattedText ellipsize(FormattedText text, int maxWidth) { public FormattedText ellipsize(FormattedText text, int maxWidth) {
return wrapped.ellipsize(text, maxWidth); return wrapped.ellipsize(text, maxWidth);
} }
@Override @Override
public int wordWrapHeight(FormattedText pText, int pMaxWidth) { public int wordWrapHeight(FormattedText pText, int pMaxWidth) {
return wrapped.wordWrapHeight(pText, pMaxWidth); return wrapped.wordWrapHeight(pText, pMaxWidth);

View file

@ -0,0 +1,16 @@
package com.simibubi.create.foundation.mixin.accessor;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.font.FontSet;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.function.Function;
@Mixin(Font.class)
public interface FontAccessor {
@Accessor("fonts")
Function<ResourceLocation, FontSet> create$getFonts();
}

View file

@ -27,6 +27,7 @@
], ],
"client": [ "client": [
"accessor.AgeableListModelAccessor", "accessor.AgeableListModelAccessor",
"accessor.FontAccessor",
"accessor.GameRendererAccessor", "accessor.GameRendererAccessor",
"accessor.HumanoidArmorLayerAccessor", "accessor.HumanoidArmorLayerAccessor",
"accessor.MouseHandlerAccessor", "accessor.MouseHandlerAccessor",