Nanosaber on/off state is now NBT
This commit is contained in:
parent
a938a1ab4d
commit
4516b9023f
1 changed files with 42 additions and 7 deletions
|
@ -24,6 +24,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import reborncore.RebornCore;
|
import reborncore.RebornCore;
|
||||||
import reborncore.api.power.IEnergyItemInfo;
|
import reborncore.api.power.IEnergyItemInfo;
|
||||||
import reborncore.common.powerSystem.PoweredItem;
|
import reborncore.common.powerSystem.PoweredItem;
|
||||||
|
import reborncore.common.util.ItemNBTHelper;
|
||||||
import reborncore.common.util.TorchHelper;
|
import reborncore.common.util.TorchHelper;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
|
||||||
|
@ -54,15 +55,49 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo, ITextur
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
ItemStack newStack = stack.copy();
|
if(player.isSneaking())
|
||||||
if(newStack.getItemDamage()==0){
|
{
|
||||||
newStack.setItemDamage(1);
|
changeMode(stack);
|
||||||
}
|
}
|
||||||
if(newStack.getItemDamage()==1){
|
return stack;
|
||||||
newStack.setItemDamage(0);
|
|
||||||
}
|
|
||||||
return newStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeMode(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (!ItemNBTHelper.verifyExistance(stack, "isActive"))
|
||||||
|
{
|
||||||
|
ItemNBTHelper.setBoolean(stack, "isActive", true);
|
||||||
|
}
|
||||||
|
else if(ItemNBTHelper.verifyExistance(stack, "isActive"))
|
||||||
|
{
|
||||||
|
stack.getTagCompound().removeTag("isActive");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItemActive(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (!ItemNBTHelper.verifyExistance(stack, "isActive"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||||
|
{
|
||||||
|
if(ItemNBTHelper.verifyExistance(stack, "isActive"))
|
||||||
|
{
|
||||||
|
list.add("Active");
|
||||||
|
}
|
||||||
|
else if(!ItemNBTHelper.verifyExistance(stack, "isActive"))
|
||||||
|
{
|
||||||
|
list.add("Not Active");
|
||||||
|
}
|
||||||
|
super.addInformation(stack, player, list, par4);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRepairable() {
|
public boolean isRepairable() {
|
||||||
|
|
Loading…
Reference in a new issue