Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wkangg committed Aug 8, 2024
1 parent 2a2d910 commit 83ba266
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package onelemonyboi.miniutilities.misc;

import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorItem;
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
import onelemonyboi.miniutilities.items.MUArmorMaterial;

import static onelemonyboi.miniutilities.renderer.AngelRingCheck.isEquipped;

public class UnstableArmorHandler {
public static void unstableArmor(LivingEquipmentChangeEvent event) {
if (event.getEntity() instanceof Player player) {
EquipmentSlot slot = event.getSlot();
// if not armour slot, return
if (slot != EquipmentSlot.HEAD && slot != EquipmentSlot.CHEST && slot != EquipmentSlot.LEGS && slot != EquipmentSlot.FEET) return;

long unstableCount = player.getInventory().armor.stream()
.filter(x -> x.getItem() instanceof ArmorItem)
.map(x -> (ArmorItem) x.getItem())
Expand All @@ -18,10 +25,14 @@ public static void unstableArmor(LivingEquipmentChangeEvent event) {
player.getAbilities().mayfly = true;
player.getAbilities().flying = true;
player.getAbilities().setWalkingSpeed(0.2f);

player.onUpdateAbilities();
}
else {
player.getAbilities().mayfly = false;
if (!player.isCreative() && !player.isSpectator() && !isEquipped(player)) {
player.getAbilities().mayfly = false;
player.getAbilities().flying = false;
}
player.getAbilities().setWalkingSpeed(0.1f);
player.onUpdateAbilities();
}
Expand Down

0 comments on commit 83ba266

Please sign in to comment.