Search in sources :

Example 1 with EquipmentSlot

use of net.minecraft.entity.EquipmentSlot in project BleachHack by BleachDrinker420.

the class AutoArmor method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (mc.player.playerScreenHandler != mc.player.currentScreenHandler || !BleachQueue.isEmpty("autoarmor_equip"))
        return;
    if (tickDelay > 0) {
        tickDelay--;
        return;
    }
    tickDelay = (getSetting(2).asToggle().getState() ? getSetting(2).asToggle().getChild(0).asSlider().getValueInt() : 0);
    /* [Slot type, [Armor slot, Armor prot, New armor slot, New armor prot]] */
    Map<EquipmentSlot, int[]> armorMap = new HashMap<>(4);
    armorMap.put(EquipmentSlot.FEET, new int[] { 36, getProtection(mc.player.getInventory().getStack(36)), -1, -1 });
    armorMap.put(EquipmentSlot.LEGS, new int[] { 37, getProtection(mc.player.getInventory().getStack(37)), -1, -1 });
    armorMap.put(EquipmentSlot.CHEST, new int[] { 38, getProtection(mc.player.getInventory().getStack(38)), -1, -1 });
    armorMap.put(EquipmentSlot.HEAD, new int[] { 39, getProtection(mc.player.getInventory().getStack(39)), -1, -1 });
    /* Anti Break */
    if (getSetting(0).asToggle().getState()) {
        for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
            ItemStack is = mc.player.getInventory().getStack(e.getValue()[0]);
            int armorSlot = (e.getValue()[0] - 34) + (39 - e.getValue()[0]) * 2;
            if (is.isDamageable() && is.getMaxDamage() - is.getDamage() < 7) {
                /* Look for an empty slot to quick move to */
                int forceMoveSlot = -1;
                for (int s = 0; s < 36; s++) {
                    if (mc.player.getInventory().getStack(s).isEmpty()) {
                        mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.QUICK_MOVE, mc.player);
                        return;
                    } else if (!(mc.player.getInventory().getStack(s).getItem() instanceof ToolItem) && !(mc.player.getInventory().getStack(s).getItem() instanceof ArmorItem) && !(mc.player.getInventory().getStack(s).getItem() instanceof ElytraItem) && mc.player.getInventory().getStack(s).getItem() != Items.TOTEM_OF_UNDYING && forceMoveSlot == -1) {
                        forceMoveSlot = s;
                    }
                }
                /* Bruh no empty spots, then force move to a non-totem/tool/armor item */
                if (forceMoveSlot != -1) {
                    // System.out.println(forceMoveSlot);
                    mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, forceMoveSlot < 9 ? 36 + forceMoveSlot : forceMoveSlot, 1, SlotActionType.THROW, mc.player);
                    mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.QUICK_MOVE, mc.player);
                    return;
                }
                /* No spots to move to, yeet the armor to not cause any bruh moments */
                mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.THROW, mc.player);
                return;
            }
        }
    }
    for (int s = 0; s < 36; s++) {
        int prot = getProtection(mc.player.getInventory().getStack(s));
        if (prot > 0) {
            EquipmentSlot slot = (mc.player.getInventory().getStack(s).getItem() instanceof ElytraItem ? EquipmentSlot.CHEST : ((ArmorItem) mc.player.getInventory().getStack(s).getItem()).getSlotType());
            for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
                if (e.getKey() == slot) {
                    if (prot > e.getValue()[1] && prot > e.getValue()[3]) {
                        e.getValue()[2] = s;
                        e.getValue()[3] = prot;
                    }
                }
            }
        }
    }
    for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
        if (e.getValue()[2] != -1) {
            if (e.getValue()[1] == -1 && e.getValue()[2] < 9) {
                if (e.getValue()[2] != mc.player.getInventory().selectedSlot) {
                    mc.player.getInventory().selectedSlot = e.getValue()[2];
                    mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(e.getValue()[2]));
                }
                mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 36 + e.getValue()[2], 1, SlotActionType.QUICK_MOVE, mc.player);
            } else if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) {
                /* Convert inventory slots to container slots */
                int armorSlot = (e.getValue()[0] - 34) + (39 - e.getValue()[0]) * 2;
                int newArmorslot = e.getValue()[2] < 9 ? 36 + e.getValue()[2] : e.getValue()[2];
                mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, newArmorslot, 0, SlotActionType.PICKUP, mc.player);
                mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 0, SlotActionType.PICKUP, mc.player);
                if (e.getValue()[1] != -1)
                    mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, newArmorslot, 0, SlotActionType.PICKUP, mc.player);
            }
            return;
        }
    }
}
Also used : ArmorItem(net.minecraft.item.ArmorItem) HashMap(java.util.HashMap) UpdateSelectedSlotC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ElytraItem(net.minecraft.item.ElytraItem) ItemStack(net.minecraft.item.ItemStack) ToolItem(net.minecraft.item.ToolItem) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with EquipmentSlot

