Skip to content

Commit

Permalink
Did some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
superblaubeere27 committed Aug 2, 2021
1 parent bf9cc3f commit e9d9b2b
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2016 - 2021 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/

package net.ccbluex.liquidbounce.injection.mixins.minecraft.render;

import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.item.BuiltinModelItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;

@Mixin(BuiltinModelItemRenderer.class)
public class MixinBuiltinModelItemRenderer {

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelPart;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V"), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/Items;SHIELD:Lnet/minecraft/item/Item;"), to = @At(value = "FIELD", target = "Lnet/minecraft/item/Items;TRIDENT:Lnet/minecraft/item/Item;")))
private void injectTransparentShield(ModelPart modelPart, MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
modelPart.render(matrices, vertices, light, overlay, red, 0.5F, 0.5F, 0.7F);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import net.ccbluex.liquidbounce.event.repeatable
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.item.convertClientSlotToServerSlot
import net.ccbluex.liquidbounce.utils.item.findHotbarSlot
import net.ccbluex.liquidbounce.utils.item.findInventorySlot
import net.minecraft.client.gui.screen.ingame.InventoryScreen
import net.minecraft.client.util.InputUtil
import net.minecraft.item.Items
Expand Down Expand Up @@ -52,13 +54,9 @@ object ModuleAutoGapple : Module("AutoGapple", Category.COMBAT) {

val repeatable = repeatable {
// Check first with Hotbar and see if it has any apples
val slot = (0..8).firstOrNull {
player.inventory.getStack(it).item == Items.GOLDEN_APPLE
}
val slot = findHotbarSlot(Items.GOLDEN_APPLE)

val invSlot = (0..40).find {
!player.inventory.getStack(it).isEmpty && player.inventory.getStack(it).item == Items.GOLDEN_APPLE
}
val invSlot = findInventorySlot(Items.GOLDEN_APPLE)

// If both have been checked but neither of these provide any result
if (slot == null && invSlot == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import net.ccbluex.liquidbounce.event.repeatable
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.item.convertClientSlotToServerSlot
import net.ccbluex.liquidbounce.utils.item.findHotbarSlot
import net.ccbluex.liquidbounce.utils.item.findInventorySlot
import net.minecraft.client.gui.screen.ingame.InventoryScreen
import net.minecraft.item.Item
import net.minecraft.item.Items
Expand Down Expand Up @@ -50,27 +52,21 @@ object ModuleAutoSoup : Module("AutoSoup", Category.COMBAT) {
private var saveSlot = false

val repeatable = repeatable {
val hotBarSlot = (0..8).firstOrNull {
hasItem(it, Items.MUSHROOM_STEW)
}
val mushroomStewSlot = findHotbarSlot(Items.MUSHROOM_STEW)

val bowlSlot = (0..8).firstOrNull {
hasItem(it, Items.BOWL)
}
val bowlHotbarSlot = findHotbarSlot(Items.BOWL)

val invSlot = (9..35).find {
hasItem(it, Items.MUSHROOM_STEW)
}
val bowlInvSlot = findInventorySlot(Items.MUSHROOM_STEW)

if (hotBarSlot == null && invSlot == null && bowlSlot == null) {
if (mushroomStewSlot == null && bowlInvSlot == null && bowlHotbarSlot == null) {
return@repeatable
}

if (player.isDead) {
return@repeatable
}

if (bowlSlot != null) {
if (bowlHotbarSlot != null) {
network.sendPacket(
PlayerActionC2SPacket(
PlayerActionC2SPacket.Action.RELEASE_USE_ITEM,
Expand All @@ -84,7 +80,7 @@ object ModuleAutoSoup : Module("AutoSoup", Category.COMBAT) {
}
when (bowl) {
BowlMode.DROP -> {
utilizeInventory(bowlSlot, 1, SlotActionType.THROW, false)
utilizeInventory(bowlHotbarSlot, 1, SlotActionType.THROW, false)
}
BowlMode.MOVE -> {
val openInventory = mc.currentScreen !is InventoryScreen
Expand All @@ -95,12 +91,12 @@ object ModuleAutoSoup : Module("AutoSoup", Category.COMBAT) {

// If there is neither an empty slot nor an empty bowl, then replace whatever there is on slot 9
if (!player.inventory.getStack(9).isEmpty || player.inventory.getStack(9).item != Items.BOWL) {
utilizeInventory(bowlSlot, 0, SlotActionType.PICKUP, true)
utilizeInventory(bowlHotbarSlot, 0, SlotActionType.PICKUP, true)
utilizeInventory(9, 0, SlotActionType.PICKUP, true)
utilizeInventory(bowlSlot, 0, SlotActionType.PICKUP, true)
utilizeInventory(bowlHotbarSlot, 0, SlotActionType.PICKUP, true)
} else {
// If there is, simply shift + click the empty bowl from hotbar
utilizeInventory(bowlSlot, 0, SlotActionType.QUICK_MOVE, true)
utilizeInventory(bowlHotbarSlot, 0, SlotActionType.QUICK_MOVE, true)
}

if (openInventory) {
Expand All @@ -112,20 +108,20 @@ object ModuleAutoSoup : Module("AutoSoup", Category.COMBAT) {
}

if (player.health < health) {
if (hotBarSlot != null) {
if (mushroomStewSlot != null) {
if (!saveSlot) {
lastSlot = player.inventory.selectedSlot
saveSlot = true
}
player.inventory.selectedSlot = hotBarSlot
player.inventory.selectedSlot = mushroomStewSlot
// Using timer so as to avoid sword shield
wait(2)
network.sendPacket(PlayerInteractItemC2SPacket(Hand.MAIN_HAND))
return@repeatable
} else {
// Search for the specific item in inventory and quick move it to hotbar
if (invSlot != null) {
utilizeInventory(invSlot, 0, SlotActionType.QUICK_MOVE, false)
if (bowlInvSlot != null) {
utilizeInventory(bowlInvSlot, 0, SlotActionType.QUICK_MOVE, false)
}
return@repeatable
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.block.getBlock
import net.ccbluex.liquidbounce.utils.block.getCenterDistanceSquared
import net.ccbluex.liquidbounce.utils.block.getState
import net.ccbluex.liquidbounce.utils.block.searchBlocks
import net.ccbluex.liquidbounce.utils.block.searchBlocksInCuboid
import net.ccbluex.liquidbounce.utils.entity.eyesPos
import net.ccbluex.liquidbounce.utils.entity.getNearestPoint
import net.minecraft.block.*
Expand Down Expand Up @@ -100,7 +100,7 @@ object ModuleAutoFarm : Module("AutoFarm", Category.WORLD) {
val radiusSquared = radius * radius
val eyesPos = mc.player!!.eyesPos

val blockToProcess = searchBlocks(radius.toInt()) { pos, state ->
val blockToProcess = searchBlocksInCuboid(radius.toInt()) { pos, state ->
!state.isAir && getNearestPoint(
eyesPos,
Box(pos, pos.add(1, 1, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.aiming.raytraceBlock
import net.ccbluex.liquidbounce.utils.block.getCenterDistanceSquared
import net.ccbluex.liquidbounce.utils.block.getState
import net.ccbluex.liquidbounce.utils.block.searchBlocks
import net.ccbluex.liquidbounce.utils.block.searchBlocksInCuboid
import net.ccbluex.liquidbounce.utils.client.Chronometer
import net.ccbluex.liquidbounce.utils.entity.eyesPos
import net.ccbluex.liquidbounce.utils.entity.getNearestPoint
Expand Down Expand Up @@ -171,7 +171,7 @@ object ModuleChestAura : Module("ChestAura", Category.WORLD) {
val radiusSquared = radius * radius
val eyesPos = mc.player!!.eyesPos

val blocksToProcess = searchBlocks(radius.toInt()) { pos, state ->
val blocksToProcess = searchBlocksInCuboid(radius.toInt()) { pos, state ->
targetedBlocks.contains(state.block) && pos !in clickedBlocks && getNearestPoint(
eyesPos,
Box(pos, pos.add(1, 1, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.aiming.raytraceBlock
import net.ccbluex.liquidbounce.utils.block.getCenterDistanceSquared
import net.ccbluex.liquidbounce.utils.block.getState
import net.ccbluex.liquidbounce.utils.block.searchBlocks
import net.ccbluex.liquidbounce.utils.block.searchBlocksInRadius
import net.ccbluex.liquidbounce.utils.client.MC_1_8
import net.ccbluex.liquidbounce.utils.client.protocolVersion
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
Expand Down Expand Up @@ -189,7 +189,7 @@ object ModuleCrystalAura : Module("CrystalAura", Category.WORLD) {
val radiusSquared = radius * radius
val eyesPos = player.eyesPos

val blockToProcess = searchBlocks(radius.toInt()) { pos, state ->
val blockToProcess = searchBlocksInRadius(radius) { pos, state ->
targetedBlocks.contains(state.block) && getNearestPoint(
eyesPos,
Box(pos, pos.add(1, 1, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import net.ccbluex.liquidbounce.utils.aiming.RotationsConfigurable
import net.ccbluex.liquidbounce.utils.aiming.raytraceBlock
import net.ccbluex.liquidbounce.utils.block.getCenterDistanceSquared
import net.ccbluex.liquidbounce.utils.block.getState
import net.ccbluex.liquidbounce.utils.block.searchBlocks
import net.ccbluex.liquidbounce.utils.block.searchBlocksInCuboid
import net.ccbluex.liquidbounce.utils.entity.eyesPos
import net.ccbluex.liquidbounce.utils.entity.getNearestPoint
import net.minecraft.block.Block
Expand Down Expand Up @@ -139,7 +139,7 @@ object ModuleFucker : Module("Fucker", Category.WORLD) {
val radiusSquared = radius * radius
val eyesPos = mc.player!!.eyesPos

val blockToProcess = searchBlocks(radius.toInt()) { pos, state ->
val blockToProcess = searchBlocksInCuboid(radius.toInt()) { pos, state ->
targetedBlocks.contains(state.block) && getNearestPoint(
eyesPos,
Box(pos, pos.add(1, 1, 1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.ccbluex.liquidbounce.utils.aiming.raycast
import net.ccbluex.liquidbounce.utils.block.getState
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
import net.ccbluex.liquidbounce.utils.entity.squaredBoxedDistanceTo
import net.ccbluex.liquidbounce.utils.item.findHotbarSlot
import net.minecraft.block.Blocks
import net.minecraft.item.ItemUsageContext
import net.minecraft.item.Items
Expand All @@ -51,9 +52,7 @@ object ModuleIgnite : Module("Ignite", Category.WORLD) {
val networkTickHandler = repeatable { event ->
val player = mc.player ?: return@repeatable

val slot = (0..8).firstOrNull {
player.inventory.getStack(it).item == Items.LAVA_BUCKET
} ?: return@repeatable
val slot = findHotbarSlot(Items.LAVA_BUCKET) ?: return@repeatable

for (enemy in targetTracker.enemies()) {
if (enemy.squaredBoxedDistanceTo(player) > 6.0 * 6.0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import net.minecraft.entity.projectile.ProjectileUtil
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.hit.HitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Direction
import net.minecraft.util.math.Vec3d
import net.minecraft.world.RaycastContext

Expand Down Expand Up @@ -109,7 +110,7 @@ fun facingEnemy(enemy: Entity, range: Double, rotation: Rotation): Boolean {
/**
* Allows you to check if a point is behind a wall
*/
fun facingBlock(eyes: Vec3d, vec3: Vec3d, blockPos: BlockPos): Boolean {
fun facingBlock(eyes: Vec3d, vec3: Vec3d, blockPos: BlockPos, expectedSide: Direction? = null): Boolean {
val searchedPos = mc.world?.raycast(
RaycastContext(
eyes,
Expand All @@ -120,7 +121,7 @@ fun facingBlock(eyes: Vec3d, vec3: Vec3d, blockPos: BlockPos): Boolean {
)
) ?: return false

if (searchedPos.type != HitResult.Type.BLOCK) {
if (searchedPos.type != HitResult.Type.BLOCK || (expectedSide != null && searchedPos.side != expectedSide)) {
return false
}

Expand Down
Loading

0 comments on commit e9d9b2b

Please sign in to comment.