Skip to content

Commit

Permalink
add vulcan hop
Browse files Browse the repository at this point in the history
fix scaffold place tnt
fix invmanager do invalid swap
  • Loading branch information
xia-mc committed Jul 8, 2024
1 parent 4c8e232 commit 9ae6e72
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 39 deletions.
94 changes: 68 additions & 26 deletions src/main/java/keystrokesmod/module/impl/movement/Speed.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.ModeSetting;
import keystrokesmod.module.setting.impl.SliderSetting;
import keystrokesmod.module.setting.utils.ModeOnly;
import keystrokesmod.utility.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.state.IBlockState;
import net.minecraft.network.play.client.C0BPacketEntityAction;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.potion.Potion;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;
Expand All @@ -20,11 +24,12 @@

public class Speed extends Module {
private final ModeSetting mode;
private final SliderSetting vulcan$lowHop;
private final ButtonSetting liquidDisable;
private final ButtonSetting sneakDisable;
private final ButtonSetting stopMotion;
private final ButtonSetting stopSprint;
private final String[] modes = new String[]{"Ground", "BlocksMC"};
private final String[] modes = new String[]{"Ground", "BlocksMC", "Vulcan"};
private int offGroundTicks = 0;
public static int ticksSinceVelocity = Integer.MAX_VALUE;

Expand All @@ -43,6 +48,7 @@ public class Speed extends Module {
public Speed() {
super("Speed", Module.category.movement);
this.registerSetting(mode = new ModeSetting("Mode", modes, 0));
this.registerSetting(vulcan$lowHop = new SliderSetting("Low hop", 2, 0, 4, 1, "ticks", new ModeOnly(mode, 2)));
this.registerSetting(liquidDisable = new ButtonSetting("Disable in liquid", true));
this.registerSetting(sneakDisable = new ButtonSetting("Disable while sneaking", true));
this.registerSetting(stopMotion = new ButtonSetting("Stop motion", false));
Expand Down Expand Up @@ -130,41 +136,73 @@ private boolean noAction() {
public void onPlayerInput(PrePlayerInputEvent event) {
if (noAction()) return;

if ((int) mode.getInput() == 1) {
final double base = MoveUtil.getAllowedHorizontalDistance();
switch ((int) mode.getInput()) {
case 1:
final double base = MoveUtil.getAllowedHorizontalDistance();

if (!Utils.jumpDown() && Utils.isMoving() && mc.currentScreen == null) {
switch (offGroundTicks) {
case 0:
mc.thePlayer.motionY = MoveUtil.jumpBoostMotion(0.42f);
speed = base * 2.15;
break;

case 1:
speed -= 0.8 * (speed - base);
break;

default:
speed -= speed / MoveUtil.BUNNY_FRICTION;
break;
}

reset = false;
} else if (!reset) {
speed = 0;

reset = true;
speed = MoveUtil.getAllowedHorizontalDistance();
}

if (!Utils.jumpDown() && Utils.isMoving() && mc.currentScreen == null) {
if (mc.thePlayer.isCollidedHorizontally || BlockUtils.getSurroundBlocks(mc.thePlayer).stream()
.map(BlockUtils::getBlockState)
.map(IBlockState::getBlock)
.allMatch(Block::isFullCube)) {
speed = MoveUtil.getAllowedHorizontalDistance();
}

event.setSpeed(Math.max(speed, base), Math.random() / 2000);
break;
case 2:
if (!MoveUtil.isMoving()) break;
switch (offGroundTicks) {
case 0:
mc.thePlayer.motionY = MoveUtil.jumpBoostMotion(0.42f);
speed = base * 2.15;
mc.thePlayer.jump();

if (mc.thePlayer.isPotionActive(Potion.moveSpeed)) {
MoveUtil.strafe(0.6);
} else {
MoveUtil.strafe(0.485);
}
break;

case 9:
if (!(blockRelativeToPlayer(0, mc.thePlayer.motionY,
0) instanceof BlockAir)) {
MoveUtil.strafe();
}
break;

case 2:
case 1:
speed -= 0.8 * (speed - base);
MoveUtil.strafe();
break;

default:
speed -= speed / MoveUtil.BUNNY_FRICTION;
case 5:
mc.thePlayer.motionY = MoveUtil.predictedMotion(mc.thePlayer.motionY, (int) vulcan$lowHop.getInput());
break;
}

reset = false;
} else if (!reset) {
speed = 0;

reset = true;
speed = MoveUtil.getAllowedHorizontalDistance();
}

if (mc.thePlayer.isCollidedHorizontally || BlockUtils.getSurroundBlocks(mc.thePlayer).stream()
.map(BlockUtils::getBlockState)
.map(IBlockState::getBlock)
.allMatch(Block::isFullCube)) {
speed = MoveUtil.getAllowedHorizontalDistance();
}

event.setSpeed(Math.max(speed, base), Math.random() / 2000);
break;
}
}

Expand All @@ -175,6 +213,10 @@ public void onReceivePacket(@NotNull ReceivePacketEvent event) {
}
}

public Block blockRelativeToPlayer(final double offsetX, final double offsetY, final double offsetZ) {
return mc.theWorld.getBlockState(new BlockPos(mc.thePlayer).add(offsetX, offsetY, offsetZ)).getBlock();
}

private boolean isYAxisChange() {
MovingObjectPosition hitResult = RotationUtils.rayCast(3, 0, 90);
return hitResult == null || hitResult.getBlockPos().getY() != groundYPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void sort(int from, int to) {
result.add(() -> sort(ContainerUtils.getMostBlocks((int) blockSlot.getInput()), (int) blockSlot.getInput()));
result.add(() -> sort(ContainerUtils.getBiggestStack(Items.ender_pearl, (int) enderPearlSlot.getInput()), (int) enderPearlSlot.getInput()));
result.add(() -> sort(ContainerUtils.getBestBow(null), (int) bowSlot.getInput()));
result.add(() -> sort(ContainerUtils.getBestFood(), (int) foodSlot.getInput()));
result.add(() -> sort(ContainerUtils.getBestFood((int) foodSlot.getInput()), (int) foodSlot.getInput()));
result.add(() -> sort(ContainerUtils.getMostProjectiles((int) throwableSlot.getInput()), (int) throwableSlot.getInput()));

return result;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/keystrokesmod/module/impl/render/Nametags.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.opengl.GL11;

import java.awt.*;
Expand Down Expand Up @@ -58,7 +59,7 @@ public Nametags() {
}

@SubscribeEvent
public void onRenderLiving(RenderLivingEvent.Specials.Pre e) {
public void onRenderLiving(RenderLivingEvent.Specials.@NotNull Pre e) {
if (e.entity instanceof EntityPlayer && (e.entity != mc.thePlayer || renderSelf.isToggled()) && e.entity.deathTime == 0) {
final EntityPlayer entityPlayer = (EntityPlayer) e.entity;
if (!showInvis.isToggled() && entityPlayer.isInvisible()) {
Expand Down
30 changes: 19 additions & 11 deletions src/main/java/keystrokesmod/utility/ContainerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public class ContainerUtils {
public static final List<Integer> ARMOR_TYPES = new ArrayList<>(Arrays.asList(0, 1, 2, 3));
public static final Set<Item> THROWABLES = new HashSet<>(Arrays.asList(Items.snowball, Items.egg));

public static boolean canBePlaced(ItemBlock itemBlock) {
Block block = itemBlock.getBlock();
if (block == null) {
return false;
}
return !BlockUtils.isInteractable(block) && !(block instanceof BlockTNT) && !(block instanceof BlockLever) && !(block instanceof BlockButton) && !(block instanceof BlockSkull) && !(block instanceof BlockLiquid) && !(block instanceof BlockCactus) && !(block instanceof BlockCarpet) && !(block instanceof BlockTripWire) && !(block instanceof BlockTripWireHook) && !(block instanceof BlockTallGrass) && !(block instanceof BlockFlower) && !(block instanceof BlockFlowerPot) && !(block instanceof BlockSign) && !(block instanceof BlockLadder) && !(block instanceof BlockTorch) && !(block instanceof BlockRedstoneTorch) && !(block instanceof BlockFence) && !(block instanceof BlockPane) && !(block instanceof BlockStainedGlassPane) && !(block instanceof BlockGravel) && !(block instanceof BlockClay) && !(block instanceof BlockSand) && !(block instanceof BlockSoulSand);
}

public static <T extends Item> int getSlot(Class<T> item, Predicate<T> predicate) {
int slot = -1;
int highestStack = -1;
Expand Down Expand Up @@ -342,10 +350,18 @@ public static boolean canDrop(@NotNull ItemStack itemStack, int slot, @Nullable
return false;
}

public static int getBestFood() {
public static int getBestFood(int desiredSlot) {
float foodLevel = 0;
int slot = -1;

if (desiredSlot != -1) {
final ItemStack stack = getItemStack(desiredSlot);
if (stack != null && stack.getItem() instanceof ItemFood) {
foodLevel = ((ItemFood) stack.getItem()).getSaturationModifier(stack);
slot = desiredSlot;
}
}

for (int i = 9; i < 45; i++) {
final ItemStack stack = getItemStack(i);
if (stack != null && stack.getItem() instanceof ItemFood) {
Expand All @@ -367,14 +383,6 @@ public static ItemStack getItemStack(int i) {
return slot.getStack();
}

public static boolean canBePlaced(ItemBlock itemBlock) {
Block block = itemBlock.getBlock();
if (block == null) {
return false;
}
return !BlockUtils.isInteractable(block) && !(block instanceof BlockLever) && !(block instanceof BlockButton) && !(block instanceof BlockSkull) && !(block instanceof BlockLiquid) && !(block instanceof BlockCactus) && !(block instanceof BlockCarpet) && !(block instanceof BlockTripWire) && !(block instanceof BlockTripWireHook) && !(block instanceof BlockTallGrass) && !(block instanceof BlockFlower) && !(block instanceof BlockFlowerPot) && !(block instanceof BlockSign) && !(block instanceof BlockLadder) && !(block instanceof BlockTorch) && !(block instanceof BlockRedstoneTorch) && !(block instanceof BlockFence) && !(block instanceof BlockPane) && !(block instanceof BlockStainedGlassPane) && !(block instanceof BlockGravel) && !(block instanceof BlockClay) && !(block instanceof BlockSand) && !(block instanceof BlockSoulSand);
}

public static boolean isChest(boolean customChest) {
if (mc.thePlayer.openContainer instanceof ContainerChest) {
final String name = ((ContainerChest) mc.thePlayer.openContainer).getLowerChestInventory().getName();
Expand Down Expand Up @@ -458,15 +466,15 @@ public static int getMostBlocks(int desiredSlot) {

if (desiredSlot != -1) {
ItemStack item = getItemStack(desiredSlot);
if (item != null && item.getItem() instanceof ItemBlock && item.stackSize > count && canBePlaced((ItemBlock) item.getItem())) {
if (item != null && item.getItem() instanceof ItemBlock && canBePlaced((ItemBlock) item.getItem())) {
count = item.stackSize;
biggestSlot = desiredSlot;
}
}

for (int i = 9; i < 45; i++) {
ItemStack item = getItemStack(i);
if (item != null && item.getItem() instanceof ItemBlock && item.stackSize > count + 1 && canBePlaced((ItemBlock) item.getItem())) {
if (item != null && item.getItem() instanceof ItemBlock && item.stackSize > count && canBePlaced((ItemBlock) item.getItem())) {
count = item.stackSize;
biggestSlot = i;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/keystrokesmod/utility/MoveUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import keystrokesmod.mixins.impl.entity.EntityAccessor;
import keystrokesmod.module.impl.movement.TargetStrafe;
import keystrokesmod.module.impl.other.anticheats.utils.world.PlayerMove;
import keystrokesmod.script.classes.Entity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.potion.Potion;
Expand Down Expand Up @@ -246,4 +247,13 @@ public static double jumpBoostMotion(final double motionY) {

return motionY;
}

/**
* Gets the players predicted jump motion the specified amount of ticks ahead
*
* @return predicted jump motion
*/
public static double predictedMotion(final double motion, final int ticks) {
return PlayerMove.predictedMotion(motion, ticks);
}
}

0 comments on commit 9ae6e72

Please sign in to comment.