2016-01-08 19:56:36 +00:00
|
|
|
package WayofTime.bloodmagic.item.soul;
|
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2016-03-16 08:10:33 +00:00
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
2016-03-17 20:00:44 +00:00
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2017-08-16 03:21:54 +00:00
|
|
|
import net.minecraft.client.util.ITooltipFlag;
|
2016-01-08 19:56:36 +00:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-18 18:54:31 +00:00
|
|
|
import net.minecraft.init.SoundEvents;
|
2016-01-08 19:56:36 +00:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-01-02 06:26:42 +00:00
|
|
|
import net.minecraft.util.*;
|
2016-01-08 19:56:36 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-03-16 08:10:33 +00:00
|
|
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2016-01-08 19:56:36 +00:00
|
|
|
|
2016-03-17 20:00:44 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public class ItemSoulSnare extends Item implements IVariantProvider {
|
|
|
|
public static String[] names = {"base"};
|
2016-01-08 19:56:36 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public ItemSoulSnare() {
|
2016-01-08 19:56:36 +00:00
|
|
|
super();
|
|
|
|
|
2017-08-15 03:53:42 +00:00
|
|
|
setUnlocalizedName(BloodMagic.MODID + ".soulSnare.");
|
|
|
|
setCreativeTab(BloodMagic.TAB_BM);
|
2016-01-08 19:56:36 +00:00
|
|
|
setHasSubtypes(true);
|
|
|
|
setMaxStackSize(16);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
2017-01-02 06:26:42 +00:00
|
|
|
ItemStack stack = playerIn.getHeldItem(hand);
|
2017-08-16 04:30:48 +00:00
|
|
|
if (!playerIn.capabilities.isCreativeMode) {
|
2017-01-02 06:26:42 +00:00
|
|
|
stack.shrink(1);
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 06:26:42 +00:00
|
|
|
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
2016-01-08 19:56:36 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
if (!worldIn.isRemote) {
|
2016-04-01 01:11:58 +00:00
|
|
|
EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn);
|
2016-04-24 17:06:28 +00:00
|
|
|
snare.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
|
2017-01-02 06:26:42 +00:00
|
|
|
worldIn.spawnEntity(snare);
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
|
|
|
|
2017-01-02 06:26:42 +00:00
|
|
|
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public String getUnlocalizedName(ItemStack stack) {
|
2016-01-08 19:56:36 +00:00
|
|
|
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-16 04:30:48 +00:00
|
|
|
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
2017-08-16 03:21:54 +00:00
|
|
|
if (!isInCreativeTab(creativeTab))
|
|
|
|
return;
|
|
|
|
|
2016-01-08 19:56:36 +00:00
|
|
|
for (int i = 0; i < names.length; i++)
|
2017-08-16 03:21:54 +00:00
|
|
|
list.add(new ItemStack(this, 1, i));
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2017-08-16 04:30:48 +00:00
|
|
|
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
2017-01-02 09:18:29 +00:00
|
|
|
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.soulSnare.desc"))));
|
2016-01-08 19:56:36 +00:00
|
|
|
|
2017-08-16 03:21:54 +00:00
|
|
|
super.addInformation(stack, world, tooltip, flag);
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
2016-03-16 08:10:33 +00:00
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public List<Pair<Integer, String>> getVariants() {
|
2016-03-16 08:10:33 +00:00
|
|
|
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
|
|
|
ret.add(new ImmutablePair<Integer, String>(0, "type=soulsnare"));
|
|
|
|
return ret;
|
|
|
|
}
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|