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

72 Zeilen
2.5 KiB
Java

package net.minecraft.server;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
// 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) {
2012-01-12 12:02:39 +01:00
int b0 = 0; // CraftBukkit - byte -> int
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
final Entity movingEntity = movingobjectposition.entity;
2011-11-20 09:01:14 +01:00
boolean stick = false;
if (movingEntity != null) {
if (movingEntity instanceof EntityLiving) {
org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity();
2011-11-20 09:01:14 +01:00
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0);
Bukkit.getPluginManager().callEvent(event);
this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle();
b0 = event.getDamage();
if (event.isCancelled()) {
stick = !projectile.doesBounce();
} else {
// this function returns if the snowball should stick in or not, i.e. !bounce
stick = movingEntity.damageEntity(DamageSource.projectile(this, this.shooter), b0);
}
} else {
stick = movingEntity.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();
}
}
}