use of net.minecraft.entity.EquipmentSlot in project MCDungeonsArmors by chronosacaria.

the class BurningEnchantment method onUserDamaged.

@Override
public void onUserDamaged(LivingEntity user, Entity attacker, int level) {
    Random random = user.getRandom();
    Entry<EquipmentSlot, ItemStack> entry = EnchantmentHelper.chooseEquipmentWith(BurningEnchantment.this, user);
    if (shouldDamageAttacker(level, random)) {
        if (attacker != null) {
            if (!attacker.isOnFire()) {
                attacker.setOnFireFor(3 * level);
            }
        }
    }
}
Also used : Random(java.util.Random) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EquipmentSlot

use of net.minecraft.entity.EquipmentSlot in project KiwiClient by TangyKiwi.

the class KiwiClient method onInitialize.

@Override
public void onInitialize() {
    mc = MinecraftClient.getInstance();
    Utils.mc = mc;
    CustomMatrix.begin(new MatrixStack());
    moduleManager = new ModuleManager();
    moduleManager.init();
    commandManager = new CommandManager();
    commandManager.init();
    discordRPC = new DiscordRP();
    discordRPC.start();
    EChestMemory eChestMemory = new EChestMemory();
    TickRate tickRate = new TickRate();
    eventBus.register(eChestMemory);
    eventBus.register(tickRate);
    eventBus.register(moduleManager);
    ClickGui.clickGui.initWindows();
    FabricLoader.getInstance().getModContainer("kiwiclient").ifPresent(modContainer -> {
        ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("kiwiclient:kiwitweaks"), "resourcepacks/kiwitweaks", modContainer, true);
    });
    UseItemCallback.EVENT.register((player, world, hand) -> {
        MinecraftClient mc = MinecraftClient.getInstance();
        ClientPlayerInteractionManager interactionManager = mc.interactionManager;
        if (mc.mouse.wasRightButtonClicked() && moduleManager.getModule(ArmorSwap.class).isEnabled()) {
            ItemStack stack = player.getMainHandStack();
            int currentItemIndex = player.getInventory().main.indexOf(stack);
            EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(stack);
            int armorIndexSlot = determineIndex(equipmentSlot);
            if (hand == Hand.MAIN_HAND && armorIndexSlot != -1) {
                SoundEvent sound = determineSound(stack.getItem());
                player.playSound(sound, 1.0F, 1.0F);
                interactionManager.clickSlot(player.playerScreenHandler.syncId, armorIndexSlot, currentItemIndex, SlotActionType.SWAP, player);
                return TypedActionResult.success(stack);
            }
        }
        return TypedActionResult.pass(ItemStack.EMPTY);
    });
    KeyBindingHelper.registerKeyBinding(zoomKey);
}
Also used : ClientPlayerInteractionManager(net.minecraft.client.network.ClientPlayerInteractionManager) MatrixStack(net.minecraft.client.util.math.MatrixStack) EquipmentSlot(net.minecraft.entity.EquipmentSlot) ModuleManager(com.tangykiwi.kiwiclient.modules.ModuleManager) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) SoundEvent(net.minecraft.sound.SoundEvent) CommandManager(com.tangykiwi.kiwiclient.command.CommandManager) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack)

