Jump to content

Recommended Posts

Posted

Hi.

 

I'm having trouble getting my items to show up on the custom creative tab that i made.

 

The items can be spawned by /give command.

And all textures are correct.

Even my custom creative tab shows, but its empty..

 

I create my custom tab in my main mod file:

public static final KaktusTab kaktusmodcreativetab = new KaktusTab("KaktusModTab");

 

My KaktusTab.java:

 

package kaktus.mods.kaktusmod;

import kaktus.mods.kaktusmod.items.kaktusItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class KaktusTab extends CreativeTabs{

public KaktusTab(String label) {
	super(label);
	this.setBackgroundImageName("kaktusmod.png");
}

@Override
public Item getTabIconItem() {
	return kaktusItems.turtleShellHelmet;
}

}

 

And my createitems routine:

 

turtleShellChestplate = new TurtleshellArmor("turtleshellchestplate", turtleArmorMaterial, 1, 1).setCreativeTab(KaktusMod.kaktusmodcreativetab);

 

I have also tried this in my custom armor class constructor:

 

this.setCreativeTab(KaktusMod.kaktusmodcreativetab);

 

So anyone knows what im doing wrong?

Not all things in the world are red, there are round objects too!

Posted

Here is my main mod file:

 

package kaktus.mods.kaktusmod;

import kaktus.mods.kaktusmod.entities.passive.EntityTurtle;

import kaktus.mods.kaktusmod.proxy.CommonProxy;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.LanguageRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.common.util.EnumHelper;

@Mod(modid = Config.MODID, name = Config.MODNAME, version = Config.VERSION, acceptedMinecraftVersions = "[1.8]", dependencies = "required-after:Forge@[11.14.3.1450,)")
public class KaktusMod {
@SidedProxy(clientSide = "kaktus.mods.kaktusmod.proxy.ClientProxy", serverSide = "kaktus.mods.kaktusmod.proxy.ServerProxy")
public static CommonProxy proxy;

@Mod.Instance(Config.MODID)
public static KaktusMod instance;

public static final KaktusTab kaktusmodcreativetab = new KaktusTab("KaktusModTab");

@EventHandler
public void preinit(FMLPreInitializationEvent event) {
	proxy.preInit(event);
}

@EventHandler
public void init(FMLInitializationEvent event) {
	proxy.init(event);
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
	proxy.postInit(event);
}

}

Not all things in the world are red, there are round objects too!

Posted

In my commonproxy.java:

 

public void preInit(FMLPreInitializationEvent event) {

	kaktusItems.createItems();

 

and then in my kaktusItems.java file:

 

package kaktus.mods.kaktusmod.items;

import kaktus.mods.kaktusmod.Config;
import kaktus.mods.kaktusmod.KaktusMod;
import kaktus.mods.kaktusmod.items.armor.TurtleshellArmor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class kaktusItems {

public static Item turtleShellHelmet;
public static Item turtleShellChestplate;
public static Item turtleShellLeggings;
public static Item turtleShellBoots;

public static ArmorMaterial turtleArmorMaterial = EnumHelper.addArmorMaterial(
		"turtleArmorMaterial",
		Config.MODID + ":turtleArmorMaterial", 
		1000, 
		new int[] {3, 8, 6, 3},
		30);


public static void createItems(){
	turtleShellHelmet = new TurtleshellArmor("turtleshellhelmet", turtleArmorMaterial, 1, 0);
	turtleShellChestplate = new TurtleshellArmor("turtleshellchestplate", turtleArmorMaterial, 1, 1).setCreativeTab(KaktusMod.kaktusmodcreativetab);
	turtleShellLeggings = new TurtleshellArmor("turtleshellleggings", turtleArmorMaterial, 2, 2).setCreativeTab(KaktusMod.kaktusmodcreativetab);
	turtleShellBoots = new TurtleshellArmor("turtleshellboots", turtleArmorMaterial, 1, 3).setCreativeTab(KaktusMod.kaktusmodcreativetab);

	registerItems();

}

public static void registerItems(){
	GameRegistry.registerItem(turtleShellHelmet, turtleShellHelmet.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(turtleShellChestplate, turtleShellChestplate.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(turtleShellLeggings, turtleShellLeggings.getUnlocalizedName().substring(5));
	GameRegistry.registerItem(turtleShellBoots, turtleShellBoots.getUnlocalizedName().substring(5));		
}

public static void registerRenders(){
	registerRender(turtleShellHelmet);
	registerRender(turtleShellChestplate);
	registerRender(turtleShellLeggings);
	registerRender(turtleShellBoots);
}

public static void registerRender(Item item){
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
			item, 0, new ModelResourceLocation(
					Config.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}

}

 

Anf then finally my armor class:

 

package kaktus.mods.kaktusmod.items.armor;

import java.util.List;

import kaktus.mods.kaktusmod.Config;
import kaktus.mods.kaktusmod.KaktusMod;
import kaktus.mods.kaktusmod.items.kaktusItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TurtleshellArmor extends ItemArmor implements ISpecialArmor {

public static final Enchantment[] helmetTurtleEnchantments = { Enchantment.thorns };
public static final int[] helmetTurtleEnchantmentLevels = { 3 };
public static final PotionEffect[] helmetTurtleEffects = { new PotionEffect(Potion.waterBreathing.id, 200, 0) };

public TurtleshellArmor(String unlocalizedName, ArmorMaterial material, int renderIndex, int armorType) {
	super(material, renderIndex, armorType);

	this.setUnlocalizedName(unlocalizedName);
	//this.setCreativeTab(KaktusMod.kaktusmodcreativetab);
	this.maxStackSize = 1;
}

@Override
public void onCreated(ItemStack itemStack, World worldIn, EntityPlayer player) {
	if (itemStack.getDisplayName().equals("turtleshellhelmet")) {
		for (int i = 0; i < helmetTurtleEnchantments.length; i++) {
			itemStack.addEnchantment(helmetTurtleEnchantments[i], helmetTurtleEnchantmentLevels[i]);
		}
	}
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) {
	ItemStack itemStack = new ItemStack(itemIn, 1, 0);

	if (itemIn.equals(kaktusItems.turtleShellHelmet)) {
		for (int i = 0; i < helmetTurtleEnchantments.length; i++) {
			itemStack.addEnchantment(helmetTurtleEnchantments[i], helmetTurtleEnchantmentLevels[i]);
		}
	}
}

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
	if (itemStack.getItem().equals(kaktusItems.turtleShellHelmet)) {
			this.effectPlayer(player, Potion.waterBreathing, 0);
	}
	if (this.isWearingFullSet(player, kaktusItems.turtleShellHelmet, kaktusItems.turtleShellChestplate, kaktusItems.turtleShellLeggings, kaktusItems.turtleShellBoots)) {
		this.effectPlayer(player, Potion.regeneration, 1);
	}
}

private void effectPlayer(EntityPlayer player, Potion potion, int amplifier) {
	//Always effect for 8 seconds, then refresh
	if (player.getActivePotionEffect(potion) == null || player.getActivePotionEffect(potion).getDuration() <= 1)
		player.addPotionEffect(new PotionEffect(potion.id, 159, amplifier, true, true));
}

private boolean isWearingFullSet(EntityPlayer player, Item helmet, Item chestplate, Item leggings, Item boots) {
	return player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() == helmet
			&& player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(2).getItem() == chestplate
			&& player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(1).getItem() == leggings
			&& player.inventory.armorItemInSlot(0) != null && player.inventory.armorItemInSlot(0).getItem() == boots;
}

@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
		int slot) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
	// TODO Auto-generated method stub

}

}

 

 

And then in my kaktusItems.java:

 


Not all things in the world are red, there are round objects too!

Posted

my clientproxy:

 

package kaktus.mods.kaktusmod.proxy;

import kaktus.mods.kaktusmod.Config;
import kaktus.mods.kaktusmod.KaktusMod;
import kaktus.mods.kaktusmod.entities.passive.EntityTurtle;
import kaktus.mods.kaktusmod.entities.renderer.RenderTurtle;
import kaktus.mods.kaktusmod.items.kaktusItems;
import kaktus.mods.kaktusmod.entities.kaktusMobs;
import kaktus.mods.kaktusmod.models.ModelTurtle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent event) {
	super.preInit(event);

	kaktusItems.createItems();
}

@Override
public void init(FMLInitializationEvent event) {
	super.init(event);

	kaktusItems.registerRenders();

	kaktusMobs.init();

}

@Override
public void postInit(FMLPostInitializationEvent event) {
	super.postInit(event);
}
}

Not all things in the world are red, there are round objects too!

Posted

Because ive tried to move the createitems call all over the place hoping to find that it would work in one place.

 

This merely the latest snapshot of my debugging.

Not all things in the world are red, there are round objects too!

Posted
Then whatever you are doing you are not registering your Items.

 

Then this must not be true, becaus i can /give my player the items, and i can wear them.

Even the potion effect of the helmet works.

Not all things in the world are red, there are round objects too!

Posted

I have now tried with

setCreativeTab(CreativeTabs.tabCombat);

 

With the same result, nothing.

 

Im setting up a github now if you want a better overlook.

Not all things in the world are red, there are round objects too!

Posted

Hm, maybe I can help. Going to look now in your repository, if I can find something I'll create a comment there.

 

And how its messed up? Well...

Example of my private (and free) Bitbucket repository:

 

gradle/wrapper

src/main

.gitignore

CONTRIBUTING.md

README.md

build.gradle

