Skip to content

Commit 3a40f39

Browse files
committed
Merge v3.1.3 changes into 1.21.2.
2 parents 8121943 + 5358741 commit 3a40f39

File tree

7 files changed

+91
-22
lines changed

7 files changed

+91
-22
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
- Fixed dynamic lighting of various projectiles.
213213
- Fixed water-sensitive items lighting up underwater while they shouldn't.
214214

215+
### 3.1.3
216+
217+
- Fixed item frames and other "block-attached" entities not ticking properly on the integrated server.
218+
215219
## 3.2.0
216220

217221
- Updated to Minecraft 1.21.2.
@@ -232,6 +236,11 @@
232236
- Fixed dynamic lighting of various projectiles.
233237
- Fixed water-sensitive items lighting up underwater while they shouldn't.
234238

239+
### 3.2.3
240+
241+
- Same changes as v3.1.3 but for 1.21.3.
242+
- Fixed item frames and other "block-attached" entities not ticking properly on the integrated server.
243+
235244
[SpruceUI]: https://github.com/LambdAurora/SpruceUI "SpruceUI page"
236245
[pridelib]: https://github.com/Queerbric/pridelib "Pridelib page"
237246
[Sodium]: https://modrinth.com/mod/sodium "Sodium Modrinth page"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ GitHub
129129
</div>
130130
<!-- modrinth_exclude.long_end -->
131131

132-
# 📖 Compatibility
132+
## 📖 Compatibility
133133

134134
- [Sodium] is recommended for better performances.
135135
- **OptiFabric is obviously incompatible.**

