Jump to content

Recommended Posts

Posted

Hi, I am having setting items in my creative tab using the tutorial on the wiki. I define my tab, then when I try to set it in my item class, it can't recognize it. Here is my mod file:

 

package NoctusRealm;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import NoctusRealm.Items.ItemDragonSword;
import NoctusRealm.Items.Items;
import NoctusRealm.References.CommonProxy;
import NoctusRealm.References.ModInfo;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION)
@NetworkMod(channels = {ModInfo.CHANNEL}, clientSideRequired = true, serverSideRequired = true)

public class NoctusRealm {

public static CreativeTabs tabNoctusRealm = new CreativeTabs("NoctusRealm") {
        public ItemStack getIconItemStack() {
                return new ItemStack(Items.DragonSword, 1, 0);
        }
};

@SidedProxy(clientSide = ModInfo.PROXYLOCATION + ".ClientProxy", serverSide = ModInfo.PROXYLOCATION + ".CommonProxy")
public static CommonProxy proxy;

@EventHandler
public static void preInit(FMLPreInitializationEvent event) {

	proxy.initRenders();
	proxy.initSounds();
	Items.init();
	MinecraftForge.EVENT_BUS.register(new ItemDragonSword.DragonFallEvent());

}

@EventHandler
public static void init(FMLInitializationEvent event) {



}

@EventHandler
public static void postInit(FMLPostInitializationEvent event) {



}

}

 

And my item file

 

package NoctusRealm.Items;

import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import NoctusRealm.References.Names;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemDragonSword extends ItemSword {

public ItemDragonSword(int id, EnumToolMaterial material) {

	super(id, material);
	this.setUnlocalizedName(Names.DragonSwordUnlocalizedName);
	this.setCreativeTabs(NoctusRealm.tabNoctusRealm);

}

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {

		double calculatedX = 5 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f);
		double calculatedZ = 5 * (double) (MathHelper.cos(player.rotationYaw	/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f);
		double calculatedY = 2.5 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f);
		player.motionY = calculatedY;
		player.motionX = calculatedX;
		player.motionZ = calculatedZ;	

	return itemStack;

}

public static class DragonFallEvent
{
	@ForgeSubscribe
	public void fallEvent(LivingFallEvent event)
	{
		EntityLivingBase player =  event.entityLiving;

		ItemStack stack = player.getHeldItem();
		if(stack != null && stack.getItem() == Items.DragonSword)

			event.setCanceled(true);

	}

}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister icon) {

	itemIcon = icon.registerIcon("nr" + ":" + "dragonsword");

}

public boolean hasEffect(ItemStack itemstack)
{
        return true;
}

@Override
    @SideOnly(Side.CLIENT)
    public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
    {
        list.add("Two-Handed");
    }
}

 

I get the error under

 

this.setCreativeTabs(NoctusRealm.tabNoctusRealm);

Posted

When extending ItemSword you cannot assign CreativeTab. What you can do is extend Item and then copy ItemSword code to it (since ItemSword extends Item it will be the same). About this ,,you cannot" - I am not sure, but after 1h of going through code I cannot get it working too. Its probably bug or you need to find some special method to do it - I realy don't know but I know that there are many who can't get it working either.

1.7.10 is no longer supported by forge, you are on your own.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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