2011-01-12 06:48:19 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit start
|
2011-12-05 09:13:10 +01:00
|
|
|
import org.bukkit.Bukkit;
|
2011-06-18 17:10:31 +02:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
|
|
import org.bukkit.entity.Projectile;
|
2011-07-19 22:26:00 +02:00
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
2011-01-12 06:48:19 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2011-01-21 06:54:30 +01:00
|
|
|
// CraftBukkit end
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public class EntitySnowball extends EntityProjectile {
|
2011-01-12 06:48:19 +01:00
|
|
|
|
|
|
|
public EntitySnowball(World world) {
|
|
|
|
super(world);
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntitySnowball(World world, EntityLiving entityliving) {
|
2011-11-20 09:01:14 +01:00
|
|
|
super(world, entityliving);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public EntitySnowball(World world, double d0, double d1, double d2) {
|
2011-11-20 09:01:14 +01:00
|
|
|
super(world, d0, d1, d2);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
|
|
if (movingobjectposition.entity != null) {
|
|
|
|
byte b0 = 0;
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (movingobjectposition.entity instanceof EntityBlaze) {
|
|
|
|
b0 = 3;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit start
|
2011-12-05 09:13:10 +01:00
|
|
|
final Entity movingEntity = movingobjectposition.entity;
|
2011-11-20 09:01:14 +01:00
|
|
|
boolean stick = false;
|
2011-07-14 19:46:02 +02:00
|
|
|
|
2011-12-05 09:13:10 +01:00
|
|
|
if (movingEntity != null) {
|
|
|
|
if (movingEntity instanceof EntityLiving) {
|
|
|
|
org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
|
2011-06-18 17:10:31 +02:00
|
|
|
Projectile projectile = (Projectile) this.getBukkitEntity();
|
2011-01-12 06:48:19 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0);
|
2011-12-05 09:13:10 +01:00
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
2011-06-18 17:10:31 +02:00
|
|
|
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
|
2011-11-20 09:01:14 +01:00
|
|
|
b0 = (byte) event.getDamage();
|
2011-01-20 10:26:19 +01:00
|
|
|
|
2011-06-18 17:10:31 +02:00
|
|
|
if (event.isCancelled()) {
|
2011-07-19 22:26:00 +02:00
|
|
|
stick = !projectile.doesBounce();
|
2011-06-18 17:10:31 +02:00
|
|
|
} else {
|
|
|
|
// this function returns if the snowball should stick in or not, i.e. !bounce
|
2011-12-05 09:13:10 +01:00
|
|
|
stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
} else {
|
2011-12-05 09:13:10 +01:00
|
|
|
stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (stick) {
|
|
|
|
// CraftBukkit end
|
|
|
|
;
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
if (!this.world.isStatic) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.die();
|
2011-01-12 06:48:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|