本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getHeldItemMainhand方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getHeldItemMainhand方法的具体用法?Java EntityLivingBase.getHeldItemMainhand怎么用?Java EntityLivingBase.getHeldItemMainhand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getHeldItemMainhand方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRenderLayer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
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.func_190926_b() || !itemstack1.func_190926_b())
{
GlStateManager.pushMatrix();
if (this.livingEntityRenderer.getMainModel().isChild)
{
float f = 0.5F;
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();
}
}
示例2: stopJump
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void stopJump(LivingEvent.LivingJumpEvent event) {
EntityLivingBase living=event.getEntityLiving();
if ((living.getActivePotionEffect(TF2weapons.stun) != null && living.getActivePotionEffect(TF2weapons.bombmrs) == null)
|| living.getActivePotionEffect(TF2weapons.charging) != null
|| (living.getHeldItemMainhand() != null && living.getHeldItemMainhand().getItem() instanceof ItemMinigun
&& living.hasCapability(TF2weapons.WEAPONS_CAP, null) && living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks > 0)) {
living.isAirBorne = false;
living.motionY -= 0.5f;
if (living.isSprinting()) {
float f = living.rotationYaw * 0.017453292F;
living.motionX += MathHelper.sin(f) * 0.2F;
living.motionZ -= MathHelper.cos(f) * 0.2F;
}
}
}
示例3: getFeignDeathWatch
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack getFeignDeathWatch(EntityLivingBase living) {
ItemStack stack=living.getHeldItemMainhand();
if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
return stack;
}
else {
stack=living.getHeldItemOffhand();
if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
return stack;
}
IItemHandler items=living.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
for(int i=0; i<items.getSlots(); i++) {
stack=items.getStackInSlot(i);
if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
return stack;
}
}
}
return ItemStack.EMPTY;
}
示例4: doAxeStuff
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private void doAxeStuff(EntityLivingBase attacked, EntityLivingBase attacker)
{
//Copied from EntityMob#attackEntityAsMob() L134-150 START
if (attacked instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)attacked;
ItemStack itemstack = attacker.getHeldItemMainhand();
ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;
if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == RegisterItems.wickerShield)
{
float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(attacker) * 0.05F;
if (attacker.world.rand.nextFloat() < f1)
{
entityplayer.getCooldownTracker().setCooldown(RegisterItems.wickerShield, 100);
attacker.world.setEntityState(entityplayer, (byte) 30);
}
}
}
//Copied from EntityMob#attackEntityAsMob() L134-150 END
}
示例5: doRenderLayer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
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 != null || itemstack1 != null)
{
GlStateManager.pushMatrix();
if (this.livingEntityRenderer.getMainModel().isChild)
{
float f = 0.5F;
GlStateManager.translate(0.0F, 0.625F, 0.0F);
GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 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();
}
}
示例6: getChargingShield
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack getChargingShield(EntityLivingBase living) {
if (living.getHeldItemMainhand() != null && living.getHeldItemMainhand().getItem() instanceof ItemChargingTarge)
return living.getHeldItemMainhand();
else if (living.getHeldItemOffhand() != null
&& living.getHeldItemOffhand().getItem() instanceof ItemChargingTarge)
return living.getHeldItemOffhand();
else
return ItemStack.EMPTY;
}
示例7: altUse
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void altUse(ItemStack stack, EntityLivingBase living, World world) {
if (TF2Attribute.getModifier("Ball Release", stack, 0, living) > 0) {
ItemStack ballStack = getNewStack("sandmanball");
if (!ItemAmmo.searchForAmmo(living, ballStack).isEmpty()) {
if (living instanceof EntityPlayer)
((EntityPlayer)living).getCooldownTracker().setCooldown(this, this.getFiringSpeed(ballStack, living)/50);
ItemStack oldHeldItem = living.getHeldItemMainhand();
living.setHeldItem(EnumHand.MAIN_HAND, ballStack);
((ItemProjectileWeapon) ballStack.getItem()).use(ballStack, living, world, EnumHand.MAIN_HAND, null);
living.setHeldItem(EnumHand.MAIN_HAND, oldHeldItem);
}
}
}
示例8: damageShield
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
void damageShield(EntityLivingBase attacked, EntityLivingBase attacker, float f)
{
ItemStack shield = null;
if(Prep1_11.isValid(attacked.getHeldItemOffhand()) && attacked.getHeldItemOffhand().getItem() == RegisterItems.wickerShield)
shield = attacked.getHeldItemOffhand();
else if(Prep1_11.isValid(attacked.getHeldItemMainhand()) && attacked.getHeldItemMainhand().getItem() == RegisterItems.wickerShield)
shield = attacked.getHeldItemMainhand();
//Copied from EntityPlayer#damageShield() START
if(Prep1_11.isEmpty(shield)) return;
shield.damageItem(1 + MathHelper.floor(f), attacker);
if (shield.getCount() <= 0)
{
EnumHand enumhand = attacked.getActiveHand();
if(attacked instanceof EntityPlayer) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem((EntityPlayer) attacked, attacked.getActiveItemStack(), enumhand);
if (enumhand == EnumHand.MAIN_HAND)
{
attacked.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
else
{
attacked.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
}
attacked.resetActiveHand();
attacked.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + attacked.world.rand.nextFloat() * 0.4F);
}
//Copied from EntityPlayer#damageShield() END
}
示例9: getLightLevel
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static int getLightLevel(Entity p_getLightLevel_0_)
{
if (p_getLightLevel_0_ == Config.getMinecraft().getRenderViewEntity() && !Config.isDynamicHandLight())
{
return 0;
}
else
{
if (p_getLightLevel_0_ instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)p_getLightLevel_0_;
if (entityplayer.isSpectator())
{
return 0;
}
}
if (p_getLightLevel_0_.isBurning())
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityFireball)
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityTNTPrimed)
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityBlaze)
{
EntityBlaze entityblaze = (EntityBlaze)p_getLightLevel_0_;
return entityblaze.isCharged() ? 15 : 10;
}
else if (p_getLightLevel_0_ instanceof EntityMagmaCube)
{
EntityMagmaCube entitymagmacube = (EntityMagmaCube)p_getLightLevel_0_;
return (double)entitymagmacube.squishFactor > 0.6D ? 13 : 8;
}
else
{
if (p_getLightLevel_0_ instanceof EntityCreeper)
{
EntityCreeper entitycreeper = (EntityCreeper)p_getLightLevel_0_;
if ((double)entitycreeper.getCreeperFlashIntensity(0.0F) > 0.001D)
{
return 15;
}
}
if (p_getLightLevel_0_ instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)p_getLightLevel_0_;
ItemStack itemstack3 = entitylivingbase.getHeldItemMainhand();
int i = getLightLevel(itemstack3);
ItemStack itemstack1 = entitylivingbase.getHeldItemOffhand();
int j = getLightLevel(itemstack1);
ItemStack itemstack2 = entitylivingbase.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
int k = getLightLevel(itemstack2);
int l = Math.max(i, j);
return Math.max(l, k);
}
else if (p_getLightLevel_0_ instanceof EntityItem)
{
EntityItem entityitem = (EntityItem)p_getLightLevel_0_;
ItemStack itemstack = getItemStack(entityitem);
return getLightLevel(itemstack);
}
else
{
return 0;
}
}
}
}
示例10: execute
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.enchant.usage", new Object[0]);
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)getEntity(server, sender, args[0], EntityLivingBase.class);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
Enchantment enchantment;
try
{
enchantment = Enchantment.getEnchantmentByID(parseInt(args[1], 0));
}
catch (NumberInvalidException var12)
{
enchantment = Enchantment.getEnchantmentByLocation(args[1]);
}
if (enchantment == null)
{
throw new NumberInvalidException("commands.enchant.notFound", new Object[] {args[1]});
}
else
{
int i = 1;
ItemStack itemstack = entitylivingbase.getHeldItemMainhand();
if (itemstack.func_190926_b())
{
throw new CommandException("commands.enchant.noItem", new Object[0]);
}
else if (!enchantment.canApply(itemstack))
{
throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
}
else
{
if (args.length >= 3)
{
i = parseInt(args[2], enchantment.getMinLevel(), enchantment.getMaxLevel());
}
if (itemstack.hasTagCompound())
{
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int j = 0; j < nbttaglist.tagCount(); ++j)
{
int k = nbttaglist.getCompoundTagAt(j).getShort("id");
if (Enchantment.getEnchantmentByID(k) != null)
{
Enchantment enchantment1 = Enchantment.getEnchantmentByID(k);
if (!enchantment.func_191560_c(enchantment1))
{
throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.getTranslatedName(i), enchantment1.getTranslatedName(nbttaglist.getCompoundTagAt(j).getShort("lvl"))});
}
}
}
}
}
itemstack.addEnchantment(enchantment, i);
notifyCommandListener(sender, this, "commands.enchant.success", new Object[0]);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 1);
}
}
}
}
示例11: execute
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.enchant.usage", new Object[0]);
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)getEntity(server, sender, args[0], EntityLivingBase.class);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 0);
Enchantment enchantment;
try
{
enchantment = Enchantment.getEnchantmentByID(parseInt(args[1], 0));
}
catch (NumberInvalidException var12)
{
enchantment = Enchantment.getEnchantmentByLocation(args[1]);
}
if (enchantment == null)
{
throw new NumberInvalidException("commands.enchant.notFound", new Object[] {Integer.valueOf(Enchantment.getEnchantmentID(enchantment))});
}
else
{
int i = 1;
ItemStack itemstack = entitylivingbase.getHeldItemMainhand();
if (itemstack == null)
{
throw new CommandException("commands.enchant.noItem", new Object[0]);
}
else if (!enchantment.canApply(itemstack))
{
throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
}
else
{
if (args.length >= 3)
{
i = parseInt(args[2], enchantment.getMinLevel(), enchantment.getMaxLevel());
}
if (itemstack.hasTagCompound())
{
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int j = 0; j < nbttaglist.tagCount(); ++j)
{
int k = nbttaglist.getCompoundTagAt(j).getShort("id");
if (Enchantment.getEnchantmentByID(k) != null)
{
Enchantment enchantment1 = Enchantment.getEnchantmentByID(k);
if (!enchantment.canApplyTogether(enchantment1) || !enchantment1.canApplyTogether(enchantment)) //Forge BugFix: Let Both enchantments veto being together
{
throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.getTranslatedName(i), enchantment1.getTranslatedName(nbttaglist.getCompoundTagAt(j).getShort("lvl"))});
}
}
}
}
}
itemstack.addEnchantment(enchantment, i);
notifyCommandListener(sender, this, "commands.enchant.success", new Object[0]);
sender.setCommandStat(CommandResultStats.Type.AFFECTED_ITEMS, 1);
}
}
}
}