[Bleeding] Implement ProjectileSource API. Addresses BUKKIT-1038, BUKKIT-1156

This commit is contained in:
t00thpick1
2014-01-20 00:03:21 -05:00
committed by Nate Mortensen
parent ac53442e7e
commit 8a5ad89a68
14 changed files with 277 additions and 33 deletions

View File

@@ -49,7 +49,10 @@ final class DispenseBehaviorFireball extends DispenseBehaviorItem {
}
}
world.addEntity(new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()));
EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
world.addEntity(entitysmallfireball);
// itemstack.a(1); // Handled during event processing
// CraftBukkit end

View File

@@ -42,6 +42,7 @@ public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem {
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
// CraftBukkit end
world.addEntity((Entity) iprojectile);

View File

@@ -109,6 +109,7 @@ public abstract class Entity {
public UUID uniqueID; // CraftBukkit - protected -> public
public EnumEntitySize at;
public boolean valid; // CraftBukkit
public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
public int getId() {
return this.id;

View File

@@ -3,6 +3,7 @@ package net.minecraft.server;
import java.util.List;
// CraftBukkit start
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
// CraftBukkit end
@@ -41,6 +42,7 @@ public class EntityArrow extends Entity implements IProjectile {
super(world);
this.k = 10.0D;
this.shooter = entityliving;
this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
this.fromPlayer = 1;
}
@@ -69,6 +71,7 @@ public class EntityArrow extends Entity implements IProjectile {
super(world);
this.k = 10.0D;
this.shooter = entityliving;
this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
this.fromPlayer = 1;
}

View File

@@ -42,6 +42,7 @@ public abstract class EntityFireball extends Entity {
public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(world);
this.shooter = entityliving;
this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
this.a(1.0F, 1.0F);
this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.setPosition(this.locX, this.locY, this.locZ);

View File

@@ -25,6 +25,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
public EntityProjectile(World world, EntityLiving entityliving) {
super(world);
this.shooter = entityliving;
this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
this.a(0.25F, 0.25F);
this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);