- 48
- 1
Вот хотел сделать вещь которой можно будет бросаться. Но при этом когда попало в кого-то дало ему эффект.
Вот код:
Как-то так
Вот код:
Java:
package com.feldsher_.gopnimod.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class EntityCanned extends EntitySnowball{
private EntityLivingBase EntityS;
public EntityCanned(World worldIn)
{
super(worldIn);
}
public EntityCanned(World worldIn, EntityLivingBase p_i1774_2_)
{
super(worldIn, p_i1774_2_);
}
public EntityCanned(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
protected void onImpact(MovingObjectPosition p_70184_1_)
{
if (p_70184_1_.entityHit != null)
{
entity.addPotionEffect(new PotionEffect(Potion.invisibility.id, 100, 0)); //в entity должно быть entity в которого попали
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 4.0F);
}
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle(EnumParticleTypes.BARRIER, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}