Skip to content
This repository was archived by the owner on Jul 2, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Sol Client - an open source Minecraft client
* Copyright (C) 2021-2023 TheKodeToad and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package io.github.solclient.client.mod.impl.visibleseasons;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Snowflake {
private int x;
private int y;
private int size;
private int speed;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Sol Client - an open source Minecraft client
* Copyright (C) 2021-2023 TheKodeToad and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package io.github.solclient.client.mod.impl.visibleseasons;

import com.google.gson.annotations.Expose;
import io.github.solclient.client.mod.impl.StandardMod;
import io.github.solclient.client.mod.option.annotation.Option;
import io.github.solclient.client.mod.option.annotation.Slider;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;

import java.util.ArrayList;
import java.util.List;

public class VisibleSeasonsMod extends StandardMod {
public static VisibleSeasonsMod instance;
protected final MinecraftClient mc = MinecraftClient.getInstance();
public List<Snowflake> snowflakes = new ArrayList<>();

@Expose
@Option
public boolean forceVisibleSeasons;

@Expose
@Option
@Slider(min = 1, max = 50, step = 1)
public float visibleSeasonsAmount = 25;

@Expose
@Option
public boolean visibleSeasonsLowDetail;


@Override
public String getDetail() {
return I18n.translate("sol_client.mod.screen.by", "ArikSquad");
}

@Override
public void init() {
super.init();
instance = this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,30 @@

package io.github.solclient.client.ui.component;

import org.apache.logging.log4j.*;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.*;

import io.github.solclient.client.mod.impl.visibleseasons.Snowflake;
import io.github.solclient.client.mod.impl.visibleseasons.VisibleSeasonsMod;
import io.github.solclient.client.ui.component.controller.ParentBoundsController;
import io.github.solclient.client.util.*;
import io.github.solclient.client.util.cursors.SystemCursors;
import io.github.solclient.client.util.data.*;
import io.github.solclient.client.util.MinecraftUtils;
import io.github.solclient.client.util.NanoVGManager;
import io.github.solclient.client.util.data.Colour;
import io.github.solclient.client.util.data.Rectangle;
import lombok.Getter;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.Window;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.nanovg.NVGPaint;
import org.lwjgl.nanovg.NanoVG;

import java.time.LocalDate;
import java.time.Month;
import java.util.Iterator;
import java.util.concurrent.ThreadLocalRandom;

public class ComponentScreen extends Screen {

Expand All @@ -41,6 +53,9 @@ public class ComponentScreen extends Screen {
protected boolean background = true;
private float mouseX, mouseY;

private long lastFrameTime = 0;
private final long nvg;

public ComponentScreen(Component root) {
this.parentScreen = MinecraftClient.getInstance().currentScreen;
rootWrapper = new Component() {
Expand All @@ -53,6 +68,8 @@ public Rectangle getBounds() {
};
rootWrapper.setScreen(this);

nvg = NanoVGManager.getNvg();

rootWrapper.add(root, new ParentBoundsController());
this.root = root;
}
Expand All @@ -63,6 +80,46 @@ public Component getRoot() {

@Override
public void render(int mouseX, int mouseY, float tickDelta) {
if (VisibleSeasonsMod.instance.forceVisibleSeasons || LocalDate.now().getMonth() == Month.DECEMBER) {
long currentTime = System.currentTimeMillis();
if (currentTime - lastFrameTime >= ThreadLocalRandom.current().nextInt(400)) {
if (VisibleSeasonsMod.instance.snowflakes.size() < (int) VisibleSeasonsMod.instance.visibleSeasonsAmount) {
int snowflakeX = ThreadLocalRandom.current().nextInt(client.width);
int snowflakeSize = 5 + ThreadLocalRandom.current().nextInt(6);
int snowflakeSpeed = 1 + ThreadLocalRandom.current().nextInt(3);
VisibleSeasonsMod.instance.snowflakes.add(new Snowflake(snowflakeX, 0, snowflakeSize, snowflakeSpeed));
lastFrameTime = currentTime;
}
}


Iterator<Snowflake> iterator = VisibleSeasonsMod.instance.snowflakes.iterator();
while (iterator.hasNext()) {
Snowflake snowflake = iterator.next();
int x = snowflake.getX();
int y = snowflake.getY();
int size = snowflake.getSize();

NanoVG.nvgBeginPath(nvg);
if (VisibleSeasonsMod.instance.visibleSeasonsLowDetail) {
NanoVG.nvgRect(nvg, x, y, size, size);
NanoVG.nvgFillColor(nvg, Colour.WHITE.nvg());
NanoVG.nvgFill(nvg);
} else {
NVGPaint paint = MinecraftUtils.nvgMinecraftTexturePaint(nvg, new Identifier("sol_client", "textures/gui/snowflake.png"), x, y, size, size, 0);
NanoVG.nvgFillPaint(nvg, paint);
NanoVG.nvgFill(nvg);
}

// Reset the snowflake if it goes beyond the screen bounds
if (y > client.height) {
iterator.remove();
} else {
snowflake.setY(y + snowflake.getSpeed());
}
}
}

try {
Window window = new Window(client);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,35 @@

package io.github.solclient.client.ui.screen.mods;

import org.lwjgl.input.Keyboard;

import io.github.solclient.client.SolClient;
import io.github.solclient.client.mod.*;
import io.github.solclient.client.mod.Mod;
import io.github.solclient.client.mod.ModUiStateManager;
import io.github.solclient.client.mod.impl.core.CoreMod;
import io.github.solclient.client.ui.*;
import io.github.solclient.client.ui.component.*;
import io.github.solclient.client.ui.component.controller.*;
import io.github.solclient.client.ui.component.impl.*;
import io.github.solclient.client.ui.ScreenAnimation;
import io.github.solclient.client.ui.Theme;
import io.github.solclient.client.ui.component.Component;
import io.github.solclient.client.ui.component.ComponentRenderInfo;
import io.github.solclient.client.ui.component.controller.AlignedBoundsController;
import io.github.solclient.client.ui.component.controller.Controller;
import io.github.solclient.client.ui.component.impl.BlockComponent;
import io.github.solclient.client.ui.component.impl.ButtonComponent;
import io.github.solclient.client.ui.component.impl.LabelComponent;
import io.github.solclient.client.ui.component.impl.TextFieldComponent;
import io.github.solclient.client.ui.screen.PanoramaBackgroundScreen;
import io.github.solclient.client.util.*;
import io.github.solclient.client.util.data.*;
import io.github.solclient.client.util.ActiveMainMenu;
import io.github.solclient.client.util.KeyBindingInterface;
import io.github.solclient.client.util.MinecraftUtils;
import io.github.solclient.client.util.data.Alignment;
import io.github.solclient.client.util.data.Rectangle;
import lombok.Getter;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;
import org.lwjgl.input.Keyboard;


public class ModsScreen extends PanoramaBackgroundScreen {

protected MinecraftClient mc = MinecraftClient.getInstance();
private final ModsScreenComponent component;
private final ScreenAnimation animation = new ScreenAnimation();

Expand Down Expand Up @@ -280,8 +292,25 @@ public boolean mouseClickedAnywhere(ComponentRenderInfo info, int button, boolea
return super.mouseClickedAnywhere(info, button, inside, processed);
}

public static final int[] keys = {
Keyboard.KEY_UP, Keyboard.KEY_UP, Keyboard.KEY_DOWN, Keyboard.KEY_DOWN, Keyboard.KEY_LEFT, Keyboard.KEY_RIGHT,
Keyboard.KEY_LEFT, Keyboard.KEY_RIGHT, Keyboard.KEY_B, Keyboard.KEY_A
};

private int keyIndex = 0;

@Override
public boolean keyPressed(ComponentRenderInfo info, int keyCode, char character) {
if (keyCode == keys[keyIndex]) {
keyIndex++;
if (keyIndex == keys.length) {
mc.setScreen(new SnakeScreen());
keyIndex = 0;
}
} else {
keyIndex = 0;
}

if ((screen.getRoot().getDialog() == null
&& (keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER))) {
if (mod == null) {
Expand Down
Loading