Skip to content

Synchronized inventory transactions #308

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

Merged
merged 23 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f0c1c59
First sketch
Avanatiker May 10, 2022
34d00a1
Getting somewhere
Avanatiker May 11, 2022
22a3854
Refined (timeout still not working fully)
Avanatiker May 12, 2022
bccc544
Fixed timeout, pause baritone process and pause on lag
Avanatiker May 14, 2022
09693ed
Add compatibility with Operation.kt
Avanatiker May 14, 2022
55b9743
Merge branch 'master' into syncedPlayerInventoryManager
Avanatiker May 20, 2022
b515d94
Merge branch 'master' into syncedPlayerInventoryManager
Avanatiker May 23, 2022
07e8e61
Add isDone
Avanatiker May 29, 2022
7086e85
Fix build
Avanatiker May 29, 2022
eff89a6
Merge branch 'master' into syncedPlayerInventoryManager
Avanatiker May 30, 2022
000f423
Add debug option
Avanatiker May 30, 2022
0723ae3
Merge with master
Avanatiker May 30, 2022
0d8669e
Merge remote-tracking branch 'lambda-client/master' into syncedPlayer…
Avanatiker Jun 4, 2022
fe8a1f1
Merge branch 'master' into syncedPlayerInventoryManager
Avanatiker Jun 17, 2022
bbadcee
Merge branch 'master' into syncedPlayerInventoryManager
Avanatiker Jun 18, 2022
b446c46
Feature to pause modules internally
Avanatiker Jun 21, 2022
a2692cd
Propagate request owner module to sync transactions
Avanatiker Jun 22, 2022
dd6454a
Cleanup residue
Avanatiker Jun 22, 2022
8d46c3b
Refactor
Avanatiker Jun 22, 2022
05054e2
Even more refactor
Avanatiker Jun 22, 2022
411742b
Refactor AutoTool
Avanatiker Jun 23, 2022
c609496
Unpause modules on failure
Avanatiker Jun 24, 2022
1feb8ab
Fix delays for old method of moving items
Avanatiker Jun 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/com/lambda/mixin/MixinMinecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import com.lambda.client.event.events.RunGameLoopEvent;
import com.lambda.client.gui.hudgui.elements.misc.FPS;
import com.lambda.client.manager.managers.HotbarManager;
import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP;
import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP;
import com.lambda.client.module.modules.combat.CrystalAura;
import com.lambda.client.module.modules.player.BlockInteraction;
import com.lambda.client.util.Wrapper;
import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP;
import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreen;
Expand Down Expand Up @@ -130,14 +130,14 @@ public void processKeyBindsInvokeIsKeyDown(CallbackInfo ci) {
public void rightClickMousePre(CallbackInfo ci) {
if (BlockInteraction.isMultiTaskEnabled()) {
isHittingBlock = playerController.getIsHittingBlock();
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(false);
((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(false);
}
}

@Inject(method = "rightClickMouse", at = @At("RETURN"))
public void rightClickMousePost(CallbackInfo ci) {
if (BlockInteraction.isMultiTaskEnabled() && !playerController.getIsHittingBlock()) {
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(isHittingBlock);
((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(isHittingBlock);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ public interface AccessorPlayerControllerMP {
void setBlockHitDelay(int value);

@Accessor("isHittingBlock")
void kbSetIsHittingBlock(boolean value);
void setIsHittingBlockFun(boolean value);

@Accessor("currentPlayerItem")
int getCurrentPlayerItem();

@Invoker("syncCurrentPlayItem")
void kb_invokeSyncCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430

void synchronizeCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.lambda.client.event.LambdaEventBus;
import com.lambda.client.event.events.PlayerAttackEvent;
import com.lambda.client.event.events.WindowClickEvent;
import com.lambda.client.module.modules.player.AutoEat;
import com.lambda.client.module.modules.player.NoGhostItems;
import com.lambda.client.module.modules.player.TpsSync;
import com.lambda.client.util.TpsCalculator;
import net.minecraft.block.state.IBlockState;
Expand All @@ -14,6 +14,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -25,7 +26,7 @@
public class MixinPlayerControllerMP {

@Redirect(method = "onPlayerDamageBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/state/IBlockState;getPlayerRelativeBlockHardness(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)F"))
float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
float getPlayerRelativeBlockHardness(@NotNull IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
return state.getPlayerRelativeBlockHardness(player, worldIn, pos) * (TpsSync.INSTANCE.isEnabled() ? (TpsCalculator.INSTANCE.getTickRate() / 20f) : 1);
}

Expand All @@ -41,8 +42,9 @@ public void attackEntity(EntityPlayer playerIn, Entity targetEntity, CallbackInf

@Inject(method = "windowClick", at = @At("HEAD"), cancellable = true)
public void onWindowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player, CallbackInfoReturnable<ItemStack> cir) {
if (NoGhostItems.INSTANCE.isEnabled()) {
NoGhostItems.INSTANCE.handleWindowClick(windowId, slotId, mouseButton, type, player);
WindowClickEvent event = new WindowClickEvent(windowId, slotId, mouseButton, type);
LambdaEventBus.INSTANCE.post(event);
if (event.getCancelled()) {
cir.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldI
}
}
}
public Block getBlock(BlockPos var0) {return mc.world.getBlockState(var0).getBlock();}

public Block getBlock(BlockPos var0) {
return mc.world.getBlockState(var0).getBlock();
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/lambda/mixin/world/MixinItemBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.lambda.mixin.world;

import com.lambda.client.module.modules.player.NoGlitchBlocks;
import com.lambda.client.module.modules.player.NoGhostBlocks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.math.BlockPos;
Expand All @@ -13,7 +13,7 @@
public class MixinItemBlock {
@Redirect(method = "placeBlockAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;I)Z"))
private boolean ignoreSetBlockState(World instance, BlockPos p_setBlockState_1_, IBlockState p_setBlockState_2_, int p_setBlockState_3_) {
if (NoGlitchBlocks.INSTANCE.isEnabled()) {
if (NoGhostBlocks.INSTANCE.isEnabled()) {
return true;
} else {
return instance.setBlockState(p_setBlockState_1_, p_setBlockState_2_, p_setBlockState_3_);
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/com/lambda/client/command/Args.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.lambda.client.command

import com.lambda.client.capeapi.PlayerProfile
import com.lambda.client.command.args.AbstractArg
import com.lambda.client.command.args.AutoComplete
import com.lambda.client.command.args.DynamicPrefixMatch
import com.lambda.client.command.args.StaticPrefixMatch
import com.lambda.client.gui.GuiManager
import com.lambda.client.gui.hudgui.AbstractHudElement
import com.lambda.client.manager.managers.UUIDManager
import com.lambda.client.module.AbstractModule
import com.lambda.client.module.ModuleManager
import com.lambda.client.util.*
import com.lambda.client.util.threads.runSafeR
import com.lambda.client.command.args.AbstractArg
import com.lambda.client.command.args.AutoComplete
import com.lambda.client.command.args.DynamicPrefixMatch
import com.lambda.client.command.args.StaticPrefixMatch
import kotlinx.coroutines.Dispatchers
import net.minecraft.block.Block
import net.minecraft.item.Item
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lambda.client.command.commands

import com.lambda.client.command.ClientCommand
import com.lambda.client.command.execute.IExecuteEvent
import com.lambda.client.event.SafeExecuteEvent
import com.lambda.client.module.modules.client.Configurations
import com.lambda.client.util.ConfigUtils
Expand All @@ -9,7 +10,6 @@ import com.lambda.client.util.TimeUnit
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.text.formatValue
import com.lambda.client.util.threads.defaultScope
import com.lambda.client.command.execute.IExecuteEvent
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
import com.lambda.client.LambdaMod
import com.lambda.client.command.ClientCommand
import com.lambda.client.commons.utils.ConnectionUtils
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.text.formatValue
import com.lambda.client.commons.utils.ConnectionUtils

object CreditsCommand : ClientCommand(
name = "credits",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.lambda.client.command.commands

import com.lambda.client.command.ClientCommand
import com.lambda.client.commons.utils.MathUtils
import com.lambda.client.manager.managers.UUIDManager
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.commons.utils.MathUtils
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.passive.AbstractHorse
import kotlin.math.pow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.lambda.client.command.commands

import com.lambda.client.command.ClientCommand
import com.lambda.client.commons.utils.SystemUtils
import com.lambda.client.event.SafeExecuteEvent
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.text.formatValue
import com.lambda.client.commons.utils.SystemUtils
import net.minecraft.item.ItemStack
import net.minecraft.nbt.JsonToNBT
import net.minecraft.nbt.NBTTagCompound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.lambda.client.command.commands
import com.lambda.client.command.ClientCommand
import com.lambda.client.event.SafeClientEvent
import com.lambda.client.mixin.extension.useEntityId
import com.lambda.client.util.items.clickSlot
import com.lambda.client.util.items.clickSlotUnsynced
import com.lambda.client.util.text.MessageSendHelper
import net.minecraft.entity.passive.EntityDonkey
import net.minecraft.entity.player.EntityPlayer
Expand Down Expand Up @@ -51,7 +51,7 @@ object PacketCommand : ClientCommand(
int("buttonId") { buttonId ->
enum<ClickType>("clickType") { clickType ->
executeSafe {
clickSlot(windowId.value, slotId.value, buttonId.value, clickType.value)
clickSlotUnsynced(windowId.value, slotId.value, buttonId.value, clickType.value)
MessageSendHelper.sendChatMessage("Sent ${TextFormatting.GRAY}CPacketClickWindow${TextFormatting.DARK_RED} > ${TextFormatting.GRAY}windowId: ${windowId.value}, slotId: ${slotId.value}, buttonId: ${buttonId.value}, clickType: ${clickType.value}")
}
}
Expand All @@ -62,7 +62,7 @@ object PacketCommand : ClientCommand(

literal("ClientSettings") {
string("lang") { lang ->
int ("renderDistanceIn") { renderDistanceIn ->
int("renderDistanceIn") { renderDistanceIn ->
enum<EntityPlayer.EnumChatVisibility>("chatVisibilityIn") { chatVisibilityIn ->
boolean("chatColorsIn") { chatColorsIn ->
int("modelPartsIn") { modelPartsIn ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.lambda.client.command.commands

import com.lambda.client.command.ClientCommand
import com.lambda.client.commons.extension.max
import com.lambda.client.util.items.itemPayload
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.text.MessageSendHelper.sendChatMessage
import com.lambda.client.util.text.formatValue
import com.lambda.client.commons.extension.max
import net.minecraft.item.ItemWritableBook
import net.minecraft.nbt.NBTTagList
import net.minecraft.nbt.NBTTagString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.OpenGlHelper
import net.minecraftforge.common.ForgeVersion
import org.lwjgl.opengl.GL11
import java.util.*

object TroubleshootCommand : ClientCommand(
name = "troubleshoot",
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/lambda/client/event/ClientEvents.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.lambda.client.event

import com.lambda.client.command.CommandManager
import com.lambda.client.util.Wrapper
import com.lambda.client.command.execute.ExecuteEvent
import com.lambda.client.command.execute.IExecuteEvent
import com.lambda.client.util.Wrapper
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraft.client.multiplayer.PlayerControllerMP
import net.minecraft.client.multiplayer.WorldClient
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.lambda.client.event

import com.lambda.client.util.Wrapper
import com.lambda.client.event.eventbus.AbstractAsyncEventBus
import com.lambda.client.event.listener.AsyncListener
import com.lambda.client.event.listener.Listener
import com.lambda.client.util.Wrapper
import io.netty.util.internal.ConcurrentSet
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.lambda.client.event.events

import com.lambda.client.commons.extension.next
import com.lambda.client.event.Cancellable
import com.lambda.client.event.Event
import com.lambda.client.event.IMultiPhase
import com.lambda.client.event.Phase
import com.lambda.client.manager.managers.PlayerPacketManager
import com.lambda.client.util.math.Vec2f
import com.lambda.client.commons.extension.next
import net.minecraft.util.math.Vec3d

class OnUpdateWalkingPlayerEvent private constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.lambda.client.event.events

import com.lambda.client.event.Cancellable
import com.lambda.client.event.Event
import com.lambda.client.event.ICancellable
import net.minecraft.inventory.ClickType

class WindowClickEvent(val windowId: Int, val slotId: Int, val mouseButton: Int, val type: ClickType) : Event, ICancellable by Cancellable()
6 changes: 3 additions & 3 deletions src/main/kotlin/com/lambda/client/gui/GuiManager.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.lambda.client.gui

import com.lambda.client.LambdaMod
import com.lambda.client.commons.collections.AliasSet
import com.lambda.client.commons.utils.ClassUtils
import com.lambda.client.commons.utils.ClassUtils.instance
import com.lambda.client.event.LambdaEventBus
import com.lambda.client.gui.clickgui.LambdaClickGui
import com.lambda.client.gui.hudgui.AbstractHudElement
import com.lambda.client.gui.hudgui.LambdaHudGui
import com.lambda.client.util.AsyncCachedValue
import com.lambda.client.util.StopTimer
import com.lambda.client.util.TimeUnit
import com.lambda.client.commons.collections.AliasSet
import com.lambda.client.commons.utils.ClassUtils
import com.lambda.client.commons.utils.ClassUtils.instance
import kotlinx.coroutines.Deferred
import java.lang.reflect.Modifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.lambda.client.gui.clickgui

import com.google.gson.JsonParser
import com.lambda.client.LambdaMod
import com.lambda.client.commons.utils.ConnectionUtils
import com.lambda.client.gui.AbstractLambdaGui
import com.lambda.client.gui.clickgui.component.*
import com.lambda.client.gui.clickgui.window.ModuleSettingWindow
Expand All @@ -16,7 +17,6 @@ import com.lambda.client.util.FolderUtils
import com.lambda.client.util.math.Vec2f
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.threads.defaultScope
import com.lambda.client.commons.utils.ConnectionUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.minecraft.util.text.TextFormatting
Expand Down Expand Up @@ -139,7 +139,7 @@ object LambdaClickGui : AbstractLambdaGui<ModuleSettingWindow, AbstractModule>()
.filter { it !in disabledRemotes }
.forEach {
it.visible = function(it)
}
}
}

fun populateRemotePlugins() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.lambda.client.gui.hudgui

import com.lambda.client.commons.interfaces.Alias
import com.lambda.client.commons.interfaces.DisplayEnum
import com.lambda.client.commons.interfaces.Nameable
import com.lambda.client.event.LambdaEventBus
import com.lambda.client.gui.rgui.windows.BasicWindow
import com.lambda.client.module.modules.client.GuiColors
Expand All @@ -15,9 +18,6 @@ import com.lambda.client.util.math.Vec2d
import com.lambda.client.util.math.Vec2f
import com.lambda.client.util.text.MessageSendHelper
import com.lambda.client.util.threads.safeListener
import com.lambda.client.commons.interfaces.Alias
import com.lambda.client.commons.interfaces.DisplayEnum
import com.lambda.client.commons.interfaces.Nameable
import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.opengl.GL11.glScalef

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.lambda.client.gui.hudgui

import com.lambda.client.commons.interfaces.Nameable
import com.lambda.client.event.SafeClientEvent
import com.lambda.client.setting.configs.AbstractConfig
import com.lambda.client.util.graphics.VertexHelper
import com.lambda.client.util.graphics.font.TextComponent
import com.lambda.client.util.math.Vec2d
import com.lambda.client.util.threads.safeAsyncListener
import com.lambda.client.commons.interfaces.Nameable
import net.minecraftforge.fml.common.gameevent.TickEvent

abstract class AbstractLabelHud(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.lambda.client.gui.hudgui

import com.lambda.client.event.events.RenderOverlayEvent
import com.lambda.client.event.listener.listener
import com.lambda.client.gui.AbstractLambdaGui
import com.lambda.client.gui.clickgui.LambdaClickGui
import com.lambda.client.gui.hudgui.component.HudButton
Expand All @@ -13,7 +14,6 @@ import com.lambda.client.module.modules.client.HudEditor
import com.lambda.client.util.graphics.GlStateUtils
import com.lambda.client.util.graphics.VertexHelper
import com.lambda.client.util.math.Vec2f
import com.lambda.client.event.listener.listener
import net.minecraftforge.fml.common.gameevent.InputEvent
import org.lwjgl.input.Keyboard
import org.lwjgl.opengl.GL11.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.lambda.client.gui.hudgui.elements.client

import com.lambda.client.commons.extension.sumByFloat
import com.lambda.client.commons.interfaces.DisplayEnum
import com.lambda.client.gui.hudgui.HudElement
import com.lambda.client.module.AbstractModule
import com.lambda.client.module.ModuleManager
Expand All @@ -15,8 +17,6 @@ import com.lambda.client.util.graphics.font.HAlign
import com.lambda.client.util.graphics.font.TextComponent
import com.lambda.client.util.graphics.font.VAlign
import com.lambda.client.util.threads.safeAsyncListener
import com.lambda.client.commons.extension.sumByFloat
import com.lambda.client.commons.interfaces.DisplayEnum
import net.minecraft.client.renderer.GlStateManager
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.awt.Color
Expand Down
Loading