Skip to content

Commit 2611ff3

Browse files
committed
Added AntiDrop
1 parent c9a12f7 commit 2611ff3

File tree

8 files changed

+214
-0
lines changed

8 files changed

+214
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ All credit for the original client goes to Wurst-Imperium and its contributors.
168168

169169
![Surface](https://i.ibb.co.com/WptKT2yY/Untitldded.png)
170170

171+
### AntiDrop
172+
- Prevents you from dropping the selected items by accident. Defaults to all weapons, tools, and shulker boxes.
173+
- When enabled you cannot press the throw button on the chosen items and you cannot drag the chosen items out of inventory.
174+
171175
## What’s changed or improved in this fork?
172176

173177
### ItemESP (Expanded)

src/main/java/net/wurstclient/hack/HackList.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public final class HackList implements UpdateListener
3434
public final AntiAfkHack antiAfkHack = new AntiAfkHack();
3535
public final AntiBlindHack antiBlindHack = new AntiBlindHack();
3636
public final AntiCactusHack antiCactusHack = new AntiCactusHack();
37+
public final AntiDropHack antiDropHack = new AntiDropHack();
3738
public final AntiEntityPushHack antiEntityPushHack =
3839
new AntiEntityPushHack();
3940
public final AntiHungerHack antiHungerHack = new AntiHungerHack();
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.hacks;
9+
10+
import net.minecraft.item.ItemStack;
11+
import net.minecraft.registry.Registries;
12+
import net.wurstclient.Category;
13+
import net.wurstclient.SearchTags;
14+
import net.wurstclient.hack.Hack;
15+
import net.wurstclient.settings.ItemListSetting;
16+
17+
@SearchTags({"anti drop", "item lock", "drop lock", "prevent drop"})
18+
public final class AntiDropHack extends Hack
19+
{
20+
private static final String[] DEFAULT_ITEMS = {
21+
// swords
22+
"minecraft:wooden_sword", "minecraft:stone_sword",
23+
"minecraft:iron_sword", "minecraft:golden_sword",
24+
"minecraft:diamond_sword", "minecraft:netherite_sword",
25+
// axes
26+
"minecraft:wooden_axe", "minecraft:stone_axe",
27+
"minecraft:iron_axe", "minecraft:golden_axe",
28+
"minecraft:diamond_axe", "minecraft:netherite_axe",
29+
// pickaxes
30+
"minecraft:wooden_pickaxe", "minecraft:stone_pickaxe",
31+
"minecraft:iron_pickaxe", "minecraft:golden_pickaxe",
32+
"minecraft:diamond_pickaxe", "minecraft:netherite_pickaxe",
33+
// shovels
34+
"minecraft:wooden_shovel", "minecraft:stone_shovel",
35+
"minecraft:iron_shovel", "minecraft:golden_shovel",
36+
"minecraft:diamond_shovel", "minecraft:netherite_shovel",
37+
// hoes
38+
"minecraft:wooden_hoe", "minecraft:stone_hoe",
39+
"minecraft:iron_hoe", "minecraft:golden_hoe",
40+
"minecraft:diamond_hoe", "minecraft:netherite_hoe",
41+
// other weapons & tools
42+
"minecraft:bow", "minecraft:crossbow", "minecraft:trident",
43+
"minecraft:mace", "minecraft:shield", "minecraft:flint_and_steel",
44+
"minecraft:shears", "minecraft:fishing_rod",
45+
"minecraft:carrot_on_a_stick", "minecraft:warped_fungus_on_a_stick",
46+
"minecraft:brush",
47+
// shulker boxes
48+
"minecraft:shulker_box", "minecraft:white_shulker_box",
49+
"minecraft:orange_shulker_box", "minecraft:magenta_shulker_box",
50+
"minecraft:light_blue_shulker_box", "minecraft:yellow_shulker_box",
51+
"minecraft:lime_shulker_box", "minecraft:pink_shulker_box",
52+
"minecraft:gray_shulker_box", "minecraft:light_gray_shulker_box",
53+
"minecraft:cyan_shulker_box", "minecraft:purple_shulker_box",
54+
"minecraft:blue_shulker_box", "minecraft:brown_shulker_box",
55+
"minecraft:green_shulker_box", "minecraft:red_shulker_box",
56+
"minecraft:black_shulker_box"
57+
};
58+
59+
private final ItemListSetting items = new ItemListSetting("Items",
60+
"Items that can't be dropped while AntiDrop is enabled.", DEFAULT_ITEMS);
61+
62+
public AntiDropHack()
63+
{
64+
super("AntiDrop");
65+
setCategory(Category.ITEMS);
66+
addSetting(items);
67+
}
68+
69+
public boolean shouldBlock(ItemStack stack)
70+
{
71+
if(stack == null || stack.isEmpty())
72+
return false;
73+
74+
String itemName = Registries.ITEM.getId(stack.getItem()).toString();
75+
return items.getItemNames().contains(itemName);
76+
}
77+
}

src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import net.minecraft.entity.effect.StatusEffect;
3131
import net.minecraft.entity.effect.StatusEffectInstance;
3232
import net.minecraft.entity.effect.StatusEffects;
33+
import net.minecraft.item.ItemStack;
3334
import net.minecraft.registry.entry.RegistryEntry;
3435
import net.minecraft.util.math.Vec3d;
3536
import net.wurstclient.WurstClient;
@@ -43,6 +44,7 @@
4344
import net.wurstclient.events.PreMotionListener.PreMotionEvent;
4445
import net.wurstclient.events.UpdateListener.UpdateEvent;
4546
import net.wurstclient.hack.HackList;
47+
import net.wurstclient.hacks.AntiDropHack;
4648
import net.wurstclient.mixinterface.IClientPlayerEntity;
4749

4850
@Mixin(ClientPlayerEntity.class)
@@ -175,6 +177,26 @@ private void onCanSprint(CallbackInfoReturnable<Boolean> cir)
175177
cir.setReturnValue(true);
176178
}
177179