Example 4 with EquipmentSlot

use of net.minecraft.entity.EquipmentSlot in project Biome-Makeover by Lemonszz.

the class EntityUtil method applyProjectileResistance.

public static void applyProjectileResistance(Iterable<ItemStack> equipment, MutableInt resistance) {
    MutableInt slotIndex = new MutableInt(0);
    equipment.forEach(e -> {
        if (!e.isEmpty()) {
            EquipmentSlot slot = EquipmentSlot.values()[2 + slotIndex.getValue()];
            if (e.getAttributeModifiers(slot).containsKey(BMEntities.ATT_PROJECTILE_RESISTANCE)) {
                Collection<EntityAttributeModifier> modifiers = e.getAttributeModifiers(slot).get(BMEntities.ATT_PROJECTILE_RESISTANCE);
                for (EntityAttributeModifier mod : modifiers) {
                    resistance.add(mod.getValue());
                }
            }
        }
        slotIndex.add(1);
    });
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) EquipmentSlot(net.minecraft.entity.EquipmentSlot) EntityAttributeModifier(net.minecraft.entity.attribute.EntityAttributeModifier)

Example 5 with EquipmentSlot

use of net.minecraft.entity.EquipmentSlot in project BedrockIfy by juancarloscp52.

the class ArmorReplacer method tryChangeArmor.

public static void tryChangeArmor(PlayerEntity user, Hand hand) {
    ItemStack newArmor = user.getStackInHand(hand);
    EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(newArmor);
    ItemStack currentArmor = user.getEquippedStack(equipmentSlot);
    user.equipStack(equipmentSlot, newArmor.copy());
    currentArmor.setCooldown(5);
    user.setStackInHand(hand, currentArmor);
}
Also used : EquipmentSlot(net.minecraft.entity.EquipmentSlot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EquipmentSlot (net.minecraft.entity.EquipmentSlot)7 ItemStack (net.minecraft.item.ItemStack)6 LivingEntity (net.minecraft.entity.LivingEntity)2 CommandManager (com.tangykiwi.kiwiclient.command.CommandManager)1 ModuleManager (com.tangykiwi.kiwiclient.modules.ModuleManager)1 EChestMemory (com.tangykiwi.kiwiclient.util.tooltip.EChestMemory)1 ArmorStandPreset (eu.pb4.armorstandeditor.config.ArmorStandPreset)1 ConfigManager (eu.pb4.armorstandeditor.config.ConfigManager)1 ArmorStandData (eu.pb4.armorstandeditor.helpers.ArmorStandData)1 ArmorStandInventory (eu.pb4.armorstandeditor.helpers.ArmorStandInventory)1 ItemFrameInventory (eu.pb4.armorstandeditor.helpers.ItemFrameInventory)1 SPEInterface (eu.pb4.armorstandeditor.helpers.SPEInterface)1 ArmorStandEntityAccessor (eu.pb4.armorstandeditor.mixin.ArmorStandEntityAccessor)1 ItemFrameEntityAccessor (eu.pb4.armorstandeditor.mixin.ItemFrameEntityAccessor)1 ClickType (eu.pb4.sgui.api.ClickType)1 GuiElement (eu.pb4.sgui.api.elements.GuiElement)1 GuiElementBuilder (eu.pb4.sgui.api.elements.GuiElementBuilder)1 GuiElementInterface (eu.pb4.sgui.api.elements.GuiElementInterface)1 AnvilInputGui (eu.pb4.sgui.api.gui.AnvilInputGui)1 SimpleGui (eu.pb4.sgui.api.gui.SimpleGui)1