Fixed destroy stones for multiple gauntlets

This commit is contained in:
Timo Ley 2019-05-30 13:24:12 +02:00
parent 68ef06a068
commit cf5846fc86

View file

@ -6,10 +6,12 @@ import anvil.infinity.data.GauntletUserInformation;
import anvil.infinity.helpers.GauntelHelper; import anvil.infinity.helpers.GauntelHelper;
import anvil.infinity.registry.Effects; import anvil.infinity.registry.Effects;
import lucraft.mods.lucraftcore.infinity.ModuleInfinity; import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
import lucraft.mods.lucraftcore.superpowers.abilities.supplier.IAbilityProvider;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityRabbit; import net.minecraft.entity.passive.EntityRabbit;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@ -63,10 +65,13 @@ public class SnapHelper {
return true; return true;
} else if (data.selectedSnapResult == SnapResult.DESTROYSTONES) { } else if (data.selectedSnapResult == SnapResult.DESTROYSTONES) {
entity.setHealth(1); entity.setHealth(1);
if (entity.getHeldItem(EnumHand.MAIN_HAND).getItem().equals(ModuleInfinity.INFINITY_GAUNTLET)) { Item mainHand = entity.getHeldItemMainhand().getItem();
entity.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(ModuleInfinity.INFINITY_GAUNTLET)); Item offHand = entity.getHeldItemOffhand().getItem();
} else { if (mainHand instanceof IAbilityProvider) {
entity.setHeldItem(EnumHand.OFF_HAND, new ItemStack(ModuleInfinity.INFINITY_GAUNTLET)); entity.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(mainHand));
}
if (offHand instanceof IAbilityProvider) {
entity.setHeldItem(EnumHand.OFF_HAND, new ItemStack(offHand));
} }
entity.attackEntityFrom(DamageSource.MAGIC, (entity.getHealth() / 10) - 0.01f); entity.attackEntityFrom(DamageSource.MAGIC, (entity.getHealth() / 10) - 0.01f);