Archiviert
13
0

Merge remote branch 'upstream/master'

Dieser Commit ist enthalten in:
durron597 2011-01-03 15:48:56 -05:00
Commit 8a717dddad
18 geänderte Dateien mit 2194 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,115 @@
package net.minecraft.server;
import org.bukkit.LivingEntity;
import org.bukkit.craftbukkit.CraftBlock;
import org.bukkit.craftbukkit.CraftEntity;
import org.bukkit.craftbukkit.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.event.entity.EntityDamagedByBlockEvent;
import org.bukkit.event.entity.EntityDamagedEvent;
import java.util.Random;
public class BlockCactus extends Block {
protected BlockCactus(int i, int j) {
super(i, j, Material.u);
a(true);
}
public void a(World world, int i, int j, int k, Random random) {
if (world.e(i, j + 1, k)) {
int l;
for (l = 1; world.a(i, j - l, k) == bh; l++) {
;
}
if (l < 3) {
int i1 = world.b(i, j, k);
if (i1 == 15) {
world.d(i, j + 1, k, bh);
world.b(i, j, k, 0);
} else {
world.b(i, j, k, i1 + 1);
}
}
}
}
public AxisAlignedBB d(World world, int i, int j, int k) {
float f1 = 0.0625F;
return AxisAlignedBB.b((float) i + f1, j, (float) k + f1, (float) (i + 1) - f1, (float) (j + 1) - f1, (float) (k + 1) - f1);
}
public int a(int i) {
if (i == 1) {
return bg - 1;
}
if (i == 0) {
return bg + 1;
} else {
return bg;
}
}
public boolean a() {
return false;
}
public boolean a(World world, int i, int j, int k) {
if (!super.a(world, i, j, k)) {
return false;
} else {
return f(world, i, j, k);
}
}
public void b(World world, int i, int j, int k, int l) {
if (!f(world, i, j, k)) {
a_(world, i, j, k, world.b(i, j, k));
world.d(i, j, k, 0);
}
}
public boolean f(World world, int i, int j, int k) {
if (world.c(i - 1, j, k).a()) {
return false;
}
if (world.c(i + 1, j, k).a()) {
return false;
}
if (world.c(i, j, k - 1).a()) {
return false;
}
if (world.c(i, j, k + 1).a()) {
return false;
} else {
int l = world.a(i, j - 1, k);
return l == Block.aV.bh || l == Block.E.bh;
}
}
public void a(World world, int i, int j, int k, Entity entity) {
// Craftbukkit: ENTITY_DAMAGEBY_BLOCK event
CraftEntity toPassIn = null;
if(entity instanceof EntityPlayerMP)
{
toPassIn = new CraftPlayer(((WorldServer)world).getServer(), (EntityPlayerMP)entity);
} else if(entity instanceof EntityLiving)
{
toPassIn = new CraftLivingEntity(((WorldServer)world).getServer(), (EntityLiving)entity);
}
if(toPassIn != null)
{
EntityDamagedByBlockEvent edbbe = new EntityDamagedByBlockEvent(((WorldServer)world).getWorld().getBlockAt(i, j, k), toPassIn, EntityDamagedEvent.DamageCause.CONTACT, 1);
((WorldServer)world).getServer().getPluginManager().callEvent(edbbe);
if(edbbe.isCancelled()) return;
}
// Craftbukkit TODO: Other entities (when their respective classes are added) hitting a Cactus
entity.a(null, 1);
}
}

Datei anzeigen

