mirror of https://github.com/kami-blue/client
Rewrote Freecam (#1375)
Co-authored-by: Dominika <sokolov.dominika@gmail.com>
This commit is contained in:
parent
7316c2171a
commit
cde0d28c6d
|
@ -0,0 +1,5 @@
|
|||
complexity:
|
||||
active: true
|
||||
ComplexMethod:
|
||||
active: true
|
||||
threshold: 25
|
|
@ -437,20 +437,24 @@ public class KamiGUI extends GUI {
|
|||
frame.setCloseable(false);
|
||||
frame.setPinnable(true);
|
||||
Label coordsLabel = new Label("");
|
||||
coordsLabel.addTickListener(new TickListener() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
coordsLabel.addTickListener(() -> {
|
||||
EntityPlayer player;
|
||||
if (Wrapper.getMinecraft().getRenderViewEntity() instanceof EntityPlayer) {
|
||||
player = (EntityPlayer) Wrapper.getMinecraft().getRenderViewEntity();
|
||||
} else {
|
||||
player = Wrapper.getPlayer();
|
||||
}
|
||||
if (player == null) return;
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
boolean inHell = mc.player.dimension == -1;
|
||||
boolean inHell = player.dimension == -1;
|
||||
|
||||
int posX = (int) mc.player.posX;
|
||||
int posY = (int) mc.player.posY;
|
||||
int posZ = (int) mc.player.posZ;
|
||||
int posX = (int) player.posX;
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) player.posZ;
|
||||
|
||||
float f = !inHell ? 0.125f : 8;
|
||||
int hposX = (int) (mc.player.posX * f);
|
||||
int hposZ = (int) (mc.player.posZ * f);
|
||||
int hposX = (int) (player.posX * f);
|
||||
int hposZ = (int) (player.posZ * f);
|
||||
|
||||
/* The 7 and f in the string formatter is the color */
|
||||
String colouredSeparator = KamiMod.colour + "7 " + KamiMod.separator + KamiMod.colour + "r";
|
||||
|
@ -478,8 +482,7 @@ public class KamiGUI extends GUI {
|
|||
);
|
||||
coordsLabel.setText("");
|
||||
coordsLabel.addLine(ow);
|
||||
coordsLabel.addLine(MathUtils.getPlayerCardinal(mc).cardinalName + colouredSeparator + nether);
|
||||
}
|
||||
coordsLabel.addLine(MathUtils.getPlayerCardinal(player).cardinalName + colouredSeparator + nether);
|
||||
});
|
||||
frame.addChild(coordsLabel);
|
||||
coordsLabel.setFontRenderer(fontRenderer);
|
||||
|
|
|
@ -3,15 +3,22 @@ package me.zeroeightsix.kami.mixin.client;
|
|||
import me.zeroeightsix.kami.KamiMod;
|
||||
import me.zeroeightsix.kami.event.events.EntityEvent;
|
||||
import me.zeroeightsix.kami.module.modules.movement.SafeWalk;
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam;
|
||||
import me.zeroeightsix.kami.module.modules.player.Scaffold;
|
||||
import me.zeroeightsix.kami.util.Wrapper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = Entity.class, priority = Integer.MAX_VALUE)
|
||||
public class MixinEntity {
|
||||
|
||||
@Shadow public int entityId;
|
||||
|
||||
@Redirect(method = "applyEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;addVelocity(DDD)V"))
|
||||
public void addVelocity(Entity entity, double x, double y, double z) {
|
||||
EntityEvent.EntityCollision entityCollisionEvent = new EntityEvent.EntityCollision(entity, x, y, z);
|
||||
|
@ -29,4 +36,14 @@ public class MixinEntity {
|
|||
public boolean isSneaking(Entity entity) {
|
||||
return SafeWalk.INSTANCE.shouldSafewalk() || Scaffold.INSTANCE.isEnabled() || entity.isSneaking();
|
||||
}
|
||||
|
||||
// Makes the camera guy instead of original player turn around when we move mouse
|
||||
@Inject(method = "turn", at = @At("HEAD"), cancellable = true)
|
||||
public void turn(float yaw, float pitch, CallbackInfo ci) {
|
||||
if (Wrapper.getPlayer() != null && this.entityId != Wrapper.getPlayer().entityId) return;
|
||||
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null) {
|
||||
Freecam.INSTANCE.getCameraGuy().turn(yaw, pitch);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import me.zeroeightsix.kami.gui.mc.KamiGuiBeacon;
|
|||
import me.zeroeightsix.kami.module.modules.chat.PortalChat;
|
||||
import me.zeroeightsix.kami.module.modules.misc.BeaconSelector;
|
||||
import me.zeroeightsix.kami.module.modules.movement.Sprint;
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam;
|
||||
import me.zeroeightsix.kami.util.math.Vec2f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
|
@ -29,6 +30,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(value = EntityPlayerSP.class, priority = Integer.MAX_VALUE)
|
||||
public abstract class MixinEntityPlayerSP extends EntityPlayer {
|
||||
|
@ -94,6 +96,14 @@ public abstract class MixinEntityPlayerSP extends EntityPlayer {
|
|||
super.setSprinting(sprinting);
|
||||
}
|
||||
|
||||
// We have to return true here so it would still update movement inputs from Baritone and send packets
|
||||
@Inject(method = "isCurrentViewEntity", at = @At("RETURN"), cancellable = true)
|
||||
protected void mixinIsCurrentViewEntity(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null) {
|
||||
cir.setReturnValue(mc.getRenderViewEntity() == Freecam.INSTANCE.getCameraGuy());
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onUpdateWalkingPlayer", at = @At("HEAD"), cancellable = true)
|
||||
private void onUpdateWalkingPlayerPre(CallbackInfo ci) {
|
||||
// Setup flags
|
||||
|
|
|
@ -2,14 +2,12 @@ package me.zeroeightsix.kami.mixin.client;
|
|||
|
||||
import com.google.common.base.Predicate;
|
||||
import me.zeroeightsix.kami.module.modules.movement.ElytraFlight;
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam;
|
||||
import me.zeroeightsix.kami.module.modules.player.NoEntityTrace;
|
||||
import me.zeroeightsix.kami.module.modules.render.AntiFog;
|
||||
import me.zeroeightsix.kami.module.modules.render.AntiOverlay;
|
||||
import me.zeroeightsix.kami.module.modules.render.CameraClip;
|
||||
import me.zeroeightsix.kami.module.modules.render.NoHurtCam;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
|
@ -71,15 +69,6 @@ public class MixinEntityRenderer {
|
|||
return worldClient.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;isSpectator()Z"))
|
||||
public boolean noclipIsSpectator(EntityPlayerSP entityPlayerSP) {
|
||||
// [WebringOfTheDamned]
|
||||
// Freecam doesn't actually use spectator mode, but it can go through walls, and only spectator mode is "allowed to" go through walls as far as the renderer is concerned
|
||||
if (Freecam.INSTANCE.isEnabled())
|
||||
return true;
|
||||
return entityPlayerSP.isSpectator();
|
||||
}
|
||||
|
||||
@Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getEyeHeight()F"))
|
||||
public float getEyeHeight(Entity entity) {
|
||||
if (ElytraFlight.INSTANCE.shouldSwing()) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
@Mixin(Frustum.class)
|
||||
public abstract class MixinFrustum {
|
||||
|
||||
@Inject(method = "Lnet/minecraft/client/renderer/culling/Frustum;isBoundingBoxInFrustum(Lnet/minecraft/util/math/AxisAlignedBB;)Z", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "isBoundingBoxInFrustum(Lnet/minecraft/util/math/AxisAlignedBB;)Z", at = @At("HEAD"), cancellable = true)
|
||||
public void isBoundingBoxEtc(AxisAlignedBB ignore, CallbackInfoReturnable<Boolean> info) {
|
||||
// [WebringOfTheDamned]
|
||||
// This is used because honestly the Mojang frustrum bounding box thing is a mess.
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.zeroeightsix.kami.mixin.client;
|
|||
|
||||
import me.zeroeightsix.kami.KamiMod;
|
||||
import me.zeroeightsix.kami.event.events.PlayerUpdateMoveEvent;
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraft.util.MovementInputFromOptions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -21,4 +22,21 @@ public abstract class MixinMovementInputFromOptions extends MovementInput {
|
|||
public void updatePlayerMoveStateReturn(CallbackInfo callback) {
|
||||
KamiMod.EVENT_BUS.post(new PlayerUpdateMoveEvent());
|
||||
}
|
||||
|
||||
// We have to cancel this so original player doesn't move around, also reset movement input when we enable Freecam
|
||||
@Inject(method = "updatePlayerMoveState", at = @At("HEAD"), cancellable = true)
|
||||
public void updatePlayerMoveStateHead(CallbackInfo ci) {
|
||||
if (Freecam.INSTANCE.isEnabled() && Freecam.INSTANCE.getCameraGuy() != null) ci.cancel();
|
||||
if (Freecam.INSTANCE.getResetInput()) {
|
||||
this.moveForward = 0f;
|
||||
this.moveStrafe = 0f;
|
||||
this.forwardKeyDown = false;
|
||||
this.backKeyDown = false;
|
||||
this.leftKeyDown = false;
|
||||
this.rightKeyDown = false;
|
||||
this.jump = false;
|
||||
this.sneak = false;
|
||||
Freecam.INSTANCE.setResetInput(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,15 @@ import me.zeroeightsix.kami.module.modules.movement.ElytraFlight;
|
|||
import me.zeroeightsix.kami.util.Wrapper;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
|
@ -32,4 +36,9 @@ public class MixinRenderPlayer {
|
|||
}
|
||||
}
|
||||
|
||||
// Redirect it to the original player so the original player can be renderer correctly
|
||||
@Redirect(method = "doRender", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderViewEntity:Lnet/minecraft/entity/Entity;", opcode = Opcodes.GETFIELD))
|
||||
public Entity getRenderViewEntity(RenderManager renderManager) {
|
||||
return Wrapper.getPlayer();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package me.zeroeightsix.kami.module.modules.combat
|
|||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam
|
||||
import me.zeroeightsix.kami.module.modules.player.NoBreakAnimation
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.BlockUtils
|
||||
|
@ -74,8 +73,6 @@ object AutoFeetPlace : Module() {
|
|||
}
|
||||
|
||||
override fun onUpdate() {
|
||||
if (Freecam.isEnabled) return
|
||||
|
||||
if (triggerable.value && totalTicksRunning >= timeoutTicks.value) {
|
||||
totalTicksRunning = 0
|
||||
disable()
|
||||
|
|
|
@ -2,7 +2,6 @@ package me.zeroeightsix.kami.module.modules.combat;
|
|||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam;
|
||||
import me.zeroeightsix.kami.module.modules.player.NoBreakAnimation;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
|
@ -49,7 +48,6 @@ public class AutoTrap extends Module {
|
|||
private final Setting<Cage> cage = register(Settings.e("Cage", Cage.TRAP));
|
||||
private final Setting<Boolean> rotate = register(Settings.b("Rotate", false));
|
||||
private final Setting<Boolean> noGlitchBlocks = register(Settings.b("NoGlitchBlocks", true));
|
||||
private final Setting<Boolean> activeInFreecam = register(Settings.b("ActiveInFreecam", true));
|
||||
private final Setting<Boolean> selfTrap = register(Settings.b("SelfTrap", false));
|
||||
private final Setting<Boolean> infoMessage = register(Settings.b("Debug", false));
|
||||
|
||||
|
@ -125,8 +123,6 @@ public class AutoTrap extends Module {
|
|||
public void onUpdate() {
|
||||
if (mc.player.getHealth() <= 0) return;
|
||||
|
||||
if (!activeInFreecam.getValue() && Freecam.INSTANCE.isEnabled()) return;
|
||||
|
||||
if (firstRun) {
|
||||
if (findObiInHotbar() == -1) {
|
||||
if (infoMessage.getValue()) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.zeroeightsix.kami.module.modules.combat
|
||||
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam
|
||||
import me.zeroeightsix.kami.module.modules.player.NoBreakAnimation
|
||||
import me.zeroeightsix.kami.setting.Setting
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
|
@ -57,7 +56,6 @@ object Surround : Module() {
|
|||
CenterPlayer.centerPlayer(1.0f)
|
||||
if (debugMsgs.value == DebugMsgs.ALL) MessageSendHelper.sendChatMessage("$chatName Auto centering. Player position is " + mc.player.positionVector.toString())
|
||||
} else {
|
||||
if (Freecam.isDisabled) {
|
||||
if (offsetStep == 0) {
|
||||
basePos = BlockPos(mc.player.positionVector).down()
|
||||
playerHotbarSlot = mc.player.inventory.currentItem
|
||||
|
@ -82,7 +80,6 @@ object Surround : Module() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override fun onEnable() {
|
||||
if (mc.player == null) return
|
||||
|
|
|
@ -12,6 +12,7 @@ import me.zeroeightsix.kami.setting.Settings
|
|||
import me.zeroeightsix.kami.util.math.MathUtils.CardinalMain
|
||||
import me.zeroeightsix.kami.util.math.MathUtils.getPlayerMainCardinal
|
||||
import me.zeroeightsix.kami.util.text.MessageSendHelper
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
|
||||
@Module.Info(
|
||||
name = "AutoTunnel",
|
||||
|
@ -33,7 +34,7 @@ object AutoTunnel : Module() {
|
|||
}
|
||||
if (AutoWalk.isEnabled) AutoWalk.disable()
|
||||
|
||||
startingDirection = getPlayerMainCardinal(mc)
|
||||
startingDirection = getPlayerMainCardinal(mc.getRenderViewEntity() as? EntityPlayer? ?: mc.player)
|
||||
sendTunnel()
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import me.zeroeightsix.kami.setting.Settings
|
|||
import me.zeroeightsix.kami.util.math.MathUtils
|
||||
import me.zeroeightsix.kami.util.math.MathUtils.Cardinal
|
||||
import me.zeroeightsix.kami.util.text.MessageSendHelper.sendErrorMessage
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraftforge.client.event.InputUpdateEvent
|
||||
|
||||
@Module.Info(
|
||||
|
@ -73,7 +74,7 @@ object AutoWalk : Module() {
|
|||
return
|
||||
}
|
||||
|
||||
when (MathUtils.getPlayerCardinal(mc)) {
|
||||
when (MathUtils.getPlayerCardinal(mc.getRenderViewEntity() as? EntityPlayer? ?: mc.player)) {
|
||||
Cardinal.POS_Z -> BaritoneAPI.getProvider().primaryBaritone.customGoalProcess.setGoalAndPath(GoalXZ(mc.player.posX.toInt(), mc.player.posZ.toInt() + border))
|
||||
Cardinal.NEG_X_POS_Z -> BaritoneAPI.getProvider().primaryBaritone.customGoalProcess.setGoalAndPath(GoalXZ(mc.player.posX.toInt() - border, mc.player.posZ.toInt() + border))
|
||||
Cardinal.NEG_X -> BaritoneAPI.getProvider().primaryBaritone.customGoalProcess.setGoalAndPath(GoalXZ(mc.player.posX.toInt() - border, mc.player.posZ.toInt()))
|
||||
|
@ -88,7 +89,7 @@ object AutoWalk : Module() {
|
|||
}
|
||||
}
|
||||
|
||||
direction = MathUtils.getPlayerCardinal(mc).cardinalName
|
||||
direction = MathUtils.getPlayerCardinal(mc.getRenderViewEntity() as? EntityPlayer? ?: mc.player).cardinalName
|
||||
}
|
||||
|
||||
override fun getHudInfo(): String {
|
||||
|
|
|
@ -8,7 +8,6 @@ import me.zeroeightsix.kami.event.KamiEvent
|
|||
import me.zeroeightsix.kami.event.events.AddCollisionBoxToListEvent
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.module.modules.player.Freecam
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.EntityUtils
|
||||
import net.minecraft.block.BlockLiquid
|
||||
|
@ -34,7 +33,6 @@ object Jesus : Module() {
|
|||
}
|
||||
|
||||
override fun onUpdate() {
|
||||
if (!Freecam.isEnabled) {
|
||||
if (EntityUtils.isInWater(mc.player) && !mc.player.isSneaking) {
|
||||
mc.player.motionY = 0.1
|
||||
if (mc.player.getRidingEntity() != null && mc.player.getRidingEntity() !is EntityBoat) {
|
||||
|
@ -42,7 +40,6 @@ object Jesus : Module() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private val addCollisionBoxToListEventListener = Listener(EventHook { event: AddCollisionBoxToListEvent ->
|
||||
|
|
|
@ -3,122 +3,187 @@ package me.zeroeightsix.kami.module.modules.player
|
|||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.event.events.ConnectionEvent
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.event.events.PlayerMoveEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.BaritoneUtils
|
||||
import me.zeroeightsix.kami.util.math.RotationUtils
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.client.entity.EntityPlayerSP
|
||||
import net.minecraft.entity.MoverType
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.network.play.client.CPacketInput
|
||||
import net.minecraft.network.play.client.CPacketPlayer
|
||||
import net.minecraft.network.play.client.CPacketUseEntity
|
||||
import net.minecraft.network.play.client.CPacketVehicleMove
|
||||
import net.minecraftforge.client.event.PlayerSPPushOutOfBlocksEvent
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent
|
||||
import org.lwjgl.input.Keyboard
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* Created by 086 on 22/12/2017.
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "Freecam",
|
||||
category = Module.Category.PLAYER,
|
||||
description = "Leave your body and transcend into the realm of the gods"
|
||||
)
|
||||
object Freecam : Module() {
|
||||
private val speed = register(Settings.i("Speed", 5)) // /100 in practice
|
||||
private val packetCancel = register(Settings.b("PacketCancel", false))
|
||||
private val horizontalSpeed = register(Settings.floatBuilder("HorizontalSpeed").withValue(20f).withRange(1f, 50f).withStep(1f))
|
||||
private val verticalSpeed = register(Settings.floatBuilder("VerticalSpeed").withValue(20f).withRange(1f, 50f).withStep(1f))
|
||||
private val arrowKeyMove = register(Settings.b("ArrowKeyMove", true))
|
||||
|
||||
private var posX = 0.0
|
||||
private var posY = 0.0
|
||||
private var posZ = 0.0
|
||||
private var pitch = 0f
|
||||
private var yaw = 0f
|
||||
private var clonedPlayer: EntityOtherPlayerMP? = null
|
||||
private var isRidingEntity = false
|
||||
private var ridingEntity: Entity? = null
|
||||
private var prevThirdPersonViewSetting = -1
|
||||
var cameraGuy: EntityPlayer? = null
|
||||
private set
|
||||
var resetInput = false
|
||||
|
||||
override fun onEnable() {
|
||||
if (mc.player != null) {
|
||||
isRidingEntity = mc.player.getRidingEntity() != null
|
||||
if (mc.player.getRidingEntity() == null) {
|
||||
posX = mc.player.posX
|
||||
posY = mc.player.posY
|
||||
posZ = mc.player.posZ
|
||||
} else {
|
||||
ridingEntity = mc.player.getRidingEntity()
|
||||
mc.player.dismountRidingEntity()
|
||||
}
|
||||
|
||||
pitch = mc.player.rotationPitch
|
||||
yaw = mc.player.rotationYaw
|
||||
clonedPlayer = EntityOtherPlayerMP(mc.world, mc.getSession().profile)
|
||||
clonedPlayer!!.copyLocationAndAnglesFrom(mc.player)
|
||||
clonedPlayer!!.rotationYawHead = mc.player.rotationYawHead
|
||||
|
||||
mc.world.addEntityToWorld(-100, clonedPlayer)
|
||||
mc.player.capabilities.isFlying = true
|
||||
mc.player.capabilities.flySpeed = speed.value / 100f
|
||||
mc.player.noClip = true
|
||||
|
||||
// WebringOfTheDamned
|
||||
// This is needed for some reason, as is the converse in onDisable.
|
||||
mc.renderChunksMany = false
|
||||
mc.renderGlobal.loadRenderers()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
val localPlayer: EntityPlayer? = mc.player
|
||||
if (localPlayer != null) {
|
||||
mc.player.setPositionAndRotation(posX, posY, posZ, yaw, pitch)
|
||||
mc.world.removeEntityFromWorld(-100)
|
||||
|
||||
clonedPlayer = null
|
||||
posZ = 0.0
|
||||
posY = posZ
|
||||
posX = posY
|
||||
yaw = 0f
|
||||
pitch = yaw
|
||||
|
||||
mc.player.capabilities.isFlying = false //getModManager().getMod("ElytraFlight").isEnabled();
|
||||
mc.player.capabilities.flySpeed = 0.05f
|
||||
mc.player.noClip = false
|
||||
mc.player.motionZ = 0.0
|
||||
mc.player.motionY = mc.player.motionZ
|
||||
mc.player.motionX = mc.player.motionY
|
||||
|
||||
if (isRidingEntity) {
|
||||
mc.player.startRiding(ridingEntity, true)
|
||||
}
|
||||
|
||||
// WebringOfTheDamned
|
||||
// This is needed for some reason, as is the converse in onEnable.
|
||||
@EventHandler
|
||||
private val disconnectListener = Listener(EventHook { event: ConnectionEvent.Disconnect ->
|
||||
prevThirdPersonViewSetting = -1
|
||||
cameraGuy = null
|
||||
mc.renderChunksMany = true
|
||||
mc.renderGlobal.loadRenderers()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpdate() {
|
||||
mc.player.capabilities.isFlying = true
|
||||
mc.player.capabilities.flySpeed = speed.value / 100f
|
||||
mc.player.noClip = true
|
||||
mc.player.onGround = false
|
||||
mc.player.fallDistance = 0f
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private val moveListener = Listener(EventHook { event: PlayerMoveEvent? -> mc.player.noClip = true })
|
||||
|
||||
@EventHandler
|
||||
private val pushListener = Listener(EventHook { event: PlayerSPPushOutOfBlocksEvent -> event.isCanceled = true })
|
||||
})
|
||||
|
||||
@EventHandler
|
||||
private val sendListener = Listener(EventHook { event: PacketEvent.Send ->
|
||||
if (event.packet is CPacketPlayer || event.packet is CPacketInput) {
|
||||
event.cancel()
|
||||
}
|
||||
if (packetCancel.value && (event.packet is CPacketUseEntity || event.packet is CPacketVehicleMove)) {
|
||||
event.cancel()
|
||||
}
|
||||
if (mc.world == null || event.packet !is CPacketUseEntity) return@EventHook
|
||||
// Don't interact with self
|
||||
if (event.packet.getEntityFromWorld(mc.world) == mc.player) event.cancel()
|
||||
})
|
||||
|
||||
@EventHandler
|
||||
private val keyboardListener = Listener(EventHook { event: InputEvent.KeyInputEvent ->
|
||||
if (mc.world == null || mc.player == null) return@EventHook
|
||||
// Force it to stay in first person lol
|
||||
if (mc.gameSettings.keyBindTogglePerspective.isKeyDown) mc.gameSettings.thirdPersonView = 2
|
||||
})
|
||||
|
||||
override fun onDisable() {
|
||||
if (mc.player == null) return
|
||||
mc.world.removeEntityFromWorld(-6969420)
|
||||
mc.setRenderViewEntity(mc.player)
|
||||
cameraGuy = null
|
||||
mc.player.rotationYawHead
|
||||
if (prevThirdPersonViewSetting != -1) mc.gameSettings.thirdPersonView = prevThirdPersonViewSetting
|
||||
}
|
||||
|
||||
override fun onUpdate() {
|
||||
if (cameraGuy == null && mc.player.ticksExisted > 20) {
|
||||
// Create a cloned player
|
||||
cameraGuy = FakeCamera(mc.player).also {
|
||||
// Add it to the world
|
||||
mc.world.addEntityToWorld(-6969420, it)
|
||||
|
||||
// Set the render view entity to our camera guy
|
||||
mc.setRenderViewEntity(it)
|
||||
|
||||
// Reset player movement input
|
||||
resetInput = true
|
||||
|
||||
// Stores prev third person view setting
|
||||
prevThirdPersonViewSetting = mc.gameSettings.thirdPersonView
|
||||
mc.gameSettings.thirdPersonView = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (arrowKeyMove.value && !BaritoneUtils.isPathing) {
|
||||
cameraGuy?.let {
|
||||
val forward = Keyboard.isKeyDown(Keyboard.KEY_UP) to Keyboard.isKeyDown(Keyboard.KEY_DOWN)
|
||||
val strafe = Keyboard.isKeyDown(Keyboard.KEY_LEFT) to Keyboard.isKeyDown(Keyboard.KEY_RIGHT)
|
||||
val movementInput = calcMovementInput(forward, strafe, false to false)
|
||||
|
||||
if (movementInput.first != 0f || movementInput.second != 0f) mc.player.rotationYaw = it.rotationYaw
|
||||
|
||||
mc.player.movementInput.moveForward = movementInput.first
|
||||
mc.player.movementInput.moveStrafe = -movementInput.second
|
||||
|
||||
mc.player.movementInput.forwardKeyDown = forward.first
|
||||
mc.player.movementInput.backKeyDown = forward.second
|
||||
mc.player.movementInput.leftKeyDown = strafe.first
|
||||
mc.player.movementInput.rightKeyDown = strafe.second
|
||||
|
||||
mc.player.movementInput.jump = Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FakeCamera(val player: EntityPlayerSP) : EntityOtherPlayerMP(mc.world, mc.session.profile) {
|
||||
init {
|
||||
copyLocationAndAnglesFrom(mc.player)
|
||||
capabilities.allowFlying = true
|
||||
capabilities.isFlying = true
|
||||
}
|
||||
|
||||
override fun onLivingUpdate() {
|
||||
// Update inventory
|
||||
inventory.copyInventory(player.inventory)
|
||||
|
||||
// Update yaw head
|
||||
updateEntityActionState()
|
||||
|
||||
// We have to update movement input from key binds because mc.player.movementInput is used by Baritone
|
||||
val forward = mc.gameSettings.keyBindForward.isKeyDown to mc.gameSettings.keyBindBack.isKeyDown
|
||||
val strafe = mc.gameSettings.keyBindLeft.isKeyDown to mc.gameSettings.keyBindRight.isKeyDown
|
||||
val vertical = mc.gameSettings.keyBindJump.isKeyDown to mc.gameSettings.keyBindSneak.isKeyDown
|
||||
val movementInput = calcMovementInput(forward, strafe, vertical)
|
||||
|
||||
moveForward = movementInput.first
|
||||
moveStrafing = movementInput.second
|
||||
moveVertical = movementInput.third
|
||||
|
||||
// Update sprinting
|
||||
isSprinting = mc.gameSettings.keyBindSprint.isKeyDown
|
||||
|
||||
val yawRad = Math.toRadians(rotationYaw - RotationUtils.getRotationFromVec(Vec3d(moveStrafing.toDouble(), 0.0, moveForward.toDouble())).x)
|
||||
val speed = (horizontalSpeed.value / 20f) * min(abs(moveForward) + abs(moveStrafing), 1f)
|
||||
|
||||
motionX = -sin(yawRad) * speed
|
||||
motionY = moveVertical.toDouble() * (verticalSpeed.value / 20f)
|
||||
motionZ = cos(yawRad) * speed
|
||||
|
||||
if (isSprinting) {
|
||||
motionX *= 1.5
|
||||
motionY *= 1.5
|
||||
motionZ *= 1.5
|
||||
}
|
||||
|
||||
noClip = true
|
||||
|
||||
move(MoverType.SELF, motionX, motionY, motionZ)
|
||||
}
|
||||
|
||||
override fun getEyeHeight() = 1.65f
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forward <Forward, Backward>
|
||||
* @param strafe <Left, Right>
|
||||
* @param vertical <Up, Down>
|
||||
*
|
||||
* @return <Forward, Strafe, Vertical>
|
||||
*/
|
||||
private fun calcMovementInput(forward: Pair<Boolean, Boolean>, strafe: Pair<Boolean, Boolean>, vertical: Pair<Boolean, Boolean>): Triple<Float, Float, Float> {
|
||||
// Forward movement input
|
||||
val moveForward = if (forward.first xor forward.second) {
|
||||
if (forward.first) 1f else -1f
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
// Strafe movement input
|
||||
val moveStrafing = if (strafe.first xor strafe.second) {
|
||||
if (strafe.second) 1f else -1f
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
// Vertical movement input
|
||||
val moveVertical = if (vertical.first xor vertical.second) {
|
||||
if (vertical.first) 1f else -1f
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
return Triple(moveForward, moveStrafing, moveVertical)
|
||||
}
|
||||
}
|
|
@ -55,7 +55,6 @@ object Scaffold : Module() {
|
|||
})
|
||||
|
||||
override fun onUpdate() {
|
||||
if (Freecam.isEnabled) return
|
||||
shouldSlow = false
|
||||
|
||||
val towering = mc.gameSettings.keyBindJump.isKeyDown && tower.value
|
||||
|
|
|
@ -234,7 +234,7 @@ object EntityUtils {
|
|||
for (entity in mc.world.loadedEntityList) {
|
||||
/* Entity type check */
|
||||
if (!isLiving(entity)) continue
|
||||
if (entity == mc.player) continue
|
||||
if (entity.name == mc.player.name) continue
|
||||
if (entity is EntityPlayer) {
|
||||
if (!player[0]) continue
|
||||
if (!playerTypeCheck(entity, player[1], player[2])) continue
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.zeroeightsix.kami.util.math
|
|||
|
||||
import me.zeroeightsix.kami.util.math.RotationUtils.normalizeAngle
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import kotlin.math.*
|
||||
|
||||
|
@ -48,22 +49,22 @@ object MathUtils {
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPlayerCardinal(mc: Minecraft): Cardinal {
|
||||
return if (isBetween(-22.5, 22.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
fun getPlayerCardinal(player: EntityPlayer): Cardinal {
|
||||
return if (isBetween(-22.5, 22.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.POS_Z
|
||||
} else if (isBetween(22.6, 67.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(22.6, 67.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.NEG_X_POS_Z
|
||||
} else if (isBetween(67.6, 112.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(67.6, 112.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.NEG_X
|
||||
} else if (isBetween(112.6, 157.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(112.6, 157.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.NEG_X_NEG_Z
|
||||
} else if (normalizeAngle(mc.player.rotationYaw.toDouble()) >= 157.6 || normalizeAngle(mc.player.rotationYaw.toDouble()) <= -157.5) {
|
||||
} else if (normalizeAngle(player.rotationYaw.toDouble()) >= 157.6 || normalizeAngle(player.rotationYaw.toDouble()) <= -157.5) {
|
||||
Cardinal.NEG_Z
|
||||
} else if (isBetween(-157.6, -112.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(-157.6, -112.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.POS_X_NEG_Z
|
||||
} else if (isBetween(-112.5, -67.5, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(-112.5, -67.5, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.POS_X
|
||||
} else if (isBetween(-67.6, -22.6, normalizeAngle(mc.player.rotationYaw.toDouble()))) {
|
||||
} else if (isBetween(-67.6, -22.6, normalizeAngle(player.rotationYaw.toDouble()))) {
|
||||
Cardinal.POS_X_POS_Z
|
||||
} else {
|
||||
Cardinal.ERROR
|
||||
|
@ -71,8 +72,8 @@ object MathUtils {
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPlayerMainCardinal(mc: Minecraft): CardinalMain {
|
||||
return when (Character.toUpperCase(mc.player.horizontalFacing.toString()[0])) {
|
||||
fun getPlayerMainCardinal(player: EntityPlayer): CardinalMain {
|
||||
return when (Character.toUpperCase(player.horizontalFacing.toString()[0])) {
|
||||
'N' -> CardinalMain.NEG_Z
|
||||
'S' -> CardinalMain.POS_Z
|
||||
'E' -> CardinalMain.POS_X
|
||||
|
|
Loading…
Reference in New Issue