Skip to content

Commit

Permalink
Merge pull request #28 from Zalgo-Dev/main
Browse files Browse the repository at this point in the history
Fix and update theme
  • Loading branch information
SpigotRCE authored Jan 27, 2025
2 parents b2eb16f + 6d6ce42 commit cc3299f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ public static void setTheme(String theme) {

/**
* Renders the background according to the current theme.
* Switches between themes and calls the appropriate render method.
*/
public static void render(DrawContext context, int width, int height) {
String theme = getTheme(); // Retrieve theme from configuration
String theme = getTheme(); // Retrieve the theme from configuration
switch (theme) {
case "ParadiseHack" -> renderMatrix(context, width, height);
case "ParadiseParticle" -> renderElegantBackground(context, width, height);
default -> renderMatrix(context, width, height); // Hack par défaut
default -> renderMatrix(context, width, height); // Default to "Hack" theme
}
}


// Theme Hack (style matrix)
/**
* Renders the "Matrix" style theme with falling characters.
*/
public static void renderMatrix(DrawContext context, int width, int height) {
context.fillGradient(0, 0, width, height, 0xCC000000, 0xCC000000);
context.fillGradient(0, 0, width, height, 0xCC000000, 0xCC000000); // Black gradient background
for (int i = 0; i < drops.length; i++) {
String text = Helper.generateRandomString(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", random);
context.drawText(MinecraftClient.getInstance().textRenderer, text, i * 10, drops[i] * 10, 0x00FF00, false);
Expand All @@ -50,22 +52,56 @@ public static void renderMatrix(DrawContext context, int width, int height) {
}
}

// Theme Particle (dynamic particles)
/**
* Renders the particle-based elegant background theme.
*/
private static int lastWidth = -1;
private static int lastHeight = -1;

public static void renderElegantBackground(DrawContext context, int width, int height) {
context.fillGradient(0, 0, width, height, 0xFF1A237E, 0xFF882dbd); // Bleu -> Violet
// Check if the window size has changed
if (width != lastWidth || height != lastHeight) {
regenerateParticles(width, height);
lastWidth = width;
lastHeight = height;
}

// Draw the gradient background
context.fillGradient(0, 0, width, height, 0x801A237E, 0x80882dbd);

// Update and draw each particle
for (Particle particle : particles) {
particle.update(width, height);
context.fill(particle.x, particle.y, particle.x + 2, particle.y + 2, particle.color);
context.fill(particle.x, particle.y, particle.x + 2, particle.y + 2, 0x80FFFFFF);
}
}

/**
* Regenerates all particles to adapt to the new window size.
*/
private static void regenerateParticles(int width, int height) {
for (Particle particle : particles) {
particle.reset(width, height);
}
}

/**
* Represents an individual particle with position, velocity, and color.
*/
private static class Particle {
int x, y, speedX, speedY, color;

public Particle() {
reset(800, 600);
this(0, 0); // Initialize without specific dimensions
}

public Particle(int width, int height) {
reset(width, height);
}

/**
* Updates the particle's position and resets it if it moves out of bounds.
*/
public void update(int width, int height) {
x += speedX;
y += speedY;
Expand All @@ -75,16 +111,19 @@ public void update(int width, int height) {
}
}

/**
* Resets the particle to a new random position, speed, and color.
*/
public void reset(int width, int height) {
x = random.nextInt(width);
y = random.nextInt(height);
x = random.nextInt(Math.max(width, 1));
y = random.nextInt(Math.max(height, 1));

do {
speedX = -1 + random.nextInt(3); // Vitesse entre -1 et 1
speedX = -1 + random.nextInt(3); // Velocity between -1 and 1
speedY = -1 + random.nextInt(3);
} while (speedX == 0 && speedY == 0);

color = 0xFFFFFFFF; // Blanc
color = 0xFFFFFFFF; // White color
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
public class RotatingCubeMapRendererMixin {
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
public void render(DrawContext context, int width, int height, float alpha, float tickDelta, CallbackInfo ci) {
WallPaper.renderMatrix(context, width, height);
ci.cancel();
// Appelle le rendu dynamique basé sur le thème défini
WallPaper.render(context, width, height);
ci.cancel(); // Annule le rendu original
}
}

0 comments on commit cc3299f

Please sign in to comment.