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;
}
}
}
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);
}
}
}
}
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);
}
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);
});
}
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);
}
Aggregations