Hello, this is LittleBreadLoaf. I'll get right into it.
In my mod, the player is given a type and texture for their sword that is unique to the player. After they unlock it, they can "upgrade" their sword for short periods of time as long as they have energy. For activating the second-tier sword, a simple method is used:
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
if(props.getZType() == 1)
{
ItemStack shikai = new ItemStack(Items.shikaifire, 1);
par1ItemStack.itemID = shikai.itemID;
}
}
This part works just fine. To answer your question that I know you have, why not just use metadata, this is why: Depending on the player's type, they can get 12 different types of tier 2 swords, each with 5 textures available. I have the first sword go to different tier 2 swords, and from there to whatever texture they have, instead of one item with 60 different subtypes (or even 12, if I did textures differently)
However, to deactivate the tier 2 sword, I used a keybind and relatively the same code:
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
{
this.keyPressed = true;
EntityPlayer player = mc.thePlayer;
ItemStack heldItem = player.getCurrentEquippedItem();
ItemStack var13 = new ItemStack(Items.zanpakuto, 1);
if(heldItem != null )
{
if(heldItem.getItem() == Items.shikaifire)
{
heldItem.itemID = var13.itemID;
}
}
}
All well and good, but on servers it will sometimes revert the texture to the original tier 1 sword (zanpakuto), but keep the effects and damage of the tier two sword, and it still drains the player's energy.
So my questions are these:
1) Is there a better way of changing one item into another than switching item IDs?
2) If not, and my methods are ridiculous and terrible coding, do I need to make a bunch of different metadatas for this item?
3) It is registering the change of ID clientside, AKA changing the texture, but serverside keeps the tier 2 sword when deactivated. Is there a way I can keep my method but use packets to alert the server of the change?
If you want the rest of the item classes, just ask. I figure that's all that's needed to answer the question, but the rest is available.
Thanks for any help that may or may not come,
LittleBreadLoaf