Skip to content

Commit 5a3a7cf

Browse files
backport to 1.21.5 for Mod Garden
1 parent 100fe50 commit 5a3a7cf

File tree

11 files changed

+59
-51
lines changed

11 files changed

+59
-51
lines changed

libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[versions]
2-
loom = "1.11.+"
2+
loom = "1.10.+"
33
minotaur = "2.+"
44

55
kaleidoConfig = "0.3.1+1.3.1"
66

7-
mc = "1.21.7"
7+
mc = "1.21.5"
88
fl = "0.16.14"
9-
yarn = "1.21.7+build.2"
10-
fapi = "0.128.2+1.21.7"
9+
yarn = "1.21.5+build.1"
10+
fapi = "0.128.1+1.21.5"
1111

12-
fpapi = "0.4.0"
13-
libgui = "14.0.0+1.21.6"
12+
fpapi = "0.3.1"
13+
libgui = "13.1.0+1.21.5"
1414

1515
[plugins]
1616
loom = { id = "fabric-loom", version.ref = "loom" }

src/main/java/net/modfest/scatteredshards/block/ShardBlockEntity.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
import net.minecraft.client.MinecraftClient;
66
import net.minecraft.client.render.WorldRenderer;
77
import net.minecraft.nbt.NbtCompound;
8+
import net.minecraft.nbt.NbtElement;
89
import net.minecraft.network.listener.ClientPlayPacketListener;
910
import net.minecraft.network.packet.Packet;
1011
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
1112
import net.minecraft.particle.ParticleEffect;
1213
import net.minecraft.registry.RegistryWrapper;
13-
import net.minecraft.storage.ReadView;
14-
import net.minecraft.storage.WriteView;
1514
import net.minecraft.util.Identifier;
1615
import net.minecraft.util.math.BlockPos;
1716
import net.minecraft.util.math.MathHelper;
@@ -86,34 +85,32 @@ public boolean canInteract() {
8685
return canInteract;
8786
}
8887

89-
@Override
90-
protected void writeData(WriteView view) {
91-
super.writeData(view);
9288

93-
if (shardId != null) view.putString(SHARD_NBT_KEY, shardId.toString());
89+
@Override
90+
protected void writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
91+
super.writeNbt(nbt, registryLookup);
92+
if (shardId != null) nbt.putString(SHARD_NBT_KEY, shardId.toString());
9493

95-
view.putBoolean("CanInteract", this.canInteract);
94+
nbt.putBoolean("CanInteract", this.canInteract);
9695

9796
NbtCompound glowSettings = new NbtCompound();
9897
glowSettings.putFloat("size", this.glowSize);
9998
glowSettings.putFloat("strength", this.glowStrength);
100-
view.put("Glow", NbtCompound.CODEC, glowSettings);
99+
nbt.put("Glow", glowSettings);
101100
}
102101

103102
@Override
104-
protected void readData(ReadView view) {
105-
super.readData(view);
106-
107-
var shardId = view.getString(SHARD_NBT_KEY, null);
108-
if (shardId != null) {
109-
setShardId(Identifier.of(shardId));
110-
}
103+
protected void readNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
104+
super.readNbt(nbt, registryLookup);
105+
nbt.getString(SHARD_NBT_KEY).ifPresent(
106+
v -> setShardId(Identifier.of(v))
107+
);
111108

112-
this.canInteract = view.getBoolean("CanInteract", false);
109+
this.canInteract = nbt.getBoolean("CanInteract", false);
113110

114-
NbtCompound glowSettings = view.read("Glow", NbtCompound.CODEC).get();
115-
this.glowSize = glowSettings.getFloat("size").orElse(this.glowSize);
116-
this.glowStrength = glowSettings.getFloat("strength").orElse(this.glowStrength);
111+
NbtCompound glowSettings = nbt.getCompound("Glow").get();
112+
this.glowSize = glowSettings.getFloat("size", this.glowSize);
113+
this.glowStrength = glowSettings.getFloat("strength", this.glowStrength);
117114
}
118115

119116
@Override

