當前位置: 首頁>>代碼示例>>Java>>正文


Java Entity.attackEntityFrom方法代碼示例

本文整理匯總了Java中net.minecraft.entity.Entity.attackEntityFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.attackEntityFrom方法的具體用法?Java Entity.attackEntityFrom怎麽用?Java Entity.attackEntityFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.Entity的用法示例。


在下文中一共展示了Entity.attackEntityFrom方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntityCollidedWithBlock

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof TileEntityHeatSink && entity instanceof EntityLivingBase) {
        IHeatExchangerLogic heat = ((TileEntityHeatSink) te).getHeatExchangerLogic(null);
        int temp = (int) ((TileEntityHeatSink) te).getHeatExchangerLogic(null).getTemperature();
        if (temp > 323) { // +50C
            entity.attackEntityFrom(DamageSource.HOT_FLOOR, 2);
            if (temp > 373) { // +100C
                entity.setFire(3);
            }
        } else if (temp < 243) { // -30C
            int durationSec = (243 - (int)heat.getTemperature()) / 10;
            int amplifier = (243 - (int) heat.getTemperature()) / 80;
            ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, durationSec * 20, amplifier));
            if (temp < 213) { // -60C
                entity.attackEntityFrom(DamageSourcePneumaticCraft.FREEZING, 2);
            }
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:22,代碼來源:BlockHeatSink.java

示例2: doSingleFire

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) > 0) { return; }	// Hasn't cooled down yet

	Helper.knockUserBack(entity, this.Kickback);			// Kickback

	// Self Harm
	entity.attackEntityFrom(DamageSource.causeThrownDamage(entity, entity), 2);				// A sacrifice in blood

	// Projectile
	SoulShot projectile = new SoulShot(world, entity, (float) this.Speed);
	world.spawnEntityInWorld(projectile); 															// Firing!

	// SFX
	world.playSoundAtEntity(entity, "tile.piston.out", 1.0F, 2.0F);
	world.playSoundAtEntity(entity, "note.bass", 1.0F, 0.4F);

	this.consumeAmmo(stack, entity, 1);
	this.setCooldown(stack, 20);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:22,代碼來源:SoulCairn.java

示例3: onCastTick

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void onCastTick(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote) {
		BlockPos centerPos = player.getPosition();
		AxisAlignedBB area = new AxisAlignedBB(centerPos).expandXyz(3F);
		for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(player, area)) {
			if (entity instanceof EntityLivingBase) {
				WorldServer worldServer = (WorldServer) world;
				if (player.getItemInUseCount() % 10 == 0 && consumePower(player)) {
					MessageSoulDrainFX message = new MessageSoulDrainFX(entity.posX,
							entity.posY + (entity.height / 2.0F), entity.posZ, player.posX,
							player.posY + (player.height / 2.0F), player.posZ);
					PacketHandler.INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(
							player.dimension, player.posX, player.posY, player.posZ, 128));
					entity.attackEntityFrom(DamageSource.magic, 1);
					world.spawnEntity(new EntityXPOrb(world, entity.posX, entity.posY + 0.5, entity.posZ, 1));
				}
			}
		}
	}
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:22,代碼來源:SpellSoulDrain.java

示例4: onLeftClickEntity

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
	if (player.worldObj.isRemote) { return false; }	// Not doing this on client side

	if (this.getDamage(stack) >= this.getMaxDamage())
	{
		entity.attackEntityFrom(DamageSource.causePlayerDamage(player), this.DmgMin);
		entity.hurtResistantTime = 0;	// No invincibility frames

		return false; 				// We're not loaded, getting out of here with minimal damage
	}

	this.consumeAmmo(stack, entity, 1);

	// SFX
	NetHelper.sendParticleMessageToAllPlayers(entity.worldObj, player.getEntityId(), (byte) 3, (byte) 4);	// smoke

	// Dmg
	entity.setFire(2);																	// Setting fire to them for 2 sec, so pigs can drop cooked porkchops
	entity.worldObj.createExplosion(player, entity.posX, entity.posY + 0.5D, entity.posZ, (float) this.ExplosionSize, this.dmgTerrain); 	// 4.0F is TNT

	entity.attackEntityFrom(DamageSource.causePlayerDamage(player), this.DmgMax);	// Dealing damage directly. Screw weapon attributes

	return false;
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:27,代碼來源:PowderKnuckle.java