@ -0,0 +1,870 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.CraftEntity;
import org.bukkit.craftbukkit.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamagedEvent;
import java.util.List;
import java.util.Random;
public abstract class Entity {
private static int a = 0;
public int g;
public double h;
public boolean i;
public Entity j;
public Entity k;
public World l;
public double m;
public double n;
public double o;
public double p;
public double q;
public double r;
public double s;
public double t;
public double u;
public float v;
public float w;
public float x;
public float y;
public final AxisAlignedBB z = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
public boolean A;
public boolean B;
public boolean C;
public boolean D;
public boolean E;
public boolean F;
public boolean G;
public float H;
public float I;
public float J;
public float K;
public float L;
protected boolean M;
protected float N;
private int b;
public double O;
public double P;
public double Q;
public float R;
public float S;
public boolean T;
public float U;
public boolean V;
protected Random W;
public int X;
public int Y;
public int Z;
protected int aa;
protected boolean ab;
public int ac;
public int ad;
private boolean c;
protected boolean ae;
private double d;
private double e;
public boolean af;
public int ag;
public int ah;
public int ai;
public Entity(World world) {
g = a++;
h = 1.0D;
i = false;
A = false;
D = false;
E = false;
F = true;
G = false;
H = 0.0F;
I = 0.6F;
J = 1.8F;
K = 0.0F;
L = 0.0F;
M = true;
N = 0.0F;
b = 1;
R = 0.0F;
S = 0.0F;
T = false;
U = 0.0F;
V = false;
W = new Random();
X = 0;
Y = 1;
Z = 0;
aa = 300;
ab = false;
ac = 0;
ad = 300;
c = true;
ae = false;
af = false;
l = world;
a(0.0D, 0.0D, 0.0D);
}
public boolean equals(Object obj) {
if (obj instanceof Entity) {
return ((Entity) obj).g == g;
} else {
return false;
}
}
public int hashCode() {
return g;
}
public void l() {
G = true;
}
protected void a(float f1, float f2) {
I = f1;
J = f2;
}
protected void b(float f1, float f2) {
v = f1;
w = f2;
}
public void a(double d1, double d2, double d3) {
p = d1;
q = d2;
r = d3;
float f1 = I / 2.0F;
float f2 = J;
z.c(d1 - (double) f1, (d2 - (double) H) + (double) R, d3 - (double) f1, d1 + (double) f1, (d2 - (double) H) + (double) R + (double) f2, d3 + (double) f1);
}
public void b_() {
m();
}
public void m() {
if (k != null && k.G) {
k = null;
}
X++;
K = L;
m = p;
n = q;
o = r;
y = w;
x = v;
if (r()) {
if (!ab && !c) {
float f1 = MathHelper.a(s * s * 0.20000000298023224D + t * t + u * u * 0.20000000298023224D) * 0.2F;
if (f1 > 1.0F) {
f1 = 1.0F;
}
l.a(this, "random.splash", f1, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F);
float f2 = MathHelper.b(z.b);
for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) {
float f3 = (W.nextFloat() * 2.0F - 1.0F) * I;
float f5 = (W.nextFloat() * 2.0F - 1.0F) * I;
l.a("bubble", p + (double) f3, f2 + 1.0F, r + (double) f5, s, t - (double) (W.nextFloat() * 0.2F), u);
}
for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) {
float f4 = (W.nextFloat() * 2.0F - 1.0F) * I;
float f6 = (W.nextFloat() * 2.0F - 1.0F) * I;
l.a("splash", p + (double) f4, f2 + 1.0F, r + (double) f6, s, t, u);
}
}
N = 0.0F;
ab = true;
Z = 0;
} else {
ab = false;
}
if (l.z) {
Z = 0;
} else if (Z > 0) {
if (ae) {
Z -= 4;
if (Z < 0) {
Z = 0;
}
} else {
if (Z % 20 == 0) {
a(((Entity) (null)), 1);
}
Z--;
}
}
if (t()) {
n();
}
if (q < -64D) {
o();
}
c = false;
}
protected void n() {
if (!ae) {
a(((Entity) (null)), 4);
Z = 600;
}
}
protected void o() {
l();
}
public boolean b(double d1, double d2, double d3) {
AxisAlignedBB axisalignedbb = z.c(d1, d2, d3);
List list = l.a(this, axisalignedbb);
if (list.size() > 0) {
return false;
}
return !l.b(axisalignedbb);
}
public void c(double d1, double d2, double d3) {
if (T) {
z.d(d1, d2, d3);
p = (z.a + z.d) / 2D;
q = (z.b + (double) H) - (double) R;
r = (z.c + z.f) / 2D;
return;
}
double d4 = p;
double d5 = r;
double d6 = d1;
double d7 = d2;
double d8 = d3;
AxisAlignedBB axisalignedbb = z.b();
boolean flag = A && p();
if (flag) {
double d9 = 0.050000000000000003D;
for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) {
if (d1 < d9 && d1 >= -d9) {
d1 = 0.0D;
continue;
}
if (d1 > 0.0D) {
d1 -= d9;
} else {
d1 += d9;
}
}
for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) {
if (d3 < d9 && d3 >= -d9) {
d3 = 0.0D;
continue;
}
if (d3 > 0.0D) {
d3 -= d9;
} else {
d3 += d9;
}
}
}
List list = l.a(this, z.a(d1, d2, d3));
for (int i1 = 0; i1 < list.size(); i1++) {
d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2);
}
z.d(0.0D, d2, 0.0D);
if (!F && d7 != d2) {
d1 = d2 = d3 = 0.0D;
}
boolean flag1 = A || d7 != d2 && d7 < 0.0D;
for (int j1 = 0; j1 < list.size(); j1++) {
d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1);
}
z.d(d1, 0.0D, 0.0D);
if (!F && d6 != d1) {
d1 = d2 = d3 = 0.0D;
}
for (int k1 = 0; k1 < list.size(); k1++) {
d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3);
}
z.d(0.0D, 0.0D, d3);
if (!F && d8 != d3) {
d1 = d2 = d3 = 0.0D;
}
if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) {
double d10 = d1;
double d12 = d2;
double d14 = d3;
d1 = d6;
d2 = S;
d3 = d8;
AxisAlignedBB axisalignedbb1 = z.b();
z.b(axisalignedbb);
List list1 = l.a(this, z.a(d1, d2, d3));
for (int j2 = 0; j2 < list1.size(); j2++) {
d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2);
}
z.d(0.0D, d2, 0.0D);
if (!F && d7 != d2) {
d1 = d2 = d3 = 0.0D;
}
for (int k2 = 0; k2 < list1.size(); k2++) {
d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1);
}
z.d(d1, 0.0D, 0.0D);
if (!F && d6 != d1) {
d1 = d2 = d3 = 0.0D;
}
for (int l2 = 0; l2 < list1.size(); l2++) {
d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3);
}
z.d(0.0D, 0.0D, d3);
if (!F && d8 != d3) {
d1 = d2 = d3 = 0.0D;
}
if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) {
d1 = d10;
d2 = d12;
d3 = d14;
z.b(axisalignedbb1);
} else {
R += 0.5D;
}
}
p = (z.a + z.d) / 2D;
q = (z.b + (double) H) - (double) R;
r = (z.c + z.f) / 2D;
B = d6 != d1 || d8 != d3;
C = d7 != d2;
A = d7 != d2 && d7 < 0.0D;
D = B || C;
a(d2, A);
if (d6 != d1) {
s = 0.0D;
}
if (d7 != d2) {
t = 0.0D;
}
if (d8 != d3) {
u = 0.0D;
}
double d11 = p - d4;
double d13 = r - d5;
if (M && !flag) {
L += (double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D;
int k3 = MathHelper.b(p);
int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H);
int l1 = MathHelper.b(r);
int i3 = l.a(k3, i4, l1);
if (L > (float) b && i3 > 0) {
b++;
StepSound stepsound = Block.m[i3].bq;
if (l.a(k3, i4 + 1, l1) == Block.aS.bh) {
stepsound = Block.aS.bq;
l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
} else if (!Block.m[i3].bs.d()) {
l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
}
Block.m[i3].b(l, k3, i4, l1, this);
}
}
int l3 = MathHelper.b(z.a);
int j4 = MathHelper.b(z.b);
int i2 = MathHelper.b(z.c);
int j3 = MathHelper.b(z.d);
int k4 = MathHelper.b(z.e);
int l4 = MathHelper.b(z.f);
for (int i5 = l3; i5 <= j3; i5++) {
for (int j5 = j4; j5 <= k4; j5++) {
for (int k5 = i2; k5 <= l4; k5++) {
int l5 = l.a(i5, j5, k5);
if (l5 > 0) {
Block.m[l5].a(l, i5, j5, k5, this);
}
}
}
}
R *= 0.4F;
boolean flag2 = r();
if (l.c(z)) {
b(1);
if (!flag2) {
Z++;
if (Z == 0) {
Z = 300;
}
}
} else if (Z <= 0) {
Z = -Y;
}
if (flag2 && Z > 0) {
l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F);
Z = -Y;
}
}
protected void a(double d1, boolean flag) {
if (flag) {
if (N > 0.0F) {
a(N);
N = 0.0F;
}
} else if (d1 < 0.0D) {
N -= d1;
}
}
public boolean p() {
return false;
}
public AxisAlignedBB q() {
return null;
}
protected void b(int i1) {
if (!ae) {
if(this instanceof EntityLiving)
{
CraftEntity defender = null;
CraftServer server = ((WorldServer)l).getServer();
if(this instanceof EntityPlayerMP)
{
defender = new CraftPlayer(server, (EntityPlayerMP)this);
} else {
defender = new CraftLivingEntity(server, (EntityLiving)this);
}
EntityDamagedEvent ede = new EntityDamagedEvent(defender, EntityDamagedEvent.DamageCause.FIRE, i1);
server.getPluginManager().callEvent(ede);
if(ede.isCancelled()) return;
}
a(((Entity) (null)), i1);
}
}
protected void a(float f1) {}
public boolean r() {
return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this);
}
public boolean a(Material material) {
double d1 = q + (double) s();
int i1 = MathHelper.b(p);
int j1 = MathHelper.d(MathHelper.b(d1));
int k1 = MathHelper.b(r);
int l1 = l.a(i1, j1, k1);
if (l1 != 0 && Block.m[l1].bs == material) {
float f1 = BlockFluids.b(l.b(i1, j1, k1)) - 0.1111111F;
float f2 = (float) (j1 + 1) - f1;
return d1 < (double) f2;
} else {
return false;
}
}
public float s() {
return 0.0F;
}
public boolean t() {
return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.g);
}
public void a(float f1, float f2, float f3) {
float f4 = MathHelper.c(f1 * f1 + f2 * f2);
if (f4 < 0.01F) {
return;
}
if (f4 < 1.0F) {
f4 = 1.0F;
}
f4 = f3 / f4;
f1 *= f4;
f2 *= f4;
float f5 = MathHelper.a((v * 3.141593F) / 180F);
float f6 = MathHelper.b((v * 3.141593F) / 180F);
s += f1 * f6 - f2 * f5;
u += f2 * f6 + f1 * f5;
}
public float b(float f1) {
int i1 = MathHelper.b(p);
double d1 = (z.e - z.b) * 0.66000000000000003D;
int j1 = MathHelper.b((q - (double) H) + d1);
int k1 = MathHelper.b(r);
return l.k(i1, j1, k1);
}
public void b(double d1, double d2, double d3, float f1,
float f2) {
m = p = d1;
n = q = d2;
o = r = d3;
x = v = f1;
y = w = f2;
R = 0.0F;
double d4 = x - f1;
if (d4 < -180D) {
x += 360F;
}
if (d4 >= 180D) {
x -= 360F;
}
a(p, q, r);
b(f1, f2);
}
public void c(double d1, double d2, double d3, float f1,
float f2) {
m = p = d1;
n = q = d2 + (double) H;
o = r = d3;
v = f1;
w = f2;
a(p, q, r);
}
public float a(Entity entity) {
float f1 = (float) (p - entity.p);
float f2 = (float) (q - entity.q);
float f3 = (float) (r - entity.r);
return MathHelper.c(f1 * f1 + f2 * f2 + f3 * f3);
}
public double d(double d1, double d2, double d3) {
double d4 = p - d1;
double d5 = q - d2;
double d6 = r - d3;
return d4 * d4 + d5 * d5 + d6 * d6;
}
public double e(double d1, double d2, double d3) {
double d4 = p - d1;
double d5 = q - d2;
double d6 = r - d3;
return (double) MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
}
public double b(Entity entity) {
double d1 = p - entity.p;
double d2 = q - entity.q;
double d3 = r - entity.r;
return d1 * d1 + d2 * d2 + d3 * d3;
}
public void b(EntityPlayer entityplayer) {}
public void c(Entity entity) {
if (entity.j == this || entity.k == this) {
return;
}
double d1 = entity.p - p;
double d2 = entity.r - r;
double d3 = MathHelper.a(d1, d2);
if (d3 >= 0.0099999997764825821D) {
d3 = MathHelper.a(d3);
d1 /= d3;
d2 /= d3;
double d4 = 1.0D / d3;
if (d4 > 1.0D) {
d4 = 1.0D;
}
d1 *= d4;
d2 *= d4;
d1 *= 0.05000000074505806D;
d2 *= 0.05000000074505806D;
d1 *= 1.0F - U;
d2 *= 1.0F - U;
f(-d1, 0.0D, -d2);
entity.f(d1, 0.0D, d2);
}
}
public void f(double d1, double d2, double d3) {
s += d1;
t += d2;
u += d3;
}
protected void u() {
E = true;
}
public boolean a(Entity entity, int i1) {
u();
return false;
}
public boolean c_() {
return false;
}
public boolean v() {
return false;
}
public void b(Entity entity, int i1) {}
public boolean c(NBTTagCompound nbttagcompound) {
String s1 = w();
if (G || s1 == null) {
return false;
} else {
nbttagcompound.a("id", s1);
d(nbttagcompound);
return true;
}
}
public void d(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Pos", a(new double[] {
p, q, r
}));
nbttagcompound.a("Motion", a(new double[] {
s, t, u
}));
nbttagcompound.a("Rotation", a(new float[] {
v, w
}));
nbttagcompound.a("FallDistance", N);
nbttagcompound.a("Fire", (short) Z);
nbttagcompound.a("Air", (short) ad);
nbttagcompound.a("OnGround", A);
a(nbttagcompound);
}
public void e(NBTTagCompound nbttagcompound) {
NBTTagList nbttaglist = nbttagcompound.k("Pos");
NBTTagList nbttaglist1 = nbttagcompound.k("Motion");
NBTTagList nbttaglist2 = nbttagcompound.k("Rotation");
a(0.0D, 0.0D, 0.0D);
s = ((NBTTagDouble) nbttaglist1.a(0)).a;
t = ((NBTTagDouble) nbttaglist1.a(1)).a;
u = ((NBTTagDouble) nbttaglist1.a(2)).a;
m = O = p = ((NBTTagDouble) nbttaglist.a(0)).a;
n = P = q = ((NBTTagDouble) nbttaglist.a(1)).a;
o = Q = r = ((NBTTagDouble) nbttaglist.a(2)).a;
x = v = ((NBTTagFloat) nbttaglist2.a(0)).a;
y = w = ((NBTTagFloat) nbttaglist2.a(1)).a;
N = nbttagcompound.f("FallDistance");
Z = nbttagcompound.c("Fire");
ad = nbttagcompound.c("Air");
A = nbttagcompound.l("OnGround");
a(p, q, r);
b(nbttagcompound);
}
protected final String w() {
return EntityList.b(this);
}
protected abstract void b(NBTTagCompound nbttagcompound);
protected abstract void a(NBTTagCompound nbttagcompound);
protected NBTTagList a(double ad1[]) {
NBTTagList nbttaglist = new NBTTagList();
double ad2[] = ad1;
int i1 = ad2.length;
for (int j1 = 0; j1 < i1; j1++) {
double d1 = ad2[j1];
nbttaglist.a(new NBTTagDouble(d1));
}
return nbttaglist;
}
protected NBTTagList a(float af1[]) {
NBTTagList nbttaglist = new NBTTagList();
float af2[] = af1;
int i1 = af2.length;
for (int j1 = 0; j1 < i1; j1++) {
float f1 = af2[j1];
nbttaglist.a(new NBTTagFloat(f1));
}
return nbttaglist;
}
public EntityItem b(int i1, int j1) {
return a(i1, j1, 0.0F);
}
public EntityItem a(int i1, int j1, float f1) {
EntityItem entityitem = new EntityItem(l, p, q + (double) f1, r, new ItemStack(i1, j1));
entityitem.c = 10;
l.a(entityitem);
return entityitem;
}
public boolean x() {
return !G;
}
public boolean y() {
int i1 = MathHelper.b(p);
int j1 = MathHelper.b(q + (double) s());
int k1 = MathHelper.b(r);
return l.d(i1, j1, k1);
}
public boolean a(EntityPlayer entityplayer) {
return false;
}
public AxisAlignedBB d(Entity entity) {
return null;
}
public void z() {
if (k.G) {
k = null;
return;
}
s = 0.0D;
t = 0.0D;
u = 0.0D;
b_();
k.A();
e += k.v - k.x;
d += k.w - k.y;
for (; e >= 180D; e -= 360D) {
;
}
for (; e < -180D; e += 360D) {
;
}
for (; d >= 180D; d -= 360D) {
;
}
for (; d < -180D; d += 360D) {
;
}
double d1 = e * 0.5D;
double d2 = d * 0.5D;
float f1 = 10F;
if (d1 > (double) f1) {
d1 = f1;
}
if (d1 < (double) (-f1)) {
d1 = -f1;
}
if (d2 > (double) f1) {
d2 = f1;
}
if (d2 < (double) (-f1)) {
d2 = -f1;
}
e -= d1;
d -= d2;
v += d1;
w += d2;
}
public void A() {
j.a(p, q + j() + j.B(), r);
}
public double B() {
return (double) H;
}
public double j() {
return (double) J * 0.75D;
}
public void e(Entity entity) {
d = 0.0D;
e = 0.0D;
if (entity == null) {
if (k != null) {
c(k.p, k.z.b + (double) k.J, k.r, v, w);
k.j = null;
}
k = null;
return;
}
if (k == entity) {
k.j = null;
k = null;
c(entity.p, entity.z.b + (double) entity.J, entity.r, v, w);
return;
}
if (k != null) {
k.j = null;
}
if (entity.j != null) {
entity.j.k = null;
}
k = entity;
entity.j = this;
}
public Vec3D C() {
return null;
}
public void D() {}
public int[] E() {
return null;
}
}