180+
@Inject(at = @At("HEAD"),
181+
method = "dropSelectedItem(Z)Z",
182+
cancellable = true)
183+
private void onDropSelectedItem(boolean entireStack,
184+
CallbackInfoReturnable<Boolean> cir)
185+
{
186+
if(!WurstClient.INSTANCE.isEnabled())
187+
return;
188+
189+
AntiDropHack antiDrop = WurstClient.INSTANCE.getHax().antiDropHack;
190+
if(!antiDrop.isEnabled())
191+
return;
192+
193+
ItemStack stack = getMainHandStack();
194+
if(!antiDrop.shouldBlock(stack))
195+
return;
196+
197+
cir.setReturnValue(false);
198+
}
199+
178200
/**
179201
* Getter method for what used to be airStrafingSpeed.
180202
* Overridden to allow for the speed to be modified by hacks.

src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@
2222
import net.minecraft.client.world.ClientWorld;
2323
import net.minecraft.entity.Entity;
2424
import net.minecraft.entity.player.PlayerEntity;
25+
import net.minecraft.item.ItemStack;
2526
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
2627
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action;
2728
import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket;
29+
import net.minecraft.screen.slot.Slot;
2830
import net.minecraft.screen.slot.SlotActionType;
2931
import net.minecraft.util.ActionResult;
3032
import net.minecraft.util.Hand;
3133
import net.minecraft.util.hit.BlockHitResult;
3234
import net.minecraft.util.math.BlockPos;
3335
import net.minecraft.util.math.Direction;
3436
import net.minecraft.util.math.Vec3d;
37+
import net.wurstclient.WurstClient;
3538
import net.wurstclient.event.EventManager;
3639
import net.wurstclient.events.BlockBreakingProgressListener.BlockBreakingProgressEvent;
3740
import net.wurstclient.events.PlayerAttacksEntityListener.PlayerAttacksEntityEvent;
3841
import net.wurstclient.events.StopUsingItemListener.StopUsingItemEvent;
42+
import net.wurstclient.hacks.AntiDropHack;
3943
import net.wurstclient.mixinterface.IClientPlayerInteractionManager;
4044

4145
@Mixin(ClientPlayerInteractionManager.class)
@@ -63,6 +67,55 @@ private void onStopUsingItem(PlayerEntity player, CallbackInfo ci)
6367
EventManager.fire(StopUsingItemEvent.INSTANCE);
6468
}
6569

70+
@Inject(at = @At("HEAD"),
71+
method = "clickSlot(IIILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/entity/player/PlayerEntity;)V",
72+
cancellable = true)
73+
private void onClickSlotHEAD(int syncId, int slotId, int button,
74+
SlotActionType actionType, PlayerEntity player, CallbackInfo ci)
75+
{
76+
if(actionType != SlotActionType.THROW)
77+
return;
78+
79+
if(!WurstClient.INSTANCE.isEnabled())
80+
return;
81+
82+
AntiDropHack antiDrop = WurstClient.INSTANCE.getHax().antiDropHack;
83+
if(!antiDrop.isEnabled())
84+
return;
85+
86+
ItemStack stack = ItemStack.EMPTY;
87+
88+
if(slotId == -999 && player.currentScreenHandler != null
89+
&& player.currentScreenHandler.syncId == syncId)
90+
{
91+
stack = player.currentScreenHandler.getCursorStack();
92+
93+
}else if(slotId >= 0)
94+
{
95+
if(player.currentScreenHandler != null
96+
&& player.currentScreenHandler.syncId == syncId
97+
&& slotId < player.currentScreenHandler.slots.size())
98+
{
99+
Slot slot = player.currentScreenHandler.getSlot(slotId);
100+
if(slot != null)
101+
stack = slot.getStack();
102+
103+
}else if(player.playerScreenHandler != null
104+
&& player.playerScreenHandler.syncId == syncId
105+
&& slotId < player.playerScreenHandler.slots.size())
106+
{
107+
Slot slot = player.playerScreenHandler.getSlot(slotId);
108+
if(slot != null)
109+
stack = slot.getStack();
110+
}
111+
}
112+
113+
if(!antiDrop.shouldBlock(stack))
114+
return;
115+
116+
ci.cancel();
117+
}
118+
66119
@Inject(at = @At("HEAD"),
67120
method = "attackEntity(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/entity/Entity;)V")
68121
private void onAttackEntity(PlayerEntity player, Entity target,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
3+
*
4+
* This source code is subject to the terms of the GNU General Public
5+
* License, version 3. If a copy of the GPL was not distributed with this
6+
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
7+
*/
8+
package net.wurstclient.mixin;
9+
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Shadow;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
import org.spongepowered.asm.mixin.injection.Inject;
14+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
15+
16+
import net.minecraft.client.gui.screen.ingame.HandledScreen;
17+
import net.minecraft.item.ItemStack;
18+
import net.minecraft.screen.slot.Slot;
19+
import net.minecraft.screen.slot.SlotActionType;
20+
import net.wurstclient.WurstClient;
21+
import net.wurstclient.hacks.AntiDropHack;
22+
23+
@Mixin(HandledScreen.class)
24+
public abstract class HandledScreenMixin
25+
{
26+
@Shadow
27+
public abstract net.minecraft.screen.ScreenHandler getScreenHandler();
28+
29+
@Inject(at = @At("HEAD"),
30+
method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V",
31+
cancellable = true)
32+
private void onMouseClick(Slot slot, int slotId, int button,
33+
SlotActionType actionType, CallbackInfo ci)
34+
{
35+
if(actionType != SlotActionType.THROW && slotId != -999)
36+
return;
37+
38+
if(!WurstClient.INSTANCE.isEnabled())
39+
return;
40+
41+
AntiDropHack antiDrop = WurstClient.INSTANCE.getHax().antiDropHack;
42+
if(!antiDrop.isEnabled())
43+
return;
44+
45+
ItemStack stack = ItemStack.EMPTY;
46+
47+
if(slotId == -999)
48+
stack = getScreenHandler().getCursorStack();
49+
else if(slot != null)
50+
stack = slot.getStack();
51+
52+
if(antiDrop.shouldBlock(stack))
53+
ci.cancel();
54+
}
55+
}

src/main/resources/assets/wurst/translations/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"description.wurst.hack.antiafk": "Walks around randomly to hide you from AFK detectors.",
1818
"description.wurst.hack.antiblind": "Prevents blindness and darkness effects.\nIncompatible with OptiFine.",
1919
"description.wurst.hack.anticactus": "Protects you from cactus damage.",
20+
"description.wurst.hack.antidrop": "Prevents you from dropping the selected items by accident. Defaults to all weapons, tools, and shulker boxes.",
2021
"description.wurst.hack.antientitypush": "Prevents you from getting pushed by players and mobs.",
2122
"description.wurst.hack.antihunger": "Slows down your hunger when you are walking.\n\n??c??lWARNING:??r There have been reports of this hack causing you to take extra fall damage under specific, unknown conditions.",
2223
"description.wurst.hack.antiknockback": "Prevents you from taking knockback from players and mobs.",

src/main/resources/wurst.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"FogRendererMixin",
4040
"GameMenuScreenMixin",
4141
"GameRendererMixin",
42+
"HandledScreenMixin",
4243
"GenericContainerScreenMixin",
4344
"GrindstoneScreenMixin",
4445
"HeldItemRendererMixin",

0 commit comments

Comments
 (0)