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.

[1.6.2][Items][Solved] Having to leave world for inventory to update.

Featured Replies

Posted

I have an item, when right clicked on a zombie, will consume current items and give another item. What is happening is that when I right click the zombie, the first items is being consumed, but the I'm not getting the other item, till I leave my world and re-login onto the world.

 

Here is the Item Code:

 

 

package evilmobs.items;

 

import java.util.List;

 

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

import net.minecraft.util.MathHelper;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import evilmobs.EvilMobs;

import evilmobs.core.config.EvilMobsItems;

 

public class ItemSyringe extends Item {

 

@SideOnly(Side.CLIENT)

private Icon[] icons;

 

public static final String[] names = new String[] {"normal", "zombie"};

 

public ItemSyringe(int par1) {

super(par1);

setUnlocalizedName("syringe");

setCreativeTab(EvilMobs.tabEvilMobs);

setHasSubtypes(true);

setMaxDamage(0);

}

 

@Override

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister par1IconRegister) {

 

icons = new Icon[2];

 

for(int i = 0; i < icons.length; i++) {

icons = par1IconRegister.registerIcon("EvilMobs:syringe"+ i);

}

}

 

@Override

public Icon getIconFromDamage(int par1) {

return icons[par1];

}

 

@Override

@SideOnly(Side.CLIENT)

public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) {

for (int x = 0; x < 2; x++) {

par3List.add(new ItemStack(this, 1, x));

}

}

 

@Override

public String getUnlocalizedName(ItemStack par1ItemStack) {

int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 15);

    return super.getUnlocalizedName() + "." + names;

}

 

@Override

public boolean func_111207_a(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) {

 

if (entity.worldObj.isRemote) {

return false;

}

 

if(player.isSneaking()) {

return false;

} else if(player.inventory.getFirstEmptyStack() != -1) {

 

if(itemstack.isItemEqual(new ItemStack(EvilMobsItems.syringe, 1, 0))) {

 

if (entity instanceof EntityZombie) {

 

entity.attackEntityAsMob(entity);

player.inventory.consumeInventoryItem(new ItemStack(EvilMobsItems.syringe, 1, 0).itemID);

player.inventory.addItemStackToInventory(new ItemStack(EvilMobsItems.syringe, 1, 1));

 

return true;

 

}

}

}

 

return false;

}

 

public static String itemName(int n) {

if(n == 0) {

return "Syringe";

}else if(n == 1) {

return "Zombie Blood";

}

return null;

}

 

}

 

 

 

 

Please help!

player.inventory.consumeInventoryItem(new ItemStack(EvilMobsItems.syringe, 1, 0).itemID);
               player.inventory.addItemStackToInventory(new ItemStack(EvilMobsItems.syringe, 1, 1));

Com'on, why don't you simply damage the item used ?

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.