Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mightydanp.eot.item;
- import java.util.List;
- import com.mightydanp.eot.EotCore;
- import com.mightydanp.eot.lib.ItemStrings;
- import com.mightydanp.eot.lib.References;
- import cpw.mods.fml.common.registry.GameRegistry;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.client.renderer.texture.IIconRegister;
- 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.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.World;
- public class ItemMagicalStone extends Item{
- public ItemMagicalStone(String unlocalizedName){
- this.setCreativeTab(EotCore.eotTab);
- this.setUnlocalizedName(unlocalizedName);
- this.setTextureName(References.RESOURCESPREFIX + unlocalizedName);
- this.setMaxDamage(16);
- this.setMaxStackSize(1);
- GameRegistry.registerItem(this, unlocalizedName);
- }
- private int cooldown = 180;
- @SideOnly(Side.CLIENT)
- public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool){
- if(itemStack.getItemDamage() > itemStack.getMaxDamage()){
- dataList.add("This seems to be pulsing power.");
- dataList.add("It only happens whenever i get close to these creatures.");
- dataList.add("I wonder if this is linked to them.");
- }else{
- dataList.add("The Magical Stone seems to be full?");
- dataList.add("It seems to be useless now.");
- dataList.add("I wonder whats inside?");
- if(cooldown < 180){
- dataList.add("");
- dataList.add("Everytime I use this now it seems to get hotter.");
- dataList.add("Maybe I should let it cool off.");
- }
- }
- }
- @Override
- public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer entityplayer, EntityLivingBase entity ){
- if(!entity.worldObj.isRemote){
- return false;
- }
- if(cooldown == 180){
- if (entity instanceof EntityMob){
- if(itemstack.getItemDamage() > 0){
- entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY +"Soul Absurbed!"));
- itemstack.damageItem(-1, entityplayer);
- entity.setHealth(0.0F);
- return true;
- } else {
- entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The Magical Stone seems to be full?"));
- entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "It seems to be useless now."));
- entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "I wonder whats inside?"));
- return true;
- }
- }else{
- entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Why has this stoped working?"));
- }
- }else{
- if(cooldown < 180){
- return false;
- }
- }
- cooldown = 0;
- return false;
- //return super.itemInteractionForEntity(itemstack, entityplayer, entity);
- }
- @Override
- public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
- super.onUpdate(stack, world, entity, par4, par5);
- if(cooldown < 180){
- cooldown++;
- }
- if (!world.isRemote && stack.getItem() == ModItems.magicalStone){
- int radius = 3;
- int x = (int)entity.posX;
- int y = (int)entity.posY;
- int z = (int)entity.posZ;
- List entities = world.getEntitiesWithinAABB(EntityMob.class, entity.boundingBox.expand(x - radius, y - radius, z - radius));
- for (int i = 0; i < entities.size(); i++){
- if (entity instanceof EntityMob){
- hasEffect(stack);
- break;
- }
- }
- }
- }
- @SideOnly(Side.CLIENT)
- public boolean hasEffect(ItemStack itemStack)
- {
- if(itemStack.getItemDamage() > 0){
- return false;
- }else{
- return itemStack.getItemDamage() == 0;
- }
- }
- public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer entityplayer)
- {
- return itemstack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement