Java Code Examples for net.minecraft.entity.EntityLivingBase#getPrimaryHand()
The following examples show how to use
net.minecraft.entity.EntityLivingBase#getPrimaryHand() .
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: ModelTofuMindCore.java From TofuCraftReload with MIT License | 5 votes |
protected EnumHandSide getMainHand(Entity entityIn) { if (entityIn instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) entityIn; EnumHandSide enumhandside = entitylivingbase.getPrimaryHand(); return entitylivingbase.swingingHand == EnumHand.MAIN_HAND ? enumhandside : enumhandside.opposite(); } else { return EnumHandSide.RIGHT; } }
Example 3
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 4
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; }
Example 5
Source File: RendererBackpack.java From WearableBackpacks with MIT License | 4 votes |
public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { IBackpack backpack; RenderOptions renderOptions; if (_overrideBackpack != null) { backpack = _overrideBackpack; renderOptions = _overrideRenderOptions; } else { backpack = BackpackHelper.getBackpack(entity); BackpackEntityEntry entry = BackpackRegistry.getEntityEntry(entity.getClass()); renderOptions = (entry != null) ? entry.renderOptions : null; } if ((backpack == null) || (renderOptions == null)) return; GlStateManager.pushMatrix(); if (entity.isChild()) { GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.translate(0.0F, 24.0F * scale, 0.0F); } ModelBase modelBase = this.livingEntityRenderer.getMainModel(); if (modelBase instanceof ModelBiped) { ModelRenderer bipedBody = ((ModelBiped) modelBase).bipedBody; if (entity.isSneaking()) { // FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..? GlStateManager.translate(0.0F, 0.2F, 0.0F); } bipedBody.postRender(scale); } else { // Fallback to the custom way of transforming the backpack. // Make backpack swing with body as players swing their arms. float swingProgress = entity.getSwingProgress(partialTicks); float swingAngle = MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2.0F)) * 0.2F; if ((entity.swingingHand == EnumHand.OFF_HAND) ^ (entity.getPrimaryHand() == EnumHandSide.LEFT)) swingAngle *= -1; if (swingAngle != 0) GlStateManager.rotate((float)Math.toDegrees(swingAngle), 0.0F, 1.0F, 0.0F); // Rotate backpack if entity is sneaking. if (entity.isSneaking()) { // FIXME: Can be sneaking while flying with the elytra, then backpack is misaligned..? GlStateManager.translate(0.0F, 0.2F, 0.0F); GlStateManager.rotate(90.0F / (float)Math.PI, 1.0F, 0.0F, 0.0F); } } GlStateManager.scale(renderOptions.scale, renderOptions.scale, renderOptions.scale); GlStateManager.translate(8.0F * scale, renderOptions.y * scale, renderOptions.z * scale); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate((float)renderOptions.rotate, 1.0F, 0.0F, 0.0F); GlStateManager.translate(0, ProxyClient.MODEL_BACKPACK_BOX.maxY * scale * -16, ProxyClient.MODEL_BACKPACK_BOX.minZ * scale * -16); renderBackpack(backpack, entity.ticksExisted + partialTicks, false); GlStateManager.popMatrix(); }