mirror of
https://github.com/GTNewHorizons/Electro-Magic-Tools.git
synced 2026-11-19 19:49:55 +00:00
75 lines
2.3 KiB
Java
75 lines
2.3 KiB
Java
package emt.item.focus;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.LinkedList;
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import emt.EMT;
|
|
import emt.entity.EntityShield;
|
|
import emt.init.EMTBlocks;
|
|
import ic2.core.IC2;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.potion.PotionEffect;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
import net.minecraft.world.World;
|
|
import thaumcraft.api.aspects.Aspect;
|
|
import thaumcraft.api.aspects.AspectList;
|
|
import thaumcraft.common.items.wands.ItemWandCasting;
|
|
|
|
public class ItemShieldFocus extends ItemBaseFocus {
|
|
private static final AspectList visCost = new AspectList().add(Aspect.ORDER, 5).add(Aspect.WATER, 5).add(Aspect.AIR, 5);
|
|
|
|
public ItemShieldFocus() {
|
|
super("shield");
|
|
}
|
|
|
|
@Override
|
|
public int getFocusColor(ItemStack stack) {
|
|
return 0x1E90FF;
|
|
}
|
|
|
|
@Override
|
|
public AspectList getVisCost(ItemStack stack) {
|
|
return visCost;
|
|
}
|
|
|
|
@Override
|
|
public String getSortingHelper(ItemStack itemstack) {
|
|
return "SHIELD";
|
|
}
|
|
|
|
@Override
|
|
public boolean isUseItem(ItemStack stack) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int count) {
|
|
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
|
|
for (PotionEffect effect : new LinkedList<PotionEffect>(player.getActivePotionEffects())) {
|
|
IC2.platform.removePotion(player, effect.getPotionID());
|
|
}
|
|
if (!player.capabilities.isCreativeMode && !wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true)) {
|
|
player.stopUsingItem();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition paramMovingObjectPosition) {
|
|
ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();
|
|
player.setItemInUse(itemstack, Integer.MAX_VALUE);
|
|
if (!world.isRemote && (player.capabilities.isCreativeMode || wand.consumeAllVis(itemstack, player, getVisCost(itemstack), true, true))) {
|
|
EntityShield shield = new EntityShield(world, player);
|
|
world.spawnEntityInWorld(shield);
|
|
}
|
|
return itemstack;
|
|
}
|
|
}
|