本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingHurtEvent.getEntity方法的具體用法?Java LivingHurtEvent.getEntity怎麽用?Java LivingHurtEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: livingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void livingHurt(LivingHurtEvent event) {
if (!event.getEntity().world.isRemote)
if(event.getSource().getTrueSource() instanceof EntityArmyMember) {
if (event.getEntityLiving() instanceof EntityPlayerMP) {
if (event.getSource().isProjectile()) {
if (event.getSource().getTrueSource() instanceof EntitySkeletonWarrior && ((EntitySkeletonWarrior) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 0);
else if (event.getSource().getTrueSource() instanceof EntityConvertedSkeleton && ((EntityConvertedSkeleton) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 1);
}
if(ConfigValues.FF && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), event.getEntityLiving().getUniqueID()))
event.setCanceled(true);
} else if(ConfigValues.FF && event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
event.setCanceled(true);
} else if (ConfigValues.FF && event.getSource().getTrueSource() instanceof EntityPlayer) {
if(event.getEntityLiving() instanceof EntityPlayer && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), event.getEntityLiving().getUniqueID()))
event.setCanceled(true);
else if(event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
event.setCanceled(true);
}
}
示例2: onPlayerFall
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerFall(LivingHurtEvent event) {
if(!(event.getEntity() instanceof EntityPlayer)) {
return;
}
if(!event.getSource().damageType.equals(DamageSource.FALL.getDamageType())) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if(boots != null && boots.getItem() == ItemRegistry.getInstance().itemFallBoots) {
event.setAmount((1.0F-ConfigurationHandler.getInstance().bootFallDamageReduction)*event.getAmount());
}
}
示例3: 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);
}
示例4: 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));
}
}
}
}
示例5: 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);
}
}
}
}
}
示例6: PlayerInteraction
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void PlayerInteraction(LivingHurtEvent evt) {
if(Main.debug==1)System.out.println(evt.getEntity().getName() + " called PlayerHurt " + evt.getEntity().toString());
if(evt.getEntity() instanceof EntityPlayer && !Main.logged.contains(evt.getEntity().getName())){
evt.setCanceled(true);
}
}
示例7: onAttacked
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onAttacked(LivingHurtEvent event) {
World world = event.getEntity().getEntityWorld();
if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) {
return;
}
if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
orderGuardsToAttackAggressor((EntityCreature) event.getEntity(), event.getSource().getTrueSource());
}
}
示例8: underworldTeleport
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void underworldTeleport(LivingHurtEvent event) {
if (!(event.getEntity() instanceof EntityPlayer)) return;
if (event.getSource() == DamageSource.FALL && fallResetter.contains(event.getEntity().getUniqueID())) {
fallResetter.remove(event.getEntity().getUniqueID());
event.setCanceled(true);
return;
}
if (event.getEntity().getEntityWorld().provider.getDimension() == Wizardry.underWorld.getId()) {
if (event.getSource() == EntityDamageSource.OUT_OF_WORLD) {
EntityPlayer player = ((EntityPlayer) event.getEntityLiving());
BlockPos spawn = player.isSpawnForced(0) ? player.getBedLocation(0) : player.world.getSpawnPoint().add(player.world.rand.nextGaussian() * 16, 0, player.world.rand.nextGaussian() * 16);
BlockPos teleportTo = spawn.add(0, 300 - spawn.getY(), 0);
TeleportUtil.teleportToDimension((EntityPlayer) event.getEntity(), 0, teleportTo.getX(), teleportTo.getY(), teleportTo.getZ());
fallResetter.add(event.getEntity().getUniqueID());
event.setCanceled(true);
}
} else if (event.getEntity().getEntityWorld().provider.getDimension() == 0) {
if (event.getSource() == EntityDamageSource.FALL && event.getEntity().fallDistance >= ConfigValues.underworldFallDistance) {
BlockPos location = event.getEntity().getPosition();
BlockPos bedrock = PosUtils.checkNeighborBlocksThoroughly(event.getEntity().getEntityWorld(), location, Blocks.BEDROCK);
if (bedrock != null) {
TeleportUtil.teleportToDimension((EntityPlayer) event.getEntity(), Wizardry.underWorld.getId(), 0, 300, 0);
((EntityPlayer) event.getEntity()).addPotionEffect(new PotionEffect(ModPotions.NULLIFY_GRAVITY, 100, 0, true, false));
fallResetter.add(event.getEntity().getUniqueID());
event.setCanceled(true);
}
}
}
}
示例9: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
if (!event.getEntity().worldObj.isRemote) {
if (event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
// Exclude Creative Players
if (player.isCreative()) {
return;
}
// Check Armor in Inventory
for (ItemStack stack : player.getArmorInventoryList()) {
if (stack != null && stack.getItem() == this) {
if (player.experienceTotal > event.getAmount()) {
float amount = event.getAmount();
// Reduce the attack amount
event.setAmount(amount * (1 - reduction));
// Take the experience
int exp = (int) (amount * reduction);
player.experience -= exp / (float) player.xpBarCap();
for (player.experienceTotal -= exp; player.experience <= 0.0F;
player.experience /= player.xpBarCap()) {
player.experience = (player.experience + 1.0F) * player.xpBarCap();
player.removeExperienceLevel(1);
}
} else {
// Reduce the attack amount
event.setAmount(event.getAmount() - player.experienceTotal);
// Take the experience
player.experienceLevel = 0;
player.experience = 0.0F;
player.experienceTotal = 0;
}
return;
}
}
}
}
}
示例10: onDamageArmor
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDamageArmor(LivingHurtEvent event) {
if (event.getEntity() instanceof EntityWolf) {
@Nullable IWolfArmorCapability wolfArmorCapability = event.getEntity().getCapability(CapabilityWolfArmor.WOLF_ARMOR_CAPABILITY, null);
if (wolfArmorCapability != null) {
wolfArmorCapability.damageArmor(event.getAmount());
}
}
}
示例11: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent ev)
{
if (ev.getEntity().world.isRemote)
return;
if (ev.getEntity() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) ev.getEntityLiving();
ItemBreakingTracker.get(player).before();
}
}
示例12: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
/** Handle living hurt events */
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
if(event.getEntity() instanceof EntityLivingBase && !event.getEntity().worldObj.isRemote) {
handleLightningSwordStrike(event);
handleSpecialStrike(event);
handleElecAuraHurt(event);
}
}
示例13: handleLightningSwordStrike
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
/** Check for Hand of Thor strikes */
public void handleLightningSwordStrike(LivingHurtEvent event) {
// make sure this hit is a valid weapon strike
EntityLivingBase target = (EntityLivingBase)event.getEntity();
if(target == null || target.isEntityInvulnerable(event.getSource())) return;
EntityLivingBase user = null;
if(event.getSource().getEntity() instanceof EntityLivingBase) user = (EntityLivingBase)event.getSource().getEntity();
if(user == null) return;
ItemStack weapon = user.getHeldItem(EnumHand.MAIN_HAND); if(weapon == null) return;
// Hand of Thor enchantment
int j = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.handOfThor, weapon);
int m = LCEnchantments.handOfThor.getMaxLevel();
Item w = weapon.getItem();
// divine overkill achievement
int s = EnchantmentHelper.getEnchantmentLevel(Enchantments.SHARPNESS, weapon);
if(!user.worldObj.isRemote && user instanceof EntityPlayer && j == 3 && s == 5) {
((EntityPlayer)user).addStat(LCAchievements.mysticHammer, 1);
}
// different chances based on item type
// hammers: 50% chance, up to 100% with top Hand of Thor
// charged swords: 15% chance, up to 45%
// regular weaponry: 0% chance, up to 10%
double init = w instanceof ItemChargedSword ? (w instanceof ItemHammer ? 0.5 : 0.15) : 0;
double var = w instanceof ItemChargedSword ? (w instanceof ItemHammer ? 0.5 : 0.3) : 0.1;
if(!user.isSneaking() && random.nextDouble() < (init + var * j / m)) {
Effect.lightning(target, false);
weapon.damageItem(2, user);
}
}
示例14: getDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void getDamage(LivingHurtEvent attackEvent) {
if (attackEvent.getSource() != null && attackEvent.getSource().getEntity() instanceof EntityPlayer) {
ItemStack tool = ((EntityPlayer) attackEvent.getSource().getEntity()).inventory.getCurrentItem();
int sharpness = getEffectStrength(tool, EnumRainbowColor.VIOLET, EnumRainbowColor.VIOLET);
if (sharpness > 0) {
attackEvent.setAmount((float) (attackEvent.getAmount() + .5 * sharpness));
}
int dullness = getEffectStrength(tool, EnumRainbowColor.VIOLET, EnumRainbowColor.GREEN);
if (dullness > 0) {
attackEvent.setAmount(attackEvent.getAmount() - dullness);
if (attackEvent.getAmount() < 0) {
attackEvent.setAmount(0);
}
}
}
if (attackEvent.getEntity() instanceof EntityPlayer) {
ItemStack heldStack = ((EntityPlayer) attackEvent.getEntity()).inventory.getCurrentItem();
if (heldStack != null) {
int protection = getEffectStrength(heldStack, EnumRainbowColor.RED, EnumRainbowColor.VIOLET);
if (protection > 0) {
attackEvent.setAmount((float) (attackEvent.getAmount() * Math.pow(.9, protection)));
}
}
}
}
示例15: handleElecAuraHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //導入方法依賴的package包/類
/** Strike back with Electrostatic Aura */
public void handleElecAuraHurt(LivingHurtEvent event) {
if (event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
if(event.getSource().getEntity() instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) event.getSource().getEntity();
// Electrostatic Aura handling
if(!attacker.isEntityInvulnerable(event.getSource())) {
IntList ench = new IntList();
ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
ItemStack chest = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
ItemStack legs = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
int lv = 0, a = 0;
int damageHelm = 0, damageChest = 0, damageLegs = 0, damageBoots = 0;
if(helm != null) {
damageHelm = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, helm);
ench.add(damageHelm);
if(helm.getItem() instanceof ItemMysticArmor) ++a;
}
if(chest != null) {
damageChest = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, chest);
ench.add(damageChest);
if(chest.getItem() instanceof ItemMysticArmor) ++a;
}
if(legs != null) {
damageLegs = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, legs);
ench.add(damageLegs);
if(legs.getItem() instanceof ItemMysticArmor) ++a;
}
if(boots != null) {
damageBoots = EnchantmentHelper.getEnchantmentLevel(LCEnchantments.elecAura, boots);
ench.add(damageBoots);
if(boots.getItem() instanceof ItemMysticArmor) ++a;
}
// get the max enchantment
for(int i : ench) {
lv += i; // the effect stacks
}
// now apply a thorns-like lightning defense
// the effect stacks (maximum of 24% chance with all armor enchanted)
if(lv > 0) {
// EA I = 2% chance per item
// EA II = 4% chance per item
// EA III = 6% chance per item
if(random.nextDouble() <= lv * 2/100D) {
Effect.lightning(attacker, false);
if(damageHelm > 0) helm.damageItem(4 * damageHelm, player);
if(damageChest > 0) chest.damageItem(4 * damageChest, player);
if(damageLegs > 0) legs.damageItem(4 * damageLegs, player);
if(damageBoots > 0) boots.damageItem(4 * damageBoots, player);
// achievement get (full Mystic armor, full elecAura)
if(a >= 4 && lv >= 12) {
player.addStat(LCAchievements.mysticArmor, 1);
}
}
}
}
}
}
}