Skip to content

Commit c048b4f

Browse files
authored
Synchronized inventory transactions (#308)
* First sketch * Getting somewhere - Timeout missing - Retry function missing - Impl for Operation.kt missing * Refined (timeout still not working fully) * Fixed timeout, pause baritone process and pause on lag * Add compatibility with Operation.kt * Add isDone * Fix build * Add debug option * Feature to pause modules internally * Propagate request owner module to sync transactions * Cleanup residue * Refactor * Even more refactor * Refactor AutoTool * Unpause modules on failure * Fix delays for old method of moving items
1 parent af45da8 commit c048b4f

File tree

154 files changed

+1666
-1572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+1666
-1572
lines changed

src/main/java/com/lambda/mixin/MixinMinecraft.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import com.lambda.client.event.events.RunGameLoopEvent;
66
import com.lambda.client.gui.hudgui.elements.misc.FPS;
77
import com.lambda.client.manager.managers.HotbarManager;
8-
import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP;
9-
import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP;
108
import com.lambda.client.module.modules.combat.CrystalAura;
119
import com.lambda.client.module.modules.player.BlockInteraction;
1210
import com.lambda.client.util.Wrapper;
11+
import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP;
12+
import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP;
1313
import net.minecraft.client.Minecraft;
1414
import net.minecraft.client.entity.EntityPlayerSP;
1515
import net.minecraft.client.gui.GuiScreen;
@@ -130,14 +130,14 @@ public void processKeyBindsInvokeIsKeyDown(CallbackInfo ci) {
130130
public void rightClickMousePre(CallbackInfo ci) {
131131
if (BlockInteraction.isMultiTaskEnabled()) {
132132
isHittingBlock = playerController.getIsHittingBlock();
133-
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(false);
133+
((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(false);
134134
}
135135
}
136136

137137
@Inject(method = "rightClickMouse", at = @At("RETURN"))
138138
public void rightClickMousePost(CallbackInfo ci) {
139139
if (BlockInteraction.isMultiTaskEnabled() && !playerController.getIsHittingBlock()) {
140-
((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(isHittingBlock);
140+
((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(isHittingBlock);
141141
}
142142
}
143143

src/main/java/com/lambda/mixin/accessor/player/AccessorPlayerControllerMP.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ public interface AccessorPlayerControllerMP {
1515
void setBlockHitDelay(int value);
1616

1717
@Accessor("isHittingBlock")
18-
void kbSetIsHittingBlock(boolean value);
18+
void setIsHittingBlockFun(boolean value);
1919

2020
@Accessor("currentPlayerItem")
2121
int getCurrentPlayerItem();
2222

2323
@Invoker("syncCurrentPlayItem")
24-
void kb_invokeSyncCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430
25-
24+
void synchronizeCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430
2625
}

src/main/java/com/lambda/mixin/player/MixinPlayerControllerMP.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.lambda.client.event.LambdaEventBus;
44
import com.lambda.client.event.events.PlayerAttackEvent;
5+
import com.lambda.client.event.events.WindowClickEvent;
56
import com.lambda.client.module.modules.player.AutoEat;
6-
import com.lambda.client.module.modules.player.NoGhostItems;
77
import com.lambda.client.module.modules.player.TpsSync;
88
import com.lambda.client.util.TpsCalculator;
99
import net.minecraft.block.state.IBlockState;
@@ -14,6 +14,7 @@
1414
import net.minecraft.item.ItemStack;
1515
import net.minecraft.util.math.BlockPos;
1616
import net.minecraft.world.World;
17+
import org.jetbrains.annotations.NotNull;
1718
import org.spongepowered.asm.mixin.Mixin;
1819
import org.spongepowered.asm.mixin.injection.At;
1920
import org.spongepowered.asm.mixin.injection.Inject;
@@ -25,7 +26,7 @@
2526
public class MixinPlayerControllerMP {
2627

2728
@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"))
28-
float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
29+
float getPlayerRelativeBlockHardness(@NotNull IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
2930
return state.getPlayerRelativeBlockHardness(player, worldIn, pos) * (TpsSync.INSTANCE.isEnabled() ? (TpsCalculator.INSTANCE.getTickRate() / 20f) : 1);
3031
}
3132

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

4243
@Inject(method = "windowClick", at = @At("HEAD"), cancellable = true)
4344
public void onWindowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player, CallbackInfoReturnable<ItemStack> cir) {
44-
if (NoGhostItems.INSTANCE.isEnabled()) {
45-
NoGhostItems.INSTANCE.handleWindowClick(windowId, slotId, mouseButton, type, player);
45+
WindowClickEvent event = new WindowClickEvent(windowId, slotId, mouseButton, type);
46+
LambdaEventBus.INSTANCE.post(event);
47+
if (event.getCancelled()) {
4648
cir.cancel();
4749
}
4850
}

src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldI
3333
}
3434
}
3535
}
36-
public Block getBlock(BlockPos var0) {return mc.world.getBlockState(var0).getBlock();}
36+
37+
public Block getBlock(BlockPos var0) {
38+
return mc.world.getBlockState(var0).getBlock();
39+
}
3740
}

src/main/java/com/lambda/mixin/world/MixinItemBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.lambda.mixin.world;
22

3-
import com.lambda.client.module.modules.player.NoGlitchBlocks;
3+
import com.lambda.client.module.modules.player.NoGhostBlocks;
44
import net.minecraft.block.state.IBlockState;
55
import net.minecraft.item.ItemBlock;
66
import net.minecraft.util.math.BlockPos;
@@ -13,7 +13,7 @@
1313
public class MixinItemBlock {
1414
@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"))
1515
private boolean ignoreSetBlockState(World instance, BlockPos p_setBlockState_1_, IBlockState p_setBlockState_2_, int p_setBlockState_3_) {
16-
if (NoGlitchBlocks.INSTANCE.isEnabled()) {
16+
if (NoGhostBlocks.INSTANCE.isEnabled()) {
1717
return true;
1818
} else {
1919
return instance.setBlockState(p_setBlockState_1_, p_setBlockState_2_, p_setBlockState_3_);

src/main/kotlin/com/lambda/client/command/Args.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package com.lambda.client.command
22

33
import com.lambda.client.capeapi.PlayerProfile
4+
import com.lambda.client.command.args.AbstractArg
5+
import com.lambda.client.command.args.AutoComplete
6+
import com.lambda.client.command.args.DynamicPrefixMatch
7+
import com.lambda.client.command.args.StaticPrefixMatch
48
import com.lambda.client.gui.GuiManager
59
import com.lambda.client.gui.hudgui.AbstractHudElement
610
import com.lambda.client.manager.managers.UUIDManager
711
import com.lambda.client.module.AbstractModule
812
import com.lambda.client.module.ModuleManager
913
import com.lambda.client.util.*
1014
import com.lambda.client.util.threads.runSafeR
11-
import com.lambda.client.command.args.AbstractArg
12-
import com.lambda.client.command.args.AutoComplete
13-
import com.lambda.client.command.args.DynamicPrefixMatch
14-
import com.lambda.client.command.args.StaticPrefixMatch
1515
import kotlinx.coroutines.Dispatchers
1616
import net.minecraft.block.Block
1717
import net.minecraft.item.Item

src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lambda.client.command.commands
22

33
import com.lambda.client.command.ClientCommand
4+
import com.lambda.client.command.execute.IExecuteEvent
45
import com.lambda.client.event.SafeExecuteEvent
56
import com.lambda.client.module.modules.client.Configurations
67
import com.lambda.client.util.ConfigUtils
@@ -9,7 +10,6 @@ import com.lambda.client.util.TimeUnit
910
import com.lambda.client.util.text.MessageSendHelper
1011
import com.lambda.client.util.text.formatValue
1112
import com.lambda.client.util.threads.defaultScope
12-
import com.lambda.client.command.execute.IExecuteEvent
1313
import kotlinx.coroutines.Dispatchers
1414
import kotlinx.coroutines.launch
1515

src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import com.google.gson.Gson
44
import com.google.gson.annotations.SerializedName
55
import com.lambda.client.LambdaMod
66
import com.lambda.client.command.ClientCommand
7+
import com.lambda.client.commons.utils.ConnectionUtils
78
import com.lambda.client.util.text.MessageSendHelper
89
import com.lambda.client.util.text.formatValue
9-
import com.lambda.client.commons.utils.ConnectionUtils
1010

1111
object CreditsCommand : ClientCommand(
1212
name = "credits",

src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.lambda.client.command.commands
22

33
import com.lambda.client.command.ClientCommand
4+
import com.lambda.client.commons.utils.MathUtils
45
import com.lambda.client.manager.managers.UUIDManager
56
import com.lambda.client.util.text.MessageSendHelper
6-
import com.lambda.client.commons.utils.MathUtils
77
import net.minecraft.entity.EntityLivingBase
88
import net.minecraft.entity.passive.AbstractHorse
99
import kotlin.math.pow

src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.lambda.client.command.commands
22

33
import com.lambda.client.command.ClientCommand
4+
import com.lambda.client.commons.utils.SystemUtils
45
import com.lambda.client.event.SafeExecuteEvent
56
import com.lambda.client.util.text.MessageSendHelper
67
import com.lambda.client.util.text.formatValue
7-
import com.lambda.client.commons.utils.SystemUtils
88
import net.minecraft.item.ItemStack
99
import net.minecraft.nbt.JsonToNBT
1010
import net.minecraft.nbt.NBTTagCompound

0 commit comments

Comments
 (0)