本文整理匯總了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);
}
}
}
}
示例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);
}
示例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));
}
}
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例15: attackEntityAsMob
import net.minecraft.entity.Entity; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
return entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F);
}