summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityProjectile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityProjectile.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityProjectile.java47
1 files changed, 32 insertions, 15 deletions
diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java
index 132af67d..7e8122dd 100644
--- a/src/main/java/net/minecraft/server/EntityProjectile.java
+++ b/src/main/java/net/minecraft/server/EntityProjectile.java
@@ -1,6 +1,5 @@
package net.minecraft.server;
-import java.util.Iterator;
import java.util.List;
import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit
@@ -13,9 +12,10 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
private int inBlockId = 0;
protected boolean inGround = false;
public int shake = 0;
- public EntityLiving shooter; // CraftBukkit - protected -> public
- private int h;
- private int i = 0;
+ public EntityLiving shooter; // CraftBukkit - private -> public
+ public String shooterName = null; // CraftBukkit - private -> public
+ private int i;
+ private int j = 0;
public EntityProjectile(World world) {
super(world);
@@ -44,7 +44,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
public EntityProjectile(World world, double d0, double d1, double d2) {
super(world);
- this.h = 0;
+ this.i = 0;
this.a(0.25F, 0.25F);
this.setPosition(d0, d1, d2);
this.height = 0.0F;
@@ -77,7 +77,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
- this.h = 0;
+ this.i = 0;
}
public void j_() {
@@ -93,8 +93,8 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
int i = this.world.getTypeId(this.blockX, this.blockY, this.blockZ);
if (i == this.inBlockId) {
- ++this.h;
- if (this.h == 1200) {
+ ++this.i;
+ if (this.i == 1200) {
this.die();
}
@@ -105,10 +105,10 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.motX *= (double) (this.random.nextFloat() * 0.2F);
this.motY *= (double) (this.random.nextFloat() * 0.2F);
this.motZ *= (double) (this.random.nextFloat() * 0.2F);
- this.h = 0;
this.i = 0;
+ this.j = 0;
} else {
- ++this.i;
+ ++this.j;
}
Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ);
@@ -125,12 +125,12 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
Entity entity = null;
List list = this.world.getEntities(this, this.boundingBox.a(this.motX, this.motY, this.motZ).grow(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
- Iterator iterator = list.iterator();
+ EntityLiving entityliving = this.getShooter();
- while (iterator.hasNext()) {
- Entity entity1 = (Entity) iterator.next();
+ for (int j = 0; j < list.size(); ++j) {
+ Entity entity1 = (Entity) list.get(j);
- if (entity1.L() && (entity1 != this.shooter || this.i >= 5)) {
+ if (entity1.L() && (entity1 != entityliving || this.j >= 5)) {
float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@@ -194,7 +194,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
float f3 = this.g();
if (this.H()) {
- for (int j = 0; j < 4; ++j) {
+ for (int k = 0; k < 4; ++k) {
float f4 = 0.25F;
this.world.addParticle("bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ);
@@ -223,6 +223,11 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
nbttagcompound.setByte("inTile", (byte) this.inBlockId);
nbttagcompound.setByte("shake", (byte) this.shake);
nbttagcompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
+ if ((this.shooterName == null || this.shooterName.length() == 0) && this.shooter != null && this.shooter instanceof EntityHuman) {
+ this.shooterName = this.shooter.getLocalizedName();
+ }
+
+ nbttagcompound.setString("ownerName", this.shooterName == null ? "" : this.shooterName);
}
public void a(NBTTagCompound nbttagcompound) {
@@ -232,5 +237,17 @@ public abstract class EntityProjectile extends Entity implements IProjectile {
this.inBlockId = nbttagcompound.getByte("inTile") & 255;
this.shake = nbttagcompound.getByte("shake") & 255;
this.inGround = nbttagcompound.getByte("inGround") == 1;
+ this.shooterName = nbttagcompound.getString("ownerName");
+ if (this.shooterName != null && this.shooterName.length() == 0) {
+ this.shooterName = null;
+ }
+ }
+
+ public EntityLiving getShooter() {
+ if (this.shooter == null && this.shooterName != null && this.shooterName.length() > 0) {
+ this.shooter = this.world.a(this.shooterName);
+ }
+
+ return this.shooter;
}
}