use of net.minecraft.item.ElytraItem 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.item.ElytraItem in project icaruswings_mod by LocusAzzurro.
the class EnchantmentPyrotechnicAffinity method fireworkExtender.
@SubscribeEvent
public static void fireworkExtender(EntityJoinWorldEvent e) {
Entity entity = e.getEntity();
if (entity instanceof FireworkRocketEntity) {
FireworkRocketEntity firework = (FireworkRocketEntity) entity;
if (firework.isAttachedToEntity() && firework.attachedToEntity.getItemBySlot(EquipmentSlotType.CHEST).getItem() instanceof ElytraItem) {
int enchLvl = EnchantmentHelper.getEnchantmentLevel(EnchantmentRegistry.pyrotechnicAffinity.get(), firework.attachedToEntity);
firework.lifetime *= 1 + enchLvl * 0.1;
}
}
}
use of net.minecraft.item.ElytraItem in project BleachHack by BleachDrinker420.
the class ElytraReplace method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (mc.player.playerScreenHandler != mc.player.currentScreenHandler)
return;
int chestSlot = 38;
ItemStack chest = mc.player.getInventory().getStack(chestSlot);
if (chest.getItem() instanceof ElytraItem && chest.getDamage() == (Items.ELYTRA.getMaxDamage() - 1)) {
// search inventory for elytra
Integer elytraSlot = null;
for (int slot = 0; slot < 36; slot++) {
ItemStack stack = mc.player.getInventory().getStack(slot);
if (stack.getItem() instanceof ElytraItem && stack.getDamage() != (Items.ELYTRA.getMaxDamage() - 1)) {
elytraSlot = slot;
break;
}
}
if (elytraSlot == null) {
return;
}
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 6, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, elytraSlot < 9 ? (elytraSlot + 36) : (elytraSlot), 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 6, 0, SlotActionType.PICKUP, mc.player);
// Make them fly again
mc.options.keyJump.setPressed(true);
jump = true;
} else if (jump) {
// Make them fly again
mc.options.keyJump.setPressed(false);
jump = false;
}
}
use of net.minecraft.item.ElytraItem in project LevelZ by Globox1997.
the class ItemStackClientMixin method getTooltipMixin.
@Inject(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;appendTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/world/World;Ljava/util/List;Lnet/minecraft/client/item/TooltipContext;)V"), locals = LocalCapture.CAPTURE_FAILSOFT)
private void getTooltipMixin(@Nullable PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> info, List<Text> list, int i) {
if (player != null) {
ItemStack stack = (ItemStack) (Object) this;
ArrayList<Object> levelList = new ArrayList<Object>();
// Block
if (stack.getItem() instanceof BlockItem) {
Block block = ((BlockItem) stack.getItem()).getBlock();
// Alchemy check
if (PlayerStatsManager.listContainsItemOrBlock(player, Registry.ITEM.getRawId(stack.getItem()), false)) {
list.add(new TranslatableText("item.levelz.alchemy.tooltip", PlayerStatsManager.getUnlockLevel(Registry.ITEM.getRawId(stack.getItem()), false)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
if (block instanceof AnvilBlock) {
levelList = LevelLists.anvilList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.BEEHIVE) {
levelList = LevelLists.beehiveList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.BREWING_STAND) {
levelList = LevelLists.brewingStandList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.ENCHANTING_TABLE) {
levelList = LevelLists.enchantingTableList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.CAULDRON) {
levelList = LevelLists.cauldronList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.BARREL) {
levelList = LevelLists.barrelList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.BLAST_FURNACE) {
levelList = LevelLists.blastFurnaceList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.CARTOGRAPHY_TABLE) {
levelList = LevelLists.cartographyList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.COMPOSTER) {
levelList = LevelLists.composterList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.GRINDSTONE) {
levelList = LevelLists.grindstoneList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.LECTERN) {
levelList = LevelLists.lecternList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.LOOM) {
levelList = LevelLists.loomList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.SMITHING_TABLE) {
levelList = LevelLists.smithingTableList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.SMOKER) {
levelList = LevelLists.smokerList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (block == Blocks.STONECUTTER) {
levelList = LevelLists.stonecutterList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (PlayerStatsManager.listContainsItemOrBlock(player, Registry.BLOCK.getRawId(block), true)) {
list.add(new TranslatableText("item.levelz.mining.tooltip", PlayerStatsManager.getUnlockLevel(Registry.BLOCK.getRawId(block), true)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else // Item
if (stack.isIn(FabricToolTags.SHEARS)) {
levelList = LevelLists.sheepList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.isIn(FabricToolTags.PICKAXES) || stack.isIn(FabricToolTags.SHOVELS)) {
levelList = LevelLists.toolList;
String material = ((ToolItem) stack.getItem()).getMaterial().toString().toLowerCase();
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, material, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(levelList.indexOf(material) + 1).toString() + ".tooltip", levelList.get(levelList.indexOf(material) + 2).toString()).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.isIn(FabricToolTags.AXES)) {
levelList = LevelLists.axeList;
String material = ((ToolItem) stack.getItem()).getMaterial().toString().toLowerCase();
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, material, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(levelList.indexOf(material) + 1).toString() + ".tooltip", levelList.get(levelList.indexOf(material) + 2).toString()).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.isIn(FabricToolTags.HOES)) {
levelList = LevelLists.hoeList;
String material = ((ToolItem) stack.getItem()).getMaterial().toString().toLowerCase();
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, material, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(levelList.indexOf(material) + 1).toString() + ".tooltip", levelList.get(levelList.indexOf(material) + 2).toString()).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.isIn(FabricToolTags.SWORDS)) {
levelList = LevelLists.swordList;
String material = ((ToolItem) stack.getItem()).getMaterial().toString().toLowerCase();
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, material, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(levelList.indexOf(material) + 1).toString() + ".tooltip", levelList.get(levelList.indexOf(material) + 2).toString()).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() == Items.FLINT_AND_STEEL) {
levelList = LevelLists.flintAndSteelList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() == Items.GLASS_BOTTLE) {
levelList = LevelLists.dragonBreathList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() == Items.TOTEM_OF_UNDYING) {
levelList = LevelLists.totemList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof BowItem) {
levelList = LevelLists.bowList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof TridentItem) {
levelList = LevelLists.tridentList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof CrossbowItem) {
levelList = LevelLists.crossbowList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof ArmorItem) {
try {
levelList = LevelLists.armorList;
String material = ((ArmorItem) stack.getItem()).getMaterial().getName().toLowerCase();
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, material, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(levelList.indexOf(material) + 1).toString() + ".tooltip", levelList.get(levelList.indexOf(material) + 2).toString()).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} catch (AbstractMethodError ignored) {
}
} else if (stack.getItem() instanceof ShieldItem) {
levelList = LevelLists.shieldList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof ElytraItem) {
levelList = LevelLists.elytraList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof BucketItem) {
levelList = LevelLists.bucketList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (stack.getItem() instanceof FishingRodItem) {
levelList = LevelLists.fishingList;
if (!PlayerStatsManager.playerLevelisHighEnough(player, levelList, null, false)) {
list.add(new TranslatableText("item.levelz." + levelList.get(0) + ".tooltip", levelList.get(1)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
} else if (PlayerStatsManager.listContainsItemOrBlock(player, Registry.ITEM.getRawId(stack.getItem()), false)) {
list.add(new TranslatableText("item.levelz.alchemy.tooltip", PlayerStatsManager.getUnlockLevel(Registry.ITEM.getRawId(stack.getItem()), false)).formatted(Formatting.GRAY));
list.add(new TranslatableText("item.levelz.locked.tooltip"));
}
}
}
use of net.minecraft.item.ElytraItem in project icaruswings_mod by LocusAzzurro.
the class EnchantmentBlessingOfTheSky method onEntityHurt.
@SubscribeEvent
public static void onEntityHurt(LivingHurtEvent e) {
if (e.getEntity() instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) e.getEntity();
ItemStack armor = livingEntity.getItemBySlot(EquipmentSlotType.CHEST);
if (livingEntity.isFallFlying() && armor.getItem() instanceof ElytraItem && EnchantmentHelper.getEnchantmentLevel(EnchantmentRegistry.blessingOfTheSky.get(), livingEntity) > 0 && isValidDamageType(e.getSource())) {
e.setAmount(e.getAmount() / 2);
}
}
}
Aggregations