本文整理匯總了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);
}
}