build_logic/src/main/kotlin/lambdynamiclights/Constants.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.gradle.accessors.dm.LibrariesForLibs
55
object Constants {
66
const val GROUP = "dev.lambdaurora"
77
const val NAME = "lambdynamiclights"
8-
const val VERSION = "3.2.2"
8+
const val VERSION = "3.2.3"
99
const val JAVA_VERSION = 21
1010

1111
private var minecraftVersion: String? = null

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
minecraft = "1.21.3"
3-
fabric-loader = "0.16.7"
3+
fabric-loader = "0.16.9"
44
fabric-api = "0.106.1+1.21.3"
55
mappings-yalmm = "2"
66
mappings-parchment = "2024.07.28"

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/dev/lambdaurora/lambdynlights/gui/RandomPrideFlagBackground.java

+73-15
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
import dev.lambdaurora.spruceui.background.Background;
1313
import dev.lambdaurora.spruceui.background.SimpleColorBackground;
14+
import dev.lambdaurora.spruceui.util.ColorUtil;
1415
import dev.lambdaurora.spruceui.widget.SpruceWidget;
15-
import io.github.queerbric.pride.PrideClient;
16-
import io.github.queerbric.pride.PrideFlag;
17-
import io.github.queerbric.pride.PrideFlagShapes;
18-
import io.github.queerbric.pride.PrideFlags;
16+
import io.github.queerbric.pride.*;
17+
import it.unimi.dsi.fastutil.ints.IntList;
18+
import net.minecraft.client.Minecraft;
1919
import net.minecraft.client.gui.GuiGraphics;
20+
import net.minecraft.network.chat.Text;
2021
import net.minecraft.resources.Identifier;
2122

2223
import java.util.Random;
@@ -27,46 +28,57 @@
2728
* If you have an issue with this, I don't care.
2829
*
2930
* @author LambdAurora
30-
* @version 3.2.0
31+
* @version 3.2.3
3132
* @since 2.1.0
3233
*/
3334
public class RandomPrideFlagBackground implements Background {
3435
private static final Background SECOND_LAYER = new SimpleColorBackground(0xe0101010);
36+
private static final IntList DEFAULT_RAINBOW_COLORS = IntList.of(
37+
0xffff0018, 0xffffa52c, 0xffffff41, 0xff008018, 0xff0000f9, 0xff86007d
38+
);
39+
private static final PrideFlagShape PROGRESS = PrideFlagShapes.get(Identifier.of("pride", "progress"));
3540
private static final Random RANDOM = new Random();
3641

3742
private final PrideFlag flag;
43+
private final boolean nuhUh;
3844

39-
public RandomPrideFlagBackground(PrideFlag flag) {
45+
RandomPrideFlagBackground(PrideFlag flag, boolean nuhUh) {
4046
this.flag = flag;
47+
this.nuhUh = nuhUh;
48+
}
49+
50+
private IntList getColors() {
51+
return this.nuhUh ? DEFAULT_RAINBOW_COLORS : this.flag.getColors();
4152
}
4253

4354
@Override
4455
public void render(GuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
4556
int x = widget.getX();
4657
int y = widget.getY();
58+
int width = widget.getWidth();
59+
int height = widget.getHeight();
4760

48-
if (this.flag.getShape() == PrideFlagShapes.get(Identifier.of("pride", "horizontal_stripes"))) {
61+
if (this.nuhUh || this.flag.getShape() == PrideFlagShapes.get(Identifier.of("pride", "horizontal_stripes"))) {
4962
graphics.drawSpecial(bufferSource -> {
5063
var buffer = bufferSource.getBuffer(PrideClient.FLAG_SHAPE_TRIANGLE_RENDER_TYPE);
5164

52-
int width = widget.getWidth();
53-
int height = widget.getHeight();
65+
var colors = this.getColors();
5466

55-
float partHeight = height / (this.flag.getColors().size() - 1.f);
67+
float partHeight = height / (colors.size() - 1.f);
5668

5769
// First one
5870
float rightY = y;
5971
float leftY = y;
6072

61-
int color = this.flag.getColors().getInt(0);
73+
int color = colors.getInt(0);
6274
buffer.addVertex(x + width, rightY + partHeight, 0).color(color);
6375
buffer.addVertex(x + width, rightY, 0).color(color);
6476
buffer.addVertex(x, leftY, 0).color(color);
6577

6678
rightY += partHeight;
6779

68-
for (int i = 1; i < this.flag.getColors().size() - 1; i++) {
69-
color = this.flag.getColors().getInt(i);
80+
for (int i = 1; i < colors.size() - 1; i++) {
81+
color = colors.getInt(i);
7082

7183
buffer.addVertex(x + width, rightY + partHeight, 0).color(color);
7284
buffer.addVertex(x + width, rightY, 0).color(color);
@@ -81,7 +93,7 @@ public void render(GuiGraphics graphics, SpruceWidget widget, int vOffset, int m
8193
}
8294

8395
// Last one
84-
color = this.flag.getColors().getInt(this.flag.getColors().size() - 1);
96+
color = colors.getInt(colors.size() - 1);
8597
buffer.addVertex(x + width, rightY, 0).color(color);
8698
buffer.addVertex(x, leftY, 0).color(color);
8799
buffer.addVertex(x, y + height, 0).color(color);
@@ -91,6 +103,19 @@ public void render(GuiGraphics graphics, SpruceWidget widget, int vOffset, int m
91103
}
92104

93105
SECOND_LAYER.render(graphics, widget, vOffset, mouseX, mouseY, delta);
106+
107+
if (this.nuhUh) {
108+
var text = Text.literal("Nuh uh, you're not going to remove this, try harder :3c");
109+
var font = Minecraft.getInstance().font;
110+
var lines = font.wrapLines(text, width - 8);
111+
112+
int startY = y + height - 24 - lines.size() * (font.lineHeight + 2);
113+
114+
for (var line : lines) {
115+
graphics.drawCenteredShadowedText(font, line, x + width / 2, startY, 0xffff0000);
116+
startY += font.lineHeight + 2;
117+
}
118+
}
94119
}
95120

96121
/**
@@ -99,6 +124,39 @@ public void render(GuiGraphics graphics, SpruceWidget widget, int vOffset, int m
99124
* @return the background
100125
*/
101126
public static Background random() {
102-
return new RandomPrideFlagBackground(PrideFlags.getRandomFlag(RANDOM));
127+
var flag = PrideFlags.getRandomFlag(RANDOM);
128+
boolean nuhUh = flag == null || (flag.getShape() != PROGRESS && areColorsSpoofed(flag.getColors()));
129+
130+
return new RandomPrideFlagBackground(flag, nuhUh);
131+
}
132+
133+
private static boolean areColorsSpoofed(IntList colors) {
134+
if (colors.size() < 2) {
135+
return true;
136+
} else {
137+
int maxDist = 0;
138+
139+
for (int colorA : colors) {
140+
for (int colorB : colors) {
141+
int dist = colorDist(colorA, colorB);
142+
143+
if (dist > maxDist) {
144+
maxDist = dist;
145+
}
146+
}
147+
}
148+
149+
return maxDist < 10;
150+
}
151+
}
152+
153+
private static int colorDist(int a, int b) {
154+
// https://en.wikipedia.org/wiki/Color_difference#sRGB
155+
float r = (ColorUtil.argbUnpackRed(a) + ColorUtil.argbUnpackRed(b)) / 2.f;
156+
int deltaR = ColorUtil.argbUnpackRed(a) - ColorUtil.argbUnpackRed(b);
157+
int deltaG = ColorUtil.argbUnpackGreen(a) - ColorUtil.argbUnpackGreen(b);
158+
int deltaB = ColorUtil.argbUnpackBlue(a) - ColorUtil.argbUnpackBlue(b);
159+
160+
return (int) Math.sqrt((2 + r / 256.f) * deltaR * deltaR + 4 * deltaG * deltaG + (2 + (255 - r) / 256) * deltaB * deltaB);
103161
}
104162
}

src/main/java/dev/lambdaurora/lambdynlights/mixin/lightsource/BlockAttachedEntityMixin.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@
1717
import net.minecraft.world.entity.decoration.BlockAttachedEntity;
1818
import net.minecraft.world.level.Level;
1919
import org.spongepowered.asm.mixin.Mixin;
20+
import org.spongepowered.asm.mixin.injection.At;
21+
import org.spongepowered.asm.mixin.injection.Inject;
22+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2023

2124
@Mixin(BlockAttachedEntity.class)
2225
public abstract class BlockAttachedEntityMixin extends Entity implements DynamicLightSource {
2326
public BlockAttachedEntityMixin(EntityType<?> type, Level level) {
2427
super(type, level);
2528
}
2629

27-
@Override
28-
public void tick() {
29-
super.tick();
30+
@Inject(method = "tick", at = @At("RETURN"))
31+
public void lambdynlights$onTick(CallbackInfo ci) {
3032
// We do not want to update the entity on the server.
3133
if (this.level().isClientSide()) {
3234
if (this.isRemoved()) {

0 commit comments

Comments
 (0)