Datei anzeigen

@ -0,0 +1,745 @@
package net.minecraft.server;
import java.util.List;
import org.bukkit.craftbukkit.CraftMinecart;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.*;
public class EntityMinecart extends Entity
implements IInventory {
private CraftServer server;
private CraftMinecart minecart;
private ItemStack ak[];
public int a;
public int b;
public int c;
private boolean al;
public int d;
public int e;
public double f;
public double aj;
private static final int am[][][] = {
{
{
0, 0, -1
}, {
0, 0, 1
}
}, {
{
-1, 0, 0
}, {
1, 0, 0
}
}, {
{
-1, -1, 0
}, {
1, 0, 0
}
}, {
{
-1, 0, 0
}, {
1, -1, 0
}
}, {
{
0, 0, -1
}, {
0, -1, 1
}
}, {
{
0, -1, -1
}, {
0, 0, 1
}
}, {
{
0, 0, 1
}, {
1, 0, 0
}
}, {
{
0, 0, 1
}, {
-1, 0, 0
}
}, {
{
0, 0, -1
}, {
-1, 0, 0
}
}, {
{
0, 0, -1
}, {
1, 0, 0
}
}
};
private int an;
private double ao;
private double ap;
private double aq;
private double ar;
private double as;
public EntityMinecart(World world) {
super(world);
ak = new ItemStack[36];
a = 0;
b = 0;
c = 1;
al = false;
i = true;
a(0.98F, 0.7F);
H = J / 2.0F;
M = false;
// CraftBukkit start
server = ((WorldServer) world).getServer();
minecart = CraftMinecart.getCraftMinecart(server, this);
VehicleCreateEvent event = new VehicleCreateEvent(Type.VEHICLE_CREATE,
minecart);
server.getPluginManager().callEvent(event);
// CraftBukkit end
}
public AxisAlignedBB d(Entity entity) {
return entity.z;
}
public AxisAlignedBB q() {
return null;
}
public boolean v() {
return true;
}
public EntityMinecart(World world, double d1, double d2, double d3,
int i) {
this(world);
a(d1, d2 + (double) H, d3);
s = 0.0D;
t = 0.0D;
u = 0.0D;
m = d1;
n = d2;
o = d3;
d = i;
// CraftBukkit start
server = ((WorldServer) world).getServer();
minecart = CraftMinecart.getCraftMinecart(server, this);
VehicleCreateEvent event = new VehicleCreateEvent(Type.VEHICLE_CREATE,
minecart);
server.getPluginManager().callEvent(event);
// CraftBukkit end
}
public double j() {
return (double) J * 0.0D - 0.30000001192092896D;
}
public boolean a(Entity entity, int i) {
// CraftBukkit start
VehicleDamageEvent event = new VehicleDamageEvent(
Type.VEHICLE_DAMAGE,
minecart,
null, // @TODO: Needs to be written
i);
server.getPluginManager().callEvent(event);
// CraftBukkit end
if (event.isCancelled()) {
return true;
}
i = event.getDamage();
if (l.z || G) {
return true;
}
c = -c;
b = 10;
u();
a += i * 10;
if (a > 40) {
a(Item.ax.aW, 1, 0.0F);
if (d == 1) {
a(Block.au.bh, 1, 0.0F);
} else if (d == 2) {
a(Block.aB.bh, 1, 0.0F);
}
l();
}
return true;
}
public boolean c_() {
return !G;
}
public void l() {
label0:
for (int i = 0; i < a(); i++) {
ItemStack itemstack = a(i);
if (itemstack == null) {
continue;
}
float f1 = W.nextFloat() * 0.8F + 0.1F;
float f2 = W.nextFloat() * 0.8F + 0.1F;
float f3 = W.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.a <= 0) {
continue label0;
}
int k = W.nextInt(21) + 10;
if (k > itemstack.a) {
k = itemstack.a;
}
itemstack.a -= k;
EntityItem entityitem = new EntityItem(l, p + (double) f1, q + (double) f2, r + (double) f3, new ItemStack(itemstack.c, k, itemstack.d));
float f4 = 0.05F;
entityitem.s = (float) W.nextGaussian() * f4;
entityitem.t = (float) W.nextGaussian() * f4 + 0.2F;
entityitem.u = (float) W.nextGaussian() * f4;
l.a(entityitem);
} while (true);
}
super.l();
}
public void b_() {
if (b > 0) {
b--;
}
if (a > 0) {
a--;
}
if (l.z && an > 0) {
if (an > 0) {
double d1 = p + (ao - p) / (double) an;
double d2 = q + (ap - q) / (double) an;
double d3 = r + (aq - r) / (double) an;
double d4;
for (d4 = ar - (double) v; d4 < -180D; d4 += 360D) {
;
}
for (; d4 >= 180D; d4 -= 360D) {
;
}
v += d4 / (double) an;
w += (as - (double) w) / (double) an;
an--;
a(d1, d2, d3);
b(v, w);
} else {
a(p, q, r);
b(v, w);
}
return;
}
m = p;
n = q;
o = r;
t -= 0.039999999105930328D;
int i = MathHelper.b(p);
int k = MathHelper.b(q);
int i1 = MathHelper.b(r);
if (l.a(i, k - 1, i1) == Block.aG.bh) {
k--;
}
double d6 = 0.40000000000000002D;
boolean flag = false;
double d5 = 0.0078125D;
if (l.a(i, k, i1) == Block.aG.bh) {
Vec3D vec3d = g(p, q, r);
int j1 = l.b(i, k, i1);
q = k;
if (j1 >= 2 && j1 <= 5) {
q = k + 1;
}
if (j1 == 2) {
s -= d5;
}
if (j1 == 3) {
s += d5;
}
if (j1 == 4) {
u += d5;
}
if (j1 == 5) {
u -= d5;
}
int ai[][] = am[j1];
double d7 = ai[1][0] - ai[0][0];
double d8 = ai[1][2] - ai[0][2];
double d9 = Math.sqrt(d7 * d7 + d8 * d8);
double d10 = s * d7 + u * d8;
if (d10 < 0.0D) {
d7 = -d7;
d8 = -d8;
}
double d11 = Math.sqrt(s * s + u * u);
s = (d11 * d7) / d9;
u = (d11 * d8) / d9;
double d14 = 0.0D;
double d15 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
double d16 = (double) i1 + 0.5D + (double) ai[0][2] * 0.5D;
double d17 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
double d18 = (double) i1 + 0.5D + (double) ai[1][2] * 0.5D;
d7 = d17 - d15;
d8 = d18 - d16;
if (d7 == 0.0D) {
p = (double) i + 0.5D;
d14 = r - (double) i1;
} else if (d8 == 0.0D) {
r = (double) i1 + 0.5D;
d14 = p - (double) i;
} else {
double d19 = p - d15;
double d21 = r - d16;
double d23 = (d19 * d7 + d21 * d8) * 2D;
d14 = d23;
}
p = d15 + d7 * d14;
r = d16 + d8 * d14;
a(p, q + (double) H, r);
double d20 = s;
double d22 = u;
if (j != null) {
d20 *= 0.75D;
d22 *= 0.75D;
}
if (d20 < -d6) {
d20 = -d6;
}
if (d20 > d6) {
d20 = d6;
}
if (d22 < -d6) {
d22 = -d6;
}
if (d22 > d6) {
d22 = d6;
}
c(d20, 0.0D, d22);
if (ai[0][1] != 0 && MathHelper.b(p) - i == ai[0][0] && MathHelper.b(r) - i1 == ai[0][2]) {
a(p, q + (double) ai[0][1], r);
} else if (ai[1][1] != 0 && MathHelper.b(p) - i == ai[1][0] && MathHelper.b(r) - i1 == ai[1][2]) {
a(p, q + (double) ai[1][1], r);
}
if (j != null) {
s *= 0.99699997901916504D;
t *= 0.0D;
u *= 0.99699997901916504D;
} else {
if (d == 2) {
double d24 = MathHelper.a(f * f + aj * aj);
if (d24 > 0.01D) {
flag = true;
f /= d24;
aj /= d24;
double d25 = 0.040000000000000001D;
s *= 0.80000001192092896D;
t *= 0.0D;
u *= 0.80000001192092896D;
s += f * d25;
u += aj * d25;
} else {
s *= 0.89999997615814209D;
t *= 0.0D;
u *= 0.89999997615814209D;
}
}
s *= 0.95999997854232788D;
t *= 0.0D;
u *= 0.95999997854232788D;
}
Vec3D vec3d1 = g(p, q, r);
if (vec3d1 != null && vec3d != null) {
double d26 = (vec3d.b - vec3d1.b) * 0.050000000000000003D;
double d12 = Math.sqrt(s * s + u * u);
if (d12 > 0.0D) {
s = (s / d12) * (d12 + d26);
u = (u / d12) * (d12 + d26);
}
a(p, vec3d1.b, r);
}
int k1 = MathHelper.b(p);
int l1 = MathHelper.b(r);
if (k1 != i || l1 != i1) {
double d13 = Math.sqrt(s * s + u * u);
s = d13 * (double) (k1 - i);
u = d13 * (double) (l1 - i1);
}
if (d == 2) {
double d27 = MathHelper.a(f * f + aj * aj);
if (d27 > 0.01D && s * s + u * u > 0.001D) {
f /= d27;
aj /= d27;
if (f * s + aj * u < 0.0D) {
f = 0.0D;
aj = 0.0D;
} else {
f = s;
aj = u;
}
}
}
} else {
if (s < -d6) {
s = -d6;
}
if (s > d6) {
s = d6;
}
if (u < -d6) {
u = -d6;
}
if (u > d6) {
u = d6;
}
if (A) {
s *= 0.5D;
t *= 0.5D;
u *= 0.5D;
}
c(s, t, u);
if (!A) {
s *= 0.94999998807907104D;
t *= 0.94999998807907104D;
u *= 0.94999998807907104D;
}
}
w = 0.0F;
double d28 = m - p;
double d29 = o - r;
if (d28 * d28 + d29 * d29 > 0.001D) {
v = (float) ((Math.atan2(d29, d28) * 180D) / 3.1415926535897931D);
if (al) {
v += 180F;
}
}
double d30;
for (d30 = v - x; d30 >= 180D; d30 -= 360D) {
;
}
for (; d30 < -180D; d30 += 360D) {
;
}
if (d30 < -170D || d30 >= 170D) {
v += 180F;
al = !al;
}
b(v, w);
List list = l.b(this, z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if (list != null && list.size() > 0) {
for (int i2 = 0; i2 < list.size(); i2++) {
Entity entity = (Entity) list.get(i2);
if (entity != j && entity.v() && (entity instanceof EntityMinecart)) {
entity.c(this);
}
}
}
if (j != null && j.G) {
j = null;
}
if (flag && W.nextInt(4) == 0) {
e--;
if (e < 0) {
f = aj = 0.0D;
}
l.a("largesmoke", p, q + 0.80000000000000004D, r, 0.0D, 0.0D, 0.0D);
}
}
public Vec3D g(double d1, double d2, double d3) {
int i = MathHelper.b(d1);
int k = MathHelper.b(d2);
int i1 = MathHelper.b(d3);
if (l.a(i, k - 1, i1) == Block.aG.bh) {
k--;
}
if (l.a(i, k, i1) == Block.aG.bh) {
int j1 = l.b(i, k, i1);
d2 = k;
if (j1 >= 2 && j1 <= 5) {
d2 = k + 1;
}
int ai[][] = am[j1];
double d4 = 0.0D;
double d5 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
double d6 = (double) k + 0.5D + (double) ai[0][1] * 0.5D;
double d7 = (double) i1 + 0.5D + (double) ai[0][2] * 0.5D;
double d8 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
double d9 = (double) k + 0.5D + (double) ai[1][1] * 0.5D;
double d10 = (double) i1 + 0.5D + (double) ai[1][2] * 0.5D;
double d11 = d8 - d5;
double d12 = (d9 - d6) * 2D;
double d13 = d10 - d7;
if (d11 == 0.0D) {
d1 = (double) i + 0.5D;
d4 = d3 - (double) i1;
} else if (d13 == 0.0D) {
d3 = (double) i1 + 0.5D;
d4 = d1 - (double) i;
} else {
double d14 = d1 - d5;
double d15 = d3 - d7;
double d16 = (d14 * d11 + d15 * d13) * 2D;
d4 = d16;
}
d1 = d5 + d11 * d4;
d2 = d6 + d12 * d4;
d3 = d7 + d13 * d4;
if (d12 < 0.0D) {
d2++;
}
if (d12 > 0.0D) {
d2 += 0.5D;
}
return Vec3D.b(d1, d2, d3);
} else {
return null;
}
}
protected void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Type", d);
if (d == 2) {
nbttagcompound.a("PushX", f);
nbttagcompound.a("PushZ", aj);
nbttagcompound.a("Fuel", (short) e);
} else if (d == 1) {
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < ak.length; i++) {
if (ak[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i);
ak[i].a(nbttagcompound1);
nbttaglist.a(nbttagcompound1);
}
}
nbttagcompound.a("Items", nbttaglist);
}
}
protected void b(NBTTagCompound nbttagcompound) {
d = nbttagcompound.d("Type");
if (d == 2) {
f = nbttagcompound.g("PushX");
aj = nbttagcompound.g("PushZ");
e = nbttagcompound.c("Fuel");
} else if (d == 1) {
NBTTagList nbttaglist = nbttagcompound.k("Items");
ak = new ItemStack[a()];
for (int i = 0; i < nbttaglist.b(); i++) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int k = nbttagcompound1.b("Slot") & 0xff;
if (k >= 0 && k < ak.length) {
ak[k] = new ItemStack(nbttagcompound1);
}
}
}
}
public void c(Entity entity) {
if (l.z) {
return;
}
if (entity == j) {
return;
}
// CraftBukkit start
VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent(
Type.VEHICLE_COLLISION_ENTITY,
minecart,
null); // @TODO: Needs to be written
server.getPluginManager().callEvent(event);
// CraftBukkit end
if ((entity instanceof EntityLiving) && !(entity instanceof EntityPlayer) && d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
entity.e(this);
}
double d1 = entity.p - p;
double d2 = entity.r - r;
double d3 = d1 * d1 + d2 * d2;
if (d3 >= 9.9999997473787516E-005D) {
d3 = MathHelper.a(d3);
d1 /= d3;
d2 /= d3;
double d4 = 1.0D / d3;
if (d4 > 1.0D) {
d4 = 1.0D;
}
d1 *= d4;
d2 *= d4;
d1 *= 0.10000000149011612D;
d2 *= 0.10000000149011612D;
d1 *= 1.0F - U;
d2 *= 1.0F - U;
d1 *= 0.5D;
d2 *= 0.5D;
if (entity instanceof EntityMinecart) {
double d5 = entity.s + s;
double d6 = entity.u + u;
if (((EntityMinecart) entity).d == 2 && d != 2) {
s *= 0.20000000298023224D;
u *= 0.20000000298023224D;
f(entity.s - d1, 0.0D, entity.u - d2);
entity.s *= 0.69999998807907104D;
entity.u *= 0.69999998807907104D;
} else if (((EntityMinecart) entity).d != 2 && d == 2) {
entity.s *= 0.20000000298023224D;
entity.u *= 0.20000000298023224D;
entity.f(s + d1, 0.0D, u + d2);
s *= 0.69999998807907104D;
u *= 0.69999998807907104D;
} else {
d5 /= 2D;
d6 /= 2D;
s *= 0.20000000298023224D;
u *= 0.20000000298023224D;
f(d5 - d1, 0.0D, d6 - d2);
entity.s *= 0.20000000298023224D;
entity.u *= 0.20000000298023224D;
entity.f(d5 + d1, 0.0D, d6 + d2);
}
} else {
f(-d1, 0.0D, -d2);
entity.f(d1 / 4D, 0.0D, d2 / 4D);
}
}
}
public int a() {
return 27;
}
public ItemStack a(int i) {
return ak[i];
}
public ItemStack a(int i, int k) {
if (ak[i] != null) {
if (ak[i].a <= k) {
ItemStack itemstack = ak[i];
ak[i] = null;
return itemstack;
}
ItemStack itemstack1 = ak[i].a(k);
if (ak[i].a == 0) {
ak[i] = null;
}
return itemstack1;
} else {
return null;
}
}
public void a(int i, ItemStack itemstack) {
ak[i] = itemstack;
if (itemstack != null && itemstack.a > c()) {
itemstack.a = c();
}
}
public String b() {
return "Minecart";
}
public int c() {
return 64;
}
public void d() {}
public boolean a(EntityPlayer entityplayer) {
if (d == 0) {
if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
return true;
}
if (!l.z) {
entityplayer.e(this);
}
} else if (d == 1) {
if (!l.z) {
entityplayer.a((IInventory)this);
}
} else if (d == 2) {
ItemStack itemstack = entityplayer.an.e();
if (itemstack != null && itemstack.c == Item.k.aW) {
if (--itemstack.a == 0) {
entityplayer.an.a(entityplayer.an.c, null);
}
e += 1200;
}
f = p - entityplayer.p;
aj = r - entityplayer.r;
}
return true;
}
public boolean a_(EntityPlayer entityplayer) {
if (G) {
return false;
}
return entityplayer.b(this) <= 64D;
}
}

Datei anzeigen

@ -0,0 +1,220 @@
package net.minecraft.server;
import org.bukkit.craftbukkit.CraftEntity;
import org.bukkit.craftbukkit.CraftLivingEntity;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamagedByBlockEvent;
import org.bukkit.event.entity.EntityDamagedByEntityEvent;
import org.bukkit.event.entity.EntityDamagedEvent;
import java.util.*;
public class Explosion {
public boolean a;
private Random h;
private World i;
public double b;
public double c;
public double d;
public Entity e;
public float f;
public Set g;
public Explosion(World world, Entity entity, double d1, double d2, double d3, float f1) {
a = false;
h = new Random();
g = new HashSet();
i = world;
e = entity;
f = f1;
b = d1;
c = d2;
d = d3;
}
public void a() {
float f1 = f;
int j = 16;
for (int k = 0; k < j; k++) {
for (int i1 = 0; i1 < j; i1++) {
label0:
for (int k1 = 0; k1 < j; k1++) {
if (k != 0 && k != j - 1 && i1 != 0 && i1 != j - 1 && k1 != 0 && k1 != j - 1) {
continue;
}
double d1 = ((float) k / ((float) j - 1.0F)) * 2.0F - 1.0F;
double d2 = ((float) i1 / ((float) j - 1.0F)) * 2.0F - 1.0F;
double d3 = ((float) k1 / ((float) j - 1.0F)) * 2.0F - 1.0F;
double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
d1 /= d4;
d2 /= d4;
d3 /= d4;
float f2 = f * (0.7F + i.l.nextFloat() * 0.6F);
double d5 = b;
double d7 = c;
double d9 = d;
float f3 = 0.3F;
do {
if (f2 <= 0.0F) {
continue label0;
}
int j2 = MathHelper.b(d5);
int k2 = MathHelper.b(d7);
int l2 = MathHelper.b(d9);
int i3 = i.a(j2, k2, l2);
if (i3 > 0) {
f2 -= (Block.m[i3].a(e) + 0.3F) * f3;
}
if (f2 > 0.0F) {
g.add(new ChunkPosition(j2, k2, l2));
}
d5 += d1 * (double) f3;
d7 += d2 * (double) f3;
d9 += d3 * (double) f3;
f2 -= f3 * 0.75F;
} while (true);
}
}
}
f *= 2.0F;
int l = MathHelper.b(b - (double) f - 1.0D);
int j1 = MathHelper.b(b + (double) f + 1.0D);
int l1 = MathHelper.b(c - (double) f - 1.0D);
int j3 = MathHelper.b(c + (double) f + 1.0D);
int k3 = MathHelper.b(d - (double) f - 1.0D);
int l3 = MathHelper.b(d + (double) f + 1.0D);
List list = i.b(e, AxisAlignedBB.b(l, l1, k3, j1, j3, l3));
Vec3D vec3d = Vec3D.b(b, c, d);
for (int i4 = 0; i4 < list.size(); i4++) {
Entity entity = (Entity) list.get(i4);
double d11 = entity.e(b, c, d) / (double) f;
if (d11 <= 1.0D) {
double d6 = entity.p - b;
double d8 = entity.q - c;
double d10 = entity.r - d;
double d12 = MathHelper.a(d6 * d6 + d8 * d8 + d10 * d10);
d6 /= d12;
d8 /= d12;
d10 /= d12;
double d13 = i.a(vec3d, entity.z);
double d14 = (1.0D - d11) * d13;
// Craftbukkit: explosion damage hook
int damage = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
CraftServer servr = ((WorldServer)i).getServer();
CraftEntity damagee = null;
if(entity instanceof EntityPlayerMP)
{
damagee = new CraftPlayer(servr, (EntityPlayerMP)entity);
} else if(entity instanceof EntityLiving)
{
damagee = new CraftLivingEntity(servr, (EntityLiving)entity);
}
if(e == null) { // Block explosion
// Craftbukkit TODO: get the x/y/z of the tnt block?
EntityDamagedByBlockEvent edbbe = new EntityDamagedByBlockEvent(null, damagee, EntityDamagedEvent.DamageCause.BLOCK_EXPLOSION, damage);
servr.getPluginManager().callEvent(edbbe);
if(!edbbe.isCancelled()) entity.a(e, damage);
} else {
CraftEntity damager = null;
if(e instanceof EntityPlayerMP)
{
// not possible in normal operations
damager = new CraftPlayer(servr, (EntityPlayerMP)e);
} else if(e instanceof EntityLiving)
{
damager = new CraftLivingEntity(servr, (EntityLiving) e);
}
EntityDamagedByEntityEvent edbbe = new EntityDamagedByEntityEvent(damager, damagee, EntityDamagedEvent.DamageCause.ENTITY_EXPLOSION, damage);
servr.getPluginManager().callEvent(edbbe);
if(!edbbe.isCancelled()) entity.a(e, damage);
}
// Craftbukkit: end
double d15 = d14;
entity.s += d6 * d15;
entity.t += d8 * d15;
entity.u += d10 * d15;
}
}
f = f1;
ArrayList arraylist = new ArrayList();
arraylist.addAll(g);
if (a) {
for (int j4 = arraylist.size() - 1; j4 >= 0; j4--) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(j4);
int i2 = chunkposition.a;
int k4 = chunkposition.b;
int l4 = chunkposition.c;
int i5 = i.a(i2, k4, l4);
int j5 = i.a(i2, k4 - 1, l4);
if (i5 == 0 && Block.o[j5] && h.nextInt(3) == 0) {
i.d(i2, k4, l4, Block.ar.bh);
}
}
}
}
public void b() {
i.a(b, c, d, "random.explode", 4F, (1.0F + (i.l.nextFloat() - i.l.nextFloat()) * 0.2F) * 0.7F);
ArrayList arraylist = new ArrayList();
arraylist.addAll(g);
for (int j = arraylist.size() - 1; j >= 0; j--) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(j);
int k = chunkposition.a;
int l = chunkposition.b;
int i1 = chunkposition.c;
int j1 = i.a(k, l, i1);
for (int k1 = 0; k1 < 1; k1++) {
double d1 = (float) k + i.l.nextFloat();
double d2 = (float) l + i.l.nextFloat();
double d3 = (float) i1 + i.l.nextFloat();
double d4 = d1 - b;
double d5 = d2 - c;
double d6 = d3 - d;
double d7 = MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
d4 /= d7;
d5 /= d7;
d6 /= d7;
double d8 = 0.5D / (d7 / (double) f + 0.10000000000000001D);
d8 *= i.l.nextFloat() * i.l.nextFloat() + 0.3F;
d4 *= d8;
d5 *= d8;
d6 *= d8;
i.a("explode", (d1 + b * 1.0D) / 2D, (d2 + c * 1.0D) / 2D, (d3 + d * 1.0D) / 2D, d4, d5, d6);
i.a("smoke", d1, d2, d3, d4, d5, d6);
}
if (j1 > 0) {
Block.m[j1].a(i, k, l, i1, i.b(k, l, i1), 0.3F);
i.d(k, l, i1, 0);
Block.m[j1].c(i, k, l, i1);
}
}
}
}

