Fixed CrystalAura hotbar swapping

This commit is contained in:
Xiaro 2021-03-12 13:28:06 -05:00
parent 9e9ad03712
commit 6919ad20f2
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 24 additions and 6 deletions

View File

@ -1,5 +1,6 @@
package org.kamiblue.client.module.modules.combat
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraft.entity.item.EntityEnderCrystal
import net.minecraft.init.Items
import net.minecraft.init.MobEffects
@ -303,12 +304,7 @@ internal object CrystalAura : Module(
private fun SafeClientEvent.place() {
getPlacingPos()?.let { pos ->
if (autoSwap) {
player.hotbarSlots.firstItem(Items.END_CRYSTAL)?.let {
if (spoofHotbar) spoofHotbar(it.hotbarSlot, 1000L)
else swapToSlot(it)
}
}
swapToCrystal()
val hand = getHand()
inactiveTicks = 0
@ -327,6 +323,28 @@ internal object CrystalAura : Module(
}
}
private fun SafeClientEvent.swapToCrystal() {
if (autoSwap && player.heldItemOffhand.item != Items.END_CRYSTAL) {
if (spoofHotbar) {
val slot = if (player.serverSideItem.item == Items.END_CRYSTAL) HotbarManager.serverSideHotbar
else player.getCrystalSlot()?.hotbarSlot
if (slot != null) {
spoofHotbar(slot, 1000L)
}
} else {
if (player.serverSideItem.item != Items.END_CRYSTAL) {
player.getCrystalSlot()?.let {
swapToSlot(it)
}
}
}
}
}
private fun EntityPlayerSP.getCrystalSlot() =
this.hotbarSlots.firstItem(Items.END_CRYSTAL)
private fun SafeClientEvent.getPlacePacket(pos: BlockPos, hand: EnumHand): CPacketPlayerTryUseItemOnBlock {
val side = getClosestVisibleSide(pos) ?: EnumFacing.UP
return CPacketPlayerTryUseItemOnBlock(pos, side, hand, 0.5f, placeOffset, 0.5f)