本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java LivingAttackEvent.getSource方法的具体用法?Java LivingAttackEvent.getSource怎么用?Java LivingAttackEvent.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingAttackEvent
的用法示例。
在下文中一共展示了LivingAttackEvent.getSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLivingHurt
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingAttackEvent event)
{
if (event.getSource() == null)
return;
if (event.getSource().getTrueSource() == null)
return;
if (event.getSource().getTrueSource() instanceof EntityLivingBase)
{
PotionEffect effect = ((EntityLivingBase) event.getSource().getTrueSource()).getActivePotionEffect(PotionRegistry.REDSTONE_NEEDLE);
if (effect == null)
return;
if (effect.getAmplifier() >= 4)
event.setCanceled(true);
}
}
示例2: 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);
}
}
}
}
}
示例3: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
if (event.getSource() != null && event.getSource().getTrueSource() != null)
{
if (event.getSource().getTrueSource() instanceof EntityLivingBase && ((EntityLivingBase)event.getSource().getTrueSource()).isPotionActive(ExPPotions.stunned))
{
event.setCanceled(true);
}
}
}
示例4: livingAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingAttacked(LivingAttackEvent event) {
if (!event.getEntityLiving().world.isRemote) {
if (!event.isCanceled() && event.getAmount() > 0) {
EntityLivingBase living = event.getEntityLiving();
if (living.isPotionActive(ModPotions.cannonball) && (event.getSource().isExplosion() || event.getSource() == DamageSource.FALL)) {
if (event.getSource() == DamageSource.FALL) //No you don't get to have superbuffs that make you immune to creepers and falldamage.
living.removePotionEffect(ModPotions.cannonball);
event.setCanceled(true);
}
}
}
}
示例5: onPlayerDamaged
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerDamaged(LivingAttackEvent event){
event.getEntityLiving().getEntityWorld();
EntityLivingBase attacked = event.getEntityLiving();
DamageSource source = event.getSource();
int pureCount = getArmorCount(attacked, "pure");
if(getArmorCount(attacked, "red") == 4 || pureCount == 4){
if(source == DamageSource.HOT_FLOOR){
event.setCanceled(true);
}
}
if(getArmorCount(attacked, "dark") == 4 || pureCount == 4){
if(source.getSourceOfDamage() !=null){
Entity toAttack = source.getSourceOfDamage();
toAttack.attackEntityFrom(DamageSource.causeThornsDamage(attacked), EnchantmentThorns.getDamage(5, EntityUtil.rand));
if(toAttack instanceof EntityLivingBase){
EntityLivingBase living = (EntityLivingBase)toAttack;
if(EntityUtil.rand.nextInt(10) == 0){
living.addPotionEffect(new PotionEffect(MobEffects.WITHER, MathHelper.getInt(EntityUtil.rand, 20*3, 20*6), 0));
}
}
}
}
/*if(source == DamageSource.FALL){
BlockPos pos = new BlockPos(attacked).down();
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockLiquid && attacked.posY > pos.getY() + 0.9 && !(world.getBlockState(pos.up()).getBlock().getMaterial(world.getBlockState(pos.up())) == Material.WATER))
{
if(UpgradeItemRecipe.isWaterWalking(attacked.getItemStackFromSlot(EntityEquipmentSlot.FEET))){
world.playSound(null, pos, SoundEvents.ENTITY_PLAYER_SPLASH, SoundCategory.PLAYERS, 1.0F, 1.0F);
event.setCanceled(true);
}
}
}*/
}
示例6: onAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttacked(LivingAttackEvent event) {
if(event.getSource() != null) {
Entity attacker = event.getSource().getEntity();
if(attacker != null && attacker instanceof EntityMinionWarrior && attacker.getRidingEntity() == event.getEntityLiving())
event.setCanceled(true);
}
}
示例7: onLivingHurt
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingAttackEvent event)
{
if (event.getSource() == null) return;
if (event.getSource().getTrueSource() == null) return;
if (event.getSource().getTrueSource() instanceof EntityLivingBase)
{
PotionEffect effect = ((EntityLivingBase) event.getSource().getTrueSource()).getActivePotionEffect(PotionRegistry.STUN);
if (effect == null) return;
event.setCanceled(true);
}
}
示例8: 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);
}
}
}
}
示例9: onDamageRender
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageRender(LivingAttackEvent e) {
if (e.getEntityLiving() instanceof EntityPlayer) {
if (e.getSource() == DamageSource.MAGIC) {
e.setCanceled(false);
return;
}
}
}
示例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 &&
((EntityPlayerMP) event.getEntity()).connection instanceof NetHandlerPlayServer &&
((NetHandlerPlayServer) ((EntityPlayerMP) event.getEntity()).connection).getOverrideNoclip()
&& event.getSource() == DamageSource.IN_WALL) event.setCanceled(true);
}
示例13: 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());
}
}
示例14: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
if(event.getSource() == DamageSource.IN_WALL) //check to see if entity is inside a portal.
{
if(isInPortal(event.getEntity()))
{
event.setCanceled(true);
}
}
}
示例15: onLivingAttack
import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event) {
if (event.getSource() == DamageSource.OUT_OF_WORLD && isEquipmented(event.getEntityLiving()))
AlchemyEventSystem.markEventCanceled(event);
}