Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mightydanp.eot.common.item;
- import java.util.List;
- import com.mightydanp.eot.api.common.item.IItem;
- import com.mightydanp.eot.common.EoT;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.monster.EntityMob;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.text.TextComponentString;
- import net.minecraft.util.text.TextFormatting;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- /**
- * @auther MightyDanp date class created: Jul 22, 2016
- */
- class ItemMagicalStone extends IItem {
- public static String emptyFirstLine = "This seems to be pulsing power.";
- public static String emptySecondLine = "It only happens whenever i get close to these creatures.";
- public static String emptyThirdLine = "I wonder if this is linked to them.";
- public static String fullFirstLine = "The Magical Stone seems to be full?";
- public static String fullSecondLine = "It seems to be useless now.";
- public static String fullThirdLine = "I wonder whats inside?";
- public static String coolDownFirstLine = "";
- public static String coolDownSecondLine = "Everytime I use this now it seems to get hotter.";
- public static String coolDownThirdLine = "Maybe I should let it cool off.";
- public static String[] subItemsDescriptionsFirstLine = new String[] { fullFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine };
- public static String[] subItemsDescriptionsSecondLine = new String[] { fullSecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine };
- public static String[] subItemsDescriptionsThirdLine = new String[] { fullThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine };
- public static String[] subItemsCoolDownDescriptionsFirstLine = new String[] { coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine };
- public static String[] subItemsCoolDownDescriptionsSecondLine = new String[] { coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine };
- public static String[] subItemsCoolDownDescriptionsThirdLine = new String[] { coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine };
- public ItemMagicalStone(String unlocalizedName) {
- super(unlocalizedName);
- this.setCreativeTab(EoT.tabEoT);
- this.setMaxDamage(16);
- this.setMaxStackSize(1);
- this.setHasSubtypes(true);
- }
- @Override
- public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) {
- super.onUpdate(itemStack, world, entity, i, flag);
- if (!world.isRemote) {
- NBTTagCompound nbtDataCompund;
- if (itemStack.hasTagCompound()) {
- nbtDataCompund = itemStack.getTagCompound();
- } else {
- nbtDataCompund = new NBTTagCompound();
- }
- int coolDown = nbtDataCompund.getInteger("coolDown");
- if (coolDown > 0) {
- --coolDown;
- nbtDataCompund.setInteger("coolDown", coolDown);
- }
- }
- }
- @Override
- public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity, EnumHand hand) {
- NBTTagCompound nbt;
- if (itemStack.hasTagCompound()) {
- nbt = itemStack.getTagCompound();
- } else {
- nbt = new NBTTagCompound();
- }
- int coolDown = nbt.getInteger("coolDown");
- if (coolDown > 0) {
- return false;
- }
- if (coolDown == 0) {
- if (entity instanceof EntityMob) {
- if (itemStack.getItemDamage() > 0) {
- entity.setHealth(0.0F);
- nbt.setInteger("coolDown", 180);
- if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Soul Absurbed!"));
- }
- itemStack.damageItem(-1, entityPlayer);
- return true;
- } else {
- if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "The Magical Stone seems to be full?"));
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "It seems to be useless now."));
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "I wonder whats inside?"));
- }
- return true;
- }
- } else if (!entity.worldObj.isRemote) {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
- }
- } else {
- entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
- }
- return false;
- }
- @SideOnly(Side.CLIENT)
- @Override
- public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool) {
- if (itemStack.getItemDamage() < 12) {
- dataList.add(subItemsDescriptionsFirstLine[itemStack.getItemDamage()]);
- dataList.add(subItemsDescriptionsSecondLine[itemStack.getItemDamage()]);
- dataList.add(subItemsDescriptionsThirdLine[itemStack.getItemDamage()]);
- }
- NBTTagCompound nbt;
- if (itemStack.hasTagCompound()) {
- nbt = itemStack.getTagCompound();
- } else {
- nbt = new NBTTagCompound();
- }
- int coolDown = nbt.getInteger("coolDown");
- if (coolDown > 0) {
- dataList.add(subItemsCoolDownDescriptionsFirstLine[itemStack.getItemDamage()]);
- dataList.add(subItemsCoolDownDescriptionsSecondLine[itemStack.getItemDamage()]);
- dataList.add(subItemsCoolDownDescriptionsThirdLine[itemStack.getItemDamage()]);
- }
- }
- @SideOnly(Side.CLIENT)
- @Override
- public boolean hasEffect(ItemStack itemStack) {
- if (itemStack.getItemDamage() > 0) {
- return false;
- } else {
- return itemStack.getItemDamage() == 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment