|
| 1 | +package com.mentalfrostbyte.jello.module.impl.movement.blockfly; |
| 2 | + |
| 3 | +import com.mentalfrostbyte.Client; |
| 4 | +import com.mentalfrostbyte.jello.event.impl.game.network.EventReceivePacket; |
| 5 | +import com.mentalfrostbyte.jello.event.impl.game.network.EventSendPacket; |
| 6 | +import com.mentalfrostbyte.jello.event.impl.player.EventGetFovModifier; |
| 7 | +import com.mentalfrostbyte.jello.event.impl.player.movement.EventJump; |
| 8 | +import com.mentalfrostbyte.jello.event.impl.player.movement.EventMove; |
| 9 | +import com.mentalfrostbyte.jello.event.impl.player.movement.EventSafeWalk; |
| 10 | +import com.mentalfrostbyte.jello.event.impl.player.movement.EventMotion; |
| 11 | +import com.mentalfrostbyte.jello.module.Module; |
| 12 | +import com.mentalfrostbyte.jello.module.data.ModuleCategory; |
| 13 | +import com.mentalfrostbyte.jello.module.impl.movement.BlockFly; |
| 14 | +import com.mentalfrostbyte.jello.module.impl.movement.SafeWalk; |
| 15 | +import com.mentalfrostbyte.jello.module.impl.movement.speed.AACSpeed; |
| 16 | +import com.mentalfrostbyte.jello.module.settings.impl.BooleanSetting; |
| 17 | +import com.mentalfrostbyte.jello.util.game.player.InvManagerUtil; |
| 18 | +import com.mentalfrostbyte.jello.util.game.player.MovementUtil; |
| 19 | +import com.mentalfrostbyte.jello.util.game.world.PositionFacing; |
| 20 | +import com.mentalfrostbyte.jello.util.game.world.blocks.BlockUtil; |
| 21 | +import net.minecraft.block.Block; |
| 22 | +import net.minecraft.block.Blocks; |
| 23 | +import net.minecraft.network.play.client.CAnimateHandPacket; |
| 24 | +import net.minecraft.network.play.client.CHeldItemChangePacket; |
| 25 | +import net.minecraft.network.play.server.SPlayerPositionLookPacket; |
| 26 | +import net.minecraft.util.ActionResultType; |
| 27 | +import net.minecraft.util.Direction; |
| 28 | +import net.minecraft.util.Hand; |
| 29 | +import net.minecraft.util.math.BlockPos; |
| 30 | +import net.minecraft.util.math.BlockRayTraceResult; |
| 31 | +import net.minecraft.util.math.RayTraceResult; |
| 32 | +import team.sdhq.eventBus.annotations.EventTarget; |
| 33 | +import team.sdhq.eventBus.annotations.priority.LowerPriority; |
| 34 | +import team.sdhq.eventBus.annotations.priority.LowestPriority; |
| 35 | + |
| 36 | +import java.util.List; |
| 37 | + |
| 38 | +public class BlockFlyAACMode extends Module { |
| 39 | + private float yaw; |
| 40 | + private float pitch; |
| 41 | + private int placeY = 0; |
| 42 | + private int previousSlot = 0; |
| 43 | + private int field23524; |
| 44 | + /** IDK, it's set to 0 when you get setback though. Speed value? **/ |
| 45 | + private int speedValue; |
| 46 | + private double field23526; |
| 47 | + |
| 48 | + public BlockFlyAACMode() { |
| 49 | + super(ModuleCategory.MOVEMENT, "AAC", "Places block underneath if it is in hand"); |
| 50 | + this.registerSetting(new BooleanSetting("Haphe (AACAP)", "Never let's you touch the ground.", false)); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public void onEnable() { |
| 55 | + this.previousSlot = mc.player.inventory.currentItem; |
| 56 | + this.yaw = mc.player.rotationYaw; |
| 57 | + this.pitch = mc.player.rotationPitch; |
| 58 | + this.placeY = (int) mc.player.getPosY(); |
| 59 | + this.speedValue = -1; |
| 60 | + ((BlockFly) this.access()).lastSpoofedSlot = -1; |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public void onDisable() { |
| 65 | + if (this.previousSlot != -1 && this.access().getStringSettingValueByName("ItemSpoof").equals("Switch")) { |
| 66 | + mc.player.inventory.currentItem = this.previousSlot; |
| 67 | + } |
| 68 | + |
| 69 | + this.previousSlot = -1; |
| 70 | + if (((BlockFly) this.access()).lastSpoofedSlot >= 0) { |
| 71 | + mc.getConnection().sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem)); |
| 72 | + ((BlockFly) this.access()).lastSpoofedSlot = -1; |
| 73 | + } |
| 74 | + |
| 75 | + mc.timer.timerSpeed = 1.0F; |
| 76 | + } |
| 77 | + |
| 78 | + @EventTarget |
| 79 | + @LowerPriority |
| 80 | + public void method16202(EventSendPacket var1) { |
| 81 | + if (this.isEnabled() && mc.player != null) { |
| 82 | + if (var1.packet instanceof CHeldItemChangePacket && ((BlockFly) this.access()).lastSpoofedSlot >= 0) { |
| 83 | + var1.cancelled = true; |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + @EventTarget |
| 89 | + public void method16203(EventReceivePacket event) { |
| 90 | + if (this.isEnabled()) { |
| 91 | + if (event.packet instanceof SPlayerPositionLookPacket) { |
| 92 | + this.speedValue = 0; |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + @EventTarget |
| 98 | + public void method16204(EventSafeWalk var1) { |
| 99 | + if (this.isEnabled()) { |
| 100 | + if (mc.player.isOnGround() && Client.getInstance().moduleManager.getModuleByClass(SafeWalk.class).isEnabled()) { |
| 101 | + var1.setSafe(true); |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + @EventTarget |
| 107 | + public void method16205(EventMove var1) { |
| 108 | + if (this.isEnabled()) { |
| 109 | + if (this.access().getBooleanValueFromSettingName("No Sprint")) { |
| 110 | + mc.player.setSprinting(false); |
| 111 | + } |
| 112 | + |
| 113 | + if (!this.getBooleanValueFromSettingName("Haphe (AACAP)")) { |
| 114 | + mc.gameSettings.keyBindSprint.setPressed(false); |
| 115 | + mc.player.setSprinting(false); |
| 116 | + } |
| 117 | + |
| 118 | + ((BlockFly) this.access()).onMove(var1); |
| 119 | + if (this.getBooleanValueFromSettingName("Haphe (AACAP)")) { |
| 120 | + if (!mc.player.isOnGround() || mc.player.moveForward == 0.0F && mc.player.moveStrafing == 0.0F) { |
| 121 | + if (this.field23524 >= 0) { |
| 122 | + this.field23524++; |
| 123 | + } |
| 124 | + } else { |
| 125 | + this.field23524 = 0; |
| 126 | + mc.player.jump(); |
| 127 | + var1.setY(0.419998 + (double) MovementUtil.getJumpBoost() * 0.1); |
| 128 | + if (this.speedValue < 3) { |
| 129 | + this.speedValue++; |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + if (mc.player.moveForward == 0.0F && mc.player.moveStrafing == 0.0F || mc.player.collidedHorizontally) { |
| 134 | + this.speedValue = 0; |
| 135 | + } |
| 136 | + |
| 137 | + this.field23526 = AACSpeed.method16016(this.field23524, this.speedValue, () -> this.speedValue = 0); |
| 138 | + if (this.field23524 >= 0) { |
| 139 | + MovementUtil.setMotion(var1, this.field23526); |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + @EventTarget |
| 146 | + public void onFOV(EventGetFovModifier var1) { |
| 147 | + if (this.isEnabled() && mc.world != null && mc.player != null) { |
| 148 | + if (this.getBooleanValueFromSettingName("Haphe (AACAP)") && MovementUtil.isMoving() && !mc.player.isSprinting()) { |
| 149 | + var1.fovModifier *= 1.14F; |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + private boolean method16207() { |
| 155 | + BlockRayTraceResult var3 = (BlockRayTraceResult) BlockUtil.method34569(mc.player.lastReportedYaw, mc.player.lastReportedPitch, BlockUtil.getBlockReachDistance(), 0.0F); |
| 156 | + boolean var4 = false; |
| 157 | + if (var3 != null && var3.getType() == RayTraceResult.Type.BLOCK) { |
| 158 | + if (this.access().getStringSettingValueByName("ItemSpoof").equals("None")) { |
| 159 | + if (!InvManagerUtil.shouldPlaceItem(mc.player.getHeldItem(Hand.MAIN_HAND).getItem())) { |
| 160 | + return false; |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + if (this.getBooleanValueFromSettingName("Haphe (AACAP)") && !mc.player.isJumping && !mc.player.isOnGround()) { |
| 165 | + if (var3.getFace() == Direction.UP) { |
| 166 | + return false; |
| 167 | + } |
| 168 | + |
| 169 | + if (var3.getPos().getY() != this.placeY - 1) { |
| 170 | + return false; |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + if (var3.getFace() == Direction.UP |
| 175 | + && (double) (var3.getPos().getY() + 2) > mc.player.getPosY() |
| 176 | + && BlockUtil.isValidBlockPosition(var3.getPos())) { |
| 177 | + return false; |
| 178 | + } |
| 179 | + |
| 180 | + if ((double) var3.getPos().getY() == mc.player.getPosY()) { |
| 181 | + return false; |
| 182 | + } |
| 183 | + |
| 184 | + ((BlockFly) this.access()).method16736(); |
| 185 | + int var5 = mc.player.inventory.currentItem; |
| 186 | + if (!this.access().getStringSettingValueByName("ItemSpoof").equals("None")) { |
| 187 | + ((BlockFly) this.access()).switchToValidHotbarItem(); |
| 188 | + } |
| 189 | + |
| 190 | + ActionResultType var6 = mc.playerController.func_217292_a(mc.player, mc.world, Hand.MAIN_HAND, var3); |
| 191 | + if (this.access().getStringSettingValueByName("ItemSpoof").equals("Spoof") || this.access().getStringSettingValueByName("ItemSpoof").equals("LiteSpoof")) { |
| 192 | + mc.player.inventory.currentItem = var5; |
| 193 | + } |
| 194 | + |
| 195 | + if (var6 == ActionResultType.SUCCESS) { |
| 196 | + if (!this.access().getBooleanValueFromSettingName("NoSwing")) { |
| 197 | + mc.player.swingArm(Hand.MAIN_HAND); |
| 198 | + } else { |
| 199 | + mc.getConnection().sendPacket(new CAnimateHandPacket(Hand.MAIN_HAND)); |
| 200 | + } |
| 201 | + |
| 202 | + if (var3.getFace() == Direction.UP) { |
| 203 | + this.placeY = var3.getPos().getY() + 2; |
| 204 | + } |
| 205 | + |
| 206 | + var4 = true; |
| 207 | + } |
| 208 | + } |
| 209 | + |
| 210 | + return var4; |
| 211 | + } |
| 212 | + |
| 213 | + public List<PositionFacing> method16208(Block var1, BlockPos var2) { |
| 214 | + return BlockFlyHelper.method35030(var1, var2, (int) mc.playerController.getBlockReachDistance()); |
| 215 | + } |
| 216 | + |
| 217 | + @EventTarget |
| 218 | + @LowestPriority |
| 219 | + public void onUpdate(EventMotion event) { |
| 220 | + if (this.isEnabled()) { |
| 221 | + if (!event.isPre()) { |
| 222 | + if (MovementUtil.isMoving() && mc.player.isOnGround() && this.getBooleanValueFromSettingName("Haphe (AACAP)") && !mc.player.isJumping) { |
| 223 | + mc.player.jump(); |
| 224 | + } |
| 225 | + |
| 226 | + if (!this.getBooleanValueFromSettingName("Haphe (AACAP)")) { |
| 227 | + if (!this.method16207()) { |
| 228 | + float var11 = 0.0F; |
| 229 | + |
| 230 | + while (var11 < 0.7F && !this.method16207()) { |
| 231 | + var11 += 0.1F; |
| 232 | + } |
| 233 | + } |
| 234 | + } else { |
| 235 | + this.method16207(); |
| 236 | + } |
| 237 | + } else { |
| 238 | + double placeY = mc.player.getPosY(); |
| 239 | + if (!mc.player.isJumping && this.getBooleanValueFromSettingName("Haphe (AACAP)")) { |
| 240 | + placeY = this.placeY; |
| 241 | + } |
| 242 | + |
| 243 | + BlockPos var6 = new BlockPos(mc.player.getPosX(), (double) Math.round(placeY - 1.0), mc.player.getPosZ()); |
| 244 | + List var7 = this.method16208(Blocks.STONE, var6); |
| 245 | + if (!var7.isEmpty()) { |
| 246 | + PositionFacing var8 = (PositionFacing) var7.get(var7.size() - 1); |
| 247 | + BlockRayTraceResult var9 = BlockUtil.rayTrace(this.yaw, this.pitch, 5.0F); |
| 248 | + if (!var9.getPos().equals(var8.blockPos()) || !var9.getFace().equals(var8.direction())) { |
| 249 | + float[] var10 = BlockUtil.rotationsToBlock(var8.blockPos(), var8.direction()); |
| 250 | + this.yaw = var10[0]; |
| 251 | + this.pitch = var10[1]; |
| 252 | + } |
| 253 | + } |
| 254 | + |
| 255 | + event.setYaw(this.yaw); |
| 256 | + event.setPitch(this.pitch); |
| 257 | + } |
| 258 | + } |
| 259 | + } |
| 260 | + |
| 261 | + @EventTarget |
| 262 | + public void method16211(EventJump var1) { |
| 263 | + if (this.isEnabled()) { |
| 264 | + if (this.access().getStringSettingValueByName("Tower Mode").equalsIgnoreCase("Vanilla") |
| 265 | + && (!MovementUtil.isMoving() || this.access().getBooleanValueFromSettingName("Tower while moving"))) { |
| 266 | + var1.cancelled = true; |
| 267 | + } |
| 268 | + } |
| 269 | + } |
| 270 | +} |
0 commit comments