本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java LivingAttackEvent.getEntity方法的具体用法?Java LivingAttackEvent.getEntity怎么用?Java LivingAttackEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingAttackEvent
的用法示例。
在下文中一共展示了LivingAttackEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
/**
* When player is morphed, he can deal an damage or effect onto the enemy.
*
* For example, if player is morphed into the wither skeleton, he also
* grants a target wither potion effect. Pretty realistic, however I don't
* really know what that does.
*/
@SubscribeEvent
public void onPlayerAttack(LivingAttackEvent event)
{
Entity source = event.getSource().getEntity();
Entity target = event.getEntity();
if (source instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) source;
IMorphing capability = Morphing.get(player);
if (capability == null || !capability.isMorphed())
{
return;
}
capability.getCurrentMorph().attack(target, player);
}
}
示例2: onLivingAttackEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttackEvent(LivingAttackEvent event)
{
if (event.getEntity() == null || event.getSource().getEntity() != Minecraft.getMinecraft().player)
return;
synchronized (this.damages)
{
for (MobWithReward mob : this.params.getMob())
{
// Have we caught one of these mobs?
for (EntityTypes et : mob.getType())
{
String mobName = et.value();
if (event.getEntity().getName().equals(mobName))
{
if (this.damages.containsKey(mob))
this.damages.put(mob, this.damages.get(mob) + event.getAmount());
else
this.damages.put(mob, event.getAmount());
}
}
}
}
}
示例3: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
EntityDamageSource source = (EntityDamageSource) evt.getSource();
if (source.getEntity() instanceof EntityPlayer) {
EntityPlayer attacker = (EntityPlayer) source.getEntity();
EntityPlayer damagee = (EntityPlayer) evt.getEntity();
ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
Item id = damageeBoots.getItem();
if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
evt.setCanceled(true);
}
}
}
}
}
示例4: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event){
if(DifficultyManager.enabled) {
Entity causeMob = event.getSource().getTrueSource();
if (causeMob instanceof EntityLiving
&& event.getEntity() instanceof EntityPlayer
&& MobNBTHandler.isModifiedMob((EntityLiving) causeMob)) {
Map<String, Integer> changes = MobNBTHandler.getChangeMap((EntityLiving) causeMob);
String regionName = MobNBTHandler.getEntityRegion((EntityLiving) causeMob);
Region mobRegion = DifficultyManager.getRegionByName(regionName);
String mobId = EntityList.getEntityString(causeMob);
for (String change : changes.keySet()) {
try {
DifficultyModifier modifier = mobRegion.getModifierForMobById(mobId, change);
if (modifier != null) {
modifier.handleDamageEvent(event);
}
} catch (Exception e) {
LOG.warn("Error applying modifier at onLivingAttack. Mob was " + causeMob.getName() + ", Modifier was " + change + ". Please report to Progressive Difficulty Developer!");
LOG.warn("\tCaught Exception had message " + e.getMessage());
}
}
} else if (event.getSource().getImmediateSource() instanceof PotionCloudModifier.PlayerEffectingOnlyEntityAreaEffectCloud
&& !(event.getEntity() instanceof EntityPlayer)) {
event.setCanceled(true);
}
}
}
示例5: handleDamageEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void handleDamageEvent(LivingAttackEvent event) {
super.handleDamageEvent(event);
if(!(event.getEntity() instanceof EntityLivingBase))
return;
EntityLivingBase hitEntity = (EntityLivingBase)event.getEntity();
EntityLiving cause = (EntityLiving)event.getSource().getTrueSource();
int level = MobNBTHandler.getModifierLevel(cause,identifier);
hitEntity.addPotionEffect(new PotionEffect(effect, duration,level,false,false));
}
示例6: playerAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
/** Alters behaviour when the player takes damage. */
@SubscribeEvent
public void playerAttacked(LivingAttackEvent event) {
if (!(event.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
DamageSource source = event.getSource();
// Copy vanilla shield functionality to allow for custom shields
if (!source.isUnblockable() && player.isActiveItemStackBlocking() &&
player.getActiveItemStack().getItem() instanceof ItemShield) {
Vec3d sourceVec = source.getDamageLocation();
if (sourceVec != null) {
Vec3d playerVec = player.getLook(1.0F);
Vec3d attackVec = sourceVec.subtractReverse(new
Vec3d(player.posX, player.posY,
player.posZ)).normalize();
attackVec = new Vec3d(attackVec.xCoord,
0.0D, attackVec.zCoord);
if (attackVec.dotProduct(playerVec) < 0.0D &&
event.getAmount() >= 3) {
player.getActiveItemStack().damageItem(1 +
MathHelper.floor(event.getAmount()), player);
}
}
}
}
示例7: onLivingHurt
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onLivingHurt(LivingAttackEvent event) {
// if it's cancelled it got handled by the battlesign (or something else. but it's a prerequisite.)
if(!event.isCanceled()) {
return;
}
if(event.getSource().isUnblockable() || !event.getSource().isProjectile() || event.getSource().getTrueSource() == null) {
return;
}
// hit entity is a player?
if(!(event.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
// needs to be blocking with a battlesign
if(!player.isActiveItemStackBlocking() || player.getActiveItemStack().getItem() != TinkerMeleeWeapons.battleSign) {
return;
}
// broken battlesign.
if(ToolHelper.isBroken(player.getActiveItemStack())) {
return;
}
// at this point we duplicated all the logic if the battlesign should reflect a projectile.. bleh.
int xp = Math.max(1, Math.round(event.getAmount()));
addXp(player.getActiveItemStack(), xp, player);
}
示例8: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (!(event.getEntity() instanceof EntityPlayerMP)) return;
if (!getPlayerSettings((EntityPlayerMP) event.getEntity()).mobdamage) {
if (event.getSource().getImmediateSource() instanceof EntityCreature || event.getSource().getTrueSource() instanceof EntityCreature)
event.setCanceled(true);
}
}
示例9: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (!(event.getEntity() instanceof EntityPlayerMP)) return;
if (getPlayerSettings((EntityPlayerMP) event.getEntity()).killattacker) {
if (event.getSource().getImmediateSource() instanceof EntityCreature || event.getSource().getTrueSource() instanceof EntityCreature) {
if (event.getSource().getImmediateSource() instanceof EntityCreature)
event.getSource().getImmediateSource().attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) event.getEntity()), Float.MAX_VALUE);
if (event.getSource().getTrueSource() instanceof EntityCreature)
event.getSource().getTrueSource().attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) event.getEntity()), Float.MAX_VALUE);
}
}
}
示例10: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (event.getEntity() instanceof EntityPlayerMP && event.getSource() == DamageSource.DROWN) {
EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
if (!getPlayerSettings((EntityPlayerMP) player).waterdamage) event.setCanceled(true);
}
}
示例11: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (event.getEntity() instanceof EntityPlayerMP && (event.getSource() == DamageSource.IN_FIRE || event.getSource() == DamageSource.ON_FIRE || event.getSource() == DamageSource.LAVA)) {
EntityPlayerMP player = (EntityPlayerMP) event.getEntity();
if (!getPlayerSettings(player).firedamage) event.setCanceled(true);
}
}
示例12: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (!(event.getEntity() instanceof EntityPlayerMP)) return;
if (!getPlayerSettings((EntityPlayerMP) event.getEntity()).damage)
event.setCanceled(true);
}
示例13: onEvent
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@Override
public void onEvent(LivingAttackEvent event) {
if (event.getEntity() instanceof EntityPlayerMP &&
((EntityPlayerMP) event.getEntity()).connection instanceof NetHandlerPlayServer &&
((NetHandlerPlayServer) ((EntityPlayerMP) event.getEntity()).connection).getOverrideNoclip()
&& event.getSource() == DamageSource.IN_WALL) event.setCanceled(true);
}
示例14: jimmysSwordPvP
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void jimmysSwordPvP(LivingAttackEvent event) {
if (event.getSource().getEntity() instanceof EntityPlayerMP && event.getEntity() instanceof EntityPlayerMP
&& isUsingProcSword((EntityPlayerMP) event.getSource().getEntity()) && !Settings.Abilities.canJimmyPvP) {
event.setCanceled(true);
}
}
示例15: onAttackEntity
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttackEntity(LivingAttackEvent event)
{
// When a "passified" entity is attacked by another entity, remove the "passified" tag,
// and restore the target AI tasks by re-adding all the AI tasks from a fresh clone
if ((event.getEntity() instanceof EntityLiving) && event.getEntity().getEntityWorld().isRemote == false &&
event.getSource() instanceof EntityDamageSource && event.getEntity().getTags().contains(ItemSyringe.TAG_PASSIFIED))
{
ItemSyringe.removePassifiedState((EntityLiving) event.getEntity());
}
}