本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.getAttackingEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.getAttackingEntity方法的具體用法?Java EntityLivingBase.getAttackingEntity怎麽用?Java EntityLivingBase.getAttackingEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getAttackingEntity方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleBounty
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@SubscribeEvent
public void handleBounty(LootingLevelEvent event) {
EntityLivingBase target = event.getEntityLiving();
EntityLivingBase attacker = target.getAttackingEntity();
if (attacker instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) attacker;
Collection<PotionEffect> potions = player.getActivePotionEffects();
for (PotionEffect potion : potions) {
if (potion.getPotion() instanceof PotionHunt) {
PotionHunt huntPotion = (PotionHunt) potion.getPotion();
if (huntPotion.appliesTo(target)) {
event.setLootingLevel(event.getLootingLevel() + 2);
return;
}
}
}
}
}
示例2: getDeathMessage
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Returns the message to be displayed on player death.
*/
@Override
public ITextComponent getDeathMessage(EntityLivingBase par1EntityLivingBase) {
String messageMeta = "";
int messageNumber = par1EntityLivingBase.getRNG().nextInt(deathMessages) + 1;
messageMeta = messageNumber + "";
EntityLivingBase entitylivingbase1 = par1EntityLivingBase.getAttackingEntity();
String s = "death.attack." + damageType + messageMeta;
String s1 = s + ".player";
return entitylivingbase1 != null && I18n.hasKey(s1) ?
new TextComponentTranslation(s1, par1EntityLivingBase.getDisplayName(), entitylivingbase1.getDisplayName()) :
new TextComponentTranslation(s, par1EntityLivingBase.getDisplayName());
}
示例3: getDeathMessage
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn) {
EntityLivingBase entitylivingbase = entityLivingBaseIn.getAttackingEntity();
String s = "death.attack." + this.damageType;
String s1 = s + ".player";
return entitylivingbase != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), entitylivingbase.getDisplayName()}) : new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName()});
}
示例4: getDeathMessage
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
@Nonnull
public ITextComponent getDeathMessage(EntityLivingBase entity) {
EntityLivingBase entitylivingbase = entity.getAttackingEntity();
String s = "solar.death." + this.damageType;
String s1 = s + ".player";
return entitylivingbase != null && I18n.canTranslate(s1)
? new TextComponentTranslation(s1, entity.getDisplayName(), entitylivingbase.getDisplayName())
: new TextComponentTranslation(s, entity.getDisplayName());
}
示例5: getDeathMessage
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Gets the death message that is displayed when the player dies
*/
public ITextComponent getDeathMessage(EntityLivingBase entityLivingBaseIn)
{
EntityLivingBase entitylivingbase = entityLivingBaseIn.getAttackingEntity();
String s = "death.attack." + this.damageType;
String s1 = s + ".player";
return entitylivingbase != null && I18n.canTranslate(s1) ? new TextComponentTranslation(s1, new Object[] {entityLivingBaseIn.getDisplayName(), entitylivingbase.getDisplayName()}): new TextComponentTranslation(s, new Object[] {entityLivingBaseIn.getDisplayName()});
}
示例6: onLivingAttack
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent e)
{
EntityLivingBase attacked = e.getEntityLiving();
EntityLivingBase attacker = attacked.getAttackingEntity();
if(attacker == null) return;
damageShield(attacked, attacker, e.getAmount());
doAxeStuff(attacked, attacker);
}