Spaces:
Build error
Build error
File size: 3,730 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
package net.minecraft.client.renderer.texture;
import com.mojang.blaze3d.vertex.VertexConsumer;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.SpriteCoordinateExpander;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class TextureAtlasSprite {
private final ResourceLocation atlasLocation;
private final SpriteContents contents;
final int x;
final int y;
private final float u0;
private final float u1;
private final float v0;
private final float v1;
protected TextureAtlasSprite(ResourceLocation p_250211_, SpriteContents p_248526_, int p_248950_, int p_249741_, int p_248672_, int p_248637_) {
this.atlasLocation = p_250211_;
this.contents = p_248526_;
this.x = p_248672_;
this.y = p_248637_;
this.u0 = (float)p_248672_ / (float)p_248950_;
this.u1 = (float)(p_248672_ + p_248526_.width()) / (float)p_248950_;
this.v0 = (float)p_248637_ / (float)p_249741_;
this.v1 = (float)(p_248637_ + p_248526_.height()) / (float)p_249741_;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public float getU0() {
return this.u0;
}
public float getU1() {
return this.u1;
}
public SpriteContents contents() {
return this.contents;
}
@Nullable
public TextureAtlasSprite.Ticker createTicker() {
final SpriteTicker spriteticker = this.contents.createTicker();
return spriteticker != null ? new TextureAtlasSprite.Ticker() {
@Override
public void tickAndUpload() {
spriteticker.tickAndUpload(TextureAtlasSprite.this.x, TextureAtlasSprite.this.y);
}
@Override
public void close() {
spriteticker.close();
}
} : null;
}
public float getU(float p_298825_) {
float f = this.u1 - this.u0;
return this.u0 + f * p_298825_;
}
public float getUOffset(float p_174728_) {
float f = this.u1 - this.u0;
return (p_174728_ - this.u0) / f;
}
public float getV0() {
return this.v0;
}
public float getV1() {
return this.v1;
}
public float getV(float p_299087_) {
float f = this.v1 - this.v0;
return this.v0 + f * p_299087_;
}
public float getVOffset(float p_174742_) {
float f = this.v1 - this.v0;
return (p_174742_ - this.v0) / f;
}
public ResourceLocation atlasLocation() {
return this.atlasLocation;
}
@Override
public String toString() {
return "TextureAtlasSprite{contents='"
+ this.contents
+ "', u0="
+ this.u0
+ ", u1="
+ this.u1
+ ", v0="
+ this.v0
+ ", v1="
+ this.v1
+ "}";
}
public void uploadFirstFrame() {
this.contents.uploadFirstFrame(this.x, this.y);
}
private float atlasSize() {
float f = (float)this.contents.width() / (this.u1 - this.u0);
float f1 = (float)this.contents.height() / (this.v1 - this.v0);
return Math.max(f1, f);
}
public float uvShrinkRatio() {
return 4.0F / this.atlasSize();
}
public VertexConsumer wrap(VertexConsumer p_118382_) {
return new SpriteCoordinateExpander(p_118382_, this);
}
@OnlyIn(Dist.CLIENT)
public interface Ticker extends AutoCloseable {
void tickAndUpload();
@Override
void close();
}
} |