本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingHurtEvent.getSource方法的具體用法?Java LivingHurtEvent.getSource怎麽用?Java LivingHurtEvent.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.getSource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onHurtEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void onHurtEvent(LivingHurtEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
DamageSource damageSource = event.getSource();
float damage = event.getAmount();
if(entity != null)
{
IAttributeInstance damageRate = null;
if(isPhysicalDamage(damageSource))
damageRate = entity.getEntityAttribute(PHYSICAL_DAMAGE_RATE);
if(damageSource.isFireDamage())
damageRate = entity.getEntityAttribute(FIRE_DAMAGE_RATE);
if(damageRate != null)
damage *= damageRate.getAttributeValue();
}
event.setAmount(damage);
}
示例2: attackEntity
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
try
{
if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof BaseHarshenSword ||
((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
&&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
}
catch (ClassCastException clazz){}
}
示例3: attackEntity
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attackEntity(LivingHurtEvent event)
{
try
{
if((event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityLivingBase
&& (((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof RaptorScythe ||
((EntityLivingBase)((EntityDamageSource)event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof HarshenProps)
&&!(Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(3).getItem() == HarshenArmors.harshen_jaguar_armor_helmet
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(2).getItem() == HarshenArmors.harshen_jaguar_armor_chestplate
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(1).getItem() == HarshenArmors.harshen_jaguar_armor_leggings
&& Lists.newArrayList(event.getEntityLiving().getArmorInventoryList().iterator()).get(0).getItem() == HarshenArmors.harshen_jaguar_armor_boots)))
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 150, 1));
}
catch (ClassCastException clazz){}
}
示例4: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getImmediateSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
EnumHand active = cause.getActiveHand();
ItemStack stack = cause.getHeldItem(active);
RandoresItemHelper.doEmpowered(stack, hurt, cause);
if(stack.getItem() instanceof RandoresSledgehammer) {
Vec3d vector = hurt.getPositionVector().subtract(cause.getPositionVector()).normalize().scale(2);
hurt.addVelocity(vector.x, 0.5, vector.z);
}
}
}
示例5: postInit
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void postInit(LivingHurtEvent e) {
DamageSource source = e.getSource();
Iterable<ItemStack> armorStacks = e.getEntityLiving().getArmorInventoryList();
// boolean hasHeavyArmor = false;
float reduction = 0;
for (ItemStack armorStack : armorStacks) {
if (isHeavyArmor(armorStack)) {
if (source.isProjectile() || source.isExplosion()) {
reduction += 0.2;
}
}
}
if (reduction > 0) {
float newDamage = (1 - reduction) * e.getAmount();
System.out.println("Heavy armor reduction: [" + reduction + "] IN[" + e.getAmount() + "] OUT[" + newDamage + "]");
e.setAmount(newDamage);
}
}
示例6: fallOutOfTeletory
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void fallOutOfTeletory(LivingHurtEvent ev) {
if (ev.getEntity().getEntityWorld().isRemote || !(ev.getEntity() instanceof EntityPlayerMP)) {
return;
}
if (ev.getSource() != DamageSource.OUT_OF_WORLD) {
return;
}
EntityPlayerMP thePlayer = (EntityPlayerMP) ev.getEntity();
if (thePlayer.dimension != Teletory.DIMID) {
return;
}
ev.setCanceled(true);
changeEntityDimension(thePlayer, TeleportorType.FALL);
}
示例7: hurtEvents
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void hurtEvents(LivingHurtEvent e) {
if (!e.getEntity().getEntityWorld().isRemote) {
DamageSource source = e.getSource();
Entity entity = e.getEntity();
if (entity == null || entity.isDead) {
return;
}
if (source == DamageSource.drown && entity.isWet() && entity instanceof EntityPlayer && ConfigurationFile.hardcoreAir) {
((EntityPlayer) entity).setHealth(0.0f);
} else if (source == DamageSource.starve && entity instanceof EntityPlayer && ConfigurationFile.hardcoreHunger) {
((EntityPlayer) entity).setHealth(0.0f);
} else if (source.getEntity() instanceof EntityPlayer && ConfigurationFile.mobsRevengeMode) {
if (!(entity instanceof EntityPlayer) && entity instanceof EntityLiving) {
((EntityLiving) entity).addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 100, 1));
}
}
}
}
示例8: onLivingHurtEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingHurtEvent(LivingHurtEvent event) {
if (event.getEntity() != null && event.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)event.getEntity();
for (ItemStack armor : player.getArmorInventoryList()) {
if (armor != null && armor.getItem() instanceof LongFallBoots)
{
if (event.getSource() == DamageSource.FLY_INTO_WALL) {
System.out.println("Flew into wall");
// this cancels the fall event so you take no damage
event.setCanceled(true);
}
}
}
}
}
示例9: onEntityDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent event) {
DamageSource source = event.getSource();
Entity attacker = source.getTrueSource();
if ((attacker instanceof EntityLivingBase) && ((EntityLivingBase) attacker).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
event.setAmount(event.getAmount() * 0.95F);
}
}
示例10: onEntityHit
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityHit(LivingHurtEvent event)
{
if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource) event.getSource()).getTrueSource() instanceof EntityLivingBase &&
((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItem() instanceof GlassContainer &&
((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand().getItemDamage() == 0)
{
ItemStack stack = ((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).getHeldItemMainhand();
stack.setItemDamage(2);
((EntityLivingBase)((EntityDamageSource) event.getSource()).getTrueSource()).setHeldItem(EnumHand.MAIN_HAND, stack);
}
}
示例11: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
if(new Random().nextDouble() < GeneralConfig.bloodChance && event.getSource() instanceof EntityDamageSource && HarshenUtils.toArray(AllowedEntities).contains(event.getEntity().getClass()))
if(event.getEntity().world.isAirBlock(event.getEntity().getPosition()) && GeneralConfig.bloodDrops)
event.getEntity().getEntityWorld().setBlockState(event.getEntity().getPosition(), HarshenBlocks.BLOOD_BLOCK.getDefaultState(), 3);
else if(event.getSource().getTrueSource() instanceof EntityPlayer && GeneralConfig.bloodOffHand &&
((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem() == HarshenItems.BLOOD_COLLECTOR)
((BloodCollector)((EntityPlayer)event.getSource().getTrueSource()).getHeldItemOffhand().getItem()).fill(((EntityPlayer)event.getSource().getTrueSource()), EnumHand.OFF_HAND, 1);
}
示例12: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityZombie &&
!(((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityPigZombie))
event.setAmount(1);
}
示例13: PlayerPunchedEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
public PlayerPunchedEvent(LivingHurtEvent event, EntityPlayer attacker)
{
super(event.getEntityLiving());
this.source = event.getSource();
this.amount = event.getAmount();
this.attacker = attacker;
this.event = event;
}
示例14: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getTrueSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
if (EmpoweredEnchantment.appliedTo(hurt)) {
EmpoweredEnchantment.doArmor(hurt, cause);
}
}
}
示例15: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
DamageSource source = event.getSource();
if (source != null && source.getImmediateSource() != null) {
Entity entity = source.getImmediateSource();
if (entity != null && entity instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) entity;
if (attacker.getHeldItemMainhand().getItem() == ModItems.mace) {
float amount = Math.max(event.getAmount() - (20F / ((event.getEntityLiving().getTotalArmorValue() + 1F)) - 1F), (event.getAmount() / 3F));
event.setAmount(amount);
}
}
}
}