Skip to content

Commit

Permalink
Release 10.1
Browse files Browse the repository at this point in the history
fixes & improvements
- fixed breakprogress in third person
- improved bedesp & xray range while maintaining performance
- improved scripting api to support newer scripts
  • Loading branch information
Strangerrrs committed Nov 30, 2024
1 parent 55c4736 commit 83830ee
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/main/java/keystrokesmod/module/impl/player/Tower.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void reset() {
offGroundTicks = 0;
}

private boolean canTower() {
public boolean canTower() {
if (!Utils.nullCheck() || !Utils.jumpDown()) {
return false;
}
Expand Down
48 changes: 26 additions & 22 deletions src/main/java/keystrokesmod/module/impl/render/BedESP.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package keystrokesmod.module.impl.render;

import keystrokesmod.Raven;
import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
Expand All @@ -19,9 +20,9 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class BedESP extends Module {
public SliderSetting theme;
Expand All @@ -30,13 +31,13 @@ public class BedESP extends Module {
private ButtonSetting firstBed;
private ButtonSetting renderFullBlock;
private BlockPos[] bed = null;
private List<BlockPos[]> beds = new ArrayList<>();
private Set<BlockPos[]> beds = ConcurrentHashMap.newKeySet();
private long lastCheck = 0;

public BedESP() {
super("BedESP", category.render);
this.registerSetting(theme = new SliderSetting("Theme", 0, Theme.themes));
this.registerSetting(range = new SliderSetting("Range", 10.0, 2.0, 30.0, 2.0));
this.registerSetting(range = new SliderSetting("Range", 10.0, 2.0, 200.0, 2.0));
this.registerSetting(rate = new SliderSetting("Rate", " second", 0.4, 0.1, 3.0, 0.1));
this.registerSetting(firstBed = new ButtonSetting("Only render first bed", false));
this.registerSetting(renderFullBlock = new ButtonSetting("Render full block", false));
Expand All @@ -47,32 +48,35 @@ public void onUpdate() {
return;
}
lastCheck = System.currentTimeMillis();
int i;
priorityLoop:
for (int n = i = (int) range.getInput(); i >= -n; --i) {
for (int j = -n; j <= n; ++j) {
for (int k = -n; k <= n; ++k) {
final BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k);
final IBlockState getBlockState = mc.theWorld.getBlockState(blockPos);
if (getBlockState.getBlock() == Blocks.bed && getBlockState.getValue((IProperty) BlockBed.PART) == BlockBed.EnumPartType.FOOT) {
if (firstBed.isToggled()) {
if (this.bed != null && BlockUtils.isSamePos(blockPos, this.bed[0])) {
Raven.getExecutor().execute(() -> {
int i;
priorityLoop:
for (int n = i = (int) range.getInput(); i >= -n; --i) {
for (int j = -n; j <= n; ++j) {
for (int k = -n; k <= n; ++k) {
final BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k);
final IBlockState getBlockState = mc.theWorld.getBlockState(blockPos);
if (getBlockState.getBlock() == Blocks.bed && getBlockState.getValue((IProperty) BlockBed.PART) == BlockBed.EnumPartType.FOOT) {
if (firstBed.isToggled()) {
if (this.bed != null && BlockUtils.isSamePos(blockPos, this.bed[0])) {
return;
}
this.bed = new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))};
return;
}
this.bed = new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))};
return;
} else {
for (int l = 0; l < this.beds.size(); ++l) {
if (BlockUtils.isSamePos(blockPos, ((BlockPos[]) this.beds.get(l))[0])) {
continue priorityLoop;
else {
for (BlockPos[] pos : beds) {
if (BlockUtils.isSamePos(blockPos, pos[0])) {
continue priorityLoop;
}
}
this.beds.add(new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))});
}
this.beds.add(new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))});
}
}
}
}
}
});
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void onRenderWorld(RenderWorldLastEvent e) {
GlStateManager.pushMatrix();
GlStateManager.translate((float) n, (float) n2, (float) n3);
GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0.0f, 1.0f, 0.0f);
GlStateManager.rotate(mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f);
GlStateManager.rotate((mc.gameSettings.thirdPersonView == 2 ? -1 : 1) * mc.getRenderManager().playerViewX, 1.0f, 0.0f, 0.0f);
GlStateManager.scale(-0.02266667f, -0.02266667f, -0.02266667f);
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
Expand Down
75 changes: 44 additions & 31 deletions src/main/java/keystrokesmod/module/impl/render/Xray.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package keystrokesmod.module.impl.render;

