mirror of https://github.com/kami-blue/client
Merge remote-tracking branch 'upstream/master' into Anchor
This commit is contained in:
commit
da557711cf
|
@ -41,6 +41,7 @@ sourceSets.main.java {
|
|||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.useIR = true
|
||||
}
|
||||
|
||||
compileJava {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
org.gradle.jvmargs=-Xmx3G
|
||||
modGroup=org.kamiblue
|
||||
modVersion=2.02.xx-dev
|
||||
modVersion=2.03.xx-dev
|
||||
kotlin_version=1.4.30
|
||||
kotlinx_coroutines_version=1.4.2
|
|
@ -18,9 +18,9 @@ VERSION="$CUR_R$CUR_M.01"
|
|||
VERSION_DEV="$CUR_R$CUR_M.xx-dev"
|
||||
|
||||
sed -i "s/modVersion=.*/modVersion=$VERSION_DEV/" gradle.properties
|
||||
sed -i "s/VERSION = \".*\";/VERSION = \"$VERSION_DEV\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_SIMPLE = \".*\";/VERSION_SIMPLE = \"$VERSION_DEV\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_MAJOR = \".*\";/VERSION_MAJOR = \"$VERSION\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION = \".*\"/VERSION = \"$VERSION_DEV\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_SIMPLE = \".*\"/VERSION_SIMPLE = \"$VERSION_DEV\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_MAJOR = \".*\"/VERSION_MAJOR = \"$VERSION\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
git commit -am "[bump] Release Major $VERSION"
|
||||
|
||||
echo "[bumpMajor] Created commit for version '$VERSION', remember to push!"
|
||||
|
|
|
@ -29,7 +29,7 @@ fi
|
|||
|
||||
# Set above information
|
||||
sed -i "s/modVersion=.*/modVersion=$VERSION/" gradle.properties
|
||||
sed -i "s/VERSION = \".*\";/VERSION = \"$VERSION\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_SIMPLE = \".*\";/VERSION_SIMPLE = \"$VERSION_SIMPLE\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_MAJOR = \".*\";/VERSION_MAJOR = \"$VERSION_MAJOR\";/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/BUILD_NUMBER = .*;/BUILD_NUMBER = $BUILD_NUMBER;/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_SIMPLE = \".*\"/VERSION_SIMPLE = \"$VERSION_SIMPLE\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/VERSION_MAJOR = \".*\"/VERSION_MAJOR = \"$VERSION_MAJOR\"/" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
sed -i "s/BUILD_NUMBER = .* \/\//BUILD_NUMBER = $BUILD_NUMBER \/\//" src/main/kotlin/org/kamiblue/client/KamiMod.kt
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 0ad2b06b687679a658995f20e0d79bf8c12c7af1
|
||||
Subproject commit 9ed896374539caff7a09e1eb403ffc3f8abc7ec5
|
|
@ -20,7 +20,7 @@ import org.kamiblue.client.manager.managers.PlayerPacketManager;
|
|||
import org.kamiblue.client.mixin.client.accessor.player.AccessorEntityPlayerSP;
|
||||
import org.kamiblue.client.mixin.client.accessor.player.AccessorPlayerControllerMP;
|
||||
import org.kamiblue.client.module.modules.combat.CrystalAura;
|
||||
import org.kamiblue.client.module.modules.player.MultiTask;
|
||||
import org.kamiblue.client.module.modules.player.BlockInteraction;
|
||||
import org.kamiblue.client.util.Wrapper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -33,7 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
* Created by 086 on 17/11/2017.
|
||||
*/
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft {
|
||||
public abstract class MixinMinecraft {
|
||||
|
||||
@Shadow public WorldClient world;
|
||||
@Shadow public EntityPlayerSP player;
|
||||
|
@ -43,6 +43,9 @@ public class MixinMinecraft {
|
|||
|
||||
@Shadow public RayTraceResult objectMouseOver;
|
||||
@Shadow public EntityRenderer entityRenderer;
|
||||
|
||||
@Shadow protected abstract void clickMouse();
|
||||
|
||||
private boolean handActive = false;
|
||||
private boolean isHittingBlock = false;
|
||||
|
||||
|
@ -103,10 +106,20 @@ public class MixinMinecraft {
|
|||
}
|
||||
}
|
||||
|
||||
// Allows left click attack while eating lol
|
||||
@Inject(method = "processKeyBinds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/settings/KeyBinding;isKeyDown()Z", shift = At.Shift.BEFORE, ordinal = 2))
|
||||
public void processKeyBindsInvokeIsKeyDown(CallbackInfo ci) {
|
||||
if (BlockInteraction.isMultiTaskEnabled()) {
|
||||
while (this.gameSettings.keyBindAttack.isPressed()) {
|
||||
this.clickMouse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hacky but safer than using @Redirect
|
||||
@Inject(method = "rightClickMouse", at = @At("HEAD"))
|
||||
public void rightClickMousePre(CallbackInfo ci) {
|
||||
if (MultiTask.INSTANCE.isEnabled()) {
|
||||
if (BlockInteraction.isMultiTaskEnabled()) {
|
||||
isHittingBlock = playerController.getIsHittingBlock();
|
||||
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(false);
|
||||
}
|
||||
|
@ -114,14 +127,14 @@ public class MixinMinecraft {
|
|||
|
||||
@Inject(method = "rightClickMouse", at = @At("RETURN"))
|
||||
public void rightClickMousePost(CallbackInfo ci) {
|
||||
if (MultiTask.INSTANCE.isEnabled() && !playerController.getIsHittingBlock()) {
|
||||
if (BlockInteraction.isMultiTaskEnabled() && !playerController.getIsHittingBlock()) {
|
||||
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(isHittingBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "sendClickBlockToController", at = @At("HEAD"))
|
||||
public void sendClickBlockToControllerPre(boolean leftClick, CallbackInfo ci) {
|
||||
if (MultiTask.INSTANCE.isEnabled()) {
|
||||
if (BlockInteraction.isMultiTaskEnabled()) {
|
||||
handActive = player.isHandActive();
|
||||
((AccessorEntityPlayerSP) player).kbSetHandActive(false);
|
||||
}
|
||||
|
@ -129,7 +142,7 @@ public class MixinMinecraft {
|
|||
|
||||
@Inject(method = "sendClickBlockToController", at = @At("RETURN"))
|
||||
public void sendClickBlockToControllerPost(boolean leftClick, CallbackInfo ci) {
|
||||
if (MultiTask.INSTANCE.isEnabled() && !player.isHandActive()) {
|
||||
if (BlockInteraction.isMultiTaskEnabled() && !player.isHandActive()) {
|
||||
((AccessorEntityPlayerSP) player).kbSetHandActive(handActive);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.kamiblue.client.mixin.client.accessor.render;
|
||||
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.client.shader.Shader;
|
||||
import net.minecraft.client.shader.ShaderGroup;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -9,8 +10,9 @@ import java.util.List;
|
|||
|
||||
@Mixin(ShaderGroup.class)
|
||||
public interface AccessorShaderGroup {
|
||||
|
||||
@Accessor("listShaders")
|
||||
List<Shader> getListShaders();
|
||||
|
||||
@Accessor("listFramebuffers")
|
||||
List<Framebuffer> getListFramebuffers();
|
||||
}
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package org.kamiblue.client.mixin.client.render;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import org.kamiblue.client.event.KamiEventBus;
|
||||
import org.kamiblue.client.event.events.RenderOverlayEvent;
|
||||
import org.kamiblue.client.module.modules.movement.ElytraFlight;
|
||||
import org.kamiblue.client.module.modules.player.NoEntityTrace;
|
||||
import org.kamiblue.client.module.modules.player.BlockInteraction;
|
||||
import org.kamiblue.client.module.modules.render.AntiFog;
|
||||
import org.kamiblue.client.module.modules.render.AntiOverlay;
|
||||
import org.kamiblue.client.module.modules.render.CameraClip;
|
||||
|
@ -21,12 +18,8 @@ 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.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = EntityRenderer.class, priority = Integer.MAX_VALUE)
|
||||
public class MixinEntityRenderer {
|
||||
|
||||
|
@ -63,12 +56,12 @@ public class MixinEntityRenderer {
|
|||
if (NoHurtCam.INSTANCE.isEnabled()) info.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "getMouseOver", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;getEntitiesInAABBexcluding(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/AxisAlignedBB;Lcom/google/common/base/Predicate;)Ljava/util/List;"))
|
||||
public List<Entity> getEntitiesInAABBexcluding(WorldClient worldClient, Entity entityIn, AxisAlignedBB boundingBox, Predicate<? super Entity> predicate) {
|
||||
if (NoEntityTrace.INSTANCE.shouldIgnoreEntity())
|
||||
return new ArrayList<>();
|
||||
else
|
||||
return worldClient.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
|
||||
@Inject(method = "getMouseOver", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPositionEyes(F)Lnet/minecraft/util/math/Vec3d;", shift = At.Shift.BEFORE), cancellable = true)
|
||||
public void getEntitiesInAABBexcluding(float partialTicks, CallbackInfo ci) {
|
||||
if (BlockInteraction.isNoEntityTraceEnabled()) {
|
||||
ci.cancel();
|
||||
Wrapper.getMinecraft().profiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "orientCamera", at = @At("RETURN"))
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.kamiblue.client.module.modules.movement.Velocity;
|
||||
import org.kamiblue.client.module.modules.player.LiquidInteract;
|
||||
import org.kamiblue.client.module.modules.player.BlockInteraction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -24,7 +24,7 @@ public class MixinBlockLiquid {
|
|||
|
||||
@Inject(method = "canCollideCheck", at = @At("HEAD"), cancellable = true)
|
||||
public void canCollideCheck(IBlockState blockState, boolean hitIfLiquid, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (LiquidInteract.INSTANCE.isEnabled()) {
|
||||
if (BlockInteraction.isLiquidInteractEnabled()) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@ class KamiMod {
|
|||
const val ID = "kamiblue"
|
||||
const val DIRECTORY = "kamiblue/"
|
||||
|
||||
const val VERSION = "2.02.xx-dev" // Used for debugging. R.MM.DD-hash format.
|
||||
const val VERSION_SIMPLE = "2.02.xx-dev" // Shown to the user. R.MM.DD[-beta] format.
|
||||
const val VERSION_MAJOR = "2.02.01" // Used for update checking. RR.MM.01 format.
|
||||
const val VERSION = "2.03.xx-dev" // Used for debugging. R.MM.DD-hash format.
|
||||
const val VERSION_SIMPLE = "2.03.xx-dev" // Shown to the user. R.MM.DD[-beta] format.
|
||||
const val VERSION_MAJOR = "2.03.01" // Used for update checking. RR.MM.01 format.
|
||||
const val BUILD_NUMBER = -1 // Do not remove, currently unused but will be used in the future.
|
||||
|
||||
const val APP_ID = "638403216278683661"
|
||||
|
|
|
@ -148,4 +148,9 @@ object ForgeEventProcessor {
|
|||
fun onClientConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
|
||||
KamiEventBus.post(ConnectionEvent.Connect())
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
fun onRenderFogColors(event: EntityViewRenderEvent.FogColors) {
|
||||
KamiEventBus.post(event)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package org.kamiblue.client.gui.hudgui.elements.player
|
|||
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.gui.hudgui.LabelHud
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.manager.managers.TimerManager
|
||||
import org.kamiblue.commons.utils.MathUtils
|
||||
|
||||
object TimerSpeed : LabelHud(
|
||||
|
@ -13,7 +12,7 @@ object TimerSpeed : LabelHud(
|
|||
) {
|
||||
|
||||
override fun SafeClientEvent.updateText() {
|
||||
val timerSpeed = MathUtils.round(50.0f / mc.timer.tickLength, 2)
|
||||
val timerSpeed = MathUtils.round(50.0f / TimerManager.tickLength, 2)
|
||||
|
||||
displayText.add("%.2f".format(timerSpeed), primaryColor)
|
||||
displayText.add("x", secondaryColor)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
package org.kamiblue.client.manager
|
||||
|
||||
interface Manager
|
||||
import org.kamiblue.client.util.Wrapper
|
||||
|
||||
interface Manager {
|
||||
val mc get() = Wrapper.minecraft
|
||||
}
|
|
@ -9,14 +9,12 @@ import org.kamiblue.client.module.AbstractModule
|
|||
import org.kamiblue.client.module.modules.client.ChatSetting
|
||||
import org.kamiblue.client.util.TaskState
|
||||
import org.kamiblue.client.util.TickTimer
|
||||
import org.kamiblue.client.util.Wrapper
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
import org.kamiblue.event.listener.listener
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
object MessageManager : Manager {
|
||||
private val mc = Wrapper.minecraft
|
||||
private val lockObject = Any()
|
||||
|
||||
private val messageQueue = TreeSet<QueuedMessage>(Comparator.reverseOrder())
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package org.kamiblue.client.manager.managers
|
||||
|
||||
import org.kamiblue.client.event.events.RunGameLoopEvent
|
||||
import org.kamiblue.client.manager.Manager
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.module.AbstractModule
|
||||
import org.kamiblue.client.util.TickTimer
|
||||
import org.kamiblue.client.util.TimeUnit
|
||||
import org.kamiblue.commons.extension.synchronized
|
||||
import org.kamiblue.event.listener.listener
|
||||
import java.util.*
|
||||
|
||||
object TimerManager : Manager {
|
||||
private val timer = TickTimer(TimeUnit.TICKS)
|
||||
private val modifications = TreeMap<AbstractModule, Pair<Float, Long>>(compareByDescending { it.modulePriority }).synchronized() // <Module, <Tick length, Added Time>>
|
||||
|
||||
private var modified = false
|
||||
|
||||
var tickLength = 50.0f; private set
|
||||
|
||||
init {
|
||||
listener<RunGameLoopEvent.Start> {
|
||||
if (timer.tick(5L)) {
|
||||
val removeTime = System.currentTimeMillis() - 250L
|
||||
modifications.values.removeIf { it.second < removeTime }
|
||||
}
|
||||
|
||||
if (mc.player != null && modifications.isNotEmpty()) {
|
||||
modifications.firstEntry()?.let {
|
||||
mc.timer.tickLength = it.value.first
|
||||
}
|
||||
modified = true
|
||||
} else if (modified) {
|
||||
reset()
|
||||
}
|
||||
|
||||
tickLength = mc.timer.tickLength
|
||||
}
|
||||
}
|
||||
|
||||
fun AbstractModule.resetTimer() {
|
||||
modifications.remove(this)
|
||||
}
|
||||
|
||||
fun AbstractModule.modifyTimer(tickLength: Float) {
|
||||
if (mc.player != null) {
|
||||
modifications[this] = tickLength to System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
private fun reset() {
|
||||
mc.timer.tickLength = 50.0f
|
||||
modified = false
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.kamiblue.client.mixin.extension
|
|||
import net.minecraft.client.renderer.RenderGlobal
|
||||
import net.minecraft.client.renderer.ViewFrustum
|
||||
import net.minecraft.client.renderer.entity.RenderManager
|
||||
import net.minecraft.client.shader.Framebuffer
|
||||
import net.minecraft.client.shader.Shader
|
||||
import net.minecraft.client.shader.ShaderGroup
|
||||
import net.minecraft.util.math.BlockPos
|
||||
|
@ -19,6 +20,7 @@ val RenderManager.renderPosZ: Double get() = (this as AccessorRenderManager).ren
|
|||
val RenderManager.renderOutlines: Boolean get() = (this as AccessorRenderManager).renderOutlines
|
||||
|
||||
val ShaderGroup.listShaders: List<Shader> get() = (this as AccessorShaderGroup).listShaders
|
||||
val ShaderGroup.listFrameBuffers: List<Framebuffer> get() = (this as AccessorShaderGroup).listFramebuffers
|
||||
|
||||
// Unused, but kept for consistency. Java equivalent used in Mixins
|
||||
fun ViewFrustum.getRenderChunk(pos: BlockPos) = (this as AccessorViewFrustum).invokeGetRenderChunk(pos)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.kamiblue.client.module.modules.chat
|
||||
|
||||
import net.minecraft.init.Items
|
||||
import net.minecraft.network.play.server.SPacketUpdateHealth
|
||||
import net.minecraft.util.EnumHand
|
||||
import org.kamiblue.client.KamiMod
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.event.events.PacketEvent
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
|
@ -66,7 +69,7 @@ internal object AutoExcuse : Module(
|
|||
init {
|
||||
safeListener<PacketEvent.Receive> {
|
||||
if (loadedExcuses.isEmpty() || it.packet !is SPacketUpdateHealth) return@safeListener
|
||||
if (it.packet.health <= 0f && timer.tick(3L)) {
|
||||
if (it.packet.health <= 0.0f && !isHoldingTotem && timer.tick(3L)) {
|
||||
sendServerMessage(getExcuse())
|
||||
}
|
||||
}
|
||||
|
@ -94,5 +97,8 @@ internal object AutoExcuse : Module(
|
|||
}
|
||||
}
|
||||
|
||||
private val SafeClientEvent.isHoldingTotem: Boolean
|
||||
get() = EnumHand.values().any { player.getHeldItem(it).item == Items.TOTEM_OF_UNDYING }
|
||||
|
||||
private fun getExcuse() = loadedExcuses.random().replace(CLIENT_NAME, clients.random())
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ internal object AutoEZ : Module(
|
|||
description = "Sends an insult in chat after killing someone"
|
||||
) {
|
||||
private val detectMode = setting("Detect Mode", DetectMode.HEALTH)
|
||||
private val messageMode = setting("Messag Mode", MessageMode.ONTOP)
|
||||
private val messageMode = setting("Message Mode", MessageMode.ONTOP)
|
||||
private val customText = setting("Custom Text", "unchanged")
|
||||
|
||||
private enum class DetectMode {
|
||||
|
|
|
@ -61,7 +61,7 @@ internal object Criticals : Module(
|
|||
safeListener<PlayerAttackEvent>(0) {
|
||||
if (it.cancelled || attacking || it.entity !is EntityLivingBase || !canDoCriticals(true)) return@safeListener
|
||||
|
||||
val cooldownReady = player.getCooledAttackStrength(0.5f) > 0.9f
|
||||
val cooldownReady = player.onGround && player.getCooledAttackStrength(0.5f) > 0.9f
|
||||
|
||||
when (mode) {
|
||||
Mode.PACKET -> {
|
||||
|
@ -71,10 +71,10 @@ internal object Criticals : Module(
|
|||
}
|
||||
}
|
||||
Mode.JUMP -> {
|
||||
jumpAndCancel(it, player.onGround && cooldownReady, null)
|
||||
jumpAndCancel(it, cooldownReady, null)
|
||||
}
|
||||
Mode.MINI_JUMP -> {
|
||||
jumpAndCancel(it, player.onGround && cooldownReady, jumpMotion)
|
||||
jumpAndCancel(it, cooldownReady, jumpMotion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,36 @@
|
|||
package org.kamiblue.client.module.modules.combat
|
||||
|
||||
import net.minecraft.network.play.server.SPacketPlayerPosLook
|
||||
import net.minecraft.util.MovementInputFromOptions
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraftforge.client.event.InputUpdateEvent
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.event.events.PacketEvent
|
||||
import org.kamiblue.client.event.events.PlayerMoveEvent
|
||||
import org.kamiblue.client.event.events.PlayerTravelEvent
|
||||
import org.kamiblue.client.event.events.RenderWorldEvent
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.module.modules.movement.Strafe
|
||||
import org.kamiblue.client.util.EntityUtils
|
||||
import org.kamiblue.client.util.EntityUtils.flooredPosition
|
||||
import org.kamiblue.client.util.MovementUtils.isCentered
|
||||
import org.kamiblue.client.util.MovementUtils.resetMove
|
||||
import org.kamiblue.client.util.MovementUtils.speed
|
||||
import org.kamiblue.client.util.combat.SurroundUtils
|
||||
import org.kamiblue.client.util.combat.SurroundUtils.checkHole
|
||||
import org.kamiblue.client.util.graphics.KamiTessellator
|
||||
import org.kamiblue.client.util.math.RotationUtils
|
||||
import org.kamiblue.client.util.math.VectorUtils
|
||||
import org.kamiblue.client.util.math.VectorUtils.distanceTo
|
||||
import org.kamiblue.client.util.math.VectorUtils.toBlockPos
|
||||
import org.kamiblue.client.util.math.VectorUtils.toVec3d
|
||||
import org.kamiblue.client.util.threads.safeAsyncListener
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
import org.kamiblue.commons.extension.ceilToInt
|
||||
import org.kamiblue.commons.extension.toRadian
|
||||
import org.kamiblue.event.listener.listener
|
||||
import org.lwjgl.opengl.GL11.*
|
||||
import kotlin.math.*
|
||||
|
||||
internal object HoleSnap : Module(
|
||||
|
@ -27,37 +38,89 @@ internal object HoleSnap : Module(
|
|||
description = "Move you into the hole nearby",
|
||||
category = Category.COMBAT
|
||||
) {
|
||||
private val airStrafe by setting("Air Strafe", true)
|
||||
private val disableStrafe by setting("Disable Strafe", true)
|
||||
private val range by setting("Range", 2.5f, 0.5f..4.0f, 0.25f)
|
||||
|
||||
private var holePos: BlockPos? = null
|
||||
private var stuckTicks = 0
|
||||
|
||||
init {
|
||||
onDisable {
|
||||
holePos = null
|
||||
stuckTicks = 0
|
||||
}
|
||||
|
||||
safeListener<RenderWorldEvent>(1) {
|
||||
holePos?.let {
|
||||
if (player.flooredPosition == it) return@safeListener
|
||||
|
||||
val posFrom = EntityUtils.getInterpolatedPos(player, KamiTessellator.pTicks())
|
||||
val posTo = it.toVec3d(0.5, 0.0, 0.5)
|
||||
val buffer = KamiTessellator.buffer
|
||||
|
||||
glLineWidth(3.0f)
|
||||
glDisable(GL_DEPTH_TEST)
|
||||
KamiTessellator.begin(GL_LINES)
|
||||
|
||||
buffer.pos(posFrom.x, posFrom.y, posFrom.z).color(32, 255, 32, 2500).endVertex()
|
||||
buffer.pos(posTo.x, posTo.y, posTo.z).color(32, 255, 32, 255).endVertex()
|
||||
|
||||
KamiTessellator.render()
|
||||
glLineWidth(1.0f)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
}
|
||||
}
|
||||
|
||||
listener<PacketEvent.Receive> {
|
||||
if (it.packet is SPacketPlayerPosLook) disable()
|
||||
}
|
||||
|
||||
listener<InputUpdateEvent>(-69) {
|
||||
if (it.movementInput is MovementInputFromOptions && holePos != null) {
|
||||
it.movementInput.resetMove()
|
||||
}
|
||||
}
|
||||
|
||||
safeAsyncListener<PlayerMoveEvent> {
|
||||
if (checkHole(player) != SurroundUtils.HoleType.NONE) {
|
||||
if (!player.isEntityAlive) return@safeAsyncListener
|
||||
|
||||
val currentSpeed = player.speed
|
||||
|
||||
if (shouldDisable(currentSpeed)) {
|
||||
disable()
|
||||
return@safeAsyncListener
|
||||
}
|
||||
|
||||
findHole()?.let {
|
||||
getHole()?.let {
|
||||
if (disableStrafe) Strafe.disable()
|
||||
if (player.onGround && !isAboveHole(it)) {
|
||||
if ((airStrafe || player.onGround) && !player.isCentered(it)) {
|
||||
val playerPos = player.positionVector
|
||||
val targetPos = Vec3d(it.x + 0.5, player.posY, it.z + 0.5)
|
||||
|
||||
val yawRad = RotationUtils.getRotationTo(playerPos, targetPos).x.toRadian()
|
||||
val dist = playerPos.distanceTo(targetPos)
|
||||
val speed = min(0.2805, dist / 2.0)
|
||||
val speed = if (player.onGround) min(0.2805, dist / 2.0) else currentSpeed + 0.02
|
||||
|
||||
player.motionX = -sin(yawRad) * speed
|
||||
player.motionZ = cos(yawRad) * speed
|
||||
|
||||
if (player.collidedHorizontally) stuckTicks++
|
||||
else stuckTicks = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun SafeClientEvent.shouldDisable(currentSpeed: Double) =
|
||||
holePos?.let { player.posY < it.y } ?: false
|
||||
|| stuckTicks > 5 && currentSpeed < 0.1
|
||||
|| currentSpeed < 0.01 && checkHole(player) != SurroundUtils.HoleType.NONE
|
||||
|
||||
private fun SafeClientEvent.getHole() =
|
||||
if (player.ticksExisted % 10 == 0) findHole()
|
||||
else holePos ?: findHole()
|
||||
|
||||
private fun SafeClientEvent.findHole(): BlockPos? {
|
||||
var closestHole = Pair(69.69, BlockPos.ORIGIN)
|
||||
val playerPos = player.positionVector.toBlockPos()
|
||||
|
@ -76,11 +139,7 @@ internal object HoleSnap : Module(
|
|||
}
|
||||
}
|
||||
|
||||
return if (closestHole.second != BlockPos.ORIGIN) closestHole.second else null
|
||||
}
|
||||
|
||||
private fun SafeClientEvent.isAboveHole(holePos: BlockPos): Boolean {
|
||||
return player.posX in holePos.x + 0.31..holePos.x + 0.69
|
||||
&& player.posZ in holePos.z + 0.31..holePos.z + 0.69
|
||||
return if (closestHole.second != BlockPos.ORIGIN) closestHole.second.also { holePos = it }
|
||||
else null
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ import org.kamiblue.client.module.Category
|
|||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.module.modules.movement.Strafe
|
||||
import org.kamiblue.client.util.*
|
||||
import org.kamiblue.client.util.MovementUtils.centerPlayer
|
||||
import org.kamiblue.client.util.MovementUtils.speed
|
||||
import org.kamiblue.client.util.WorldUtils.buildStructure
|
||||
import org.kamiblue.client.util.WorldUtils.getPlaceInfo
|
||||
|
@ -33,19 +34,15 @@ internal object Surround : Module(
|
|||
description = "Surrounds you with obsidian to take less damage",
|
||||
modulePriority = 200
|
||||
) {
|
||||
private val autoCenter = setting("Auto Center", AutoCenterMode.MOTION)
|
||||
private val placeSpeed = setting("Places Per Tick", 4f, 0.25f..5f, 0.25f)
|
||||
private val autoDisable = setting("Auto Disable", AutoDisableMode.OUT_OF_HOLE)
|
||||
private val outOfHoleTimeout = setting("Out Of Hole Timeout", 10, 1..50, 5, { autoDisable.value == AutoDisableMode.OUT_OF_HOLE }, description = "Delay before disabling Surround when you are out of hole, in ticks")
|
||||
private val placeSpeed by setting("Places Per Tick", 4f, 0.25f..5f, 0.25f)
|
||||
private val disableStrafe by setting("Disable Strafe", true)
|
||||
private val autoDisable by setting("Auto Disable", AutoDisableMode.OUT_OF_HOLE)
|
||||
private val outOfHoleTimeout by setting("Out Of Hole Timeout", 10, 1..50, 5, { autoDisable == AutoDisableMode.OUT_OF_HOLE }, description = "Delay before disabling Surround when you are out of hole, in ticks")
|
||||
private val enableInHole = setting("Enable In Hole", false)
|
||||
private val inHoleTimeout = setting("In Hole Timeout", 50, 1..100, 5, { enableInHole.value }, description = "Delay before enabling Surround when you are in hole, in ticks")
|
||||
private val disableStrafe = setting("Disable Strafe", true)
|
||||
private val inHoleTimeout by setting("In Hole Timeout", 50, 1..100, 5, { enableInHole.value }, description = "Delay before enabling Surround when you are in hole, in ticks")
|
||||
private val toggleMessage by setting("Toggle Message", true)
|
||||
|
||||
enum class AutoCenterMode {
|
||||
OFF, TP, MOTION
|
||||
}
|
||||
|
||||
enum class AutoDisableMode {
|
||||
private enum class AutoDisableMode {
|
||||
ONE_TIME, OUT_OF_HOLE
|
||||
}
|
||||
|
||||
|
@ -91,12 +88,19 @@ internal object Surround : Module(
|
|||
toggleTimer.reset()
|
||||
}
|
||||
|
||||
// Placeable & Centered check
|
||||
if (!canRun() || !centerPlayer()) {
|
||||
if (autoDisable.value == AutoDisableMode.ONE_TIME) disable()
|
||||
// Centered check
|
||||
if (!player.centerPlayer()) return@safeListener
|
||||
|
||||
// Placeable
|
||||
if (!canRun()) {
|
||||
if (autoDisable == AutoDisableMode.ONE_TIME) disable()
|
||||
return@safeListener
|
||||
}
|
||||
|
||||
if (disableStrafe) {
|
||||
Strafe.disable()
|
||||
}
|
||||
|
||||
// The actual job
|
||||
if (!job.isActiveOrFalse) {
|
||||
job = runSurround()
|
||||
|
@ -111,8 +115,8 @@ internal object Surround : Module(
|
|||
|
||||
private fun SafeClientEvent.enableInHoleCheck() {
|
||||
if (enableInHole.value && inHoleCheck()) {
|
||||
if (toggleTimer.stop() > inHoleTimeout.value) {
|
||||
MessageSendHelper.sendChatMessage("$chatName You are in hole for longer than ${inHoleTimeout.value} ticks, enabling")
|
||||
if (toggleTimer.stop() > inHoleTimeout) {
|
||||
if (toggleMessage) MessageSendHelper.sendChatMessage("$chatName You are in hole for longer than $inHoleTimeout ticks, enabling")
|
||||
enable()
|
||||
}
|
||||
} else {
|
||||
|
@ -123,9 +127,9 @@ internal object Surround : Module(
|
|||
private fun SafeClientEvent.inHoleCheck() = player.onGround && player.speed < 0.15 && checkHole(player) == SurroundUtils.HoleType.OBBY
|
||||
|
||||
private fun outOfHoleCheck() {
|
||||
if (autoDisable.value == AutoDisableMode.OUT_OF_HOLE) {
|
||||
if (toggleTimer.stop() > outOfHoleTimeout.value) {
|
||||
MessageSendHelper.sendChatMessage("$chatName You are out of hole for longer than ${outOfHoleTimeout.value} ticks, disabling")
|
||||
if (autoDisable == AutoDisableMode.OUT_OF_HOLE) {
|
||||
if (toggleTimer.stop() > outOfHoleTimeout) {
|
||||
if (toggleMessage) MessageSendHelper.sendChatMessage("$chatName You are out of hole for longer than $outOfHoleTimeout ticks, disabling")
|
||||
disable()
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +144,7 @@ internal object Surround : Module(
|
|||
|
||||
if (slots == null) { // Obsidian check
|
||||
if (isEnabled) {
|
||||
MessageSendHelper.sendChatMessage("$chatName No obsidian in hotbar, disabling!")
|
||||
if (toggleMessage) MessageSendHelper.sendChatMessage("$chatName No obsidian in hotbar, disabling!")
|
||||
disable()
|
||||
}
|
||||
return null
|
||||
|
@ -158,19 +162,10 @@ internal object Surround : Module(
|
|||
return false
|
||||
}
|
||||
|
||||
private fun centerPlayer(): Boolean {
|
||||
return if (autoCenter.value == AutoCenterMode.OFF) {
|
||||
true
|
||||
} else {
|
||||
if (disableStrafe.value) Strafe.disable()
|
||||
SurroundUtils.centerPlayer(autoCenter.value == AutoCenterMode.TP)
|
||||
}
|
||||
}
|
||||
|
||||
private fun SafeClientEvent.runSurround() = defaultScope.launch {
|
||||
spoofHotbar()
|
||||
|
||||
buildStructure(placeSpeed.value) {
|
||||
buildStructure(placeSpeed) {
|
||||
if (isEnabled && CombatManager.isOnTopPriority(this@Surround)) {
|
||||
getPlaceInfo(player.positionVector.toBlockPos(), SurroundUtils.surroundOffset, it, 2)
|
||||
} else {
|
||||
|
|
|
@ -13,107 +13,112 @@ import org.kamiblue.client.module.Module
|
|||
import org.kamiblue.client.util.color.EnumTextColor
|
||||
import org.kamiblue.client.util.text.MessageSendHelper
|
||||
import org.kamiblue.client.util.text.MessageSendHelper.sendServerMessage
|
||||
import org.kamiblue.client.util.text.format
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
import org.kamiblue.commons.extension.synchronized
|
||||
import org.kamiblue.event.listener.listener
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
import kotlin.collections.LinkedHashMap
|
||||
|
||||
internal object TotemPopCounter : Module(
|
||||
name = "TotemPopCounter",
|
||||
description = "Counts how many times players pop",
|
||||
category = Category.COMBAT
|
||||
) {
|
||||
private val countFriends = setting("Count Friends", true)
|
||||
private val countSelf = setting("Count Self", false)
|
||||
private val resetOnDeath = setting("Reset On Death", true)
|
||||
private val announceSetting = setting("Announce", Announce.CLIENT)
|
||||
private val thanksTo = setting("Thanks To", false)
|
||||
private val colorName = setting("Color Name", EnumTextColor.DARK_PURPLE)
|
||||
private val colorNumber = setting("Color Number", EnumTextColor.LIGHT_PURPLE)
|
||||
private val countFriends by setting("Count Friends", true)
|
||||
private val countSelf by setting("Count Self", true)
|
||||
private val announceSetting by setting("Announce", Announce.CLIENT)
|
||||
private val thanksTo by setting("Thanks To", false)
|
||||
private val colorName by setting("Color Name", EnumTextColor.DARK_PURPLE)
|
||||
private val colorNumber by setting("Color Number", EnumTextColor.LIGHT_PURPLE)
|
||||
|
||||
private enum class Announce {
|
||||
CLIENT, EVERYONE
|
||||
}
|
||||
|
||||
private val playerList = HashMap<EntityPlayer, Int>().synchronized()
|
||||
private var wasDead = false
|
||||
private val popCountMap = WeakHashMap<EntityPlayer, Int>().synchronized()
|
||||
private var wasSent = false
|
||||
|
||||
init {
|
||||
onDisable {
|
||||
playerList.clear()
|
||||
popCountMap.clear()
|
||||
wasSent = true
|
||||
}
|
||||
|
||||
safeListener<PacketEvent.Receive> {
|
||||
if (it.packet !is SPacketEntityStatus || it.packet.opCode.toInt() != 35 || player.isDead) return@safeListener
|
||||
if (it.packet !is SPacketEntityStatus || it.packet.opCode.toInt() != 35 || !player.isEntityAlive) return@safeListener
|
||||
val player = (it.packet.getEntity(world) as? EntityPlayer) ?: return@safeListener
|
||||
|
||||
if (friendCheck(player) || selfCheck(player)) {
|
||||
val count = playerList.getOrDefault(player, 0) + 1
|
||||
playerList[player] = count
|
||||
sendMessage("${formatName(player)} popped ${formatNumber(count)} ${plural(count)}${ending()}")
|
||||
if (friendCheck(player) && selfCheck(player)) {
|
||||
val count = popCountMap.getOrDefault(player, 0) + 1
|
||||
popCountMap[player] = count
|
||||
|
||||
val isSelf = player == this.player
|
||||
val message = "${formatName(player)} popped ${formatNumber(count)} ${plural(count)}${ending(isSelf)}"
|
||||
sendMessage(message, !isSelf && isPublic)
|
||||
}
|
||||
}
|
||||
|
||||
listener<ConnectionEvent.Disconnect> {
|
||||
playerList.clear()
|
||||
popCountMap.clear()
|
||||
}
|
||||
|
||||
safeListener<TickEvent.ClientTickEvent> {
|
||||
if (it.phase != TickEvent.Phase.END) return@safeListener
|
||||
|
||||
if (wasDead && !player.isDead && resetOnDeath.value) {
|
||||
sendMessage("${formatName(player)} died and ${grammar(player)} pop list was reset!")
|
||||
playerList.clear()
|
||||
wasDead = false
|
||||
if (!player.isEntityAlive) {
|
||||
if (!wasSent) {
|
||||
popCountMap.clear()
|
||||
wasSent = true
|
||||
}
|
||||
return@safeListener
|
||||
}
|
||||
|
||||
val toRemove = ArrayList<EntityPlayer>()
|
||||
for ((poppedPlayer, count) in playerList) {
|
||||
if (!poppedPlayer.isDead) continue
|
||||
if (poppedPlayer == player) continue
|
||||
sendMessage("${formatName(poppedPlayer)} died after popping ${formatNumber(count)} ${plural(count)}${ending()}")
|
||||
toRemove.add(poppedPlayer)
|
||||
wasSent = false
|
||||
|
||||
popCountMap.entries.removeIf { (player, count) ->
|
||||
if (player == this.player || player.isEntityAlive) {
|
||||
false
|
||||
} else {
|
||||
val message = "${formatName(player)} died after popping ${formatNumber(count)} ${plural(count)}${ending(false)}"
|
||||
sendMessage(message, isPublic)
|
||||
true
|
||||
}
|
||||
}
|
||||
playerList.keys.removeAll(toRemove)
|
||||
|
||||
wasDead = player.isDead
|
||||
}
|
||||
}
|
||||
|
||||
private fun friendCheck(player: EntityPlayer) = FriendManager.isFriend(player.name) && countFriends.value
|
||||
private fun friendCheck(player: EntityPlayer) = countFriends || !FriendManager.isFriend(player.name)
|
||||
|
||||
private fun selfCheck(player: EntityPlayer) = player == mc.player && countSelf.value
|
||||
private fun selfCheck(player: EntityPlayer) = countSelf || player != mc.player
|
||||
|
||||
private fun formatName(player: EntityPlayer): String {
|
||||
val name = when {
|
||||
player == mc.player -> "I"
|
||||
FriendManager.isFriend(player.name) -> if (isPublic) "My friend, " else "Your friend, "
|
||||
else -> player.name
|
||||
private fun formatName(player: EntityPlayer) =
|
||||
colorName.textFormatting format when {
|
||||
player == mc.player -> {
|
||||
"I"
|
||||
}
|
||||
FriendManager.isFriend(player.name) -> {
|
||||
if (isPublic) "My friend ${player.name}, " else "Your friend ${player.name}, "
|
||||
}
|
||||
else -> {
|
||||
player.name
|
||||
}
|
||||
}
|
||||
return colorName.value.textFormatting.toString() + name + TextFormatting.RESET
|
||||
}
|
||||
|
||||
private val isPublic: Boolean
|
||||
get() = announceSetting.value == Announce.EVERYONE
|
||||
get() = announceSetting == Announce.EVERYONE
|
||||
|
||||
private fun formatNumber(message: Int) = colorNumber.textFormatting format message
|
||||
|
||||
private fun plural(count: Int) = if (count == 1) "totem" else "totems"
|
||||
|
||||
private fun grammar(player: EntityPlayer) = if (player == mc.player) "my" else "their"
|
||||
private fun ending(self: Boolean): String = if (!self && thanksTo) " thanks to ${KamiMod.NAME} !" else "!"
|
||||
|
||||
private fun ending(): String = if (thanksTo.value) " thanks to ${KamiMod.NAME} !" else "!"
|
||||
|
||||
private fun formatNumber(message: Int) = colorNumber.value.textFormatting.toString() + message + TextFormatting.RESET
|
||||
|
||||
private fun sendMessage(message: String) {
|
||||
when (announceSetting.value) {
|
||||
Announce.CLIENT -> {
|
||||
MessageSendHelper.sendChatMessage("$chatName $message")
|
||||
}
|
||||
Announce.EVERYONE -> {
|
||||
sendServerMessage(TextFormatting.getTextWithoutFormattingCodes(message))
|
||||
}
|
||||
private fun sendMessage(message: String, public: Boolean) {
|
||||
if (public) {
|
||||
sendServerMessage(TextFormatting.getTextWithoutFormattingCodes(message))
|
||||
} else {
|
||||
MessageSendHelper.sendChatMessage("$chatName $message")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import net.minecraft.util.EnumHand
|
|||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.RayTraceResult
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import net.minecraft.world.EnumDifficulty
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.event.events.BlockBreakEvent
|
||||
|
@ -69,9 +70,9 @@ internal object AutoObsidian : Module(
|
|||
private val instantMiningDelay by setting("Instant Mining Delay", 10, 1..20, 1, { instantMining })
|
||||
private val threshold by setting("Refill Threshold", 32, 1..64, 1, { autoRefill && fillMode != FillMode.INFINITE })
|
||||
private val targetStacks by setting("Target Stacks", 1, 1..20, 1, { fillMode == FillMode.TARGET_STACKS })
|
||||
private val delayTicks by setting("Delay Ticks", 5, 1..10, 1)
|
||||
private val delayTicks by setting("Delay Ticks", 4, 1..10, 1)
|
||||
private val rotationMode by setting("Rotation Mode", RotationMode.SPOOF)
|
||||
private val maxReach by setting("Max Reach", 4.5f, 2.0f..6.0f, 0.1f)
|
||||
private val maxReach by setting("Max Reach", 4.9f, 2.0f..6.0f, 0.1f)
|
||||
|
||||
private enum class FillMode(override val displayName: String, val message: String) : DisplayEnum {
|
||||
TARGET_STACKS("Target Stacks", "Target stacks reached"),
|
||||
|
@ -82,6 +83,7 @@ internal object AutoObsidian : Module(
|
|||
enum class State(override val displayName: String) : DisplayEnum {
|
||||
SEARCHING("Searching"),
|
||||
PLACING("Placing"),
|
||||
PRE_MINING("Pre Mining"),
|
||||
MINING("Mining"),
|
||||
COLLECTING("Collecting"),
|
||||
DONE("Done")
|
||||
|
@ -90,6 +92,7 @@ internal object AutoObsidian : Module(
|
|||
enum class SearchingState(override val displayName: String) : DisplayEnum {
|
||||
PLACING("Placing"),
|
||||
OPENING("Opening"),
|
||||
PRE_MINING("Pre Mining"),
|
||||
MINING("Mining"),
|
||||
COLLECTING("Collecting"),
|
||||
DONE("Done")
|
||||
|
@ -171,7 +174,10 @@ internal object AutoObsidian : Module(
|
|||
}
|
||||
|
||||
safeListener<TickEvent.ClientTickEvent>(69) {
|
||||
if (it.phase != TickEvent.Phase.START || PauseProcess.isActive) return@safeListener
|
||||
if (it.phase != TickEvent.Phase.START || PauseProcess.isActive ||
|
||||
(world.difficulty == EnumDifficulty.PEACEFUL &&
|
||||
player.dimension == 1 &&
|
||||
player.serverBrand.contains("2b2t"))) return@safeListener
|
||||
|
||||
updateMiningMap()
|
||||
runAutoObby()
|
||||
|
@ -215,8 +221,11 @@ internal object AutoObsidian : Module(
|
|||
State.PLACING -> {
|
||||
placeEnderChest(placingPos)
|
||||
}
|
||||
State.PRE_MINING -> {
|
||||
mineBlock(placingPos, true)
|
||||
}
|
||||
State.MINING -> {
|
||||
mineBlock(placingPos)
|
||||
mineBlock(placingPos, false)
|
||||
}
|
||||
State.COLLECTING -> {
|
||||
collectDroppedItem(Blocks.OBSIDIAN.id)
|
||||
|
@ -307,7 +316,7 @@ internal object AutoObsidian : Module(
|
|||
startPlacing()
|
||||
}
|
||||
state == State.PLACING && !world.isAirBlock(placingPos) -> {
|
||||
State.MINING
|
||||
State.PRE_MINING
|
||||
}
|
||||
state == State.SEARCHING && searchingState == SearchingState.DONE && passCountCheck -> {
|
||||
startPlacing()
|
||||
|
@ -396,14 +405,14 @@ internal object AutoObsidian : Module(
|
|||
}
|
||||
searchingState == SearchingState.OPENING
|
||||
&& (enderChestCount > 0 || player.inventorySlots.firstEmpty() == null) -> {
|
||||
SearchingState.MINING
|
||||
SearchingState.PRE_MINING
|
||||
}
|
||||
searchingState == SearchingState.PLACING && !world.isAirBlock(placingPos) -> {
|
||||
if (world.getBlockState(placingPos).block is BlockShulkerBox) {
|
||||
SearchingState.OPENING
|
||||
} else {
|
||||
// In case if the shulker wasn't placed due to server lag
|
||||
SearchingState.MINING
|
||||
SearchingState.PRE_MINING
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
|
@ -425,8 +434,11 @@ internal object AutoObsidian : Module(
|
|||
SearchingState.OPENING -> {
|
||||
openShulker(placingPos)
|
||||
}
|
||||
SearchingState.PRE_MINING -> {
|
||||
mineBlock(placingPos, true)
|
||||
}
|
||||
SearchingState.MINING -> {
|
||||
mineBlock(placingPos)
|
||||
mineBlock(placingPos, false)
|
||||
}
|
||||
SearchingState.COLLECTING -> {
|
||||
collectDroppedItem(shulkerID)
|
||||
|
@ -503,7 +515,7 @@ internal object AutoObsidian : Module(
|
|||
player.closeScreen()
|
||||
} else if (shulkerOpenTimer.tick(100, false)) { // Wait for maximum of 5 seconds
|
||||
if (leaveEmptyShulkers && container.inventory.subList(0, 27).all { it.isEmpty }) {
|
||||
searchingState = SearchingState.MINING
|
||||
searchingState = SearchingState.PRE_MINING
|
||||
player.closeScreen()
|
||||
} else {
|
||||
MessageSendHelper.sendChatMessage("$chatName No ender chest was found in shulker, disabling.")
|
||||
|
@ -565,7 +577,7 @@ internal object AutoObsidian : Module(
|
|||
}
|
||||
}
|
||||
|
||||
private fun SafeClientEvent.mineBlock(pos: BlockPos) {
|
||||
private fun SafeClientEvent.mineBlock(pos: BlockPos, pre: Boolean) {
|
||||
if (!swapToValidPickaxe()) return
|
||||
|
||||
val center = pos.toVec3dCenter()
|
||||
|
@ -589,8 +601,12 @@ internal object AutoObsidian : Module(
|
|||
defaultScope.launch {
|
||||
delay(20L)
|
||||
onMainThreadSafe {
|
||||
connection.sendPacket(CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, side))
|
||||
connection.sendPacket(CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, side))
|
||||
if (pre || miningTimeoutTimer.tick(8L)) {
|
||||
connection.sendPacket(CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, side))
|
||||
if (state != State.SEARCHING) state = State.MINING else searchingState = SearchingState.MINING
|
||||
} else {
|
||||
connection.sendPacket(CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, side))
|
||||
}
|
||||
player.swingArm(EnumHand.MAIN_HAND)
|
||||
lastMiningSide = side
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.kamiblue.client.module.modules.movement
|
||||
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
||||
import org.kamiblue.client.manager.managers.TimerManager.modifyTimer
|
||||
import org.kamiblue.client.manager.managers.TimerManager.resetTimer
|
||||
import org.kamiblue.client.mixin.extension.isInWeb
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
|
@ -11,7 +11,8 @@ import org.kamiblue.client.util.threads.safeListener
|
|||
internal object FastFall : Module(
|
||||
name = "FastFall",
|
||||
category = Category.MOVEMENT,
|
||||
description = "Makes you fall faster"
|
||||
description = "Makes you fall faster",
|
||||
modulePriority = 50
|
||||
) {
|
||||
private val mode = setting("Mode", Mode.MOTION)
|
||||
private val fallSpeed = setting("Fall Speed", 6.0, 0.1..10.0, 0.1)
|
||||
|
@ -43,7 +44,7 @@ internal object FastFall : Module(
|
|||
motioning = true
|
||||
}
|
||||
Mode.TIMER -> {
|
||||
mc.timer.tickLength = 50.0f / (fallSpeed.value * 2.0f).toFloat()
|
||||
modifyTimer(50.0f / (fallSpeed.value * 2.0f).toFloat())
|
||||
timering = true
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +58,7 @@ internal object FastFall : Module(
|
|||
|
||||
private fun reset() {
|
||||
if (timering) {
|
||||
mc.timer.tickLength = 50.0f
|
||||
resetTimer()
|
||||
timering = false
|
||||
}
|
||||
motioning = false
|
||||
|
|
|
@ -3,9 +3,9 @@ package org.kamiblue.client.module.modules.movement
|
|||
import net.minecraft.client.settings.KeyBinding
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.event.events.PlayerTravelEvent
|
||||
import org.kamiblue.client.manager.managers.TimerManager.modifyTimer
|
||||
import org.kamiblue.client.manager.managers.TimerManager.resetTimer
|
||||
import org.kamiblue.client.mixin.extension.isInWeb
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.util.BaritoneUtils
|
||||
|
@ -24,9 +24,9 @@ import kotlin.math.sin
|
|||
internal object Strafe : Module(
|
||||
name = "Strafe",
|
||||
category = Category.MOVEMENT,
|
||||
description = "Improves control in air"
|
||||
description = "Improves control in air",
|
||||
modulePriority = 100
|
||||
) {
|
||||
|
||||
private val mode by setting("Mode", SpeedBoost.NCP)
|
||||
private val page by setting("Page", Page.GENERIC_SETTINGS)
|
||||
|
||||
|
@ -73,7 +73,7 @@ internal object Strafe : Module(
|
|||
|
||||
|
||||
if (airSpeedBoost) player.jumpMovementFactor = 0.029f
|
||||
if (timerBoost) mc.timer.tickLength = 45.87155914306640625f
|
||||
if (timerBoost) modifyTimer(45.87155914306640625f)
|
||||
if (!player.collidedHorizontally) {
|
||||
if (autoJump) jump()
|
||||
setSpeed(getSpeed())
|
||||
|
@ -85,7 +85,7 @@ internal object Strafe : Module(
|
|||
|
||||
private fun reset() {
|
||||
mc.player?.jumpMovementFactor = 0.02f
|
||||
mc.timer.tickLength = 50.0f
|
||||
resetTimer()
|
||||
jumpTicks = 0
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import net.minecraft.item.ItemPickaxe
|
||||
import net.minecraft.util.math.RayTraceResult
|
||||
import org.kamiblue.client.mixin.client.MixinMinecraft
|
||||
import org.kamiblue.client.mixin.client.render.MixinEntityRenderer
|
||||
import org.kamiblue.client.mixin.client.world.MixinBlockLiquid
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
|
||||
/**
|
||||
* @see MixinBlockLiquid Liquid Interact
|
||||
* @see MixinMinecraft Multi Task
|
||||
* @see MixinEntityRenderer No Entity Trace
|
||||
*/
|
||||
internal object BlockInteraction : Module(
|
||||
name = "BlockInteraction",
|
||||
alias = arrayOf("LiquidInteract", "MultiTask", "NoEntityTrace", "NoMiningTrace"),
|
||||
category = Category.PLAYER,
|
||||
description = "Modifies block interaction"
|
||||
) {
|
||||
private val liquidInteract by setting("Liquid Interact", false, description = "Place block on liquid")
|
||||
private val multiTask by setting("Multi Task", true, description = "Breaks block and uses item at the same time")
|
||||
private val noEntityTrace by setting("No Entity Trace", true, description = "Interact with blocks through entity")
|
||||
private val checkBlocks by setting("Check Blocks", true, { noEntityTrace }, description = "Only ignores entity when there is block behind")
|
||||
private val checkPickaxe by setting("Check Pickaxe", true, { noEntityTrace }, description = "Only ignores entity when holding pickaxe")
|
||||
private val sneakOverrides by setting("Sneak Override", true, { noEntityTrace && checkPickaxe }, description = "Overrides pickaxe check if sneaking")
|
||||
|
||||
@JvmStatic
|
||||
val isLiquidInteractEnabled
|
||||
get() = isEnabled && liquidInteract
|
||||
|
||||
@JvmStatic
|
||||
val isMultiTaskEnabled
|
||||
get() = isEnabled && multiTask
|
||||
|
||||
@JvmStatic
|
||||
fun isNoEntityTraceEnabled() : Boolean {
|
||||
if (isDisabled || !noEntityTrace) return false
|
||||
|
||||
val objectMouseOver = mc.objectMouseOver
|
||||
val holdingPickAxe = mc.player?.heldItemMainhand?.item is ItemPickaxe
|
||||
val sneaking = mc.gameSettings.keyBindSneak.isKeyDown
|
||||
|
||||
return (!checkBlocks || objectMouseOver != null && objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) // Blocks
|
||||
&& (!checkPickaxe || holdingPickAxe // Pickaxe
|
||||
|| sneakOverrides && sneaking) // Override
|
||||
}
|
||||
}
|
|
@ -25,9 +25,10 @@ import org.kamiblue.client.module.Category
|
|||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.util.*
|
||||
import org.kamiblue.client.util.MovementUtils.calcMoveYaw
|
||||
import org.kamiblue.client.util.MovementUtils.resetJumpSneak
|
||||
import org.kamiblue.client.util.MovementUtils.resetMove
|
||||
import org.kamiblue.client.util.math.RotationUtils
|
||||
import org.kamiblue.client.util.math.RotationUtils.getRotationTo
|
||||
import org.kamiblue.client.util.math.VectorUtils.toBlockPos
|
||||
import org.kamiblue.client.util.threads.onMainThreadSafe
|
||||
import org.kamiblue.client.util.threads.runSafeR
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
|
@ -45,13 +46,14 @@ internal object Freecam : Module(
|
|||
category = Category.PLAYER,
|
||||
description = "Leave your body and transcend into the realm of the gods"
|
||||
) {
|
||||
private val directionMode = setting("Flight Mode", FlightMode.CREATIVE)
|
||||
private val horizontalSpeed = setting("Horizontal Speed", 20f, 1f..50f, 1f)
|
||||
private val verticalSpeed = setting("Vertical Speed", 20f, 1f..50f, 1f)
|
||||
private val autoRotate = setting("Auto Rotate", true)
|
||||
private val arrowKeyMove = setting("Arrow Key Move", true)
|
||||
private val disableOnDisconnect = setting("Disconnect Disable", true)
|
||||
private val leftClickCome = setting("Left Click Come", true)
|
||||
private val directionMode by setting("Flight Mode", FlightMode.CREATIVE)
|
||||
private val horizontalSpeed by setting("Horizontal Speed", 20.0f, 1.0f..50.0f, 1f)
|
||||
private val verticalSpeed by setting("Vertical Speed", 20.0f, 1.0f..50.0f, 1f, { directionMode == FlightMode.CREATIVE })
|
||||
private val autoRotate by setting("Auto Rotate", true)
|
||||
private val arrowKeyMove by setting("Arrow Key Move", true)
|
||||
private val disableOnDisconnect by setting("Disconnect Disable", true)
|
||||
private val leftClickCome by setting("Left Click Come", false)
|
||||
private val relative by setting("Relative", false)
|
||||
|
||||
private enum class FlightMode(override val displayName: String) : DisplayEnum {
|
||||
CREATIVE("Creative"),
|
||||
|
@ -112,7 +114,7 @@ internal object Freecam : Module(
|
|||
|
||||
listener<ConnectionEvent.Disconnect> {
|
||||
prevThirdPersonViewSetting = -1
|
||||
if (disableOnDisconnect.value) disable()
|
||||
if (disableOnDisconnect) disable()
|
||||
else cameraGuy = null
|
||||
}
|
||||
|
||||
|
@ -149,35 +151,26 @@ internal object Freecam : Module(
|
|||
|
||||
if (BaritoneUtils.isActive) return@safeListener
|
||||
|
||||
if (autoRotate.value) updatePlayerRotation()
|
||||
if (arrowKeyMove.value) updatePlayerMovement()
|
||||
if (autoRotate) updatePlayerRotation()
|
||||
if (arrowKeyMove) updatePlayerMovement()
|
||||
}
|
||||
|
||||
listener<InputEvent.MouseInputEvent> {
|
||||
if (leftClickCome.value && Mouse.getEventButton() == 0 && clickTimer.tick(1L)) {
|
||||
if (leftClickCome && Mouse.getEventButton() == 0 && clickTimer.tick(1L)) {
|
||||
val result = mc.objectMouseOver ?: return@listener
|
||||
|
||||
if (result.typeOfHit != RayTraceResult.Type.BLOCK) {
|
||||
return@listener
|
||||
if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
BaritoneUtils.cancelEverything()
|
||||
BaritoneUtils.primary?.customGoalProcess?.setGoalAndPath(GoalTwoBlocks(result.blockPos))
|
||||
}
|
||||
|
||||
BaritoneUtils.cancelEverything()
|
||||
BaritoneUtils.primary?.customGoalProcess?.setGoalAndPath(GoalTwoBlocks(result.hitVec.toBlockPos()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetMovementInput(movementInput: MovementInput?) {
|
||||
if (movementInput !is MovementInputFromOptions) return
|
||||
movementInput.apply {
|
||||
moveForward = 0f
|
||||
moveStrafe = 0f
|
||||
forwardKeyDown = false
|
||||
backKeyDown = false
|
||||
leftKeyDown = false
|
||||
rightKeyDown = false
|
||||
jump = false
|
||||
sneak = false
|
||||
if (movementInput is MovementInputFromOptions) {
|
||||
movementInput.resetMove()
|
||||
movementInput.resetJumpSneak()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,16 +212,16 @@ internal object Freecam : Module(
|
|||
|
||||
val yawDiff = player.rotationYaw - it.rotationYaw
|
||||
val yawRad = calcMoveYaw(yawDiff, movementInput.first, movementInput.second).toFloat()
|
||||
val inputTotal = min(abs(movementInput.first) + abs(movementInput.second), 1f)
|
||||
val inputTotal = min(abs(movementInput.first) + abs(movementInput.second), 1.0f)
|
||||
|
||||
player.movementInput?.apply {
|
||||
moveForward = cos(yawRad) * inputTotal
|
||||
moveStrafe = sin(yawRad) * inputTotal
|
||||
|
||||
forwardKeyDown = moveForward > 0f
|
||||
backKeyDown = moveForward < 0f
|
||||
leftKeyDown = moveStrafe < 0f
|
||||
rightKeyDown = moveStrafe > 0f
|
||||
forwardKeyDown = moveForward > 0.0f
|
||||
backKeyDown = moveForward < 0.0f
|
||||
leftKeyDown = moveStrafe < 0.0f
|
||||
rightKeyDown = moveStrafe > 0.0f
|
||||
|
||||
jump = Keyboard.isKeyDown(Keyboard.KEY_RCONTROL)
|
||||
}
|
||||
|
@ -273,17 +266,18 @@ internal object Freecam : Module(
|
|||
// Update sprinting
|
||||
isSprinting = mc.gameSettings.keyBindSprint.isKeyDown
|
||||
|
||||
val yawRad = (rotationYaw - RotationUtils.getRotationFromVec(Vec3d(moveStrafing.toDouble(), 0.0, moveForward.toDouble())).x).toDouble().toRadian()
|
||||
val speed = (horizontalSpeed.value / 20f) * min(abs(moveForward) + abs(moveStrafing), 1f)
|
||||
val absYaw = RotationUtils.getRotationFromVec(Vec3d(moveStrafing.toDouble(), 0.0, moveForward.toDouble())).x
|
||||
val yawRad = (rotationYaw - absYaw).toDouble().toRadian()
|
||||
val speed = (horizontalSpeed / 20.0f) * min(abs(moveForward) + abs(moveStrafing), 1.0f)
|
||||
|
||||
if (directionMode.value == FlightMode.THREE_DEE) {
|
||||
val pitchRad = Math.toRadians(rotationPitch.toDouble()) * moveForward
|
||||
if (directionMode == FlightMode.THREE_DEE) {
|
||||
val pitchRad = rotationPitch.toDouble().toRadian() * moveForward
|
||||
motionX = -sin(yawRad) * cos(pitchRad) * speed
|
||||
motionY = -sin(pitchRad) * speed
|
||||
motionZ = cos(yawRad) * cos(pitchRad) * speed
|
||||
} else {
|
||||
motionX = -sin(yawRad) * speed
|
||||
motionY = moveVertical.toDouble() * (verticalSpeed.value / 20f)
|
||||
motionY = moveVertical.toDouble() * (verticalSpeed / 20.0f)
|
||||
motionZ = cos(yawRad) * speed
|
||||
}
|
||||
|
||||
|
@ -293,13 +287,19 @@ internal object Freecam : Module(
|
|||
motionZ *= 1.5
|
||||
}
|
||||
|
||||
noClip = true
|
||||
if (relative) {
|
||||
motionX += player.posX - player.prevPosX
|
||||
motionY += player.posY - player.prevPosY
|
||||
motionZ += player.posZ - player.prevPosZ
|
||||
}
|
||||
|
||||
move(MoverType.SELF, motionX, motionY, motionZ)
|
||||
}
|
||||
|
||||
override fun getEyeHeight() = 1.65f
|
||||
|
||||
override fun isSpectator() = true
|
||||
|
||||
override fun isInvisible() = true
|
||||
|
||||
override fun isInvisibleToPlayer(player: EntityPlayer) = true
|
||||
|
@ -315,23 +315,23 @@ internal object Freecam : Module(
|
|||
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
|
||||
if (forward.first) 1.0f else -1.0f
|
||||
} else {
|
||||
0f
|
||||
0.0f
|
||||
}
|
||||
|
||||
// Strafe movement input
|
||||
val moveStrafing = if (strafe.first xor strafe.second) {
|
||||
if (strafe.second) 1f else -1f
|
||||
if (strafe.second) 1.0f else -1.0f
|
||||
} else {
|
||||
0f
|
||||
0.0f
|
||||
}
|
||||
|
||||
// Vertical movement input
|
||||
val moveVertical = if (vertical.first xor vertical.second) {
|
||||
if (vertical.first) 1f else -1f
|
||||
if (vertical.first) 1.0f else -1.0f
|
||||
} else {
|
||||
0f
|
||||
0.0f
|
||||
}
|
||||
|
||||
return Triple(moveForward, moveStrafing, moveVertical)
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import org.kamiblue.client.mixin.client.world.MixinBlockLiquid
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
|
||||
/**
|
||||
* @see MixinBlockLiquid
|
||||
*/
|
||||
internal object LiquidInteract : Module(
|
||||
name = "LiquidInteract",
|
||||
category = Category.PLAYER,
|
||||
description = "Place blocks on liquid!"
|
||||
)
|
|
@ -1,10 +0,0 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
|
||||
internal object MultiTask : Module(
|
||||
name = "MultiTask",
|
||||
category = Category.PLAYER,
|
||||
description = "Breaks block and uses item at the same time"
|
||||
)
|
|
@ -1,17 +0,0 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import net.minecraft.item.ItemPickaxe
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
|
||||
internal object NoEntityTrace : Module(
|
||||
name = "NoEntityTrace",
|
||||
category = Category.PLAYER,
|
||||
description = "Blocks entities from stopping you from mining"
|
||||
) {
|
||||
private val sneakTrigger = setting("Sneak Trigger", false)
|
||||
private val pickaxeOnly = setting("Pickaxe Only", true)
|
||||
|
||||
fun shouldIgnoreEntity() = isEnabled && (!sneakTrigger.value || mc.player?.isSneaking == true)
|
||||
&& (!pickaxeOnly.value || mc.player?.heldItemMainhand?.item is ItemPickaxe)
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import net.minecraft.network.play.client.CPacketPlayer
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
||||
import org.kamiblue.client.event.events.ConnectionEvent
|
||||
import org.kamiblue.client.event.events.PacketEvent
|
||||
import org.kamiblue.client.manager.managers.TimerManager.modifyTimer
|
||||
import org.kamiblue.client.manager.managers.TimerManager.resetTimer
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.event.listener.listener
|
||||
import kotlin.math.min
|
||||
|
||||
internal object PacketLimiter : Module(
|
||||
name = "PacketLimiter",
|
||||
category = Category.PLAYER,
|
||||
description = "Adjust timer automatically to ensure not sending too many movement packets",
|
||||
modulePriority = 1000
|
||||
) {
|
||||
private val maxPacketsLong by setting("Max Packets Long", 22.0f, 10.0f..40.0f, 0.25f,
|
||||
description = "Maximum packets per second in long term")
|
||||
private val longTermTicks by setting("Long Term Ticks", 100, 20..250, 5)
|
||||
private val maxPacketsShort by setting("Max Packets Short", 25.0f, 10.0f..40.0f, 0.25f,
|
||||
description = "Maximum packets per second in short term")
|
||||
private val shortTermTicks by setting("Short Term Ticks", 20, 5..50, 1)
|
||||
private val minTimer by setting("Min Timer", 0.6f, 0.1f..1.0f, 0.01f)
|
||||
|
||||
private var lastPacketTime = -1L
|
||||
|
||||
private val longPacketTime = ArrayDeque<Short>( 100)
|
||||
private val shortPacketTime = ArrayDeque<Short>(20)
|
||||
|
||||
private var longPacketSpeed = 20.0f
|
||||
private var shortPacketSpeed = 20.0f
|
||||
private var prevTimerSpeed = 1.0f
|
||||
|
||||
init {
|
||||
onDisable {
|
||||
resetTimer()
|
||||
reset()
|
||||
}
|
||||
|
||||
listener<ConnectionEvent.Disconnect> {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
private fun reset() {
|
||||
lastPacketTime = -1L
|
||||
|
||||
synchronized(PacketLimiter) {
|
||||
longPacketTime.clear()
|
||||
shortPacketTime.clear()
|
||||
}
|
||||
|
||||
longPacketSpeed = 20.0f
|
||||
shortPacketSpeed = 20.0f
|
||||
}
|
||||
|
||||
init {
|
||||
listener<PacketEvent.PostSend> {
|
||||
if (it.cancelled || it.packet !is CPacketPlayer) return@listener
|
||||
|
||||
if (lastPacketTime != -1L) {
|
||||
val duration = (System.currentTimeMillis() - lastPacketTime).toShort()
|
||||
|
||||
synchronized(PacketLimiter) {
|
||||
longPacketTime.addAndTrim(duration, longTermTicks)
|
||||
shortPacketTime.addAndTrim(duration, shortTermTicks)
|
||||
|
||||
longPacketSpeed = (1000.0 / shortPacketTime.average()).toFloat()
|
||||
shortPacketSpeed = (1000.0 / shortPacketTime.average()).toFloat()
|
||||
}
|
||||
}
|
||||
|
||||
lastPacketTime = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
listener<TickEvent.ClientTickEvent>(Int.MIN_VALUE) { event ->
|
||||
if (event.phase != TickEvent.Phase.END) return@listener
|
||||
|
||||
if (maxPacketsLong <= maxPacketsShort) {
|
||||
limit(longPacketSpeed, maxPacketsLong) ?: limit(shortPacketSpeed, maxPacketsShort)
|
||||
} else {
|
||||
limit(longPacketSpeed, maxPacketsLong) ?: limit(shortPacketSpeed, maxPacketsShort)
|
||||
}?.let {
|
||||
prevTimerSpeed = min(it, prevTimerSpeed).coerceAtLeast(minTimer)
|
||||
modifyTimer(50.0f / prevTimerSpeed)
|
||||
} ?: run {
|
||||
prevTimerSpeed = 1.0f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun ArrayDeque<Short>.addAndTrim(value: Short, max: Int) {
|
||||
add(value)
|
||||
val validMax = max.coerceAtLeast(0)
|
||||
while (this.size > validMax){
|
||||
this.removeFirst()
|
||||
}
|
||||
}
|
||||
|
||||
private fun limit(input: Float, max: Float) =
|
||||
if (input > max) max / input else null
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.kamiblue.client.util.text.MessageSendHelper
|
|||
import org.kamiblue.client.util.threads.defaultScope
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
import org.kamiblue.commons.interfaces.DisplayEnum
|
||||
import org.kamiblue.event.listener.listener
|
||||
import java.io.*
|
||||
import java.time.LocalTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
@ -39,10 +40,10 @@ internal object PacketLogger : Module(
|
|||
private val ignoreCancelled by setting("Ignore Cancelled", true, description = "Ignore cancelled packets.")
|
||||
|
||||
private val fileTimeFormatter = DateTimeFormatter.ofPattern("HH-mm-ss_SSS")
|
||||
private val logTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS")
|
||||
|
||||
private var start = 0L
|
||||
private var last = 0L
|
||||
private var lastTick = 0L
|
||||
private val timer = TickTimer(TimeUnit.SECONDS)
|
||||
|
||||
private const val directory = "${KamiMod.DIRECTORY}packetLogs"
|
||||
|
@ -73,8 +74,10 @@ internal object PacketLogger : Module(
|
|||
if (it.phase != TickEvent.Phase.START) return@safeListener
|
||||
|
||||
if (showClientTicks) {
|
||||
synchronized(this) {
|
||||
lines.add("Tick Pulse - Realtime: ${logTimeFormatter.format(LocalTime.now())} - Runtime: ${System.currentTimeMillis() - start}ms\n")
|
||||
synchronized(this@PacketLogger) {
|
||||
val current = System.currentTimeMillis()
|
||||
lines.add("Tick Pulse,,${current - start},${current - lastTick}\n")
|
||||
lastTick = current
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,215 +91,305 @@ internal object PacketLogger : Module(
|
|||
disable()
|
||||
}
|
||||
|
||||
safeListener<PacketEvent.Receive>(Int.MIN_VALUE) {
|
||||
if (ignoreCancelled && it.cancelled) return@safeListener
|
||||
listener<PacketEvent.PostReceive>(Int.MIN_VALUE) {
|
||||
if (ignoreCancelled && it.cancelled) return@listener
|
||||
|
||||
if (packetSide == PacketSide.SERVER || packetSide == PacketSide.BOTH) {
|
||||
when (it.packet) {
|
||||
is SPacketEntityTeleport -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"x: ${it.packet.x} " +
|
||||
"y: ${it.packet.y} " +
|
||||
"z: ${it.packet.z} " +
|
||||
"pitch: ${it.packet.pitch} " +
|
||||
"yaw: ${it.packet.yaw} " +
|
||||
"entityID: ${it.packet.entityId}")
|
||||
}
|
||||
is SPacketEntityMetadata -> {
|
||||
val dataEntry = StringBuilder().run {
|
||||
append("dataEntries: ")
|
||||
for (entry in it.packet.dataManagerEntries) {
|
||||
append("> isDirty: ${entry.isDirty} key: ${entry.key} value: ${entry.value} ")
|
||||
}
|
||||
toString()
|
||||
}
|
||||
|
||||
add(PacketSide.SERVER, it.packet, dataEntry)
|
||||
}
|
||||
is SPacketUnloadChunk -> {
|
||||
if (!ignoreChunkLoading) {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"x: ${it.packet.x} " +
|
||||
"z: ${it.packet.z}")
|
||||
}
|
||||
}
|
||||
is SPacketDestroyEntities -> {
|
||||
val entities = StringBuilder().run {
|
||||
append("entityIDs: ")
|
||||
for (entry in it.packet.entityIDs) {
|
||||
append("> $entry ")
|
||||
}
|
||||
toString()
|
||||
}
|
||||
|
||||
add(PacketSide.SERVER, it.packet, entities)
|
||||
}
|
||||
is SPacketPlayerPosLook -> {
|
||||
val flags = StringBuilder().run {
|
||||
append("flags: ")
|
||||
for (entry in it.packet.flags) {
|
||||
append("> ${entry.name} ")
|
||||
}
|
||||
toString()
|
||||
}
|
||||
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"x: ${it.packet.x} " +
|
||||
"y: ${it.packet.y} " +
|
||||
"z: ${it.packet.z} " +
|
||||
"pitch: ${it.packet.pitch} " +
|
||||
"yaw: ${it.packet.yaw} " +
|
||||
"teleportID: ${it.packet.teleportId}" +
|
||||
flags)
|
||||
|
||||
}
|
||||
is SPacketBlockChange -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"x: ${it.packet.blockPosition.x} " +
|
||||
"y: ${it.packet.blockPosition.y} " +
|
||||
"z: ${it.packet.blockPosition.z}")
|
||||
}
|
||||
is SPacketMultiBlockChange -> {
|
||||
val changedBlock = StringBuilder().run {
|
||||
append("changedBlocks: ")
|
||||
for (changedBlock in it.packet.changedBlocks) {
|
||||
append("> x: ${changedBlock.pos.x} y: ${changedBlock.pos.y} z: ${changedBlock.pos.z} ")
|
||||
}
|
||||
toString()
|
||||
log(it) {
|
||||
"x" to it.packet.blockPosition.x
|
||||
"y" to it.packet.blockPosition.y
|
||||
"z" to it.packet.blockPosition.z
|
||||
}
|
||||
|
||||
add(PacketSide.SERVER, it.packet, changedBlock)
|
||||
}
|
||||
is SPacketTimeUpdate -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"totalWorldTime: ${it.packet.totalWorldTime} " +
|
||||
"worldTime: ${it.packet.worldTime}")
|
||||
}
|
||||
is SPacketChat -> {
|
||||
if (!ignoreChat) {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"unformattedText: ${it.packet.chatComponent.unformattedText} " +
|
||||
"type: ${it.packet.type} " +
|
||||
"isSystem: ${it.packet.isSystem}")
|
||||
log(it) {
|
||||
"unformattedText" to it.packet.chatComponent.unformattedText
|
||||
"type" to it.packet.type
|
||||
"itSystem" to it.packet.isSystem
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketTeams -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"action: ${it.packet.action} " +
|
||||
"displayName: ${it.packet.displayName} " +
|
||||
"color: ${it.packet.color}")
|
||||
}
|
||||
is SPacketChunkData -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"chunkX: ${it.packet.chunkX} " +
|
||||
"chunkZ: ${it.packet.chunkZ} " +
|
||||
"extractedSize: ${it.packet.extractedSize}")
|
||||
log(it) {
|
||||
"chunkX" to it.packet.chunkX
|
||||
"chunkZ" to it.packet.chunkZ
|
||||
"extractedSize" to it.packet.extractedSize
|
||||
}
|
||||
}
|
||||
is SPacketConfirmTransaction -> {
|
||||
log(it) {
|
||||
"windowId" to it.packet.windowId
|
||||
"transactionID" to it.packet.actionNumber
|
||||
"accepted" to it.packet.wasAccepted()
|
||||
}
|
||||
}
|
||||
is SPacketDestroyEntities -> {
|
||||
log(it) {
|
||||
"entityIDs" to buildString {
|
||||
for (entry in it.packet.entityIDs) {
|
||||
append("> ")
|
||||
append(entry)
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketEntityMetadata -> {
|
||||
log(it) {
|
||||
"dataEntries" to buildString {
|
||||
for (entry in it.packet.dataManagerEntries) {
|
||||
append("> isDirty: ")
|
||||
append(entry.isDirty)
|
||||
|
||||
append(" key: ")
|
||||
append(entry.key)
|
||||
|
||||
append(" value: ")
|
||||
append(entry.value)
|
||||
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketEntityProperties -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"entityID: ${it.packet.entityId}")
|
||||
log(it) {
|
||||
"entityID" to it.packet.entityId
|
||||
}
|
||||
}
|
||||
is SPacketUpdateTileEntity -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"posX: ${it.packet.pos.x} " +
|
||||
"posY: ${it.packet.pos.y} " +
|
||||
"posZ: ${it.packet.pos.z}")
|
||||
}
|
||||
is SPacketSpawnObject -> {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"entityID: ${it.packet.entityID} " +
|
||||
"data: ${it.packet.data}")
|
||||
is SPacketEntityTeleport -> {
|
||||
log(it) {
|
||||
"x" to it.packet.x
|
||||
"y" to it.packet.y
|
||||
"z" to it.packet.z
|
||||
"yaw" to it.packet.yaw
|
||||
"pitch" to it.packet.pitch
|
||||
"entityID" to it.packet.entityId
|
||||
}
|
||||
}
|
||||
is SPacketKeepAlive -> {
|
||||
if (!ignoreKeepAlive) {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"id: ${it.packet.id}")
|
||||
log(it) {
|
||||
"id" to it.packet.id
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketMultiBlockChange -> {
|
||||
log(it) {
|
||||
"changedBlocks" to buildString {
|
||||
for (changedBlock in it.packet.changedBlocks) {
|
||||
append("> x: ")
|
||||
append(changedBlock.pos.x)
|
||||
|
||||
append("y: ")
|
||||
append(changedBlock.pos.y)
|
||||
|
||||
append("z: ")
|
||||
append(changedBlock.pos.z)
|
||||
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketPlayerPosLook -> {
|
||||
log(it) {
|
||||
"x" to it.packet.x
|
||||
"y" to it.packet.y
|
||||
"z" to it.packet.z
|
||||
"yaw" to it.packet.yaw
|
||||
"pitch" to it.packet.pitch
|
||||
"teleportID" to it.packet.teleportId
|
||||
"flags" to buildString {
|
||||
for (entry in it.packet.flags) {
|
||||
append("> ")
|
||||
append(entry.name)
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketSoundEffect -> {
|
||||
log(it) {
|
||||
"sound" to it.packet.sound.soundName
|
||||
"category" to it.packet.category
|
||||
"posX" to it.packet.x
|
||||
"posY" to it.packet.y
|
||||
"posZ" to it.packet.z
|
||||
"volume" to it.packet.volume
|
||||
"pitch" to it.packet.pitch
|
||||
}
|
||||
}
|
||||
is SPacketSpawnObject -> {
|
||||
log(it) {
|
||||
"entityID" to it.packet.entityID
|
||||
"data" to it.packet.data
|
||||
}
|
||||
}
|
||||
is SPacketTeams -> {
|
||||
log(it) {
|
||||
"action" to it.packet.action
|
||||
"type" to it.packet.displayName
|
||||
"itSystem" to it.packet.color
|
||||
}
|
||||
}
|
||||
is SPacketTimeUpdate -> {
|
||||
log(it) {
|
||||
"totalWorldTime" to it.packet.totalWorldTime
|
||||
"worldTime" to it.packet.worldTime
|
||||
}
|
||||
}
|
||||
is SPacketUnloadChunk -> {
|
||||
if (!ignoreChunkLoading) {
|
||||
log(it) {
|
||||
"x" to it.packet.x
|
||||
"z" to it.packet.z
|
||||
}
|
||||
}
|
||||
}
|
||||
is SPacketUpdateTileEntity -> {
|
||||
log(it) {
|
||||
"x" to it.packet.pos.x
|
||||
"y" to it.packet.pos.y
|
||||
"z" to it.packet.pos.z
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (!ignoreUnknown) {
|
||||
add(PacketSide.SERVER, it.packet, "Not Registered in PacketLogger.kt")
|
||||
log(it) {
|
||||
+ "Not Registered in PacketLogger"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
safeListener<PacketEvent.Send>(Int.MIN_VALUE) {
|
||||
if (ignoreCancelled && it.cancelled) return@safeListener
|
||||
listener<PacketEvent.PostSend>(Int.MIN_VALUE) {
|
||||
if (ignoreCancelled && it.cancelled) return@listener
|
||||
|
||||
if (packetSide == PacketSide.CLIENT || packetSide == PacketSide.BOTH) {
|
||||
when (it.packet) {
|
||||
is CPacketAnimation -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"hand: ${it.packet.hand}")
|
||||
}
|
||||
is CPacketPlayer.Rotation -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"pitch: ${it.packet.pitch} " +
|
||||
"yaw: ${it.packet.yaw} " +
|
||||
"onGround: ${it.packet.isOnGround}")
|
||||
}
|
||||
is CPacketPlayer.Position -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"x: ${it.packet.x} " +
|
||||
"y: ${it.packet.y} " +
|
||||
"z: ${it.packet.z} " +
|
||||
"onGround: ${it.packet.isOnGround}")
|
||||
}
|
||||
is CPacketPlayer.PositionRotation -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"x: ${it.packet.x} " +
|
||||
"y: ${it.packet.y} " +
|
||||
"z: ${it.packet.z} " +
|
||||
"pitch: ${it.packet.pitch} " +
|
||||
"yaw: ${it.packet.yaw} " +
|
||||
"onGround: ${it.packet.isOnGround}")
|
||||
}
|
||||
is CPacketPlayerDigging -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"positionX: ${it.packet.position.x} " +
|
||||
"positionY: ${it.packet.position.y} " +
|
||||
"positionZ: ${it.packet.position.z} " +
|
||||
"facing: ${it.packet.facing} " +
|
||||
"action: ${it.packet.action} ")
|
||||
}
|
||||
is CPacketEntityAction -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"action: ${it.packet.action} " +
|
||||
"auxData: ${it.packet.auxData}")
|
||||
}
|
||||
is CPacketUseEntity -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"action: ${it.packet.action} " +
|
||||
"hand: ${it.packet.hand} " +
|
||||
"hitVecX: ${it.packet.hitVec.x} " +
|
||||
"hitVecY: ${it.packet.hitVec.y} " +
|
||||
"hitVecZ: ${it.packet.hitVec.z}")
|
||||
}
|
||||
is CPacketPlayerTryUseItem -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"hand: ${it.packet.hand}")
|
||||
}
|
||||
is CPacketConfirmTeleport -> {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"teleportID: ${it.packet.teleportId}")
|
||||
log(it) {
|
||||
"hand" to it.packet.hand
|
||||
}
|
||||
}
|
||||
is CPacketChatMessage -> {
|
||||
if (!ignoreChat) {
|
||||
add(PacketSide.SERVER, it.packet,
|
||||
"message: ${it.packet.message}")
|
||||
log(it) {
|
||||
"message" to it.packet.message
|
||||
}
|
||||
}
|
||||
}
|
||||
is CPacketClickWindow -> {
|
||||
if (!ignoreChat) {
|
||||
log(it) {
|
||||
"windowId" to it.packet.windowId
|
||||
"slotID" to it.packet.slotId
|
||||
"mouseButton" to it.packet.usedButton
|
||||
"clickType" to it.packet.clickType
|
||||
"transactionID" to it.packet.actionNumber
|
||||
"clickedItem" to it.packet.clickedItem
|
||||
}
|
||||
}
|
||||
}
|
||||
is CPacketConfirmTeleport -> {
|
||||
log(it) {
|
||||
"teleportID" to it.packet.teleportId
|
||||
}
|
||||
}
|
||||
is CPacketEntityAction -> {
|
||||
log(it) {
|
||||
"action" to it.packet.action.name
|
||||
"auxData" to it.packet.auxData
|
||||
}
|
||||
}
|
||||
is CPacketHeldItemChange -> {
|
||||
log(it) {
|
||||
"slotID" to it.packet.slotId
|
||||
}
|
||||
}
|
||||
is CPacketKeepAlive -> {
|
||||
if (!ignoreKeepAlive) {
|
||||
add(PacketSide.CLIENT, it.packet,
|
||||
"key: ${it.packet.key}")
|
||||
log(it) {
|
||||
"ket" to it.packet.key
|
||||
}
|
||||
}
|
||||
}
|
||||
is CPacketPlayer.Rotation -> {
|
||||
log(it) {
|
||||
"yaw" to it.packet.yaw
|
||||
"pitch" to it.packet.pitch
|
||||
"onGround" to it.packet.isOnGround
|
||||
}
|
||||
}
|
||||
is CPacketPlayer.Position -> {
|
||||
log(it) {
|
||||
"x" to it.packet.x
|
||||
"y" to it.packet.y
|
||||
"z" to it.packet.z
|
||||
"onGround" to it.packet.isOnGround
|
||||
}
|
||||
}
|
||||
is CPacketPlayer.PositionRotation -> {
|
||||
log(it) {
|
||||
"x" to it.packet.x
|
||||
"y" to it.packet.y
|
||||
"z" to it.packet.z
|
||||
"yaw" to it.packet.yaw
|
||||
"pitch" to it.packet.pitch
|
||||
"onGround" to it.packet.isOnGround
|
||||
}
|
||||
}
|
||||
is CPacketPlayer -> {
|
||||
log(it) {
|
||||
"onGround" to it.packet.isOnGround
|
||||
}
|
||||
}
|
||||
is CPacketPlayerDigging -> {
|
||||
log(it) {
|
||||
"x" to it.packet.position.x
|
||||
"y" to it.packet.position.y
|
||||
"z" to it.packet.position.z
|
||||
"facing" to it.packet.facing
|
||||
"action" to it.packet.action
|
||||
}
|
||||
}
|
||||
is CPacketPlayerTryUseItem -> {
|
||||
log(it) {
|
||||
"hand" to it.packet.hand
|
||||
}
|
||||
}
|
||||
is CPacketPlayerTryUseItemOnBlock -> {
|
||||
log(it) {
|
||||
"x" to it.packet.pos.x
|
||||
"y" to it.packet.pos.y
|
||||
"z" to it.packet.pos.z
|
||||
"side" to it.packet.direction
|
||||
"hitVecX" to it.packet.facingX
|
||||
"hitVecY" to it.packet.facingY
|
||||
"hitVecZ" to it.packet.facingZ
|
||||
}
|
||||
}
|
||||
is CPacketUseEntity -> {
|
||||
@Suppress("UNNECESSARY_SAFE_CALL")
|
||||
log(it) {
|
||||
"action" to it.packet.action
|
||||
"action" to it.packet.hand
|
||||
"hitVecX" to it.packet.hitVec?.x
|
||||
"hitVecX" to it.packet.hitVec?.y
|
||||
"hitVecX" to it.packet.hitVec?.z
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
if (!ignoreUnknown) {
|
||||
add(PacketSide.CLIENT, it.packet, "Not Registered in PacketLogger.kt")
|
||||
log(it) {
|
||||
+ "Not Registered in PacketLogger"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,24 +419,72 @@ internal object PacketLogger : Module(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line to the csv following the format:
|
||||
* from (client or server), packet name, time since start, time since last packet, packet data
|
||||
*
|
||||
* @param side The [PacketSide] where this packet is from
|
||||
* @param packet Packet to add
|
||||
* @param data Data of the [packet] in [String]
|
||||
*/
|
||||
private fun add(side: PacketSide, packet: Packet<*>, data: String) {
|
||||
val string = "${side.displayName},${packet.javaClass.simpleName},${System.currentTimeMillis() - start},${System.currentTimeMillis() - last},${data}\n"
|
||||
private inline fun log(event: PacketEvent.PostSend, block: PacketLogBuilder.() -> Unit) {
|
||||
PacketLogBuilder(PacketSide.CLIENT, event.packet).apply(block).build()
|
||||
}
|
||||
|
||||
synchronized(this) {
|
||||
lines.add(string)
|
||||
last = System.currentTimeMillis()
|
||||
private inline fun log(event: PacketEvent.PostReceive, block: PacketLogBuilder.() -> Unit) {
|
||||
PacketLogBuilder(PacketSide.SERVER, event.packet).apply(block).build()
|
||||
}
|
||||
|
||||
private class PacketLogBuilder(val side: PacketSide, val packet: Packet<*>) {
|
||||
private val stringBuilder = StringBuilder()
|
||||
|
||||
init {
|
||||
stringBuilder.apply {
|
||||
append(side.displayName)
|
||||
append(',')
|
||||
|
||||
append(packet.javaClass.simpleName)
|
||||
append(',')
|
||||
|
||||
append(System.currentTimeMillis() - start)
|
||||
append(',')
|
||||
|
||||
append(System.currentTimeMillis() - last)
|
||||
append(',')
|
||||
}
|
||||
}
|
||||
|
||||
if (logInChat) {
|
||||
MessageSendHelper.sendChatMessage(string)
|
||||
operator fun String.unaryPlus() {
|
||||
stringBuilder.append(this)
|
||||
}
|
||||
|
||||
infix fun String.to(value: Any?) {
|
||||
if (value != null) {
|
||||
add(this, value.toString())
|
||||
}
|
||||
}
|
||||
|
||||
infix fun String.to(value: String?) {
|
||||
if (value != null) {
|
||||
add(this, value)
|
||||
}
|
||||
}
|
||||
|
||||
fun add(key: String, value: String) {
|
||||
stringBuilder.apply {
|
||||
append(key)
|
||||
append(": ")
|
||||
append(value)
|
||||
append(' ')
|
||||
}
|
||||
}
|
||||
|
||||
fun build() {
|
||||
val string = stringBuilder.run {
|
||||
append('\n')
|
||||
toString()
|
||||
}
|
||||
|
||||
synchronized(PacketLogger) {
|
||||
lines.add(string)
|
||||
last = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
if (logInChat) {
|
||||
MessageSendHelper.sendChatMessage(string)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package org.kamiblue.client.module.modules.player
|
||||
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.manager.managers.TimerManager.modifyTimer
|
||||
import org.kamiblue.client.manager.managers.TimerManager.resetTimer
|
||||
import org.kamiblue.client.module.Category
|
||||
import org.kamiblue.client.module.Module
|
||||
import org.kamiblue.client.util.threads.safeListener
|
||||
import org.kamiblue.event.listener.listener
|
||||
|
||||
internal object Timer : Module(
|
||||
name = "Timer",
|
||||
category = Category.PLAYER,
|
||||
description = "Changes your client tick speed"
|
||||
description = "Changes your client tick speed",
|
||||
modulePriority = 500
|
||||
) {
|
||||
private val slow by setting("Slow Mode", false)
|
||||
private val tickNormal by setting("Tick N", 2.0f, 1f..10f, 0.1f, { !slow })
|
||||
|
@ -18,13 +19,14 @@ internal object Timer : Module(
|
|||
|
||||
init {
|
||||
onDisable {
|
||||
mc.timer.tickLength = 50.0f
|
||||
resetTimer()
|
||||
}
|
||||
|
||||
safeListener<TickEvent.ClientTickEvent> {
|
||||
mc.timer.tickLength = 50.0f /
|
||||
if (!slow) tickNormal
|
||||
else (tickSlow / 10.0f)
|
||||
listener<TickEvent.ClientTickEvent> {
|
||||
if (it.phase != TickEvent.Phase.END) return@listener
|
||||
|
||||
val multiplier = if (!slow) tickNormal else tickSlow / 10.0f
|
||||
modifyTimer(50.0f / multiplier)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,12 +8,14 @@ import net.minecraft.entity.item.EntityXPOrb
|
|||
import net.minecraft.entity.projectile.EntityArrow
|
||||
import net.minecraft.entity.projectile.EntityThrowable
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent
|
||||
import org.kamiblue.client.event.Phase
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.event.events.RenderEntityEvent
|
||||
import org.kamiblue.client.event.events.RenderWorldEvent
|
||||
import org.kamiblue.client.mixin.extension.entityOutlineShader
|
||||
import org.kamiblue.client.mixin.extension.listFrameBuffers
|
||||
import org.kamiblue.client.mixin.extension.listShaders
|
||||
import org.kamiblue.client.mixin.extension.renderOutlines
|
||||
import org.kamiblue.client.module.Category
|
||||
|
@ -144,6 +146,12 @@ internal object ESP : Module(
|
|||
}
|
||||
|
||||
init {
|
||||
safeListener<EntityViewRenderEvent.FogColors> { event ->
|
||||
shaderHelper.shader?.listFrameBuffers?.forEach {
|
||||
it.setFramebufferColor(event.red, event.green, event.blue, 0.0f)
|
||||
}
|
||||
}
|
||||
|
||||
safeListener<RenderWorldEvent> {
|
||||
if (mc.renderManager.options == null) return@safeListener
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.kamiblue.client.util
|
||||
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.mixin.extension.tickLength
|
||||
import org.kamiblue.client.mixin.extension.timer
|
||||
import org.kamiblue.client.manager.managers.TimerManager
|
||||
import org.kamiblue.client.util.MovementUtils.realSpeed
|
||||
|
||||
object InfoCalculator {
|
||||
|
@ -14,7 +13,7 @@ object InfoCalculator {
|
|||
fun ping() = mc.player?.let { mc.connection?.getPlayerInfo(it.uniqueID)?.responseTime ?: 1 } ?: -1
|
||||
|
||||
fun SafeClientEvent.speed(): Double {
|
||||
val tps = 1000.0 / mc.timer.tickLength
|
||||
val tps = 1000.0 / TimerManager.tickLength
|
||||
return player.realSpeed * tps
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package org.kamiblue.client.util
|
||||
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.entity.EntityPlayerSP
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.init.MobEffects
|
||||
import net.minecraft.util.MovementInput
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.util.math.VectorUtils.toBlockPos
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.hypot
|
||||
import kotlin.math.round
|
||||
import kotlin.math.sin
|
||||
|
||||
object MovementUtils {
|
||||
|
@ -50,4 +56,42 @@ object MovementUtils {
|
|||
player.getActivePotionEffect(MobEffects.SPEED)?.let {
|
||||
speed * (1.0 + (it.amplifier + 1) * 0.2)
|
||||
} ?: speed
|
||||
|
||||
fun EntityPlayerSP.centerPlayer(): Boolean {
|
||||
val center = Vec3d(round(this.posX + 0.5) - 0.5, this.posY, round(this.posZ + 0.5) - 0.5)
|
||||
val centered = isCentered(center.toBlockPos())
|
||||
|
||||
if (!centered) {
|
||||
this.motionX = (center.x - this.posX) / 2.0
|
||||
this.motionZ = (center.z - this.posZ) / 2.0
|
||||
|
||||
val speed = this.speed
|
||||
|
||||
if (speed > 0.2805) {
|
||||
val multiplier = 0.2805 / speed
|
||||
this.motionX *= multiplier
|
||||
this.motionZ *= multiplier
|
||||
}
|
||||
}
|
||||
|
||||
return centered
|
||||
}
|
||||
|
||||
fun Entity.isCentered(pos: BlockPos) =
|
||||
this.posX in pos.x + 0.31..pos.x + 0.69
|
||||
&& this.posZ in pos.z + 0.31..pos.z + 0.69
|
||||
|
||||
fun MovementInput.resetMove() {
|
||||
moveForward = 0.0f
|
||||
moveStrafe = 0.0f
|
||||
forwardKeyDown = false
|
||||
backKeyDown = false
|
||||
leftKeyDown = false
|
||||
rightKeyDown = false
|
||||
}
|
||||
|
||||
fun MovementInput.resetJumpSneak() {
|
||||
jump = false
|
||||
sneak = false
|
||||
}
|
||||
}
|
|
@ -4,11 +4,9 @@ import net.minecraft.block.Block
|
|||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import org.kamiblue.client.event.SafeClientEvent
|
||||
import org.kamiblue.client.util.EntityUtils.flooredPosition
|
||||
import org.kamiblue.client.util.Wrapper
|
||||
import kotlin.math.round
|
||||
|
||||
object SurroundUtils {
|
||||
private val mc = Wrapper.minecraft
|
||||
|
@ -21,13 +19,6 @@ object SurroundUtils {
|
|||
BlockPos(-1, 0, 0) // west
|
||||
)
|
||||
|
||||
val surroundOffsetNoFloor = arrayOf(
|
||||
BlockPos(0, 0, -1), // north
|
||||
BlockPos(1, 0, 0), // east
|
||||
BlockPos(0, 0, 1), // south
|
||||
BlockPos(-1, 0, 0) // west
|
||||
)
|
||||
|
||||
fun SafeClientEvent.checkHole(entity: Entity) =
|
||||
checkHole(entity.flooredPosition)
|
||||
|
||||
|
@ -51,38 +42,10 @@ object SurroundUtils {
|
|||
return type
|
||||
}
|
||||
|
||||
fun checkBlock(block: Block): Boolean {
|
||||
private fun checkBlock(block: Block): Boolean {
|
||||
return block == Blocks.BEDROCK || block == Blocks.OBSIDIAN || block == Blocks.ENDER_CHEST || block == Blocks.ANVIL
|
||||
}
|
||||
|
||||
fun centerPlayer(tp: Boolean): Boolean {
|
||||
val centerDiff = getCenterDiff()
|
||||
val centered = isCentered()
|
||||
if (!centered) {
|
||||
if (tp) {
|
||||
val posX = mc.player.posX + (centerDiff.x).coerceIn(-0.2, 0.2)
|
||||
val posZ = mc.player.posZ + (centerDiff.z).coerceIn(-0.2, 0.2)
|
||||
mc.player.setPosition(posX, mc.player.posY, posZ)
|
||||
} else {
|
||||
mc.player.motionX = (centerDiff.x / 2.0).coerceIn(-0.2, 0.2)
|
||||
mc.player.motionZ = (centerDiff.z / 2.0).coerceIn(-0.2, 0.2)
|
||||
}
|
||||
}
|
||||
return centered
|
||||
}
|
||||
|
||||
private fun isCentered(): Boolean {
|
||||
return getCenterDiff().length() < 0.2
|
||||
}
|
||||
|
||||
private fun getCenterDiff(): Vec3d {
|
||||
return Vec3d(roundToCenter(mc.player.posX), mc.player.posY, roundToCenter(mc.player.posZ)).subtract(mc.player.positionVector)
|
||||
}
|
||||
|
||||
private fun roundToCenter(doubleIn: Double): Double {
|
||||
return round(doubleIn + 0.5) - 0.5
|
||||
}
|
||||
|
||||
enum class HoleType {
|
||||
NONE, OBBY, BEDROCK
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue