Jump to content

addInformation method help!


Toxic_Herobrine

Recommended Posts

Hello, Im fairly new to modding, heres what I have so far for my items lore:

 

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
      par3List.add("Herobrines sword.");
      par3List.add("Press shift for more info");
      if(GuiScreen.isShiftKeyDown()){
      par3List.add("Damage mob: Instant kills any mob with life of 10 hearts");
      par3List.add("Ability: Smoke screen for pvp.");
      par3List.add("Upgrade: none (W.I.P)");
}
   }

I would like to know how can I make the "Press shift for more info" Disapear on more info is shown, please note im not good with java I really only want an answer that can fix my problem with only editing in the item class file.

Link to comment
Share on other sites

if(GuiScreen.isShiftKeyDown()){
//...
}
else {
    par3List.add("Press shift for more info");
}

 

?

 

I mean come on...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You don't check if the key is being held at first-

@Override
    public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par3) {
        if(GuiScreen.isShiftKeyDown()){
            list.add("Damage mob: Instant kills any mob with life of 10 hearts");
            list.add("Ability: Smoke screen for pvp.");
            list.add("Upgrade: none (W.I.P)");
        }else{
            list.add("Herobrines sword.");
            list.add("Press shift for more info");
        }
    }

View my website at -> http://www.xelitexirish.com/

You can nearly always contact me on my twitter (XeliteXirish)

Link to comment
Share on other sites

Hey, I know I asked a really dumb question last night but, I used the method provided by @Draco18s but, Its not working now, when I add the method and test it its just a blank space, there's no change to the code given to me, it worked last night but now, it won't even show the lore thats default when not pushing shift. just a blank spot where it should be.

if this is a known issue or a bug and you know a fix please reply or pm me.

 

Link to comment
Share on other sites

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {

if(GuiScreen.isShiftKeyDown()){

      par3List.add("Damage to mobs: 15 Hearts");

      par3List.add("Ability: Sharpened edge");

}

else {

    par3List.add("Crafted from the raw essence of gods");

    par3List.add("Press shift");

}

}

Link to comment
Share on other sites

That would work.

 

Ok ok, Ima be honest, I *used* MCreator most of the time for the basic class files to be made easily, now I use eclipse.

but the problem is I pasted that in. and its just blank then shift makes it all blank where it would be, I get no errors.

so Ima post the whole code below, but please don't make fun of me for using mcreator, Im now just learning java and its methods/reference's.

 

Code:

package mod.mcreator;//based on master condiguration

import cpw.mods.fml.client.*;
import cpw.mods.fml.client.registry.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.asm.*;
import cpw.mods.fml.common.asm.transformers.*;
import cpw.mods.fml.common.discovery.*;
import cpw.mods.fml.common.discovery.asm.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.functions.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.toposort.*;
import cpw.mods.fml.common.versioning.*;
import cpw.mods.fml.relauncher.*;
import cpw.mods.fml.server.*;
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.*;
import net.minecraft.client.audio.*;
import net.minecraft.client.entity.*;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.achievement.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraft.client.model.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.tileentity.*;
import net.minecraft.client.settings.*;
import net.minecraft.command.*;
import net.minecraft.crash.*;
import net.minecraft.creativetab.*;
import net.minecraft.dispenser.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.boss.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.item.*;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.*;
import net.minecraft.entity.projectile.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.item.crafting.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.network.rcon.*;
import net.minecraft.pathfinding.*;
import net.minecraft.potion.*;
import net.minecraft.profiler.*;
import net.minecraft.server.*;
import net.minecraft.server.dedicated.*;
import net.minecraft.server.gui.*;
import net.minecraft.server.integrated.*;
import net.minecraft.server.management.*;
import net.minecraft.src.*;
import net.minecraft.stats.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.village.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.*;
import net.minecraft.world.chunk.storage.*;
import net.minecraft.world.demo.*;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.layer.*;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.storage.*;
import net.minecraftforge.classloading.*;
import net.minecraftforge.client.*;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.common.*;
import net.minecraftforge.event.*;
import net.minecraftforge.event.entity.*;
import net.minecraftforge.event.entity.item.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.minecart.*;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.oredict.*;
import net.minecraftforge.transformers.*;
import net.minecraft.init.*;
import java.util.*;

import net.minecraftforge.common.util.*;public class mcreator_swordOfGods{

public mcreator_swordOfGods(){}

public static Item block;
public static Object instance;public void load(){
ItemStack stack = new ItemStack(block, 1);
GameRegistry.addRecipe(stack, new Object[]{
"X1X", "X4X", "X7X", Character.valueOf('1'), new ItemStack(Items.nether_star, 1), Character.valueOf('4'), new ItemStack(Items.nether_star, 1), Character.valueOf('7'), new ItemStack(Items.blaze_rod, 1), 
});}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public int addFuel(ItemStack fuel){return 0;}
public void serverLoad(FMLServerStartingEvent event){}
public void preInit(FMLPreInitializationEvent event){}
public void registerRenderers(){}

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
if(GuiScreen.isShiftKeyDown()){
      par3List.add("Damage to mobs: 15 Hearts");
      par3List.add("Ability: Sharpened edge");
}
else {
    par3List.add("Crafted from the raw essence of gods");
    par3List.add("Press shift");
}
}


static{
Item.ToolMaterial enumt = EnumHelper.addToolMaterial("SWORDOFGODS", 0, 2500, 0F, 15, 2);block = (Item)(new ItemSword(enumt){public Set<String> getToolClasses(ItemStack stack){
HashMap<String, Integer> ret = new HashMap<String, Integer>();
ret.put("sword", 0);
return ret.keySet();
}
}).setUnlocalizedName("SwordOfGods").setTextureName("Herobrines_sword");
Item.itemRegistry.addObject(436, "SwordOfGods", block);

}

}

 

Like I said, im a newb so, please no hate.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.