Skip to content

Commit

Permalink
betterchat, better animations etc
Browse files Browse the repository at this point in the history
  • Loading branch information
lolwut2 committed May 4, 2024
1 parent e4a2fe5 commit 62f8f1c
Show file tree
Hide file tree
Showing 16 changed files with 640 additions and 92 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'com.github.gmazzo.buildconfig' version '5.3.5'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public ModuleManager() {
new AutoReconnectModule(),
new AutoRespawnModule(),
new BeaconSelectorModule(),
new BetterChatModule(),
// new BetterChatModule(),
new ChatNotifierModule(),
new ChestSwapModule(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package net.shoreline.client.impl.module.client;

import net.minecraft.client.gui.hud.ChatHudLine;
import net.shoreline.client.api.config.Config;
import net.shoreline.client.api.config.setting.BooleanConfig;
import net.shoreline.client.api.config.setting.EnumConfig;
import net.shoreline.client.api.config.setting.NumberConfig;
import net.shoreline.client.api.module.ConcurrentModule;
import net.shoreline.client.api.module.ModuleCategory;
import net.shoreline.client.util.render.animation.Easing;
import net.shoreline.client.util.render.animation.TimeAnimation;

import java.util.HashMap;
import java.util.Map;

/**
* @author linus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.shoreline.client.util.math.timer.Timer;
import net.shoreline.client.util.player.PlayerUtil;
import net.shoreline.client.util.player.RotationUtil;
import net.shoreline.client.util.render.animation.Animation;
import net.shoreline.client.util.render.animation.TimeAnimation;
import net.shoreline.client.util.world.EndCrystalUtil;
import net.shoreline.client.util.world.EntityUtil;
Expand Down Expand Up @@ -167,9 +168,7 @@ public class AutoCrystalModule extends RotationModule {
private final Map<BlockPos, Long> placePackets =
Collections.synchronizedMap(new ConcurrentHashMap<>());

//gonna make a better solution for this in the future.
private final Map<BlockPos, TimeAnimation> fadeBoxes = new HashMap<>();
private final Map<BlockPos, TimeAnimation> fadeLines = new HashMap<>();
private final Map<BlockPos, Animation> fadeList = new HashMap<>();

private final ExecutorService executor = Executors.newFixedThreadPool(2);

Expand All @@ -195,6 +194,7 @@ public void onDisable() {
silentRotations = null;
attackPackets.clear();
placePackets.clear();
fadeList.clear();
setStage("NONE");
}

Expand Down Expand Up @@ -303,30 +303,20 @@ public void onRenderWorld(RenderWorldEvent event)
{
if (fadeConfig.getValue())
{
for (Map.Entry<BlockPos, TimeAnimation> set : fadeBoxes.entrySet())
for (Map.Entry<BlockPos, Animation> set : fadeList.entrySet())
{
if (set.getKey() == renderPos)
{
continue;
}

set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), color.getRGB());
}

for (Map.Entry<BlockPos, TimeAnimation> set : fadeLines.entrySet())
{
if (set.getKey() == renderPos)
{
continue;
}

set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, color.getRGB());
int boxAlpha = (int) (80 * set.getValue().getFactor());
int lineAlpha = (int) (145 * set.getValue().getFactor());
Color boxColor = Modules.COLORS.getColor(boxAlpha);
Color lineColor = Modules.COLORS.getColor(lineAlpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), boxColor.getRGB());
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, lineColor.getRGB());
}
}

Expand All @@ -348,16 +338,12 @@ public void onRenderWorld(RenderWorldEvent event)
}
else
{
TimeAnimation boxAnimation = new TimeAnimation(true, 0, 80, fadeTimeConfig.getValue());
TimeAnimation lineAnimation = new TimeAnimation(true, 0, 145, fadeTimeConfig.getValue());
fadeBoxes.put(renderPos, boxAnimation);
fadeLines.put(renderPos, lineAnimation);
Animation animation = new Animation(true, fadeTimeConfig.getValue());
fadeList.put(renderPos, animation);
}
}

fadeBoxes.entrySet().removeIf(e ->
e.getValue().getFactor() == 0.0);
fadeLines.entrySet().removeIf(e ->
fadeList.entrySet().removeIf(e ->
e.getValue().getFactor() == 0.0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import net.shoreline.client.init.Managers;
import net.shoreline.client.init.Modules;
import net.shoreline.client.util.player.PlayerUtil;
import net.shoreline.client.util.render.animation.Animation;
import net.shoreline.client.util.render.animation.TimeAnimation;

import java.awt.*;
Expand All @@ -59,8 +60,7 @@ public final class AutoTrapModule extends ObsidianPlacerModule
Config<Boolean> renderConfig = new BooleanConfig("Render", "Renders where autotrap is placing blocks", false);
Config<Integer> fadeTimeConfig = new NumberConfig<>("Fade-Time", "Time to fade", 0, 250, 1000, () -> false);

private final Map<BlockPos, TimeAnimation> fadeBoxes = new HashMap<>();
private final Map<BlockPos, TimeAnimation> fadeLines = new HashMap<>();
private final Map<BlockPos, Animation> fadeList = new HashMap<>();

private List<BlockPos> surround = new ArrayList<>();
private List<BlockPos> placements = new ArrayList<>();
Expand Down Expand Up @@ -412,34 +412,32 @@ public void onRenderWorld(RenderWorldEvent event)
{
if (renderConfig.getValue())
{
for (Map.Entry<BlockPos, TimeAnimation> set : fadeBoxes.entrySet())
{
set.getValue().setState(false);
set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), color.getRGB());
}

for (Map.Entry<BlockPos, TimeAnimation> set : fadeLines.entrySet())
for (Map.Entry<BlockPos, Animation> set : fadeList.entrySet())
{
set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, color.getRGB());
int boxAlpha = (int) (80 * set.getValue().getFactor());
int lineAlpha = (int) (145 * set.getValue().getFactor());
Color boxColor = Modules.COLORS.getColor(boxAlpha);
Color lineColor = Modules.COLORS.getColor(lineAlpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), boxColor.getRGB());
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, lineColor.getRGB());
}


if (placements.isEmpty())
{
return;
}

for (BlockPos pos : placements)
{
TimeAnimation boxAnimation = new TimeAnimation(true, 0, 80, fadeTimeConfig.getValue());
TimeAnimation lineAnimation = new TimeAnimation(true, 0, 145, fadeTimeConfig.getValue());
fadeBoxes.put(pos, boxAnimation);
fadeLines.put(pos, lineAnimation);
Animation animation = new Animation(true, fadeTimeConfig.getValue());
fadeList.put(pos, animation);
}
}

fadeList.entrySet().removeIf(e ->
e.getValue().getFactor() == 0.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.shoreline.client.init.Modules;
import net.shoreline.client.util.math.position.PositionUtil;
import net.shoreline.client.util.player.PlayerUtil;
import net.shoreline.client.util.render.animation.Animation;
import net.shoreline.client.util.render.animation.TimeAnimation;

import java.awt.*;
Expand All @@ -58,8 +59,7 @@ public class SurroundModule extends ObsidianPlacerModule {
Config<Boolean> renderConfig = new BooleanConfig("Render", "Renders where scaffold is placing blocks", false);
Config<Integer> fadeTimeConfig = new NumberConfig<>("Fade-Time", "Time to fade", 0, 250, 1000, () -> false);

private final Map<BlockPos, TimeAnimation> fadeBoxes = new HashMap<>();
private final Map<BlockPos, TimeAnimation> fadeLines = new HashMap<>();
private final Map<BlockPos, Animation> fadeList = new HashMap<>();

private List<BlockPos> surround = new ArrayList<>();
private List<BlockPos> placements = new ArrayList<>();
Expand Down Expand Up @@ -321,33 +321,31 @@ public void onRenderWorld(RenderWorldEvent event)
{
if (renderConfig.getValue())
{
for (Map.Entry<BlockPos, TimeAnimation> set : fadeBoxes.entrySet())
for (Map.Entry<BlockPos, Animation> set : fadeList.entrySet())
{
set.getValue().setState(false);
set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), color.getRGB());
int boxAlpha = (int) (80 * set.getValue().getFactor());
int lineAlpha = (int) (145 * set.getValue().getFactor());
Color boxColor = Modules.COLORS.getColor(boxAlpha);
Color lineColor = Modules.COLORS.getColor(lineAlpha);
RenderManager.renderBox(event.getMatrices(), set.getKey(), boxColor.getRGB());
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, lineColor.getRGB());
}

for (Map.Entry<BlockPos, TimeAnimation> set : fadeLines.entrySet())
{
set.getValue().setState(false);
int alpha = (int) set.getValue().getCurrent();
Color color = Modules.COLORS.getColor(alpha);
RenderManager.renderBoundingBox(event.getMatrices(), set.getKey(), 1.5f, color.getRGB());
}

if (placements.isEmpty())
{
return;
}

for (BlockPos pos : placements)
{
TimeAnimation boxAnimation = new TimeAnimation(true, 0, 80, fadeTimeConfig.getValue());
TimeAnimation lineAnimation = new TimeAnimation(true, 0, 145, fadeTimeConfig.getValue());
fadeBoxes.put(pos, boxAnimation);
fadeLines.put(pos, lineAnimation);
Animation animation = new Animation(true, fadeTimeConfig.getValue());
fadeList.put(pos, animation);
}
}

fadeList.entrySet().removeIf(e ->
e.getValue().getFactor() == 0.0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package net.shoreline.client.impl.module.misc;

import net.minecraft.client.gui.hud.ChatHudLine;
import net.shoreline.client.api.config.Config;
import net.shoreline.client.api.config.setting.BooleanConfig;
import net.shoreline.client.api.config.setting.EnumConfig;
import net.shoreline.client.api.config.setting.NumberConfig;
import net.shoreline.client.api.module.ModuleCategory;
import net.shoreline.client.api.module.ToggleModule;
import net.shoreline.client.util.render.animation.Easing;
import net.shoreline.client.util.render.animation.TimeAnimation;

import java.util.HashMap;
import java.util.Map;

//TODO: add easing when linus fixes enumconfig...
public class BetterChatModule extends ToggleModule
{
Config<Boolean> animation = new BooleanConfig("Animation", "Animates the chat", false);
Config<Integer> time = new NumberConfig<>("Time", "Time for the animation", 0, 200, 1000);
/* Config<Easing> easing = new EnumConfig<>("Easing", "Easing for the animation", Easing.LINEAR, new Easing[]{
Easing.LINEAR,
Easing.SINE_IN,
Easing.SINE_OUT,
Easing.SINE_IN_OUT,
Easing.CUBIC_IN,
Easing.CUBIC_OUT,
Easing.CUBIC_IN_OUT,
Easing.QUAD_IN,
Easing.QUAD_OUT,
Easing.QUAD_IN_OUT,
Easing.QUART_IN,
Easing.QUART_OUT,
Easing.QUART_IN_OUT,
Easing.QUINT_IN,
Easing.QUINT_OUT,
Easing.QUINT_IN_OUT,
Easing.CIRC_IN,
Easing.CIRC_OUT,
Easing.CIRC_IN_OUT,
Easing.EXPO_IN,
Easing.EXPO_OUT,
Easing.EXPO_IN_OUT,
Easing.ELASTIC_IN,
Easing.ELASTIC_OUT,
Easing.ELASTIC_IN_OUT,
Easing.BACK_IN,
Easing.BACK_OUT,
Easing.BACK_IN_OUT,
Easing.BOUNCE_IN,
Easing.BOUNCE_OUT,
Easing.BOUNCE_IN_OUT
}); */

public final Map<ChatHudLine, TimeAnimation> animationMap = new HashMap<>();

public BetterChatModule()
{
super("BetterChat", "Modifications for the chat", ModuleCategory.MISCELLANEOUS);
}

public Config<Boolean> getAnimationConfig()
{
return animation;
}

public Config<Integer> getTimeConfig()
{
return time;
}

/*
public Config<Easing> getEasingConfig()
{
return easing;
}
*/

public Easing getEasingConfig()
{
return Easing.LINEAR;
}
}
Loading

0 comments on commit 62f8f1c

Please sign in to comment.