本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.setCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.setCanceled方法的具体用法?Java LivingHurtEvent.setCanceled怎么用?Java LivingHurtEvent.setCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.setCanceled方法的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: reflecteffect
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void reflecteffect(LivingHurtEvent lde,EntityPlayerMP sender)
{
if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
{
EntityPlayer ep = (EntityPlayer)lde.entityLiving;
if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion2))
{
if (!ep.worldObj.isRemote)
{
lde.setCanceled(true);
ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion2.id);
}
}
}
}
示例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: onLivingHurtEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtEvent(LivingHurtEvent event) {
if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer && DragonPlayer.get((EntityPlayer) event.entity).isDragon()) {
if (event.source.equals(DamageSource.lava) || event.source.equals(DamageSource.onFire) || event.source.equals(DamageSource.inFire)) {
event.setCanceled(true);
// LogHelper.info("DragonPlayerEventHandler: onLivingHurtEvent, no damage from lava!");
}
// Damage yourself (probably an explosion)
else if (BALANCE.DRAGON_PLAYER_ABILITIES.RECEIVE_EXPLODING_FIREBALL_DAMAGE == false && event.source.isExplosion()) {
event.setCanceled(true);
}
else if (ItemDragonEgg.hasAbility((EntityPlayer) event.entity, Abilities.NOBLOCKDAMAGE) && event.source.equals(DamageSource.inWall)) {
event.setCanceled(true);
}
else if (event.source.equals(DamageSource.fall)) {
event.setCanceled(true);
}
// Prevent damage from entities that are picked up (that ride the dragon)
else if (event.entity.riddenByEntity != null) {
event.setCanceled(true);
}
}
}
示例5: onPlayerHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerHurt(LivingHurtEvent event) {
if (event.getEntityLiving().getHealth() - event.getAmount() <= 0 && event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) event.getEntityLiving();
for (int i = 0; i < p.inventory.getSizeInventory(); ++i) {
ItemStack s = p.inventory.getStackInSlot(i);
if (s.getItem() instanceof ItemSoulstone) {
UtilChat.addChatMessage(p, event.getEntityLiving().getName() + UtilChat.lang("item.soulstone.used"));
p.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
UtilSound.playSound(p, SoundEvents.BLOCK_GLASS_BREAK);
p.setHealth(6);// 3 hearts
int time = Const.TICKS_PER_SEC * 30;
p.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, time));
time = Const.TICKS_PER_SEC * 60;//a full minute
p.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, time));
p.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, time, 4));
//and bad luck lasts much longer
time = Const.TICKS_PER_SEC * 60 * 10;
p.addPotionEffect(new PotionEffect(MobEffects.UNLUCK, time));
p.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, time, 1));
event.setCanceled(true);
break;
}
}
}
}
示例6: 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);
}
}
}
}
}
示例7: shieldAbsorbDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void shieldAbsorbDamage(LivingHurtEvent event)
{
if (!event.source.isUnblockable())
{
ScienceShield shield = ScienceShield.loadShieldForEntity(event.entityLiving);
float dmgRemaining = shield.tryAbsorbDamage(event.ammount);
if (dmgRemaining <= 0) {
event.setCanceled(true);
}
else {
event.ammount = dmgRemaining;
}
shield.save();
}
}
示例8: onPreHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/**
* Pre-event to handle shield blocking (only posted when not in BG2 battle mode)
*/
@SubscribeEvent(priority=EventPriority.NORMAL)
public void onPreHurt(LivingHurtEvent event) {
if (event.entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entity;
ItemStack stack = player.getHeldItem();
if (stack != null && stack.getItem() instanceof ItemZeldaShield && player.isUsingItem()) {
ItemZeldaShield shield = (ItemZeldaShield) stack.getItem();
if (ZSSPlayerInfo.get(player).canBlock() && shield.canBlockDamage(stack, event.source)) {
Entity opponent = event.source.getEntity();
if (opponent != null && TargetUtils.isTargetInFrontOf(opponent, player, 60)) {
event.ammount = shield.onBlock(player, stack, event.source, event.ammount);
event.setCanceled(event.ammount < 0.1F);
}
}
}
}
}
示例9: onEntityHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event){
if (event.entity.worldObj.isRemote)
return;
EntityPlayer player = null;
if (event.source.getSourceOfDamage() != null && event.source.getSourceOfDamage() instanceof EntityPlayer){
player = (EntityPlayer)event.source.getSourceOfDamage();
}
if (player == null)
return;
if (event.entity instanceof EntityPlayer)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_PLAYERS, event.entity.posX, event.entity.posY, event.entity.posZ))
event.setCanceled(true);
if (event.entity instanceof EntityCreature)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_CREATURES, event.entity.posX, event.entity.posY, event.entity.posZ))
event.setCanceled(true);
if (event.entity instanceof EntityMob)
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_MONSTERS, event.entity.posX, event.entity.posY, event.entity.posZ))
event.setCanceled(true);
}
示例10: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
Entity attacker = source.getImmediateSource();
if (attacker != null) {
event.setCanceled(true);
}
}
示例11: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
Entity attacker = source.getImmediateSource();
if (attacker != null && source.isProjectile()) {
event.setCanceled(true);
}
}
示例12: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
if(HarshenUtils.toArray(DamageSource.FLY_INTO_WALL, DamageSource.FALL).contains(event.getSource())
&& event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() == Items.ELYTRA)
event.setCanceled(true);
}
示例13: 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);
}
}
示例14: onDamageTaken
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageTaken(LivingHurtEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer && !event.getEntityLiving().world.isRemote)
{
if (event.getSource() != null && !event.getSource().canHarmInCreative())
{
PlayerManager.takeDamage((EntityPlayer) event.getEntityLiving(), event.getSource(), event.getAmount());
event.setCanceled(true);
}
}
}
示例15: onEntityDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SideOnly(Side.SERVER)
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent e) {
if(e.source.getEntity() instanceof EntityPlayer) {
EntityPlayer attacker = (EntityPlayer) e.source.getEntity();
PlayerAokIEEP attackerAok = PlayerAokIEEP.get(attacker);
TileCore nearByCore = AgeOfKingdom.serverProxy.getClosestTileCoreInField(attacker);
if(nearByCore == null || nearByCore.getAokName().equals("null") || nearByCore.getAokName().equals(attackerAok.getAokName())) {
return;
}
attacker.addChatComponentMessage(new ChatComponentText( StatCollector.translateToLocal("event.onEntityDamage.NoPermission")));
e.setCanceled(true);
}
}