import keystrokesmod.Raven;
import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
Expand All @@ -14,9 +15,9 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class Xray extends Module {
private SliderSetting range;
Expand All @@ -30,7 +31,7 @@ public class Xray extends Module {
private ButtonSetting coal;
private ButtonSetting spawner;
private ButtonSetting obsidian;
private List<BlockPos> blocks = new ArrayList<>();
private Set<BlockPos> blocks = ConcurrentHashMap.newKeySet();
private long lastCheck = 0;

public Xray() {
Expand All @@ -57,21 +58,25 @@ public void onUpdate() {
return;
}
lastCheck = System.currentTimeMillis();
int i;
for (int n = i = (int) range.getInput(); i >= -n; --i) {
for (int j = -n; j <= n; ++j) {
for (int k = -n; k <= n; ++k) {
BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k);
if (blocks.contains(blockPos)) {
continue;
}
Block blockState = BlockUtils.getBlock(blockPos);
if (blockState != null && canBreak(blockState)) {
blocks.add(blockPos);
Raven.getExecutor().execute(() -> {
synchronized (blocks) {
int i;
for (int n = i = (int) range.getInput(); i >= -n; --i) {
for (int j = -n; j <= n; ++j) {
for (int k = -n; k <= n; ++k) {
BlockPos blockPos = new BlockPos(mc.thePlayer.posX + j, mc.thePlayer.posY + i, mc.thePlayer.posZ + k);
if (blocks.contains(blockPos)) {
continue;
}
Block blockState = BlockUtils.getBlock(blockPos);
if (blockState != null && canBreak(blockState)) {
blocks.add(blockPos);
}
}
}
}
}
}
});
}

@SubscribeEvent
Expand All @@ -86,16 +91,18 @@ public void onRenderWorld(RenderWorldLastEvent ev) {
if (!Utils.nullCheck()) {
return;
}
if (!this.blocks.isEmpty()) {
Iterator iterator = blocks.iterator();
while (iterator.hasNext()) {
BlockPos blockPos = (BlockPos) iterator.next();
Block block = BlockUtils.getBlock(blockPos);
if (block == null || !canBreak(block)) {
iterator.remove();
continue;
synchronized (blocks) {
if (!this.blocks.isEmpty()) {
Iterator<BlockPos> iterator = blocks.iterator();
while (iterator.hasNext()) {
BlockPos blockPos = iterator.next();
Block block = BlockUtils.getBlock(blockPos);
if (block == null || !canBreak(block)) {
iterator.remove();
continue;
}
this.drawBox(blockPos);
}
this.drawBox(blockPos);
}
}
}
Expand All @@ -118,21 +125,27 @@ private int[] getColor(Block b) {
red = 255;
green = 255;
blue = 255;
} else if (b.equals(Blocks.gold_ore)) {
}
else if (b.equals(Blocks.gold_ore)) {
red = 255;
green = 255;
} else if (b.equals(Blocks.diamond_ore)) {
}
else if (b.equals(Blocks.diamond_ore)) {
green = 220;
blue = 255;
} else if (b.equals(Blocks.emerald_ore)) {
}
else if (b.equals(Blocks.emerald_ore)) {
red = 35;
green = 255;
} else if (b.equals(Blocks.lapis_ore)) {
}
else if (b.equals(Blocks.lapis_ore)) {
green = 50;
blue = 255;
} else if (b.equals(Blocks.redstone_ore)) {
}
else if (b.equals(Blocks.redstone_ore)) {
red = 255;
} else if (b.equals(Blocks.mob_spawner)) {
}
else if (b.equals(Blocks.mob_spawner)) {
red = 30;
blue = 135;
}
Expand All @@ -151,4 +164,4 @@ public boolean canBreak(Block block) {
(spawner.isToggled() && block.equals(Blocks.mob_spawner)) ||
(obsidian.isToggled() && block.equals(Blocks.obsidian));
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/keystrokesmod/script/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class Manager extends Module {
private long lastLoad;
public final String documentationURL = "https://blowsy.gitbook.io/raven";

public Manager() {
super("Manager", category.scripts);
this.registerSetting(new ButtonSetting("Load scripts", () -> {
Expand All @@ -30,7 +31,8 @@ public Manager() {
Utils.sendMessage("&7No scripts found.");
}
else {
Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "." : "s."));
double timeTaken = Utils.round((System.currentTimeMillis() - currentTimeMillis) / 1000.0, 1);
Utils.sendMessage("&7Loaded &b" + Raven.scriptManager.scripts.size() + " &7script" + ((Raven.scriptManager.scripts.size() == 1) ? "" : "s") + " in &b" + (Utils.isWholeNumber(timeTaken) ? (int) timeTaken + "" : timeTaken) + "&7s.");
}
Entity.clearCache();
if (Raven.currentProfile != null && Raven.currentProfile.getModule() != null) {
Expand Down
34 changes: 30 additions & 4 deletions src/main/java/keystrokesmod/script/ScriptDefaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import keystrokesmod.script.packets.serverbound.PacketHandler;
import keystrokesmod.utility.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.*;
Expand Down Expand Up @@ -54,6 +53,17 @@ public static boolean allowFlying() {
return mc.thePlayer.capabilities.allowFlying;
}

public static void removePotionEffect(int id) {
if (mc.thePlayer == null) {
return;
}
mc.thePlayer.removePotionEffectClient(id);
}

public static int getUID() {
return 8;
}

public static void addEnemy(String username) {
Utils.addEnemy(username);
}
Expand Down Expand Up @@ -83,6 +93,10 @@ public static void print(Object object) {
Utils.sendRawMessage(s);
}

public static boolean isDiagonal() {
return Utils.isDiagonal(false);
}

public static boolean isHoldingWeapon() {
return Utils.holdingWeapon();
}
Expand Down Expand Up @@ -135,6 +149,10 @@ public static long getFreeMemory() {
return Runtime.getRuntime().freeMemory();
}

public static long getMaxMemory() {
return Runtime.getRuntime().maxMemory();
}

public static void jump() {
mc.thePlayer.jump();
}
Expand Down Expand Up @@ -286,7 +304,7 @@ public static String getServerIP() {

public static int[] getDisplaySize() {
final ScaledResolution scaledResolution = new ScaledResolution(mc);
return new int[]{scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()};
return new int[]{scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaleFactor()};
}

public static boolean placeBlock(Vec3 targetPos, String side, Vec3 hitVec) {
Expand Down Expand Up @@ -414,6 +432,14 @@ public Vec3 getBedAuraPosition() {
return new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ());
}

public boolean isScaffolding() {
return ModuleManager.scaffold.isEnabled() && ModuleManager.scaffold.tower.isToggled();
}

public boolean isTowering() {
return ModuleManager.tower.canTower();
}

public boolean isHidden(String moduleName) {
Module module = getModule(moduleName);
if (module != null) {
Expand Down Expand Up @@ -719,8 +745,8 @@ public static void player(Entity entity, int color, float partialTicks, boolean
}
}

public static void rect(int startX, int startY, int endX, int endY, int color) {
Gui.drawRect(startX, startY, endX, endY, color);
public static void rect(float startX, float startY, float endX, float endY, int color) {
RenderUtils.drawRectangleGL(startX, startY, endX, endY, color);
}

public static void line2D(double startX, double startY, double endX, double endY, float lineWidth, int color) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/keystrokesmod/script/classes/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public List<Object[]> getPotionEffects() {
return potionEffects;
}
for (PotionEffect potionEffect : ((EntityLivingBase) entity).getActivePotionEffects()) {
Object[] potionData = new Object[]{potionEffect.getEffectName(), potionEffect.getAmplifier(), potionEffect.getDuration()};
Object[] potionData = new Object[]{potionEffect.getPotionID(), potionEffect.getEffectName(), potionEffect.getAmplifier(), potionEffect.getDuration()};
potionEffects.add(potionData);
}
return potionEffects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

public class S27 extends SPacket {
public float strength;
public Vec3 pos;
public Vec3 position;
public Vec3 motion;

public S27(S27PacketExplosion packet) {
super(packet);
this.strength = packet.getStrength();
this.pos = new Vec3(packet.getX(), packet.getY(), packet.getZ());
this.position = new Vec3(packet.getX(), packet.getY(), packet.getZ());
this.motion = new Vec3(packet.func_149149_c(), packet.func_149144_d(), packet.func_149147_e());
}
}
Loading

0 comments on commit 83830ee

Please sign in to comment.