Manually apply: 4fe5b68aaa100eeca675a596fcad9329403ecab8
This commit is contained in:
parent
145124e3dd
commit
f669e8b47b
1 changed files with 38 additions and 16 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue