|
| 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 | +} |
0 commit comments