Skip to content

Commit

Permalink
2.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Jul 14, 2023
1 parent f586b95 commit 864a0e1
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 91 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
}

//DynamicHUD
modImplementation 'com.github.V-Fast:DynamicHUD:v1.1.0'
modImplementation 'com.github.V-Fast:DynamicHUD:1.1.3'


// Mod Menu
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.1
loader_version=0.14.21

# Mod Properties
mod_version = 2.5.0
mod_version = 2.5.1
maven_group = net.smphack
archives_base_name = smp-hack

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class AutoSprint extends MainGui {
@Override
public void update() {
AutoSprint= GeneralConfig.getConfig().getAutoSprint();
assert mc.player != null;
Entity e = mc.player.getRootVehicle();
e.setSprinting(AutoSprint);
if (mc.player!=null && !mc.player.getRootVehicle().isSprinting()) {
Entity e = mc.player.getRootVehicle();
boolean alreadySprinting=e.isSprinting();
e.setSprinting(AutoSprint || alreadySprinting);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import net.fabricmc.smphack.MainGui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.decoration.EndCrystalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
Expand All @@ -24,8 +27,11 @@ public class EndCrystalBreaker extends MainGui {
private static int ASdamage;
private boolean isBreaking = false;
private int CrystalDelay;
private boolean SmartCrystal;
private final Object lock = new Object();

// Added variables for SmartCrystal mode
private double smartCrystalRange;
private double smartCrystalDamageThreshold = 5.0;

@Override
public void toggled() {
Expand All @@ -41,9 +47,9 @@ public void toggled() {
}
private void startBreaking() {
isBreaking = true;
CrystalDelay = GeneralConfig.getConfig().getCrystalBreakDelay_in_seconds();
Thread t = new Thread(() -> {
while (isBreaking) {
CrystalDelay = GeneralConfig.getConfig().getCrystalBreakDelay_in_seconds();
long startTime = System.currentTimeMillis();
breakNextCrystal();
long endTime = System.currentTimeMillis();
Expand Down Expand Up @@ -73,6 +79,9 @@ private void breakNextCrystal() {

AntiSuicide = GeneralConfig.getConfig().getAntiSuicide();
OnlyOwn = GeneralConfig.getConfig().getOnlyOwn();
SmartCrystal=GeneralConfig.getConfig().getSmartCrystal();
smartCrystalDamageThreshold=GeneralConfig.getConfig().getSmartCrystalDamageThreshold();
distance = GeneralConfig.getConfig().getRange() + 0.5;

x = player.getX();
y = player.getY();
Expand All @@ -83,24 +92,32 @@ private void breakNextCrystal() {
synchronized (lock) {
crystals = mc.world.getEntitiesByType(EntityType.END_CRYSTAL, searchBox, entity -> true);
}
distance = GeneralConfig.getConfig().getRange() + 0.5;

// Group multiple crystals together
Queue<EndCrystalEntity> crystalsToBreak = new ConcurrentLinkedQueue<>();
for (EndCrystalEntity crystal : crystals) {
try {
if (EndCrystalDamage(player, crystal)) {
return;
} else {
crystalsToBreak.add(crystal);
if (SmartCrystal) {
for (EndCrystalEntity crystal : crystals) {
try {
if (shouldBreakSmartCrystal(player, crystal)) {
crystalsToBreak.add(crystal);
}
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
}
} else {
for (EndCrystalEntity crystal : crystals) {
try {
if (EndCrystalDamage(player, crystal)) {
return;
} else {
crystalsToBreak.add(crystal);
}
} catch (ConcurrentModificationException e) {
e.printStackTrace();
}
} catch (ConcurrentModificationException e) {
// Handle the ConcurrentModificationException
// For example, log the error and continue with the next iteration of the loop
e.printStackTrace();
}
}

// Break all crystals in a single batch
for (EndCrystalEntity crystal : crystalsToBreak) {
player.swingHand(Hand.MAIN_HAND);
Expand All @@ -110,6 +127,24 @@ private void breakNextCrystal() {
}
}

// Added method for SmartCrystal mode
private boolean shouldBreakSmartCrystal(PlayerEntity player, EndCrystalEntity crystal) {
smartCrystalRange=10f;
Box searchBox = new Box(crystal.getX() - smartCrystalRange, crystal.getY() - smartCrystalRange, crystal.getZ() - smartCrystalRange, crystal.getX() + smartCrystalRange, crystal.getY() + smartCrystalRange, crystal.getZ() + smartCrystalRange);
assert MinecraftClient.getInstance().world != null;
List<Entity> entities = MinecraftClient.getInstance().world.getOtherEntities(player, searchBox);
for (Entity entity : entities) {
if (!(entity instanceof EndCrystalEntity) && !(entity instanceof ItemEntity)&& !(entity instanceof ExperienceOrbEntity)) {
double distance = Math.sqrt(entity.distanceTo(crystal));
double damage = 6 * (1.01 - (distance / 5.5));
System.out.println("Damage: " + damage);
if (damage > smartCrystalDamageThreshold) {
return true;
}
}
}
return false;
}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.fabricmc.smphack.Hacks.CrystalAura;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;

public class RenderUtils {
public static void drawBox(BlockPos blockPos, float r, float g, float b) {
RenderSystem.lineWidth(5);
WorldRenderer.drawBox(new MatrixStack(),
MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers().getBuffer(RenderLayer.getLines()),
blockPos.getX(), blockPos.getY(), blockPos.getZ(),
blockPos.getX() + 1, blockPos.getY() + 1, blockPos.getZ() + 1,
r, g, b, 1f
);
}
}
13 changes: 12 additions & 1 deletion src/main/java/net/fabricmc/smphack/config/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ public Screen openconfigscreen() {
.setDefaultValue(1)
.setSaveConsumer(newValue -> GeneralConfig.getConfig().setCrystalBreakDelay_in_seconds(newValue))
.build());
Combat.addEntry(entryBuilder.startBooleanToggle(Text.of("SmartCrystal"), GeneralConfig.getConfig().getSmartCrystal())
.setDefaultValue(false)
.setSaveConsumer(newValue -> GeneralConfig.getConfig().setSmartCrystal(newValue))
.setTooltip(Text.of("Smartly breaks crystal based on nearby entities and damage threshold"))
.build());
Combat.addEntry(entryBuilder.startFloatField(Text.of("SmartCrystal"), (float) GeneralConfig.getConfig().getSmartCrystalDamageThreshold())
.setDefaultValue(5f)
.setSaveConsumer(newValue -> GeneralConfig.getConfig().setSmartCrystalDamageThreshold(newValue))
.setTooltip(Text.of("Min Damage Threshold so the crystal would break"))
.build());

Combat.addEntry(entryBuilder.startBooleanToggle(Text.of("AntiSuicide"), GeneralConfig.getConfig().getAntiSuicide())
.setDefaultValue(false)
.setSaveConsumer(newValue -> GeneralConfig.getConfig().setAntiSuicide(newValue))
.build());
Combat.addEntry(entryBuilder.startIntSlider(Text.of("Min Damage to player for antisuicide"), GeneralConfig.getConfig().getASdamage(), 1, 32)
Combat.addEntry(entryBuilder.startIntSlider(Text.of("Min Damage to Player"), GeneralConfig.getConfig().getASdamage(), 1, 32)
.setDefaultValue(10)
.setSaveConsumer(newValue -> GeneralConfig.getConfig().setASdamage(newValue))
.build());
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/net/fabricmc/smphack/config/ControllersConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public enum MouseKeybind
private int speedforjesus = 1;
private int DelayAC = 0;
private int AntiSuicideDamage=10;
private double SmartCrystalDamageThreshold=5;


public boolean Antikick = true;
public boolean Fullbright = true;
Expand All @@ -112,6 +114,7 @@ public enum MouseKeybind
private boolean OnlyOwn=false;
private boolean AutoTool=false;
private boolean CustomBG=true;
private boolean SmartCrystal=false;

private int playernametagcolour = 0xFF;

Expand Down Expand Up @@ -173,6 +176,20 @@ public boolean getAutoTool() {
public void setAutoTool(boolean Autotool) {
this.AutoTool = Autotool;
}
public double getSmartCrystalDamageThreshold() {
return SmartCrystalDamageThreshold;
}

public void setSmartCrystalDamageThreshold(double damageThreshold) {
this.SmartCrystalDamageThreshold = damageThreshold;
}
public boolean getSmartCrystal() {
return SmartCrystal;
}

public void setSmartCrystal(boolean SmartCrystal) {
this.SmartCrystal = SmartCrystal;
}

public boolean getShowMuppet() {
return showMuppet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.tanishisherewith.dynamichud.helpers.ColorHelper;
import com.tanishisherewith.dynamichud.helpers.TextureHelper;
import com.tanishisherewith.dynamichud.util.TextGenerator;
import com.tanishisherewith.dynamichud.interfaces.TextGenerator;
import com.tanishisherewith.dynamichud.widget.armor.ArmorWidget;
import net.fabricmc.smphack.config.ConfigUtil;
import net.minecraft.client.MinecraftClient;
Expand All @@ -27,8 +27,8 @@ public class ArmorWidgetExtension extends ArmorWidget {
* @param textGenerator
* @param color
*/
public ArmorWidgetExtension(MinecraftClient client, EquipmentSlot slot, float xPercent, float yPercent, boolean enabled, TextureHelper.Position currentTextPosition, TextGenerator textGenerator, Supplier<Color> color) {
super(client, slot, xPercent, yPercent, enabled, currentTextPosition, textGenerator, color);
public ArmorWidgetExtension(MinecraftClient client, EquipmentSlot slot, float xPercent, float yPercent, boolean enabled, TextureHelper.Position currentTextPosition, TextGenerator textGenerator, Supplier<Color> color, boolean TextBackground,String label) {
super(client, slot, xPercent, yPercent, enabled, currentTextPosition, textGenerator, color,TextBackground,label);
}
private static final int COLOR_GREEN = 0x00FF00;
private static final int COLOR_YELLOW = 0xFFFF00;
Expand Down
Loading

0 comments on commit 864a0e1

Please sign in to comment.