-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(AutoTool): Settings refactoring #5260
base: nextgen
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.Via | |
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper | ||
import com.viaversion.viaversion.api.type.Types | ||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ServerboundPackets1_9_3 | ||
import it.unimi.dsi.fastutil.ints.IntObjectImmutablePair | ||
import net.ccbluex.liquidbounce.config.types.Configurable | ||
import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.* | ||
import net.ccbluex.liquidbounce.features.module.modules.world.scaffold.ModuleScaffold | ||
|
@@ -36,15 +37,16 @@ import net.ccbluex.liquidbounce.utils.client.* | |
import net.ccbluex.liquidbounce.utils.input.shouldSwingHand | ||
import net.ccbluex.liquidbounce.utils.item.isNothing | ||
import net.fabricmc.loader.api.FabricLoader | ||
import net.minecraft.block.BlockState | ||
import net.minecraft.block.Blocks | ||
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen | ||
import net.minecraft.component.type.DyedColorComponent | ||
import net.minecraft.entity.player.PlayerInventory | ||
import net.minecraft.item.Item | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket | ||
import net.minecraft.registry.Registries | ||
import net.minecraft.registry.tag.ItemTags | ||
import net.minecraft.util.ActionResult | ||
import net.minecraft.util.Hand | ||
import kotlin.math.abs | ||
|
||
|
@@ -247,6 +249,29 @@ fun ItemStack.getArmorColor(): Int? { | |
} | ||
} | ||
|
||
fun PlayerInventory.findBestToolToMineBlock( | ||
blockState: BlockState?, | ||
ignoreDurability: Boolean = true | ||
): IntObjectImmutablePair<ItemStack>? { | ||
val (hotbarSlot, stack) = | ||
(0..8).map { | ||
it to getStack(it) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesnt make sense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the end it's not my code (I moved it). If you want to change something, change it and create a pr. |
||
}.filter { (_, stack) -> | ||
val durabilityCheck = (stack.damage < (stack.maxDamage - 2) || ignoreDurability) | ||
(stack.isNothing() || (!player.isCreative && durabilityCheck)) | ||
}.maxByOrNull { (_, stack) -> | ||
stack.getMiningSpeedMultiplier(blockState) | ||
} ?: return null | ||
|
||
val miningSpeedMultiplier = stack.getMiningSpeedMultiplier(blockState) | ||
|
||
// The current slot already matches the best | ||
if (miningSpeedMultiplier == player.inventory.mainHandStack.getMiningSpeedMultiplier(blockState)) { | ||
return null | ||
} | ||
return IntObjectImmutablePair(hotbarSlot, stack) | ||
} | ||
Comment on lines
+252
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason to move this into another class when it's not being used multiple times. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i did it 'cause of the confusion in this code. Logically, I don't think PacketMine should inherit the AutoTool settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But it still does? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'm confused, make your own verdict, if it has to inherit AutoTool settings, then yes, there is no point in a separate [findBestToolToMineBlock] method. |
||
|
||
/** | ||
* A list of blocks which may not be placed (apart from the usual checks), so inv cleaner and scaffold | ||
* won't count them as blocks | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we want to choose a static slot though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already there, I didn't change the functionality of AutoTool itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at what's already available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see.