Datei anzeigen

@ -90,8 +90,6 @@ implements ICommandListener, Runnable {
a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file."); a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
} }
server = new CraftServer(this, "1.1"); // CraftBukkit
f = new ServerConfigurationManager(this); f = new ServerConfigurationManager(this);
k = new EntityTracker(this); k = new EntityTracker(this);
String s1 = d.a("level-name", "world"); String s1 = d.a("level-name", "world");

Datei anzeigen

@ -28,6 +28,7 @@ public class ServerConfigurationManager {
private CraftServer server; // Craftbukkit private CraftServer server; // Craftbukkit
public ServerConfigurationManager(MinecraftServer minecraftserver) { public ServerConfigurationManager(MinecraftServer minecraftserver) {
minecraftserver.server = new CraftServer(minecraftserver, this); // CraftBukkit
server = minecraftserver.server; // Craftbukkit server = minecraftserver.server; // Craftbukkit
b = new ArrayList<EntityPlayerMP>(); b = new ArrayList<EntityPlayerMP>();

Datei anzeigen

@ -0,0 +1,15 @@
package org.bukkit.craftbukkit;
import org.bukkit.Arrow;
import net.minecraft.server.EntityArrow;
/**
* Represents an arrow.
*
* @author sk89q
*/
public class CraftArrow extends CraftEntity implements Arrow {
CraftArrow(CraftServer server, EntityArrow entity) {
super(server, entity);
}
}

Datei anzeigen

@ -1,15 +0,0 @@
package org.bukkit.craftbukkit;
import org.bukkit.ArrowEntity;
import net.minecraft.server.EntityArrow;
/**
* Represents an arrow.
*
* @author sk89q
*/
public class CraftArrowEntity extends CraftEntity implements ArrowEntity {
CraftArrowEntity(CraftServer server, EntityArrow entity) {
super(server, entity);
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityEgg;
import org.bukkit.Egg;
/**
* An egg.
*
* @author sk89q
*/
public class CraftEgg extends CraftEntity implements Egg {
public CraftEgg(CraftServer server, EntityEgg ent) {
super(server, ent);
}
}

Datei anzeigen

@ -6,7 +6,7 @@ import net.minecraft.server.WorldServer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
public class CraftEntity implements org.bukkit.Entity { public abstract class CraftEntity implements org.bukkit.Entity {
protected final CraftServer server; protected final CraftServer server;
private Entity entity; private Entity entity;

Datei anzeigen

@ -2,8 +2,13 @@
package org.bukkit.craftbukkit; package org.bukkit.craftbukkit;
import net.minecraft.server.Entity; import net.minecraft.server.Entity;
import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntitySnowball;
import org.bukkit.Egg;
import org.bukkit.LivingEntity; import org.bukkit.LivingEntity;
import org.bukkit.Snowball;
public class CraftLivingEntity extends CraftEntity implements LivingEntity { public class CraftLivingEntity extends CraftEntity implements LivingEntity {
private EntityLiving entity; private EntityLiving entity;
@ -39,4 +44,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public String toString() { public String toString() {
return "CraftLivingEntity{" + "id=" + getEntityID() + '}'; return "CraftLivingEntity{" + "id=" + getEntityID() + '}';
} }
public Egg throwEgg() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
EntityEgg egg = new EntityEgg(world, entity);
world.a(egg);
return new CraftEgg(server, egg);
}
public Snowball throwSnowball() {
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
EntitySnowball snowball = new EntitySnowball(world, entity);
world.a(snowball);
return new CraftSnowball(server, snowball);
}
} }

Datei anzeigen

@ -0,0 +1,87 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.LivingEntity;
import org.bukkit.Minecart;
import org.bukkit.Vector;
/**
* A minecart.
*
* @author sk89q
*/
public class CraftMinecart extends CraftVehicle implements Minecart {
/**
* Stores the minecart type ID, which is used by Minecraft to differentiate
* minecart types. Here we use subclasses.
*/
public enum Type {
Minecart(0),
StorageMinecart(1),
PoweredMinecart(2);
private final int id;
private Type(int id) {
this.id = id;
}
public int getID() {
return id;
}
}
protected EntityMinecart minecart;
public CraftMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
minecart = entity;
}
public Vector getVelocity() {
return new Vector(minecart.s, minecart.t, minecart.u);
}
public void setVelocity(Vector vel) {
minecart.s = vel.getX();
minecart.t = vel.getY();
minecart.u = vel.getZ();
}
public LivingEntity getPassenger() {
// @TODO: Implement
return null;
}
public boolean isEmpty() {
return minecart.j == null;
}
public void setDamage(int damage) {
minecart.a = damage;
}
public int getDamage() {
return minecart.a;
}
/**
* Internal function to convert an MC entity to an appropriate CraftBukkit
* entity.
*
* @param server
* @param minecart
* @return
*/
public static CraftMinecart getCraftMinecart(CraftServer server,
EntityMinecart minecart) {
if (minecart.d == Type.StorageMinecart.getID()) {
return new CraftStorageMinecart(server, minecart);
} else if (minecart.d == Type.PoweredMinecart.getID()) {
return new CraftPoweredMinecart(server, minecart);
} else {
return new CraftMinecart(server, minecart);
}
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.PoweredMinecart;
/**
* A powered minecart.
*
* @author sk89q
*/
public class CraftPoweredMinecart extends CraftMinecart
implements PoweredMinecart {
public CraftPoweredMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
}
}

Datei anzeigen

@ -15,17 +15,15 @@ import org.bukkit.plugin.java.JavaPluginLoader;
public final class CraftServer implements Server { public final class CraftServer implements Server {
private final String serverName = "Craftbukkit"; private final String serverName = "Craftbukkit";
private final String serverVersion; private final String serverVersion = "1.1";
private final PluginManager pluginManager = new SimplePluginManager(this); private final PluginManager pluginManager = new SimplePluginManager(this);
protected final MinecraftServer console; protected final MinecraftServer console;
protected final ServerConfigurationManager server; protected final ServerConfigurationManager server;
public CraftServer(MinecraftServer instance, String ver) { public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
serverVersion = ver; this.console = console;
this.server = server;
console = instance;
server = console.f;
pluginManager.RegisterInterface(JavaPluginLoader.class); pluginManager.RegisterInterface(JavaPluginLoader.class);

Datei anzeigen

@ -0,0 +1,15 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntitySnowball;
import org.bukkit.Snowball;
/**
* A snowball.
*
* @author sk89q
*/
public class CraftSnowball extends CraftEntity implements Snowball {
public CraftSnowball(CraftServer server, EntitySnowball ent) {
super(server, ent);
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.EntityMinecart;
import org.bukkit.StorageMinecart;
/**
* A storage minecart.
*
* @author sk89q
*/
public class CraftStorageMinecart extends CraftMinecart
implements StorageMinecart {
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
}
}

Datei anzeigen

@ -0,0 +1,16 @@
package org.bukkit.craftbukkit;
import net.minecraft.server.Entity;
import org.bukkit.Vehicle;
/**
* A vehicle.
*
* @author sk89q
*/
public abstract class CraftVehicle extends CraftEntity implements Vehicle {
public CraftVehicle(CraftServer server, Entity entity) {
super(server, entity);
}
}

Datei anzeigen

@ -3,15 +3,20 @@ package org.bukkit.craftbukkit;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.server.EntityMinecart;
import java.util.Random; import java.util.Random;
import net.minecraft.server.WorldGenBigTree; import net.minecraft.server.WorldGenBigTree;
import net.minecraft.server.WorldGenTrees;
import net.minecraft.server.WorldServer; import net.minecraft.server.WorldServer;
import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityArrow;
import org.bukkit.ArrowEntity; import net.minecraft.server.WorldGenTrees;
import org.bukkit.Arrow;
import org.bukkit.Block; import org.bukkit.Block;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Minecart;
import org.bukkit.PoweredMinecart;
import org.bukkit.StorageMinecart;
import org.bukkit.Vector; import org.bukkit.Vector;
import org.bukkit.World; import org.bukkit.World;
@ -79,13 +84,40 @@ public class CraftWorld implements World {
return world; return world;
} }
public ArrowEntity spawnArrow(Location loc, Vector velocity, float speed, public Arrow spawnArrow(Location loc, Vector velocity, float speed,
float spread) { float spread) {
EntityArrow arrow = new EntityArrow(world); EntityArrow arrow = new EntityArrow(world);
arrow.c(loc.getX(), loc.getY(), loc.getZ()); arrow.c(loc.getX(), loc.getY(), loc.getZ());
world.a(arrow); world.a(arrow);
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
return new CraftArrowEntity(world.getServer(), arrow); return new CraftArrow(world.getServer(), arrow);
}
public Minecart spawnMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.Minecart.getID());
world.a(minecart);
return new CraftMinecart(world.getServer(), minecart);
}
public StorageMinecart spawnStorageMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.StorageMinecart.getID());
world.a(minecart);
return new CraftStorageMinecart(world.getServer(), minecart);
}
public PoweredMinecart spawnPoweredMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
loc.getX(), loc.getY(), loc.getZ(),
CraftMinecart.Type.PoweredMinecart.getID());
world.a(minecart);
return new CraftPoweredMinecart(world.getServer(), minecart);
} }
public boolean generateTree(Location loc) { public boolean generateTree(Location loc) {