Java Code Examples for net.minecraft.entity.EntityLivingBase#getHeldItemMainhand()
The following examples show how to use
net.minecraft.entity.EntityLivingBase#getHeldItemMainhand() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerTofunianHeldItem.java From TofuCraftReload with MIT License | 6 votes |
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { boolean flag = entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT; ItemStack itemstack = flag ? entitylivingbaseIn.getHeldItemOffhand() : entitylivingbaseIn.getHeldItemMainhand(); ItemStack itemstack1 = flag ? entitylivingbaseIn.getHeldItemMainhand() : entitylivingbaseIn.getHeldItemOffhand(); if (!itemstack.isEmpty() || !itemstack1.isEmpty()) { GlStateManager.pushMatrix(); if (this.livingEntityRenderer.getMainModel().isChild) { GlStateManager.translate(0.0F, 0.75F, 0.0F); GlStateManager.scale(0.5F, 0.5F, 0.5F); } this.renderHeldItem(entitylivingbaseIn, itemstack1, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); this.renderHeldItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); GlStateManager.popMatrix(); } }
Example 2
Source File: ItemUnicornDagger.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void onAttackEntity(AttackEntityEvent event) { if (event.getTarget().canBeAttackedWithItem() && !event.getTarget().hitByEntity(event.getEntity()) && event.getTarget() instanceof EntityLivingBase && event.getTarget().hurtResistantTime <= 0) { EntityLivingBase attacker = event.getEntityLiving(); EntityLivingBase target = (EntityLivingBase) event.getTarget(); if (attacker.getHeldItemMainhand() == ItemStack.EMPTY) return; if (attacker.getHeldItemMainhand().getItem() != ModItems.UNICORN_DAGGER) return; float damage = 1 + EnchantmentHelper.getEnchantmentLevel(Enchantments.KNOCKBACK, attacker.getHeldItemMainhand()); float attackCD = attacker instanceof EntityPlayer ? ((EntityPlayer) attacker).getCooledAttackStrength(0.5F) : 1; damage *= (0.2f + attackCD * attackCD * 0.8f); target.attackEntityFrom(DamageSource.causeIndirectMagicDamage(attacker, null), damage); target.hurtResistantTime = 0; } }
Example 3
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public static ItemStack getHeldItemOfType(EntityLivingBase entity, Item item) { ItemStack stack = entity.getHeldItemMainhand(); if (stack.isEmpty() == false && stack.getItem() == item) { return stack; } stack = entity.getHeldItemOffhand(); if (stack.isEmpty() == false && stack.getItem() == item) { return stack; } return ItemStack.EMPTY; }
Example 4
Source File: EntityUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public static ItemStack getHeldItemOfType(EntityLivingBase entity, Class<?> clazz) { ItemStack stack = entity.getHeldItemMainhand(); if (stack.isEmpty() == false) { if (clazz.isAssignableFrom(stack.getItem().getClass())) { return stack; } } stack = entity.getHeldItemOffhand(); if (stack.isEmpty() == false) { if (clazz.isAssignableFrom(stack.getItem().getClass())) { return stack; } } return ItemStack.EMPTY; }
Example 5
Source File: ModuleInstance.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
/** * Will return the blockstate if one is selected when shift right clicking on a block in the stack. * * @param caster gets the caster's held item for convenience. */ @Nullable public final IBlockState getSelectedBlockState(EntityLivingBase caster) { ItemStack hand = caster.getHeldItemMainhand(); if (hand.isEmpty()) return null; if (NBTHelper.hasNBTEntry(hand, "selected")) { NBTTagCompound compound = NBTHelper.getCompound(hand, "selected"); if (compound == null) return null; return NBTUtil.readBlockState(compound); } return null; }
Example 6
Source File: ItemHandUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent(priority=EventPriority.NORMAL) public void handleLivingUpdate(CyberwareUpdateEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 1); if (CyberwareAPI.isCyberwareInstalled(e, test)) { boolean last = getLastClaws(e); boolean isEquipped = e.getHeldItemMainhand() == null && (e.getPrimaryHand() == EnumHandSide.RIGHT ? (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 1))) : (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(CyberwareContent.cyberlimbs, 1, 0)))); if (isEquipped && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, test))) { this.addUnarmedDamage(e, test); lastClaws.put(e.getEntityId(), true); if (!last) { if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { updateHand(e, true); } } } else { this.removeUnarmedDamage(e, test); lastClaws.put(e.getEntityId(), false); } } else { lastClaws.put(e.getEntityId(), false); } }
Example 7
Source File: ItemKimono.java From Sakura_mod with MIT License | 4 votes |
@SideOnly(Side.CLIENT) public static ModelBiped getKimonoModel(EntityLivingBase entityLiving, ItemStack itemStack,ModelBiped model) { if (model != null) { model.setVisible(true); model.isSneak = entityLiving.isSneaking(); model.isRiding = entityLiving.isRiding(); model.isChild = entityLiving.isChild(); ItemStack itemstack = entityLiving.getHeldItemMainhand(); ItemStack itemstack1 = entityLiving.getHeldItemOffhand(); ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY; ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY; if ((itemstack != null) && (!itemstack.isEmpty())) { modelbiped$armpose = ModelBiped.ArmPose.ITEM; if (entityLiving.getItemInUseCount() > 0) { EnumAction enumaction = itemstack.getItemUseAction(); if (enumaction == EnumAction.BLOCK) { modelbiped$armpose = ModelBiped.ArmPose.BLOCK; } else if (enumaction == EnumAction.BOW) { modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW; } } } if ((itemstack1 != null) && (!itemstack1.isEmpty())) { modelbiped$armpose1 = ModelBiped.ArmPose.ITEM; if (entityLiving.getItemInUseCount() > 0) { EnumAction enumaction1 = itemstack1.getItemUseAction(); if (enumaction1 == EnumAction.BLOCK) { modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK; } } } if (entityLiving.getPrimaryHand() == EnumHandSide.RIGHT) { model.rightArmPose = modelbiped$armpose; model.leftArmPose = modelbiped$armpose1; } else { model.rightArmPose = modelbiped$armpose1; model.leftArmPose = modelbiped$armpose; } } return model; }