Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I tried to make a food item with 7 metadata states. Each one should have a own potion effect. They should have the same texture and label. I want to implement the addInformation() Method so that the effect is displayed under the Item! My code so far:

 

package VoidCatz.Basic;

import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemFoodBasic extends ItemFood{
private String filename = "Basic:basicitem"; //icon filename
private int effectID = getEffectID(??); //What do you put here?

public ItemFoodBasic(int id, int food, float saturation, boolean wolf) {
	super(id, food, saturation, wolf);
	this.setMaxStackSize(16);
	this.setHasSubtypes(true);
	this.setMaxDamage(0);
	this.setCreativeTab(CreativeTabs.tabFood);
	this.setPotionEffect(effectID, 60, 2, 1.0F);
}

@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg){
	this.itemIcon = reg.registerIcon(filename);
}

public int getEffectID(ItemStack is){ //checks the metadata and returns the effect id
	int damage = getItemDamageFromStack(is);
	switch(damage){
	case 0: return 1;
	case 1: return 3;
	case 2: return 5;
	case 3: return 8;
	case 4: return 11;
	case 5: return 12;
	case 6: return 13;
	default: return 1;
	}

}

public void setIcon(String IconLoc){
	filename = IconLoc;
}

@Override
public void addInformation(ItemStack is, EntityPlayer player, List l, boolean B){ //Additional info (eg. the names of music discs)
	int damage = getItemDamageFromStack(is);
	switch(damage){
	case 0: l.add("Speed");
	case 1: l.add("Haste");
	case 2: l.add("Strength");
	case 3: l.add("Jump Boost");
	case 4: l.add("Resistance");
	case 5: l.add("Fire Protection");
	case 6: l.add("Water Breathing");
	default: l.add("Speed");
}

}
}

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.