diff --git a/src/main/java/dev/heliosclient/event/events/input/KeyboardInputEvent.java b/src/main/java/dev/heliosclient/event/events/input/KeyboardInputEvent.java index 1f0750bc..50df737d 100644 --- a/src/main/java/dev/heliosclient/event/events/input/KeyboardInputEvent.java +++ b/src/main/java/dev/heliosclient/event/events/input/KeyboardInputEvent.java @@ -5,8 +5,6 @@ @Cancelable public class KeyboardInputEvent extends Event { - public float movementSideways; - public float movementForward; public boolean pressingForward; public boolean pressingBack; public boolean pressingLeft; @@ -14,9 +12,7 @@ public class KeyboardInputEvent extends Event { public boolean jumping; public boolean sneaking; - public KeyboardInputEvent(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) { - this.movementSideways = movementSideways; - this.movementForward = movementForward; + public KeyboardInputEvent(boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) { this.pressingForward = pressingForward; this.pressingBack = pressingBack; this.pressingLeft = pressingLeft; @@ -24,10 +20,7 @@ public KeyboardInputEvent(float movementSideways, float movementForward, boolean this.jumping = jumping; this.sneaking = sneaking; } - - public void set(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) { - this.movementSideways = movementSideways; - this.movementForward = movementForward; + public void set( boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking) { this.pressingForward = pressingForward; this.pressingBack = pressingBack; this.pressingLeft = pressingLeft; @@ -36,12 +29,12 @@ public void set(float movementSideways, float movementForward, boolean pressingF this.sneaking = sneaking; } - public boolean isSame(float movementSideways, float movementForward, boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking){ - return this.movementForward == movementForward && this.movementSideways == movementSideways && this.pressingForward == pressingForward && this.pressingBack == pressingBack && this.pressingRight == pressingRight && this.jumping == jumping && this.sneaking == sneaking && this.pressingLeft == pressingLeft; + public boolean isSame(boolean pressingForward, boolean pressingBack, boolean pressingLeft, boolean pressingRight, boolean jumping, boolean sneaking){ + return this.pressingForward == pressingForward && this.pressingBack == pressingBack && this.pressingRight == pressingRight && this.jumping == jumping && this.sneaking == sneaking && this.pressingLeft == pressingLeft; } public void setNone() { - this.set(0f,0f,false,false,false,false,false,false); + this.set(false,false,false,false,false,false); } } diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java b/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java index 419e03ec..7c3e2e30 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java @@ -1,5 +1,6 @@ package dev.heliosclient.hud.hudelements; +import dev.heliosclient.HeliosClient; import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.heliosclient.FontChangeEvent; import dev.heliosclient.hud.HudElement; @@ -75,7 +76,7 @@ public ArmorHud() { public void onSettingChange(Setting setting) { super.onSettingChange(setting); - if(setting == textSize){ + if(setting == textSize && HeliosClient.shouldUpdate()){ this.cFontRenderer = new fxFontRenderer(FontManager.fonts,textSize.getFloat()); } } diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java index 17281ba4..7fa1c71b 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java @@ -70,7 +70,7 @@ public class ModuleList extends HudElement implements Listener { .shouldRender(() -> background.value) .build()); private final BooleanSetting glow = sgSettings.add(new BooleanSetting.Builder() - .name("Render Glow") + .name("Render-Glow") .description("Renders a glow behind the text depending on the color of text") .onSettingChange(this) .defaultValue(false) diff --git a/src/main/java/dev/heliosclient/mixin/MixinKeyboardInput.java b/src/main/java/dev/heliosclient/mixin/MixinKeyboardInput.java index 996b8620..6fc60a2a 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinKeyboardInput.java +++ b/src/main/java/dev/heliosclient/mixin/MixinKeyboardInput.java @@ -19,7 +19,7 @@ protected static float getMovementMultiplier(boolean positive, boolean negative) @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/input/KeyboardInput;sneaking:Z", shift = At.Shift.AFTER), allow = 1) private void onTick(boolean slowDown, float slowDownFactor, CallbackInfo ci) { - KeyboardInputEvent event = new KeyboardInputEvent(movementSideways, movementForward, pressingForward, pressingBack, pressingLeft, pressingRight, jumping, sneaking); + KeyboardInputEvent event = new KeyboardInputEvent(pressingForward, pressingBack, pressingLeft, pressingRight, jumping, sneaking); EventManager.postEvent(event); if(event.isCanceled()){ @@ -31,6 +31,7 @@ private void onTick(boolean slowDown, float slowDownFactor, CallbackInfo ci) { this.movementForward = getMovementMultiplier(this.pressingForward, this.pressingBack); this.movementSideways = getMovementMultiplier(this.pressingLeft, this.pressingRight); + this.jumping = event.jumping; this.sneaking = event.sneaking; } diff --git a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java index fbb23fe2..588d6411 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java @@ -14,6 +14,7 @@ import dev.heliosclient.util.ChatUtils; import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.TickTimer; +import dev.heliosclient.util.player.DamageUtils; import dev.heliosclient.util.player.InventoryUtils; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; @@ -53,15 +54,21 @@ public class AutoTotem extends Module_ { ); BooleanSetting log = sgGeneral.add(new BooleanSetting.Builder() .name("Notify") - .description("Notifies when we restock a totem or there is no totems left") + .description("Notifies when you restock a totem or there are no totems left") + .defaultValue(false) + .onSettingChange(this) + .build() + ); + BooleanSetting predictDamage = sgGeneral.add(new BooleanSetting.Builder() + .name("Predict Damage") + .description("Will try to predict the damage you will take and auto totem") .defaultValue(false) .onSettingChange(this) .build() ); - KeyBind totemSwitchKey = sgGeneral.add(new KeyBind.Builder() .name("Totem Switch Key") - .description("When you press this key, the module will automatically switch to a totem") + .description("When you press this key, you will automatically switch to a totem") .value(KeyBind.none()) .onSettingChange(this) .build() @@ -157,7 +164,7 @@ public void packetReceive(PacketEvent.RECEIVE e){ } private boolean isPlayerLow(){ - return mc.player.getHealth() + mc.player.getAbsorptionAmount() <= healthThreshold.value; + return mc.player.getHealth() + mc.player.getAbsorptionAmount() - (predictDamage.value? DamageUtils.calculateDamageByEnv() : 0) <= healthThreshold.value; } @Override diff --git a/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java b/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java index a1beba9b..c6a93b36 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java @@ -235,10 +235,11 @@ public void onSettingChange(Setting setting) { super.onSettingChange(setting); + //TODO: Use ray-casting instead of this unholy finding. targetFinder.setRange(range.value); targetFinder.setFilter(entity -> { - //Apply to all entities (like end crystal, TNT, etc.) + //Apply to all entities (like end crystal, TNT, armor-stands etc.) boolean A = entities.getSelectedEntries().contains(entity.getType()) && PlayerUtils.isPlayerLookingAtEntity(mc.player, entity, range.value) && entity.isAlive() && @@ -248,11 +249,7 @@ public void onSettingChange(Setting setting) { //Apply to only living entities if (entity instanceof LivingEntity e) { - B = entities.getSelectedEntries().contains(entity.getType()) && - PlayerUtils.isPlayerLookingAtEntity(mc.player, entity, range.value) && - entity.isAlive() && - entity.isAttackable() && - !isTeamMate(e) && + B = !isTeamMate(e) && !isFriend(e) && !isInvisible(e) && !AntiBot.isBot(e); diff --git a/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java b/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java index 6ac41669..5fe07e3f 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java @@ -5,7 +5,7 @@ import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; import dev.heliosclient.util.blocks.BlockUtils; -import dev.heliosclient.util.EntityUtils; +import dev.heliosclient.util.entity.EntityUtils; import net.minecraft.util.math.BlockPos; /** diff --git a/src/main/java/dev/heliosclient/module/modules/player/AutoLog.java b/src/main/java/dev/heliosclient/module/modules/player/AutoLog.java index 3bc08e98..b4cdf85c 100644 --- a/src/main/java/dev/heliosclient/module/modules/player/AutoLog.java +++ b/src/main/java/dev/heliosclient/module/modules/player/AutoLog.java @@ -10,7 +10,7 @@ import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.system.Friend; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.EntityUtils; +import dev.heliosclient.util.entity.EntityUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java index ed1536ba..270db613 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java @@ -1,6 +1,7 @@ package dev.heliosclient.module.modules.render; import dev.heliosclient.event.SubscribeEvent; +import dev.heliosclient.event.events.TickEvent; import dev.heliosclient.event.events.render.Render3DEvent; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; @@ -12,13 +13,12 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; -import java.awt.*; +import java.util.ArrayList; import java.util.List; import static dev.heliosclient.util.blocks.HoleUtils.HoleType.*; public class HoleESP extends Module_ { - static Color TRANSPARENT_BLUE = new Color(0, 30, 175, 179); SettingGroup sgGeneral = new SettingGroup("General"); BooleanSetting throughWalls = sgGeneral.add(new BooleanSetting.Builder() .name("ThroughWalls") @@ -32,7 +32,7 @@ public class HoleESP extends Module_ { .name("Hole Range") .description("Maximum distance of the hole to the player") .min(3) - .max(100) + .max(40) .value(20d) .defaultValue(20d) .roundingPlace(0) @@ -134,8 +134,8 @@ public class HoleESP extends Module_ { .description("Start of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#1dfb00"), 123)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#1dfb00"), 123)) + .value(ColorUtils.hexToColor("#1dfb00", 123)) + .defaultValue(ColorUtils.hexToColor("#1dfb00", 123)) .shouldRender(() -> setColorCycle.getOption() == SAFE) .build() ); @@ -144,8 +144,8 @@ public class HoleESP extends Module_ { .description("End of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#4bfb83"), 3)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#4bfb83"), 3)) + .value(ColorUtils.hexToColor("#4bfb83", 3)) + .defaultValue(ColorUtils.hexToColor("#4bfb83", 3)) .shouldRender(() -> setColorCycle.getOption() == SAFE) .build() ); @@ -154,8 +154,8 @@ public class HoleESP extends Module_ { .description("Start of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff6d00"), 142)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff6d00"), 142)) + .value(ColorUtils.hexToColor("#ff6d00", 142)) + .defaultValue(ColorUtils.hexToColor("#ff6d00", 142)) .shouldRender(() -> setColorCycle.getOption() == UNSAFE) .build() ); @@ -164,8 +164,8 @@ public class HoleESP extends Module_ { .description("End of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb9804"), 3)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb9804"), 3)) + .value(ColorUtils.hexToColor("#fb9804", 3)) + .defaultValue(ColorUtils.hexToColor("#fb9804", 3)) .shouldRender(() -> setColorCycle.getOption() == UNSAFE) .build() ); @@ -174,8 +174,8 @@ public class HoleESP extends Module_ { .description("Start of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff0000"), 145)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#ff0000"), 145)) + .value(ColorUtils.hexToColor("#ff0000", 145)) + .defaultValue(ColorUtils.hexToColor("#ff0000", 145)) .shouldRender(() -> setColorCycle.getOption() == DANGER) .build() ); @@ -184,12 +184,14 @@ public class HoleESP extends Module_ { .description("End of the gradient.") .onSettingChange(this) .rainbow(false) - .value(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb794b"), 7)) - .defaultValue(ColorUtils.changeAlpha(ColorUtils.hexToColor("#fb794b"), 7)) + .value(ColorUtils.hexToColor("#f80000", 7)) + .defaultValue(ColorUtils.hexToColor("#f80000", 7)) .shouldRender(() -> setColorCycle.getOption() == DANGER) .build() ); + + public HoleESP() { super("HoleESP", "Displays holes in your area", Categories.RENDER); addSettingGroup(sgGeneral); @@ -197,24 +199,29 @@ public HoleESP() { addQuickSettings(sgGeneral.getSettings()); addQuickSettings(sgColor.getSettings()); + } + + List holes = new ArrayList<>(); + @SubscribeEvent + public void onTick(TickEvent.PLAYER event) { + holes = HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value).stream().toList(); } @SubscribeEvent public void onRender3d(Render3DEvent event) { if (throughWalls.value) Renderer3D.renderThroughWalls(); + QuadColor.CardinalDirection direction = gradientDirection.getOption().equals("Down") ? QuadColor.CardinalDirection.SOUTH : QuadColor.CardinalDirection.NORTH; - for (HoleUtils.HoleInfo info : HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value)) { + for (HoleUtils.HoleInfo info : holes) { if (!renderSelf.value && mc.player.getBlockPos().isWithinDistance(info.holePosition, 1d)) { continue; } - //Contract and offset so that it does not fight for Z level with block textures. - Box box = new Box(info.holePosition); - double ogMaxY = box.maxY; - box = box.contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0).withMaxY(ogMaxY + height.value); + // Use the box from HoleInfo + Box box = info.holeBox.withMaxY(info.holeBox.maxY + height.value); if (info.holeType == SAFE) { renderHole(QuadColor.gradient(safeColorStart.value.getRGB(), safeColorEnd.value.getRGB(), direction), QuadColor.single(safeColorStart.value.getRGB()), box); @@ -225,14 +232,12 @@ public void onRender3d(Render3DEvent event) { if (info.holeType == DANGER) { renderHole(QuadColor.gradient(dangerColorStart.value.getRGB(), dangerColorEnd.value.getRGB(), direction), QuadColor.single(dangerColorStart.value.getRGB()), box); } - if (info.holeType == SIZED) { - //Renderer3D.drawBoxFill(box, QuadColor.single(TRANSPARENT_BLUE.getRGB()), Direction.UP,Direction.NORTH,Direction.SOUTH,Direction.EAST,Direction.WEST); - } } if (throughWalls.value) Renderer3D.stopRenderingThroughWalls(); } + private void renderHole(QuadColor fillColor, QuadColor lineColor, Box box) { Direction[] excludeDirs = new Direction[2]; if (!renderTop.value) { diff --git a/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java b/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java index 4d427a5d..9ee1fbec 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java @@ -15,13 +15,11 @@ import net.minecraft.util.math.Direction; import net.minecraft.world.LightType; -import java.awt.*; - public class LightLevelESP extends Module_ { SettingGroup sgGeneral = new SettingGroup("General"); DoubleSetting range = sgGeneral.add(new DoubleSetting.Builder() - .name("Range") - .description("Range to check light levels") + .name("Horizontal Range") + .description("Horizontal Range to check light levels") .min(0f) .max(50f) .value(10d) @@ -30,6 +28,17 @@ public class LightLevelESP extends Module_ { .onSettingChange(this) .build() ); + DoubleSetting vRange = sgGeneral.add(new DoubleSetting.Builder() + .name("Vertical Range") + .description("Vertical Range to check light levels") + .min(0f) + .max(10) + .value(4d) + .defaultValue(4d) + .roundingPlace(0) + .onSettingChange(this) + .build() + ); public LightLevelESP() { super("LightLevelESP", "Shows light levels on surface of blocks", Categories.RENDER); @@ -38,13 +47,9 @@ public LightLevelESP() { } - int RED_LOW = ColorUtils.changeAlpha(Color.RED,100).getRGB(); - int GREEN_LOW = ColorUtils.changeAlpha(Color.GREEN,100).getRGB(); - int YELLOW_LOW = ColorUtils.changeAlpha(Color.YELLOW,100).getRGB(); - @SubscribeEvent public void onRender3d(Render3DEvent event) { - BlockIterator iterator = new BlockIterator(mc.player, (int) range.value, 4); + BlockIterator iterator = new BlockIterator(mc.player, (int) range.value, vRange.getInt()); while (iterator.hasNext()) { BlockPos pos = iterator.next(); @@ -54,14 +59,11 @@ public void onRender3d(Render3DEvent event) { int lightLevel = mc.world.getLightLevel(LightType.BLOCK, pos); - if (lightLevel < 4) { - renderTop(pos, RED_LOW); // Red for very dark - } else if (lightLevel < 8) { - renderTop(pos, GREEN_LOW); // Orange for moderately dark - } else if (lightLevel < 12) { - renderTop(pos, YELLOW_LOW); // Yellow for moderately lit - } - //Nothing for well lit + float ratio = (float) lightLevel/mc.world.getMaxLightLevel(); + int red = (int) (255 * (1 - ratio)); + int green = (int) (255 * ratio); + int color = ColorUtils.rgbaToInt(red,green,0,100); + renderTop(pos,color); } } diff --git a/src/main/java/dev/heliosclient/module/modules/world/AutoNametag.java b/src/main/java/dev/heliosclient/module/modules/world/AutoNametag.java index c1c7d0a0..f3946d35 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/AutoNametag.java +++ b/src/main/java/dev/heliosclient/module/modules/world/AutoNametag.java @@ -8,7 +8,7 @@ import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.EntityUtils; +import dev.heliosclient.util.entity.EntityUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.RotationUtils; import net.minecraft.entity.Entity; diff --git a/src/main/java/dev/heliosclient/scripting/LuaExecutor.java b/src/main/java/dev/heliosclient/scripting/LuaExecutor.java index 9928746b..433da8d2 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaExecutor.java +++ b/src/main/java/dev/heliosclient/scripting/LuaExecutor.java @@ -5,7 +5,11 @@ import dev.heliosclient.scripting.libraries.ChatLib; import dev.heliosclient.scripting.libraries.PacketLib; import dev.heliosclient.scripting.libraries.PlayerLib; -import dev.heliosclient.util.*; +import dev.heliosclient.util.ChatUtils; +import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.entity.EntityUtils; import dev.heliosclient.util.player.DamageUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.PlayerUtils; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java index 091f5d23..8e6dabf3 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java @@ -105,7 +105,7 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float x, int } if(module.isActive() && gui.textHighlight.value) { - Renderer2D.drawBlurredShadow(drawContext.getMatrices(), x + 2, textY, Renderer2D.getFxStringWidth(module.name) + 1, moduleNameHeight, 9, ColorManager.INSTANCE.primaryGradientStart); + Renderer2D.drawBlurredShadow(drawContext.getMatrices(), x + 2, textY, Renderer2D.getFxStringWidth(module.name) + 2, moduleNameHeight + 1, 9,ColorUtils.changeAlpha(ColorManager.INSTANCE.primaryGradientStart,125)); } Renderer2D.drawFixedString(drawContext.getMatrices(), module.name, x + 3, textY, ColorManager.INSTANCE.defaultTextColor()); diff --git a/src/main/java/dev/heliosclient/util/ColorUtils.java b/src/main/java/dev/heliosclient/util/ColorUtils.java index eb78a8d5..90582b51 100644 --- a/src/main/java/dev/heliosclient/util/ColorUtils.java +++ b/src/main/java/dev/heliosclient/util/ColorUtils.java @@ -296,6 +296,14 @@ public static Color hexToColor(String hex) { Integer.valueOf(hex.substring(5, 7), 16) ); } + public static Color hexToColor(String hex, int alpha) { + return new Color( + Integer.valueOf(hex.substring(1, 3), 16), + Integer.valueOf(hex.substring(3, 5), 16), + Integer.valueOf(hex.substring(5, 7), 16), + alpha + ); + } public static Color blend(Color color1, Color color2, float fraction) { int r = (int) (color1.getRed() * (1 - fraction) + color2.getRed() * fraction); diff --git a/src/main/java/dev/heliosclient/util/blocks/BlockIterator.java b/src/main/java/dev/heliosclient/util/blocks/BlockIterator.java index 921d71cd..9fa4f4e3 100644 --- a/src/main/java/dev/heliosclient/util/blocks/BlockIterator.java +++ b/src/main/java/dev/heliosclient/util/blocks/BlockIterator.java @@ -13,6 +13,8 @@ public class BlockIterator implements Iterator { private final int verticalRadius; private int x, y, z; + BlockPos.Mutable mut = new BlockPos.Mutable(); + public BlockIterator(PlayerEntity player, int horizontalRadius, int verticalRadius) { this.player = player; this.world = player.getWorld(); @@ -30,24 +32,27 @@ public boolean hasNext() { @Override public BlockPos next() { - BlockPos nextPos = player.getBlockPos().add(x, y, z); - while (!world.isChunkLoaded(nextPos.getX() >> 4, nextPos.getZ() >> 4)) { - if (++x > horizontalRadius) { - x = -horizontalRadius; - if (++z > horizontalRadius) { - z = -horizontalRadius; - y++; + while (y <= world.getTopY() && y >= world.getBottomY()) { + mut.set(player.getBlockPos().add(x, y, z)); + if (world.isChunkLoaded(mut.getX() >> 4, mut.getZ() >> 4)) { + if (++x > horizontalRadius) { + x = -horizontalRadius; + if (++z > horizontalRadius) { + z = -horizontalRadius; + y++; + } + } + return mut.toImmutable(); + } else { + if (++x > horizontalRadius) { + x = -horizontalRadius; + if (++z > horizontalRadius) { + z = -horizontalRadius; + y++; + } } - } - nextPos = player.getBlockPos().add(x, y, z); - } - if (++x > horizontalRadius) { - x = -horizontalRadius; - if (++z > horizontalRadius) { - z = -horizontalRadius; - y++; } } - return nextPos; + return mut.toImmutable(); } } diff --git a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java index 73d7955f..35403f1f 100644 --- a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java +++ b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.world.World; @@ -16,9 +17,13 @@ public class HoleUtils { public static Set getHoles(int range, int vRange) { Set holes = Collections.synchronizedSet(new HashSet<>()); BlockIterator iterator = new BlockIterator(HeliosClient.MC.player, range, vRange); + Set checkedPositions = Collections.synchronizedSet(new HashSet<>()); + while (iterator.hasNext()) { BlockPos pos = iterator.next(); - HoleInfo hole = checkHole(HeliosClient.MC.world, pos); + if (checkedPositions.contains(pos)) continue; + + HoleInfo hole = getHoleType(HeliosClient.MC.world, pos, checkedPositions); if (hole != null) { holes.add(hole); } @@ -26,20 +31,16 @@ public static Set getHoles(int range, int vRange) { return holes; } - private static HoleInfo checkHole(World world, BlockPos pos) { - HoleType holeType = getHoleType(world, pos); - if (holeType != null) { - return new HoleInfo(holeType, pos); - } - return null; - } - - private static HoleType getHoleType(World world, BlockPos pos) { - if (!world.getBlockState(pos).isAir()) { + private static HoleInfo getHoleType(World world, BlockPos pos, Set checkedPositions) { + if (!world.getBlockState(pos).isAir() || !world.getBlockState(pos.up()).isAir() || checkedPositions.contains(pos)) { return null; } + checkedPositions.add(pos); + + HoleType hT = null; int obsidian = 0, bedrock = 0, air = 0; + BlockPos doubleStart = null; Block floorBlock = null; for (Direction dir : Direction.values()) { if (dir == Direction.UP) continue; @@ -50,63 +51,66 @@ private static HoleType getHoleType(World world, BlockPos pos) { floorBlock = block; continue; } - if (block == Blocks.OBSIDIAN) { + if (block == Blocks.OBSIDIAN || block == Blocks.CRYING_OBSIDIAN || block == Blocks.RESPAWN_ANCHOR || block == Blocks.ENDER_CHEST) { obsidian++; } else if (block == Blocks.BEDROCK) { bedrock++; } else if (block == Blocks.AIR) { - //Todo: fix int coveringBlocks = 0; - - /* for (Direction dir1: Direction.values()) { - if (dir1 == Direction.UP || dir.getOpposite() == dir1 || dir1 == Direction.DOWN) continue; + for (Direction dir1 : Direction.values()) { + if (dir1 == Direction.UP || dir.getOpposite() == dir1) continue; Block block1 = world.getBlockState(newPos.offset(dir1)).getBlock(); - if(block1 == Blocks.OBSIDIAN || block1 == Blocks.BEDROCK || block1 == Blocks.ENDER_CHEST){ - ++coveringBlocks; + if (block1 == Blocks.OBSIDIAN || block1 == Blocks.BEDROCK || block1 == Blocks.ENDER_CHEST || block1 == Blocks.CRYING_OBSIDIAN || block1 == Blocks.RESPAWN_ANCHOR) { + coveringBlocks++; } } - */ - - if (coveringBlocks > 2) { + if (4 - coveringBlocks == 0 && !checkedPositions.contains(newPos)) { + checkedPositions.add(newPos); air++; + doubleStart = newPos; } } } - if (bedrock >= 4 && floorBlock == Blocks.OBSIDIAN) { - return HoleType.UNSAFE; + if (bedrock >= 4 - air && floorBlock == Blocks.OBSIDIAN) { + hT = HoleType.UNSAFE; + } + if (obsidian == 0 && bedrock >= 4 - air && floorBlock == Blocks.BEDROCK) { + hT = HoleType.SAFE; } - if (obsidian == 0 && bedrock >= 4 && floorBlock == Blocks.BEDROCK) { - return HoleType.SAFE; + if (obsidian >= 4 - air && bedrock == 0 && (floorBlock == Blocks.OBSIDIAN || floorBlock == Blocks.BEDROCK)) { + hT = HoleType.DANGER; } - if (obsidian >= 4 && bedrock == 0 && (floorBlock == Blocks.OBSIDIAN || floorBlock == Blocks.BEDROCK)) { - return HoleType.DANGER; + if (obsidian > 0 && bedrock > 0 && (obsidian + bedrock) >= 4 - air && floorBlock != Blocks.AIR) { + hT = HoleType.UNSAFE; } - if (obsidian > 0 && bedrock > 0 && (obsidian + bedrock) >= 4 && floorBlock != Blocks.AIR) { - return HoleType.UNSAFE; + + if(air > 0 && hT != null){ + return new HoleInfo(hT,pos,new Box(pos).union(new Box(doubleStart)).contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0)); } - //Meaning the size of the hole is more than 1 - if (air <= 2 && air != 0 && obsidian + bedrock >= 2 && floorBlock != Blocks.AIR) { - return HoleType.SIZED; + + if(hT != null){ + return new HoleInfo(hT,pos,new Box(pos).contract(0.005f, 0f, 0.005f).offset(0, 0.005f, 0)); } + return null; } - public enum HoleType { - SAFE, UNSAFE, DANGER, SIZED + SAFE, UNSAFE, DANGER } public static class HoleInfo { public HoleType holeType; public BlockPos holePosition; + public Box holeBox; - public HoleInfo(HoleType holeType, BlockPos holePosition) { + public HoleInfo(HoleType holeType, BlockPos holePosition, Box holeBox) { this.holeType = holeType; this.holePosition = holePosition; + this.holeBox = holeBox; } } - } diff --git a/src/main/java/dev/heliosclient/util/EntityUtils.java b/src/main/java/dev/heliosclient/util/entity/EntityUtils.java similarity index 81% rename from src/main/java/dev/heliosclient/util/EntityUtils.java rename to src/main/java/dev/heliosclient/util/entity/EntityUtils.java index c0d61dde..998deb4a 100644 --- a/src/main/java/dev/heliosclient/util/EntityUtils.java +++ b/src/main/java/dev/heliosclient/util/entity/EntityUtils.java @@ -1,5 +1,6 @@ -package dev.heliosclient.util; +package dev.heliosclient.util.entity; +import dev.heliosclient.HeliosClient; import net.minecraft.block.BedBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -9,6 +10,7 @@ import net.minecraft.world.World; import java.util.Comparator; +import java.util.List; import java.util.function.Predicate; public class EntityUtils { @@ -41,6 +43,17 @@ public static Entity getNearestCrystal(World world, PlayerEntity player, double .orElse(null); } + public static List getAllOfType(float radius, EntityType... entities) { + return HeliosClient.MC.world.getOtherEntities(HeliosClient.MC.player, new Box(HeliosClient.MC.player.getBlockPos()).expand(radius), entity -> { + for (EntityType e : entities) { + if (e == entity.getType()) { + return true; + } + } + return false; + }); + } + public static BlockPos getNearestBed(World world, PlayerEntity player, int radius) { return BlockPos.streamOutwards(player.getBlockPos(), radius, radius, radius) .filter(pos -> world.getBlockState(pos).getBlock() instanceof BedBlock) diff --git a/src/main/java/dev/heliosclient/util/entity/TargetUtils.java b/src/main/java/dev/heliosclient/util/entity/TargetUtils.java index 6618a071..ecaa8ba9 100644 --- a/src/main/java/dev/heliosclient/util/entity/TargetUtils.java +++ b/src/main/java/dev/heliosclient/util/entity/TargetUtils.java @@ -1,6 +1,5 @@ package dev.heliosclient.util.entity; -import dev.heliosclient.util.EntityUtils; import dev.heliosclient.util.SortMethod; import dev.heliosclient.util.player.PlayerUtils; import net.minecraft.entity.Entity; diff --git a/src/main/java/dev/heliosclient/util/player/DamageUtils.java b/src/main/java/dev/heliosclient/util/player/DamageUtils.java index b1ebe1d5..54f0005e 100644 --- a/src/main/java/dev/heliosclient/util/player/DamageUtils.java +++ b/src/main/java/dev/heliosclient/util/player/DamageUtils.java @@ -4,11 +4,18 @@ import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.player.PlayerJoinEvent; import dev.heliosclient.event.listener.Listener; +import dev.heliosclient.managers.ModuleManager; +import dev.heliosclient.module.modules.movement.NoFall; import dev.heliosclient.system.mixininterface.IExplosion; +import dev.heliosclient.util.blocks.ChunkUtils; +import dev.heliosclient.util.entity.EntityUtils; +import net.minecraft.block.entity.BedBlockEntity; +import net.minecraft.block.entity.BlockEntity; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.DamageUtil; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; @@ -19,6 +26,7 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.tag.EntityTypeTags; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.dimension.DimensionTypes; import net.minecraft.world.explosion.Explosion; import net.minecraft.world.explosion.ExplosionBehavior; @@ -29,6 +37,9 @@ public class DamageUtils implements Listener { static ExplosionBehavior behavior = new ExplosionBehavior(); private static Explosion explosion; + //Explosion power + public static int BED_POWER = 5, CRYSTAL_POWER = 6; + public static double calculateBedBlastDamage(Vec3d bedLocation, LivingEntity target) { if (target instanceof PlayerEntity && ((PlayerEntity) target).getAbilities().creativeMode) return 0; assert HeliosClient.MC.world != null; @@ -161,6 +172,28 @@ public static float calculateSwordDamage(ItemStack sword, PlayerEntity attacker, return swordDamage; } + public static float calculateDamageByEnv(){ + float totalDamage = 0; + + for(Entity e: EntityUtils.getAllOfType(CRYSTAL_POWER + 2, EntityType.END_CRYSTAL)){ + double crystalDamage = calculateCrystalDamage(e.getPos(),HeliosClient.MC.player); + totalDamage = (float) Math.max(crystalDamage,totalDamage); + } + + if (!HeliosClient.MC.world.getDimensionEntry().matchesKey(DimensionTypes.OVERWORLD)) { + for(BlockEntity blockEntity : ChunkUtils.getBlockEntityStreamInChunks().filter(bE -> bE instanceof BedBlockEntity).toList()) { + float damage = (float) calculateBedBlastDamage(blockEntity.getPos().toCenterPos(),HeliosClient.MC.player); + totalDamage = Math.max(damage,totalDamage); + } + } + + if(!ModuleManager.get(NoFall.class).isActive()){ + totalDamage = Math.max(calcFallDamage(HeliosClient.MC.player),totalDamage); + } + + return totalDamage; + } + @SubscribeEvent public void onPlayerJoinEvent(PlayerJoinEvent event) { explosion = new Explosion(HeliosClient.MC.world, null, 0, 0, 0, 6, false, Explosion.DestructionType.DESTROY);