3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-22 14:28:09 +01:00
Paper/src/main/java/net/minecraft/server/EntitySnowball.java
2011-12-05 19:23:40 +11:00

75 Zeilen
2.7 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;
import org.bukkit.event.entity.ProjectileHitEvent;
// CraftBukkit end
public class EntitySnowball extends EntityProjectile {
public EntitySnowball(World world) {
super(world);
}
public EntitySnowball(World world, EntityLiving entityliving) {
super(world, entityliving);
}
public EntitySnowball(World world, double d0, double d1, double d2) {
super(world, d0, d1, d2);
}
protected void a(MovingObjectPosition movingobjectposition) {
if (movingobjectposition.entity != null) {
byte b0 = 0;
if (movingobjectposition.entity instanceof EntityBlaze) {
b0 = 3;
}
// CraftBukkit start
ProjectileHitEvent hitEvent = new ProjectileHitEvent((Projectile) this.getBukkitEntity());
Bukkit.getPluginManager().callEvent(hitEvent);
final Entity movingEntity = movingobjectposition.entity;
boolean stick = false;
if (movingEntity != null) {
if (movingEntity instanceof EntityLiving) {
org.bukkit.entity.Entity damagee = movingEntity.getBukkitEntity();
Projectile projectile = (Projectile) this.getBukkitEntity();
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 = (byte) 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);
}
}
if (stick) {
// CraftBukkit end
;
}
}
for (int i = 0; i < 8; ++i) {
this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
}
if (!this.world.isStatic) {
this.die();
}
}
}