3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-18 22:10:06 +01:00
Paper/src/main/java/net/minecraft/server/EntitySnowball.java

74 Zeilen
2.8 KiB
Java

package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end
2011-11-20 09:01:14 +01:00
public class EntitySnowball extends EntityProjectile {
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-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-11-20 09:01:14 +01:00
protected void a(MovingObjectPosition movingobjectposition) {
if (movingobjectposition.entity != null) {
byte b0 = 0;
2011-11-20 09:01:14 +01:00
if (movingobjectposition.entity instanceof EntityBlaze) {
b0 = 3;
}
2011-01-29 22:50:29 +01:00
// CraftBukkit start
2011-11-20 09:01:14 +01:00
ProjectileHitEvent hitEvent = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
this.world.getServer().getPluginManager().callEvent(hitEvent);
boolean stick = false;
if (movingobjectposition.entity != null) {
if (movingobjectposition.entity instanceof EntityLiving) {
org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity();
// TODO @see EntityArrow#162
2011-11-20 09:01:14 +01:00
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0);
this.world.getServer().getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
2011-11-20 09:01:14 +01:00
b0 = (byte) event.getDamage();
if (event.isCancelled()) {
stick = !projectile.doesBounce();
} else {
// this function returns if the snowball should stick in or not, i.e. !bounce
2011-11-20 09:01:14 +01:00
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
}
} else {
2011-11-20 09:01:14 +01:00
stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
}
}
2011-01-29 22:50:29 +01:00
2011-11-20 09:01:14 +01:00
if (stick) {
// CraftBukkit end
;
}
}
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-29 22:50:29 +01:00
2011-11-20 09:01:14 +01:00
if (!this.world.isStatic) {
this.die();
}
}
}