build.propeties

gradlew

gradlew.bat

 

Do you see the difference? (not just more files)

Bektor

Developer of Primeval Forest.

Posted

Hm, maybe I can help. Going to look now in your repository, if I can find something I'll create a comment there.

 

And how its messed up? Well...

Example of my private (and free) Bitbucket repository:

 

gradle/wrapper

src/main

.gitignore

CONTRIBUTING.md

README.md

build.gradle

build.propeties

gradlew

gradlew.bat

 

Do you see the difference? (not just more files)

Bektor

 

Ahh now I see, I created the repository one level to deep.  :P

 

(And thanks b.t.w. to offer your help  :) )

Not all things in the world are red, there are round objects too!

Posted

Yep. I'm now installing your Forge version, could take a while.

And I would recommend you to correct your class names:

 

Java:

  • Class names: first letter capitalized, example: Test
  • package names: first letter small, example: test
  • variable names: first letter small, example: test

Just a small information for the future, ;) because I saw one class which was different named. xD

 

Bektor

 

EDIT:

hm, it seems to be that your Forge is a bit out of date: In your main class you are using Forge 1.8-11.14.3.1450, newest recommend build is 1.8-11.14.4.1563. ;)

 

EDIT 2:

hm, for me there are no items, they just don't appear in the Game... going to track down the problem now

 

EDIT 3:

thats weird, how can the CreativeTab has access to an item which is never used... which does not appear in the game for me...

Developer of Primeval Forest.

Posted

I've updated the repo with your suggestions (Thanks b.t.w.)

 

Now I'm trying to figure out how I update Forge ith my current setup.

 

Updated forge to the latest recommended, still same error though, or rather, no error but strange behaviour ^^

Not all things in the world are red, there are round objects too!

Posted

Added this ti my armor class to se if it would crash. ( To se if this was actually run )

 

Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("MineCraft DIE!"));
	this.setCreativeTab(KaktusMod.kaktusmodcreativetab);
	Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("MineCraft DIE End."));

 

And sure enough, it crashed.

 

Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue

 

So am I right assuming that without these chat message the code will be runned? And therefor should set the item to the creative tab? (But it doesnt)

Not all things in the world are red, there are round objects too!

Posted

Hm, for me it the items don't want to appear ingame in any CreativeTab, but the CreativeTab is using the helmet for the icon, so they should be loaded.

But I wasn't able to find out why they don't appear in the CreativeTab...

 

Oh and when you rename the class, you have to rename the file itself, too. ;)

<classname>.java
public class <classname>

So replace the <classname> with your classname and then both should be the same, the filename and the class name, except for the .java ending of the filename ;)

(besides that, I'm wondering if there are BB codes like [icode][/icode] here on the forum)

 

Bektor

 

Developer of Primeval Forest.

Posted

That was my problem, that the items wont show up in creative tab, but they are accessible by "/give player kaktusmod:turtleshelhelmet" for example.

 

Then the item will show up in the inventory and you can throw it to the ground, pick it up again. Wear it, and the potion effect will start etc. It behaves like a normal item. But refuses to be in the creative tab.

 

Which class are you refering to?

 

I thought i renamed all classes and files.

Not all things in the world are red, there are round objects too!

Posted

What is your experience in the debugger? What breakpoints did you set, and what variable values did you see that you can't explain?

 

The debugger is your friend (at least it's a tool). Don't come here until you have either a log file from crash or a narrative from using the debugger.

 

You'll be amazed how many bugs you crack on your own steam once you invoke the debugger, and we will be so much more productive when you can share its info after you get stuck again.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

What is your experience in the debugger? What breakpoints did you set, and what variable values did you see that you can't explain?

 

The debugger dont show me anything useful, maybe I'm not using it as effectively as I could.

 

But I made a brekpoint on the setCreativeTab call in my item.

 

Followed (stepped) thru it and saw that the setCreativeTab function was run, and my item was passed along. (Not much of a function the setCreativeTab)

 

Then all went along.

 

There is no errors or anything.

Not all things in the world are red, there are round objects too!

Posted
Well, duh. Using the debug mode doesn't change how your program runs.
That was just an answer to him that there is no crash.

 

I did find the error though: This if statement will never ever evaluate to true, hence you do not produce any sub-items to be listed in the creative tab.

 

This actually evaluate to true, and the debugger share my beliefe becaus if i set a brekpoint inside it, the debugger kicks in and breaks at the breakpoint  ;)

http://image.baver.se/img/tce47wH

Not all things in the world are red, there are round objects too!

Posted

Yeah, I misread. The method still does not produce any sub-items. It creates an ItemStack, adds some enchantments to it and then forgets about it.

 

Ahh there it was.

 

I wonder what I was thinking..

 

But thank you for kickstarting my brain.

Not all things in the world are red, there are round objects too!

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.