Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Aug 18, 2023
1 parent e62f17d commit fec27e9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version = 1.19
yarn_mappings = 1.19+build.4
loader_version = 0.14.21

mod_version = 1.0.0
mod_version = 1.1.0
maven_group = net.krlite
archives_base_name = tapestop

Expand Down
30 changes: 28 additions & 2 deletions src/main/java/net/krlite/tapestop/TapeStop.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.*;
import java.util.Arrays;
import java.util.Random;

Expand All @@ -42,7 +43,7 @@ public class TapeStop implements ModInitializer {
};

private static long lastActionTime = 0, tapeStopTime;
private static int color;
private static int blockColor, color;
private static @Nullable RotatingCubeMapRenderer cubeMapRenderer;

@Override
Expand All @@ -67,14 +68,39 @@ public static boolean shouldTapeStop(@Nullable Screen screen) {
return false;
}

private static void updateColors() {
blockColor = randomColorBits() << 16 | randomColorBits() << 8 | randomColorBits();
color = brighten(blockColor);
}

private static int randomColorBits() {
return new Random().nextInt(0x3C) | 0x10;
int color = new Random().nextInt(0x10, 0x3C);
return color <= 0x10 ? 0 : color;
}

private static int brighten(int color) {
if (color <= 0) return 0;

Color hslColor = new Color(color);
float[] hsl = Color.RGBtoHSB(hslColor.getRed(), hslColor.getGreen(), hslColor.getBlue(), null);

float[] factors = new float[]{ 1, new Random().nextFloat(1.9F, 2.2F), new Random().nextFloat(2.3F, 3.1F) };
for (int i = 0; i < 3; i++) {
hsl[i] *= factors[i];
hsl[i] = Math.max(0, Math.min(1, hsl[i]));
}

return Color.HSBtoRGB(hsl[0], hsl[1], hsl[2]);
}

public static long tapeStopTime() {
return tapeStopTime;
}

public static int blockColor() {
return blockColor;
}

public static int color() {
return color;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/krlite/tapestop/config/TapeStopConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.io.File;

public class TapeStopConfig extends Pierced {
@Silent
private static final File file = FabricLoader.getInstance().getConfigDir().resolve("tapestop.toml").toFile();
private static @Silent final File file = FabricLoader.getInstance().getConfigDir().resolve("tapestop.toml").toFile();

public TapeStopConfig() {
super(TapeStopConfig.class, file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ private boolean skipGameRender(MinecraftClient client) {
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();

float
red = (float) (TapeStop.color() >> 16 & 0xFF) / 255.0F,
green = (float) (TapeStop.color() >> 8 & 0xFF) / 255.0F,
blue = (float) (TapeStop.color() & 0xFF) / 255.0F;
red = (float) (TapeStop.blockColor() >> 16 & 0xFF) / 255.0F,
green = (float) (TapeStop.blockColor() >> 8 & 0xFF) / 255.0F,
blue = (float) (TapeStop.blockColor() & 0xFF) / 255.0F;

new BlockModelRenderer(MinecraftClient.getInstance().getBlockColors()).render(
modelMatrixStack.peek(), immediate.getBuffer(RenderLayers.getBlockLayer(blockState)), blockState,
Expand All @@ -119,7 +119,7 @@ private boolean skipGameRender(MinecraftClient client) {
}

if (!skipped) {
TapeStop.LOGGER.info("Tape stopped. Rendering overlay with background color 0x" + Integer.toHexString(TapeStop.color()).toUpperCase(Locale.ROOT));
TapeStop.LOGGER.info("Tape stopped. Rendering overlay with background color " + String.format("#%06x", TapeStop.blockColor() & 0xFFFFFF).toUpperCase(Locale.ROOT));
}
}

Expand Down

0 comments on commit fec27e9

Please sign in to comment.