示例5: onUserHurt

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
 * called.
 */
public void onUserHurt(EntityLivingBase user, Entity attacker, int level)
{
    Random random = user.getRNG();
    ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.thorns, user);

    if (func_92094_a(level, random))
    {
        if (attacker != null)
        {
            attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)func_92095_b(level, random));
            attacker.playSound("damage.thorns", 0.5F, 1.0F);
        }

        if (itemstack != null)
        {
            itemstack.damageItem(3, user);
        }
    }
    else if (itemstack != null)
    {
        itemstack.damageItem(1, user);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:28,代碼來源:EnchantmentThorns.java

示例6: attackEntitiesInList

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Attacks all entities inside this list, dealing 5 hearts of damage.
 */
private void attackEntitiesInList(List<Entity> p_70971_1_)
{
    for (int i = 0; i < p_70971_1_.size(); ++i)
    {
        Entity entity = (Entity)p_70971_1_.get(i);

        if (entity instanceof EntityLivingBase)
        {
            entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F);
            this.applyEnchantments(this, entity);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:17,代碼來源:EntityDragon.java

示例7: onEntityWalk

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
/**
 * Triggered whenever an entity collides with this block (enters into the block)
 */
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn)
{
    if (!entityIn.isImmuneToFire() && entityIn instanceof EntityLivingBase && !EnchantmentHelper.hasFrostWalkerEnchantment((EntityLivingBase)entityIn))
    {
        entityIn.attackEntityFrom(DamageSource.hotFloor, 1.0F);
    }

    super.onEntityWalk(worldIn, pos, entityIn);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:BlockMagma.java

示例8: attackEntityAsMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    this.attackTimer = 10;
    this.worldObj.setEntityState(this, (byte)4);
    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15)));

    if (flag)
    {
        entityIn.motionY += 0.4000000059604645D;
        this.applyEnchantments(this, entityIn);
    }

    this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
    return flag;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:16,代碼來源:EntityIronGolem.java

示例9: attackEntityAsMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()));

    if (flag)
    {
        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:EntityWolf.java

示例10: onEntityCollidedWithBlock

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
	super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
	if (entityIn instanceof EntityLivingBase) {
		entityIn.attackEntityFrom(DamageSource.IN_FIRE, 2); // Maybe we should just set the entity on fire
		// ((EntityLivingBase) entityIn).setFire(1);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:9,代碼來源:BlockEmberGrass.java

示例11: attackEntityAsMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    if (this.getRabbitType() == 99)
    {
        this.playSound(SoundEvents.ENTITY_RABBIT_ATTACK, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 8.0F);
    }
    else
    {
        return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:13,代碼來源:EntityRabbit.java

示例12: onHurt

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
	Entity attacker = source.getImmediateSource();
	int redo = 5 - amplifier;
	if (attacker != null && (redo < 0 || attacker.world.rand.nextInt(redo) == 0)) {
		float damage = event.getAmount();
		attacker.attackEntityFrom(DamageSource.causeThornsDamage(affected), damage);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:10,代碼來源:ShellArmorBrew.java

示例13: onEntityCollidedWithBlock

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
 if (entity.isSneaking()){
 } else {
  entity.attackEntityFrom(DamageSource.cactus, 1F);
 }
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:8,代碼來源:Magma.java

示例14: attackEntityAsMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    if (this.getRabbitType() == 99)
    {
        this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 8.0F);
    }
    else
    {
        return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:13,代碼來源:EntityRabbit.java

示例15: attackEntityAsMob

import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:EntityOcelot.java


注:本文中的net.minecraft.entity.Entity.attackEntityFrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。