src/main/java/net/modfest/scatteredshards/client/ShardCollectedToast.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.client.font.TextRenderer;
77
import net.minecraft.client.gl.RenderPipelines;
88
import net.minecraft.client.gui.DrawContext;
9+
import net.minecraft.client.render.RenderLayer;
910
import net.minecraft.client.toast.Toast;
1011
import net.minecraft.client.toast.ToastManager;
1112
import net.minecraft.item.ItemStack;
@@ -77,7 +78,7 @@ public void update(ToastManager manager, long time) {
7778

7879
@Override
7980
public void draw(DrawContext context, TextRenderer textRenderer, long startTime) {
80-
context.drawGuiTexture(RenderPipelines.GUI_TEXTURED, TEXTURE, 0, 0, this.getWidth(), this.getHeight());
81+
context.drawGuiTexture(RenderLayer::getGuiTextured, TEXTURE, 0, 0, this.getWidth(), this.getHeight());
8182

8283
context.drawText(
8384
textRenderer,

src/main/java/net/modfest/scatteredshards/client/render/ShardBlockEntityRenderer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public void render(ShardBlockEntity entity, float tickDelta, MatrixStack matrice
6666

6767
float alpha = collected ? 0.5f : 1f;
6868

69-
VertexConsumer buf = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(ShardType.getBackingTexture(shard.shardTypeId())));
69+
// old VertexConsumer buf = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucentCull(ShardType.getBackingTexture(shard.shardTypeId())));
70+
// .7 VertexConsumer buf = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(ShardType.getBackingTexture(shard.shardTypeId())));
71+
Identifier bt = ShardType.getBackingTexture(shard.shardTypeId());
72+
VertexConsumer buf = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(bt));
7073

7174
/*
7275
* A note about scale here:
@@ -126,7 +129,9 @@ public void render(ShardBlockEntity entity, float tickDelta, MatrixStack matrice
126129

127130
//Draw card front
128131
Vector3f revNormal = normal.mul(-1, -1, -1);
129-
buf = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(ShardType.getFrontTexture(shard.shardTypeId())));
132+
Identifier ft = ShardType.getFrontTexture(shard.shardTypeId());
133+
// cheating: .5 weirdly only wants to use the last texture, so we just use a different renderlayer /shrug
134+
buf = vertexConsumers.getBuffer(RenderLayer.getItemEntityTranslucentCull(ft));
130135
buf
131136
.vertex(matrices.peek().getPositionMatrix(), dl.x, dl.y, dl.z)
132137
.color(1, 1, 1, alpha)

src/main/java/net/modfest/scatteredshards/client/screen/widget/WAlternativeToggle.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import net.fabricmc.api.EnvType;
1111
import net.fabricmc.api.Environment;
1212
import net.minecraft.client.gui.DrawContext;
13+
import net.minecraft.client.util.math.MatrixStack;
1314
import net.minecraft.text.Text;
1415
import net.minecraft.util.Identifier;
1516
import net.modfest.scatteredshards.ScatteredShards;
1617
import org.jetbrains.annotations.Nullable;
17-
import org.joml.Matrix3x2fStack;
1818

1919
import java.util.Optional;
2020
import java.util.function.Function;
@@ -149,16 +149,16 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
149149
int hoverX = (isRight) ? 0 : halfWidth - 1;
150150
boolean hovered = (mouseX >= hoverX && mouseY >= 0 && mouseX < hoverX + halfWidth && mouseY < getHeight());
151151

152-
Matrix3x2fStack matrices = context.getMatrices();
153-
matrices.pushMatrix();
154-
matrices.translate(x, y);
152+
MatrixStack matrices = context.getMatrices();
153+
matrices.push();
154+
matrices.translate(x, y, 0);
155155
NinePatch<Identifier> leftButton = map(recessedButton, button);
156156
NinePatch<Identifier> rightButton = map(button, recessedButton);
157157
leftButton.draw(NinePatchTextureRendererImpl.INSTANCE, context, halfWidth, this.getHeight());
158-
matrices.translate(halfWidth - 1, 0);
158+
matrices.translate(halfWidth - 1, 0, 0);
159159
rightButton.draw(NinePatchTextureRendererImpl.INSTANCE, context, halfWidth, this.getHeight());
160160

161-
matrices.popMatrix();
161+
matrices.pop();
162162

163163
ScreenDrawing.drawStringWithShadow(context, leftLabel.asOrderedText(), HorizontalAlignment.CENTER, x + 2, y + 5, halfWidth - 4, 0xFF_FFFFFF);
164164
ScreenDrawing.drawStringWithShadow(context, rightLabel.asOrderedText(), HorizontalAlignment.CENTER, x + 2 + halfWidth, y + 5, halfWidth - 4, 0xFF_FFFFFF);

src/main/java/net/modfest/scatteredshards/client/screen/widget/WMiniShard.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
7474

7575
ShardIconOffsets.Offset offset = this.shardType.getOffsets().getMini();
7676
shard.icon().ifLeft((it) -> {
77-
context.getMatrices().pushMatrix();
78-
context.getMatrices().translate(x + offset.left(), y + offset.up());
79-
context.getMatrices().scale(0.5f, 0.5f); // 16px -> 8px
77+
context.getMatrices().push();
78+
context.getMatrices().translate(x + offset.left(), y + offset.up(), 0);
79+
context.getMatrices().scale(0.5f, 0.5f, 1); // 16px -> 8px
80+
// RenderSystem.enableDepthTest();
8081
context.drawItemWithoutEntity(it, 0, 0);
81-
context.getMatrices().popMatrix();
82+
context.getMatrices().pop();
8283
});
8384
shard.icon().ifRight((it) -> ScreenDrawing.texturedRect(context, x + offset.left(), y + offset.up(), 8, 8, it, 0xFF_FFFFFF));
8485
}

src/main/java/net/modfest/scatteredshards/client/screen/widget/WShardPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
public class WShardPanel extends WPlainPanel {
3838

39-
public static final IntSupplier WHITE = () -> 0xFF_FFFFFF;
39+
public static final IntSupplier WHITE = () -> 0xFFFFFF;
4040
public static final Style HINT_STYLE = Style.EMPTY.withFont(Identifier.of("minecraft:alt"));
4141

4242
private Shard shard = Shard.MISSING_SHARD.copy();
@@ -229,7 +229,7 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
229229
public void addPainters() {
230230
ShardDisplaySettings displaySettings = ScatteredShardsAPI.getClientLibrary().shardDisplaySettings();
231231
this.setBackgroundPainter((context, left, top, panel) -> {
232-
//context.setShaderColor(1, 1, 1, 1);
232+
// context.setShaderColor(1, 1, 1, 1);
233233
ScreenDrawing.drawGuiPanel(context, left, top, panel.getWidth(), panel.getHeight());
234234
ScreenDrawing.drawBeveledPanel(context, left + 4, top + 4, panel.getWidth() - 8, panel.getHeight() - 8);
235235
context.fillGradient(

src/main/java/net/modfest/scatteredshards/client/screen/widget/scalable/WScalableWidget.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public abstract class WScalableWidget extends WWidget {
1212
@Environment(EnvType.CLIENT)
1313
@Override
1414
public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
15-
context.getMatrices().pushMatrix();
15+
context.getMatrices().push();
1616

17-
context.getMatrices().translate(x, y);
18-
context.getMatrices().scale(scale, scale);
17+
context.getMatrices().translate(x, y, 0);
18+
context.getMatrices().scale(scale, scale, 1.0f);
1919

2020
paintScaled(context, (int) (this.getWidth() / scale), (int) (this.getHeight() / scale), (int) (mouseX / scale), (int) (mouseY / scale));
21-
context.getMatrices().popMatrix();
21+
context.getMatrices().pop();
2222
}
2323

2424
/**

src/main/java/net/modfest/scatteredshards/client/screen/widget/scalable/WScaledLabel.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.font.TextRenderer;
99
import net.minecraft.client.gui.DrawContext;
10+
import net.minecraft.client.gui.tooltip.HoveredTooltipPositioner;
1011
import net.minecraft.text.OrderedText;
1112
import net.minecraft.text.Text;
1213
import net.minecraft.util.Util;
@@ -87,16 +88,17 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
8788
//Paint background here because it's one pixel more accurate; results are validated for scaled painting already.
8889
if (backgroundColor != 0) ScreenDrawing.coloredRect(context, x, y, getWidth(), getHeight(), backgroundColor);
8990

90-
context.enableScissor(x, y, x + width, y + height);
91+
// both of these behave spuriously in 1.21.5 and it looks "normal" besides this
92+
// context.enableScissor(x, y, width, height);
93+
// Scissors.push(x, y, width, height);
9194
super.paint(context, x, y, mouseX, mouseY);
92-
context.disableScissor();
95+
// Scissors.pop();
96+
// context.disableScissor();
9397

9498
if (mouseX >= 0 && mouseX < width && mouseY >= 0 && mouseY < height) {
9599
List<OrderedText> tooltip = hover.get();
96100
if (!tooltip.isEmpty()) {
97-
98-
context.drawTooltip(tooltip, x + mouseX, y + mouseY);
99-
101+
context.drawTooltip(MinecraftClient.getInstance().textRenderer, tooltip, HoveredTooltipPositioner.INSTANCE, x + mouseX, y + mouseY);
100102
}
101103
}
102104
}
@@ -129,7 +131,8 @@ public static void drawScrollableString(DrawContext context, OrderedText text, H
129131
xofs = (int) MathHelper.lerp(t, 0.0, scrollWidth);
130132
}
131133

132-
//context.setShaderColor(1, 1, 1, 1);
134+
135+
// context.setShaderColor(1, 1, 1, 1);
133136
if (shadow) {
134137
ScreenDrawing.drawStringWithShadow(context, text, alignment, x - xofs, y, width, color);
135138
} else {

src/main/java/net/modfest/scatteredshards/client/screen/widget/scalable/WScaledText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
9292
if (mouseX >= 0 && mouseX < width && mouseY >= 0 && mouseY < height) {
9393
List<OrderedText> tooltip = hover.get();
9494
if (!tooltip.isEmpty()) {
95-
context.drawTooltip(tooltip, x + mouseX, y + mouseY);
95+
context.drawTooltip(MinecraftClient.getInstance().textRenderer, tooltip, HoveredTooltipPositioner.INSTANCE, x + mouseX, y + mouseY);
9696
}
9797
}
9898
}

0 commit comments

Comments
 (0)