Manually apply: 4fe5b68aaa100eeca675a596fcad9329403ecab8

This commit is contained in:
modmuss50 2016-11-05 16:29:37 +00:00
parent 145124e3dd
commit f669e8b47b
No known key found for this signature in database
GPG key ID: 203A5ED4D3E48BEA

View file

@ -3,6 +3,7 @@ package techreborn.items.tools;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
@ -132,8 +133,16 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player,
EnumHand hand) {
if (player.isSneaking()) {
if (!PoweredItem.canUseEnergy(cost, stack)) {
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberEnergyErrorTo") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberActivate")));
} else {
if (stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("isActive")) {
if (stack.getTagCompound() == null) {
stack.setTagCompound(new NBTTagCompound());
}
stack.getTagCompound().setBoolean("isActive", true);
if (!world.isRemote && ConfigTechReborn.NanosaberChat) {
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
@ -153,6 +162,19 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo {
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (stack.getTagCompound() != null && stack.getTagCompound().getBoolean("isActive") && !PoweredItem.canUseEnergy(cost, stack)) {
ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString(
TextFormatting.GRAY + I18n.translateToLocal("techreborn.message.nanosaberEnergyError") + " "
+ TextFormatting.GOLD + I18n
.translateToLocal("techreborn.message.nanosaberDeactivating")));
stack.getTagCompound().setBoolean("isActive", false);
}
}
@Override
public double getDurabilityForDisplay(ItemStack stack) {