Port to new mc-dev format.

This commit is contained in:
Erik Broes 2011-01-29 22:50:29 +01:00
parent d0cd8c6cc7
commit df69047324
96 changed files with 8809 additions and 9406 deletions

View File

@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId> <artifactId>minecraft-server</artifactId>
<version>1.2_01</version> <version>1.2_01_01</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View File

@ -17,8 +17,8 @@ import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockButton extends Block { public class BlockButton extends Block {
protected BlockButton(int i, int j) { protected BlockButton(int i, int j) {
super(i, j, Material.n); super(i, j, Material.ORIENTABLE);
a(true); this.a(true);
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
@ -34,35 +34,30 @@ public class BlockButton extends Block {
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
if (world.d(i - 1, j, k)) { return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : world.d(i, j, k + 1)));
return true;
}
if (world.d(i + 1, j, k)) {
return true;
}
if (world.d(i, j, k - 1)) {
return true;
}
return world.d(i, j, k + 1);
} }
public void c(World world, int i, int j, int k, int l) { public void c(World world, int i, int j, int k, int l) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
int j1 = i1 & 8; int j1 = i1 & 8;
i1 &= 7; i1 &= 7;
if (l == 2 && world.d(i, j, k + 1)) { if (l == 2 && world.d(i, j, k + 1)) {
i1 = 4; i1 = 4;
} }
if (l == 3 && world.d(i, j, k - 1)) { if (l == 3 && world.d(i, j, k - 1)) {
i1 = 3; i1 = 3;
} }
if (l == 4 && world.d(i + 1, j, k)) { if (l == 4 && world.d(i + 1, j, k)) {
i1 = 2; i1 = 2;
} }
if (l == 5 && world.d(i - 1, j, k)) { if (l == 5 && world.d(i - 1, j, k)) {
i1 = 1; i1 = 1;
} }
world.c(i, j, k, i1 + j1); world.c(i, j, k, i1 + j1);
} }
@ -76,36 +71,41 @@ public class BlockButton extends Block {
} else if (world.d(i, j, k + 1)) { } else if (world.d(i, j, k + 1)) {
world.c(i, j, k, 4); world.c(i, j, k, 4);
} }
g(world, i, j, k);
this.g(world, i, j, k);
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
if (g(world, i, j, k)) { if (this.g(world, i, j, k)) {
int i1 = world.b(i, j, k) & 7; int i1 = world.getData(i, j, k) & 7;
boolean flag = false; boolean flag = false;
if (!world.d(i - 1, j, k) && i1 == 1) { if (!world.d(i - 1, j, k) && i1 == 1) {
flag = true; flag = true;
} }
if (!world.d(i + 1, j, k) && i1 == 2) { if (!world.d(i + 1, j, k) && i1 == 2) {
flag = true; flag = true;
} }
if (!world.d(i, j, k - 1) && i1 == 3) { if (!world.d(i, j, k - 1) && i1 == 3) {
flag = true; flag = true;
} }
if (!world.d(i, j, k + 1) && i1 == 4) { if (!world.d(i, j, k + 1) && i1 == 4) {
flag = true; flag = true;
} }
if (flag) { if (flag) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
} }
} }
private boolean g(World world, int i, int j, int k) { private boolean g(World world, int i, int j, int k) {
if (!a(world, i, j, k)) { if (!this.a(world, i, j, k)) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
return false; return false;
} else { } else {
@ -114,7 +114,7 @@ public class BlockButton extends Block {
} }
public void a(IBlockAccess iblockaccess, int i, int j, int k) { public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.b(i, j, k); int l = iblockaccess.getData(i, j, k);
int i1 = l & 7; int i1 = l & 7;
boolean flag = (l & 8) > 0; boolean flag = (l & 8) > 0;
float f = 0.375F; float f = 0.375F;
@ -125,122 +125,113 @@ public class BlockButton extends Block {
if (flag) { if (flag) {
f3 = 0.0625F; f3 = 0.0625F;
} }
if (i1 == 1) { if (i1 == 1) {
a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); this.a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
} else if (i1 == 2) { } else if (i1 == 2) {
a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); this.a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
} else if (i1 == 3) { } else if (i1 == 3) {
a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); this.a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
} else if (i1 == 4) { } else if (i1 == 4) {
a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); this.a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
} }
} }
public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
a(world, i, j, k, entityplayer); this.a(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
// CraftBukkit start - Interact Button if (world.isStatic) {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) {
return true; return true;
} } else {
// CraftBukkit end // CraftBukkit start - Interact Button
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (world.z) { if (event.isCancelled()) {
return true; return true;
} }
int l = world.b(i, j, k); // CraftBukkit end
int i1 = l & 7;
int j1 = 8 - (l & 8); int l = world.getData(i, j, k);
int i1 = l & 7;
if (j1 == 0) { int j1 = 8 - (l & 8);
return true;
} if (j1 == 0) {
return true;
//Allow the lever to change the current } else {
int old = (j1 != 8) ? 1 : 0; //Allow the lever to change the current
int current = (j1 == 8) ? 1 : 0; int old = (j1 != 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current); int current = (j1 == 8) ? 1 : 0;
server.getPluginManager().callEvent(bre); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
if ((bre.getNewCurrent() > 0) == (j1 == 8)) { server.getPluginManager().callEvent(eventRedstone);
world.c(i, j, k, i1 + j1); if ((eventRedstone.getNewCurrent() > 0) == (j1 == 8)) {
world.b(i, j, k, i, j, k); world.c(i, j, k, i1 + j1);
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); world.b(i, j, k, i, j, k);
world.h(i, j, k, bi); world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
if (i1 == 1) { world.h(i, j, k, this.id);
world.h(i - 1, j, k, bi); if (i1 == 1) {
} else if (i1 == 2) { world.h(i - 1, j, k, this.id);
world.h(i + 1, j, k, bi); } else if (i1 == 2) {
} else if (i1 == 3) { world.h(i + 1, j, k, this.id);
world.h(i, j, k - 1, bi); } else if (i1 == 3) {
} else if (i1 == 4) { world.h(i, j, k - 1, this.id);
world.h(i, j, k + 1, bi); } else if (i1 == 4) {
} else { world.h(i, j, k + 1, this.id);
world.h(i, j - 1, k, bi); } else {
world.h(i, j - 1, k, this.id);
}
world.i(i, j, k, this.id);
}
return true;
} }
world.i(i, j, k, bi);
} }
return true;
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) > 0) { if ((l & 8) > 0) {
world.h(i, j, k, bi); world.h(i, j, k, this.id);
int i1 = l & 7; int i1 = l & 7;
if (i1 == 1) { if (i1 == 1) {
world.h(i - 1, j, k, bi); world.h(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, bi); world.h(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, bi); world.h(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, bi); world.h(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
} }
} }
super.b(world, i, j, k); super.b(world, i, j, k);
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return (iblockaccess.b(i, j, k) & 8) > 0; return (iblockaccess.getData(i, j, k) & 8) > 0;
} }
public boolean d(World world, int i, int j, int k, int l) { public boolean d(World world, int i, int j, int k, int l) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
if ((i1 & 8) == 0) { if ((i1 & 8) == 0) {
return false; return false;
} } else {
int j1 = i1 & 7; int j1 = i1 & 7;
if (j1 == 5 && l == 1) { return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5)));
return true;
} }
if (j1 == 4 && l == 2) {
return true;
}
if (j1 == 3 && l == 3) {
return true;
}
if (j1 == 2 && l == 4) {
return true;
}
return j1 == 1 && l == 5;
} }
public boolean c() { public boolean c() {
@ -248,30 +239,29 @@ public class BlockButton extends Block {
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
if (world.z) { if (!world.isStatic) {
return; int l = world.getData(i, j, k);
}
int l = world.b(i, j, k);
if ((l & 8) == 0) { if ((l & 8) != 0) {
return; world.c(i, j, k, l & 7);
} world.h(i, j, k, this.id);
world.c(i, j, k, l & 7); int i1 = l & 7;
world.h(i, j, k, bi);
int i1 = l & 7;
if (i1 == 1) { if (i1 == 1) {
world.h(i - 1, j, k, bi); world.h(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, bi); world.h(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, bi); world.h(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, bi); world.h(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
}
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
world.b(i, j, k, i, j, k);
}
} }
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
world.b(i, j, k, i, j, k);
} }
} }

View File

@ -12,22 +12,23 @@ import java.util.Random;
public class BlockCactus extends Block { public class BlockCactus extends Block {
protected BlockCactus(int i, int j) { protected BlockCactus(int i, int j) {
super(i, j, Material.u); super(i, j, Material.CACTUS);
a(true); this.a(true);
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
if (world.e(i, j + 1, k)) { if (world.isEmpty(i, j + 1, k)) {
int l; int l;
for (l = 1; world.a(i, j - l, k) == bi; l++) { for (l = 1; world.getTypeId(i, j - l, k) == this.id; ++l) {
; ;
} }
if (l < 3) { if (l < 3) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
if (i1 == 15) { if (i1 == 15) {
world.e(i, j + 1, k, bi); world.e(i, j + 1, k, this.id);
world.c(i, j, k, 0); world.c(i, j, k, 0);
} else { } else {
world.c(i, j, k, i1 + 1); world.c(i, j, k, i1 + 1);
@ -37,20 +38,13 @@ public class BlockCactus extends Block {
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
float f1 = 0.0625F; float f = 0.0625F;
return AxisAlignedBB.b((float) i + f1, j, (float) k + f1, (float) (i + 1) - f1, (float) (j + 1) - f1, (float) (k + 1) - f1); return AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f));
} }
public int a(int i) { public int a(int i) {
if (i == 1) { return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId + 1 : this.textureId);
return bh - 1;
}
if (i == 0) {
return bh + 1;
} else {
return bh;
}
} }
public boolean a() { public boolean a() {
@ -58,42 +52,34 @@ public class BlockCactus extends Block {
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
if (!super.a(world, i, j, k)) { return !super.a(world, i, j, k) ? false : this.f(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) { public void b(World world, int i, int j, int k, int l) {
if (!f(world, i, j, k)) { if (!this.f(world, i, j, k)) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
} }
public boolean f(World world, int i, int j, int k) { public boolean f(World world, int i, int j, int k) {
if (world.c(i - 1, j, k).a()) { if (world.getMaterial(i - 1, j, k).isBuildable()) {
return false; return false;
} } else if (world.getMaterial(i + 1, j, k).isBuildable()) {
if (world.c(i + 1, j, k).a()) {
return false; return false;
} } else if (world.getMaterial(i, j, k - 1).isBuildable()) {
if (world.c(i, j, k - 1).a()) {
return false; return false;
} } else if (world.getMaterial(i, j, k + 1).isBuildable()) {
if (world.c(i, j, k + 1).a()) {
return false; return false;
} else { } else {
int l = world.a(i, j - 1, k); int l = world.getTypeId(i, j - 1, k);
return l == Block.aV.bi || l == Block.E.bi; return l == Block.CACTUS.id || l == Block.SAND.id;
} }
} }
public void a(World world, int i, int j, int k, Entity entity) { public void a(World world, int i, int j, int k, Entity entity) {
// CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event // CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event
if(entity instanceof EntityLiving) { if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k); org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
@ -101,16 +87,15 @@ public class BlockCactus extends Block {
DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT; DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT;
int damageDone = 1; int damageDone = 1;
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbbe); server.getPluginManager().callEvent(event);
if (!edbbe.isCancelled()){ if (!event.isCancelled()){
entity.a(((Entity) (null)), edbbe.getDamage()); entity.a((Entity) null, event.getDamage());
} }
return; return;
} else {
entity.a(((Entity) (null)), 1);
} }
// CraftBukkit end // CraftBukkit end
entity.a((Entity) null, 1);
} }
} }

View File

@ -14,163 +14,129 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockChest extends BlockContainer { public class BlockChest extends BlockContainer {
private Random a; private Random a = new Random();
protected BlockChest(int i) { protected BlockChest(int i) {
super(i, Material.c); super(i, Material.WOOD);
a = new Random(); this.textureId = 26;
bh = 26;
} }
public int a(int i) { public int a(int i) {
if (i == 1) { return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId));
return bh - 1;
}
if (i == 0) {
return bh - 1;
}
if (i == 3) {
return bh + 1;
} else {
return bh;
}
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
int l = 0; int l = 0;
if (world.a(i - 1, j, k) == bi) { if (world.getTypeId(i - 1, j, k) == this.id) {
l++; ++l;
} }
if (world.a(i + 1, j, k) == bi) {
l++; if (world.getTypeId(i + 1, j, k) == this.id) {
++l;
} }
if (world.a(i, j, k - 1) == bi) {
l++; if (world.getTypeId(i, j, k - 1) == this.id) {
++l;
} }
if (world.a(i, j, k + 1) == bi) {
l++; if (world.getTypeId(i, j, k + 1) == this.id) {
++l;
} }
if (l > 1) {
return false; return l > 1 ? false : (this.g(world, i - 1, j, k) ? false : (this.g(world, i + 1, j, k) ? false : (this.g(world, i, j, k - 1) ? false : !this.g(world, i, j, k + 1))));
}
if (g(world, i - 1, j, k)) {
return false;
}
if (g(world, i + 1, j, k)) {
return false;
}
if (g(world, i, j, k - 1)) {
return false;
}
return !g(world, i, j, k + 1);
} }
private boolean g(World world, int i, int j, int k) { private boolean g(World world, int i, int j, int k) {
if (world.a(i, j, k) != bi) { return world.getTypeId(i, j, k) != this.id ? false : (world.getTypeId(i - 1, j, k) == this.id ? true : (world.getTypeId(i + 1, j, k) == this.id ? true : (world.getTypeId(i, j, k - 1) == this.id ? true : world.getTypeId(i, j, k + 1) == this.id)));
return false;
}
if (world.a(i - 1, j, k) == bi) {
return true;
}
if (world.a(i + 1, j, k) == bi) {
return true;
}
if (world.a(i, j, k - 1) == bi) {
return true;
}
return world.a(i, j, k + 1) == bi;
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
TileEntityChest tileentitychest = (TileEntityChest) world.m(i, j, k); TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(i, j, k);
label0: for (int l = 0; l < tileentitychest.h_(); ++l) {
for (int l = 0; l < ((IInventory) (tileentitychest)).h_(); l++) { ItemStack itemstack = tileentitychest.a(l);
ItemStack itemstack = ((IInventory) (tileentitychest)).a(l);
if (itemstack == null) { if (itemstack != null) {
continue; float f = this.a.nextFloat() * 0.8F + 0.1F;
float f1 = this.a.nextFloat() * 0.8F + 0.1F;
float f2 = this.a.nextFloat() * 0.8F + 0.1F;
while (itemstack.count > 0) {
int i1 = this.a.nextInt(21) + 10;
if (i1 > itemstack.count) {
i1 = itemstack.count;
}
itemstack.count -= i1;
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.h()));
float f3 = 0.05F;
entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
world.a((Entity) entityitem);
}
} }
float f = a.nextFloat() * 0.8F + 0.1F;
float f1 = a.nextFloat() * 0.8F + 0.1F;
float f2 = a.nextFloat() * 0.8F + 0.1F;
do {
if (itemstack.a <= 0) {
continue label0;
}
int i1 = a.nextInt(21) + 10;
if (i1 > itemstack.a) {
i1 = itemstack.a;
}
itemstack.a -= i1;
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.c, i1, itemstack.h()));
float f3 = 0.05F;
entityitem.s = (float) a.nextGaussian() * f3;
entityitem.t = (float) a.nextGaussian() * f3 + 0.2F;
entityitem.u = (float) a.nextGaussian() * f3;
world.a(((Entity) (entityitem)));
} while (true);
} }
super.b(world, i, j, k); super.b(world, i, j, k);
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
Object obj = (((TileEntityChest) world.m(i, j, k))); Object object = (TileEntityChest) world.getTileEntity(i, j, k);
if (world.d(i, j + 1, k)) { if (world.d(i, j + 1, k)) {
return true; return true;
} } else if (world.getTypeId(i - 1, j, k) == this.id && world.d(i - 1, j + 1, k)) {
if (world.a(i - 1, j, k) == bi && world.d(i - 1, j + 1, k)) {
return true; return true;
} } else if (world.getTypeId(i + 1, j, k) == this.id && world.d(i + 1, j + 1, k)) {
if (world.a(i + 1, j, k) == bi && world.d(i + 1, j + 1, k)) {
return true; return true;
} } else if (world.getTypeId(i, j, k - 1) == this.id && world.d(i, j + 1, k - 1)) {
if (world.a(i, j, k - 1) == bi && world.d(i, j + 1, k - 1)) {
return true; return true;
} } else if (world.getTypeId(i, j, k + 1) == this.id && world.d(i, j + 1, k + 1)) {
if (world.a(i, j, k + 1) == bi && world.d(i, j + 1, k + 1)) {
return true;
}
if (world.a(i - 1, j, k) == bi) {
obj = ((new InventoryLargeChest("Large chest", ((IInventory) ((TileEntityChest) world.m(i - 1, j, k))), ((IInventory) (obj)))));
}
if (world.a(i + 1, j, k) == bi) {
obj = ((new InventoryLargeChest("Large chest", ((IInventory) (obj)), ((IInventory) ((TileEntityChest) world.m(i + 1, j, k))))));
}
if (world.a(i, j, k - 1) == bi) {
obj = ((new InventoryLargeChest("Large chest", ((IInventory) ((TileEntityChest) world.m(i, j, k - 1))), ((IInventory) (obj)))));
}
if (world.a(i, j, k + 1) == bi) {
obj = ((new InventoryLargeChest("Large chest", ((IInventory) (obj)), ((IInventory) ((TileEntityChest) world.m(i, j, k + 1))))));
}
if (world.z) {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Chest if (world.getTypeId(i - 1, j, k) == this.id) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i - 1, j, k), (IInventory) object);
CraftServer server = ((WorldServer) world).getServer(); }
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true; if (world.getTypeId(i + 1, j, k) == this.id) {
// CraftBukkit end object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i + 1, j, k));
}
entityplayer.a(((IInventory) (obj))); if (world.getTypeId(i, j, k - 1) == this.id) {
return true; object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i, j, k - 1), (IInventory) object);
}
if (world.getTypeId(i, j, k + 1) == this.id) {
object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i, j, k + 1));
}
if (world.isStatic) {
return true;
} else {
// CraftBukkit start - Interact Chest
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) return true;
// CraftBukkit end
entityhuman.a((IInventory) object);
return true;
}
} }
} }
protected TileEntity a_() { protected TileEntity a_() {
return ((TileEntity) (new TileEntityChest())); return new TileEntityChest();
} }
} }

View File

@ -16,14 +16,15 @@ public class BlockDoor extends Block {
protected BlockDoor(int i, Material material) { protected BlockDoor(int i, Material material) {
super(i, material); super(i, material);
bh = 97; this.textureId = 97;
if (material == Material.e) { if (material == Material.ORE) {
bh++; ++this.textureId;
} }
float f = 0.5F; float f = 0.5F;
float f1 = 1.0F; float f1 = 1.0F;
a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
} }
public boolean a() { public boolean a() {
@ -31,170 +32,165 @@ public class BlockDoor extends Block {
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
a(((IBlockAccess) (world)), i, j, k); this.a((IBlockAccess) world, i, j, k);
return super.d(world, i, j, k); return super.d(world, i, j, k);
} }
public void a(IBlockAccess iblockaccess, int i, int j, int k) { public void a(IBlockAccess iblockaccess, int i, int j, int k) {
c(d(iblockaccess.b(i, j, k))); this.c(this.d(iblockaccess.getData(i, j, k)));
} }
public void c(int i) { public void c(int i) {
float f = 0.1875F; float f = 0.1875F;
a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); this.a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
if (i == 0) { if (i == 0) {
a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
} }
if (i == 1) { if (i == 1) {
a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
} }
if (i == 2) { if (i == 2) {
a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
} }
if (i == 3) { if (i == 3) {
a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
} }
} }
public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
a(world, i, j, k, entityplayer); this.a(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
if (bt == Material.e) { if (this.material == Material.ORE) {
return true; return true;
}
int l = world.b(i, j, k);
if ((l & 8) != 0) {
if (world.a(i, j - 1, k) == bi) {
a(world, i, j - 1, k, entityplayer);
}
return true;
}
// CraftBukkit start - Interact Door
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
// CraftBukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data.
if (bie.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world));
return true;
}
// CraftBukkit end
if (world.a(i, j + 1, k) == bi) {
world.c(i, j + 1, k, (l ^ 4) + 8);
}
world.c(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
} else { } else {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); int l = world.getData(i, j, k);
if ((l & 8) != 0) {
if (world.getTypeId(i, j - 1, k) == this.id) {
this.a(world, i, j - 1, k, entityhuman);
}
return true;
} else {
// CraftBukkit start - Interact Door
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
// CraftBukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data.
if (event.isCancelled()) {
((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world));
return true;
}
// CraftBukkit end
if (world.getTypeId(i, j + 1, k) == this.id) {
world.c(i, j + 1, k, (l ^ 4) + 8);
}
world.c(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
} else {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
}
return true;
}
} }
return true;
} }
public void a(World world, int i, int j, int k, boolean flag) { public void a(World world, int i, int j, int k, boolean flag) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) != 0) { if ((l & 8) != 0) {
if (world.a(i, j - 1, k) == bi) { if (world.getTypeId(i, j - 1, k) == this.id) {
a(world, i, j - 1, k, flag); this.a(world, i, j - 1, k, flag);
} }
return;
}
boolean flag1 = (world.b(i, j, k) & 4) > 0;
if (flag1 == flag) {
return;
}
if (world.a(i, j + 1, k) == bi) {
world.c(i, j + 1, k, (l ^ 4) + 8);
}
world.c(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
} else { } else {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F); boolean flag1 = (world.getData(i, j, k) & 4) > 0;
if (flag1 != flag) {
if (world.getTypeId(i, j + 1, k) == this.id) {
world.c(i, j + 1, k, (l ^ 4) + 8);
}
world.c(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
} else {
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
}
}
} }
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
if ((i1 & 8) != 0) { if ((i1 & 8) != 0) {
if (world.a(i, j - 1, k) != bi) { if (world.getTypeId(i, j - 1, k) != this.id) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
if (l > 0 && Block.m[l].c()) {
b(world, i, j - 1, k, l); if (l > 0 && Block.byId[l].c()) {
this.b(world, i, j - 1, k, l);
} }
} else { } else {
boolean flag = false; boolean flag = false;
if (world.a(i, j + 1, k) != bi) { if (world.getTypeId(i, j + 1, k) != this.id) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
flag = true; flag = true;
} }
if (!world.d(i, j - 1, k)) { if (!world.d(i, j - 1, k)) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
flag = true; flag = true;
if (world.a(i, j + 1, k) == bi) { if (world.getTypeId(i, j + 1, k) == this.id) {
world.e(i, j + 1, k, 0); world.e(i, j + 1, k, 0);
} }
} }
if (flag) { if (flag) {
a_(world, i, j, k, i1); this.a_(world, i, j, k, i1);
} else if (l > 0 && Block.m[l].c()) { } else if (l > 0 && Block.byId[l].c()) {
boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k); boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k);
a(world, i, j, k, flag1); this.a(world, i, j, k, flag1);
} }
} }
} }
public int a(int i, Random random) { public int a(int i, Random random) {
if ((i & 8) != 0) { return (i & 8) != 0 ? 0 : (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id);
return 0;
}
if (bt == Material.e) {
return Item.az.ba;
} else {
return Item.at.ba;
}
} }
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
a(((IBlockAccess) (world)), i, j, k); this.a((IBlockAccess) world, i, j, k);
return super.a(world, i, j, k, vec3d, vec3d1); return super.a(world, i, j, k, vec3d, vec3d1);
} }
public int d(int i) { public int d(int i) {
if ((i & 4) == 0) { return (i & 4) == 0 ? i - 1 & 3 : i & 3;
return i - 1 & 3;
} else {
return i & 3;
}
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
if (j >= 127) { return j >= 127 ? false : world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k);
return false;
} else {
return world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k);
}
} }
} }

View File

@ -1,36 +1,35 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import java.util.Random;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
// CraftBukkit end // CraftBukkit end
public class BlockFire extends Block { public class BlockFire extends Block {
private int a[]; private int[] a = new int[256];
private int b[]; private int[] b = new int[256];
protected BlockFire(int i, int j) { protected BlockFire(int i, int j) {
super(i, j, Material.l); super(i, j, Material.FIRE);
a = new int[256]; this.a(Block.WOOD.id, 5, 20);
b = new int[256]; this.a(Block.LOG.id, 5, 5);
a(Block.x.bi, 5, 20); this.a(Block.LEAVES.id, 30, 60);
a(Block.J.bi, 5, 5); this.a(Block.BOOKSHELF.id, 30, 20);
a(Block.K.bi, 30, 60); this.a(Block.TNT.id, 15, 100);
a(Block.an.bi, 30, 20); this.a(Block.WOOL.id, 30, 60);
a(Block.am.bi, 15, 100); this.a(true);
a(Block.ab.bi, 30, 60);
a(true);
} }
private void a(int i, int j, int k) { private void a(int i, int j, int k) {
a[i] = j; this.a[i] = j;
b[i] = k; this.b[i] = k;
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
@ -50,62 +49,66 @@ public class BlockFire extends Block {
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
boolean flag = world.a(i, j - 1, k) == Block.bb.bi; boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id;
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if (l < 15) { if (l < 15) {
world.c(i, j, k, l + 1); world.c(i, j, k, l + 1);
world.i(i, j, k, bi); world.i(i, j, k, this.id);
} }
if (!flag && !g(world, i, j, k)) {
if (!flag && !this.g(world, i, j, k)) {
if (!world.d(i, j - 1, k) || l > 3) { if (!world.d(i, j - 1, k) || l > 3) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
return; } else if (!flag && !this.b((IBlockAccess)world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { // CraftBukkit - Cast to IBlockAccess
}
if (!flag && !b(((IBlockAccess) (world)), i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
return; } else {
} if (l % 2 == 0 && l > 2) {
if (l % 2 == 0 && l > 2) { this.a(world, i + 1, j, k, 300, random);
a(world, i + 1, j, k, 300, random); this.a(world, i - 1, j, k, 300, random);
a(world, i - 1, j, k, 300, random); this.a(world, i, j - 1, k, 250, random);
a(world, i, j - 1, k, 250, random); this.a(world, i, j + 1, k, 250, random);
a(world, i, j + 1, k, 250, random); this.a(world, i, j, k - 1, 300, random);
a(world, i, j, k - 1, 300, random); this.a(world, i, j, k + 1, 300, random);
a(world, i, j, k + 1, 300, random);
for (int i1 = i - 1; i1 <= i + 1; i1++) {
for (int j1 = k - 1; j1 <= k + 1; j1++) {
for (int k1 = j - 1; k1 <= j + 4; k1++) {
if (i1 == i && k1 == j && j1 == k) {
continue;
}
int l1 = 100;
if (k1 > j + 1) { // CraftBukkit start - Call to stop spread of fire.
l1 += (k1 - (j + 1)) * 100; Server server = ((WorldServer)world).getServer();
} CraftWorld cworld = ((WorldServer)world).getWorld();
int i2 = h(world, i1, k1, j1);
// CraftBukkit start: Call to stop spread of fire. IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
Server server = ((WorldServer)world).getServer(); Player thePlayer = null;
CraftWorld cworld = ((WorldServer)world).getWorld(); // CraftBukkit
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, k1, j1)); for (int i1 = i - 1; i1 <= i + 1; ++i1) {
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD; for (int j1 = k - 1; j1 <= k + 1; ++j1) {
Player thePlayer = null; for (int k1 = j - 1; k1 <= j + 4; ++k1) {
if (i1 != i || k1 != j || j1 != k) {
if (theBlock.getTypeId() != Block.ar.bi){ int l1 = 100;
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
server.getPluginManager().callEvent(event); if (k1 > j + 1) {
if (event.isCancelled()) { l1 += (k1 - (j + 1)) * 100;
continue; }
int i2 = this.h(world, i1, k1, j1);
if (i2 > 0 && random.nextInt(l1) <= i2) {
// CraftBukkit start - Call to stop spread of fire.
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, k1, j1));
if (theBlock.getTypeId() != Block.FIRE.id){
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
}
// CraftBukkit end
world.e(i1, k1, j1, this.id);
}
} }
} }
// CraftBukkit end
if (i2 > 0 && random.nextInt(l1) <= i2) {
world.e(i1, k1, j1, bi);
}
} }
} }
} }
@ -113,74 +116,43 @@ public class BlockFire extends Block {
} }
private void a(World world, int i, int j, int k, int l, Random random) { private void a(World world, int i, int j, int k, int l, Random random) {
int i1 = b[world.a(i, j, k)]; int i1 = this.b[world.getTypeId(i, j, k)];
if (random.nextInt(l) < i1) { if (random.nextInt(l) < i1) {
boolean flag = world.a(i, j, k) == Block.am.bi; boolean flag = world.getTypeId(i, j, k) == Block.TNT.id;
// CraftBukkit start: BlockBurnEvent
Server server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
BlockBurnEvent burnEvent = new BlockBurnEvent(theBlock);
server.getPluginManager().callEvent(burnEvent);
if(!burnEvent.isCancelled()) {
if (random.nextInt(2) == 0) {
// CraftBukkit start: Call to stop very slow spread of fire.
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SLOW_SPREAD; if (random.nextInt(2) == 0) {
Player thePlayer = null; world.e(i, j, k, this.id);
} else {
if (theBlock.getTypeId() != Block.ar.bi){ world.e(i, j, k, 0);
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer); }
server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (flag) {
return; Block.TNT.a(world, i, j, k, 0);
}
}
// CraftBukkit end
world.e(i, j, k, bi);
} else {
world.e(i, j, k, 0);
}
if (flag) {
Block.am.a(world, i, j, k, 0);
}
} }
// CraftBukkit end: BlockBurnEvent
} }
} }
private boolean g(World world, int i, int j, int k) { // CraftBukkit start -- fix cast to IBlockAccess
if (b(((IBlockAccess) (world)), i + 1, j, k)) { private boolean g(World world1, int i, int j, int k) {
return true; IBlockAccess world = (IBlockAccess) world1;
} // CraftBukkit end
if (b(((IBlockAccess) (world)), i - 1, j, k)) { return this.b(world, i + 1, j, k) ? true : (this.b(world, i - 1, j, k) ? true : (this.b(world, i, j - 1, k) ? true : (this.b(world, i, j + 1, k) ? true : (this.b(world, i, j, k - 1) ? true : this.b(world, i, j, k + 1)))));
return true;
}
if (b(((IBlockAccess) (world)), i, j - 1, k)) {
return true;
}
if (b(((IBlockAccess) (world)), i, j + 1, k)) {
return true;
}
if (b(((IBlockAccess) (world)), i, j, k - 1)) {
return true;
}
return b(((IBlockAccess) (world)), i, j, k + 1);
} }
private int h(World world, int i, int j, int k) { private int h(World world, int i, int j, int k) {
int l = 0; byte b0 = 0;
if (!world.e(i, j, k)) { if (!world.isEmpty(i, j, k)) {
return 0; return 0;
} else { } else {
l = f(world, i + 1, j, k, l); int l = this.f(world, i + 1, j, k, b0);
l = f(world, i - 1, j, k, l);
l = f(world, i, j - 1, k, l); l = this.f(world, i - 1, j, k, l);
l = f(world, i, j + 1, k, l); l = this.f(world, i, j - 1, k, l);
l = f(world, i, j, k - 1, l); l = this.f(world, i, j + 1, k, l);
l = f(world, i, j, k + 1, l); l = this.f(world, i, j, k - 1, l);
l = this.f(world, i, j, k + 1, l);
return l; return l;
} }
} }
@ -190,43 +162,32 @@ public class BlockFire extends Block {
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
return a[iblockaccess.a(i, j, k)] > 0; return this.a[iblockaccess.getTypeId(i, j, k)] > 0;
} }
public int f(World world, int i, int j, int k, int l) { public int f(World world, int i, int j, int k, int l) {
int i1 = a[world.a(i, j, k)]; int i1 = this.a[world.getTypeId(i, j, k)];
if (i1 > l) { return i1 > l ? i1 : l;
return i1;
} else {
return l;
}
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
return world.d(i, j - 1, k) || g(world, i, j, k); return world.d(i, j - 1, k) || this.g(world, i, j, k);
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
if (!world.d(i, j - 1, k) && !g(world, i, j, k)) { if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
world.e(i, j, k, 0); world.e(i, j, k, 0);
return;
} else {
return;
} }
} }
public void e(World world, int i, int j, int k) { public void e(World world, int i, int j, int k) {
//TODO this section deals with lighting a block on fire too if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.b_(world, i, j, k)) {
if (world.a(i, j - 1, k) == Block.ap.bi && Block.be.b_(world, i, j, k)) { if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
return; world.e(i, j, k, 0);
} } else {
if (!world.d(i, j - 1, k) && !g(world, i, j, k)) { world.i(i, j, k, this.id);
world.e(i, j, k, 0); }
return;
} else {
world.i(i, j, k, bi);
return;
} }
} }
} }

View File

@ -11,121 +11,125 @@ import org.bukkit.event.block.BlockFromToEvent;
public class BlockFlowing extends BlockFluids { public class BlockFlowing extends BlockFluids {
int a; int a = 0;
boolean b[]; boolean[] b = new boolean[4];
int c[]; int[] c = new int[4];
protected BlockFlowing(int i1, Material material) { protected BlockFlowing(int i, Material material) {
super(i1, material); super(i, material);
a = 0;
b = new boolean[4];
c = new int[4];
} }
private void i(World world, int i1, int j1, int k1) { private void i(World world, int i, int j, int k) {
int l1 = world.b(i1, j1, k1); int l = world.getData(i, j, k);
world.a(i1, j1, k1, bi + 1, l1); world.setTypeIdAndData(i, j, k, this.id + 1, l);
world.b(i1, j1, k1, i1, j1, k1); world.b(i, j, k, i, j, k);
world.g(i1, j1, k1); world.g(i, j, k);
} }
public void a(World world, int i1, int j1, int k1, Random random) { public void a(World world, int i, int j, int k, Random random) {
// CraftBukkit start // CraftBukkit start
// skedit: Moved up to make sure that it is accurate CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i1, j1, k1);
// CraftBukkit end // CraftBukkit end
int l1 = g(world, i1, j1, k1);
byte byte0 = 1;
if (bt == Material.g && !world.q.d) { int l = this.g(world, i, j, k);
byte0 = 2; byte b0 = 1;
if (this.material == Material.LAVA && !world.q.d) {
b0 = 2;
} }
boolean flag = true; boolean flag = true;
int i1;
if (l1 > 0) { if (l > 0) {
int i2 = -100; byte b1 = -100;
a = 0; this.a = 0;
i2 = e(world, i1 - 1, j1, k1, i2); int j1 = this.e(world, i - 1, j, k, b1);
i2 = e(world, i1 + 1, j1, k1, i2);
i2 = e(world, i1, j1, k1 - 1, i2);
i2 = e(world, i1, j1, k1 + 1, i2);
int j2 = i2 + byte0;
if (j2 >= 8 || i2 < 0) { j1 = this.e(world, i + 1, j, k, j1);
j2 = -1; j1 = this.e(world, i, j, k - 1, j1);
j1 = this.e(world, i, j, k + 1, j1);
i1 = j1 + b0;
if (i1 >= 8 || j1 < 0) {
i1 = -1;
} }
if (g(world, i1, j1 + 1, k1) >= 0) {
int l2 = g(world, i1, j1 + 1, k1);
if (l2 >= 8) { if (this.g(world, i, j + 1, k) >= 0) {
j2 = l2; int k1 = this.g(world, i, j + 1, k);
if (k1 >= 8) {
i1 = k1;
} else { } else {
j2 = l2 + 8; i1 = k1 + 8;
} }
} }
if (a >= 2 && bt == Material.f) {
if (world.d(i1, j1 - 1, k1)) { if (this.a >= 2 && this.material == Material.WATER) {
j2 = 0; if (world.d(i, j - 1, k)) {
} else if (world.c(i1, j1 - 1, k1) == bt && world.b(i1, j1, k1) == 0) { i1 = 0;
j2 = 0; } else if (world.getMaterial(i, j - 1, k) == this.material && world.getData(i, j, k) == 0) {
i1 = 0;
} }
} }
if (bt == Material.g && l1 < 8 && j2 < 8 && j2 > l1 && random.nextInt(4) != 0) {
j2 = l1; if (this.material == Material.LAVA && l < 8 && i1 < 8 && i1 > l && random.nextInt(4) != 0) {
i1 = l;
flag = false; flag = false;
} }
if (j2 != l1) {
l1 = j2; if (i1 != l) {
if (l1 < 0) { l = i1;
world.e(i1, j1, k1, 0); if (i1 < 0) {
world.e(i, j, k, 0);
} else { } else {
world.c(i1, j1, k1, l1); world.c(i, j, k, i1);
world.i(i1, j1, k1, bi); world.i(i, j, k, this.id);
world.h(i1, j1, k1, bi); world.h(i, j, k, this.id);
} }
} else if (flag) { } else if (flag) {
i(world, i1, j1, k1); this.i(world, i, j, k);
} }
} else { } else {
i(world, i1, j1, k1); this.i(world, i, j, k);
} }
if (l(world, i1, j1 - 1, k1)) { if (this.l(world, i, j - 1, k)) {
// CraftBukkit start // CraftBukkit start
// Craftbucket send "down" to the server // Craftbucket send "down" to the server
BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.DOWN); BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.DOWN);
((WorldServer) world).getServer().getPluginManager().callEvent(blockFlow); ((WorldServer) world).getServer().getPluginManager().callEvent(event);
if (!blockFlow.isCancelled()) { if (!event.isCancelled()) {
if (l1 >= 8) { if (l >= 8) {
world.b(i1, j1 - 1, k1, bi, l1); world.b(i, j - 1, k, this.id, l);
} else { } else {
world.b(i1, j1 - 1, k1, bi, l1 + 8); world.b(i, j - 1, k, this.id, l + 8);
} }
} }
// CraftBukkit end // CraftBukkit end
} else if (l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1))) { } else if (l >= 0 && (l == 0 || this.k(world, i, j - 1, k))) {
boolean aflag[] = j(world, i1, j1, k1); boolean[] aboolean = this.j(world, i, j, k);
int k2 = l1 + byte0;
if (l1 >= 8) { i1 = l + b0;
k2 = 1; if (l >= 8) {
i1 = 1;
} }
if (k2 >= 8) {
if (i1 >= 8) {
return; return;
} }
// CraftBukkit start - all four cardinal directions. Do not change the order! // CraftBukkit start - all four cardinal directions. Do not change the order!
BlockFace[] faces = new BlockFace[]{ BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST }; BlockFace[] faces = new BlockFace[]{ BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
int index = 0; int index = 0;
for (BlockFace currentFace: faces) { for (BlockFace currentFace: faces) {
if (aflag[index]) { if (aboolean[index]) {
BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace); BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace);
((WorldServer) world).getServer().getPluginManager().callEvent(event); ((WorldServer) world).getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2); f(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1);
} }
} }
index++; index++;
@ -134,153 +138,158 @@ public class BlockFlowing extends BlockFluids {
} }
} }
private void f(World world, int i1, int j1, int k1, int l1) { private void f(World world, int i, int j, int k, int l) {
if (l(world, i1, j1, k1)) { if (this.l(world, i, j, k)) {
int i2 = world.a(i1, j1, k1); int i1 = world.getTypeId(i, j, k);
if (i2 > 0) { if (i1 > 0) {
if (bt == Material.g) { if (this.material == Material.LAVA) {
h(world, i1, j1, k1); this.h(world, i, j, k);
} else { } else {
Block.m[i2].a_(world, i1, j1, k1, world.b(i1, j1, k1)); Block.byId[i1].a_(world, i, j, k, world.getData(i, j, k));
} }
} }
world.b(i1, j1, k1, bi, l1);
world.b(i, j, k, this.id, l);
} }
} }
private int b(World world, int i1, int j1, int k1, int l1, int i2) { private int b(World world, int i, int j, int k, int l, int i1) {
int j2 = 1000; int j1 = 1000;
for (int k2 = 0; k2 < 4; k2++) { for (int k1 = 0; k1 < 4; ++k1) {
if (k2 == 0 && i2 == 1 || k2 == 1 && i2 == 0 || k2 == 2 && i2 == 3 || k2 == 3 && i2 == 2) { if ((k1 != 0 || i1 != 1) && (k1 != 1 || i1 != 0) && (k1 != 2 || i1 != 3) && (k1 != 3 || i1 != 2)) {
continue; int l1 = i;
} int i2 = k;
int l2 = i1;
int i3 = j1;
int j3 = k1;
if (k2 == 0) { if (k1 == 0) {
l2--; l1 = i - 1;
} }
if (k2 == 1) {
l2++;
}
if (k2 == 2) {
j3--;
}
if (k2 == 3) {
j3++;
}
if (k(world, l2, i3, j3) || world.c(l2, i3, j3) == bt && world.b(l2, i3, j3) == 0) {
continue;
}
if (!k(world, l2, i3 - 1, j3)) {
return l1;
}
if (l1 >= 4) {
continue;
}
int k3 = b(world, l2, i3, j3, l1 + 1, k2);
if (k3 < j2) { if (k1 == 1) {
j2 = k3; ++l1;
}
if (k1 == 2) {
i2 = k - 1;
}
if (k1 == 3) {
++i2;
}
if (!this.k(world, l1, j, i2) && (world.getMaterial(l1, j, i2) != this.material || world.getData(l1, j, i2) != 0)) {
if (!this.k(world, l1, j - 1, i2)) {
return l;
}
if (l < 4) {
int j2 = this.b(world, l1, j, i2, l + 1, k1);
if (j2 < j1) {
j1 = j2;
}
}
}
} }
} }
return j2; return j1;
} }
private boolean[] j(World world, int i1, int j1, int k1) { private boolean[] j(World world, int i, int j, int k) {
for (int l1 = 0; l1 < 4; l1++) { int l;
c[l1] = 1000; int i1;
int j2 = i1;
int i3 = j1;
int j3 = k1;
if (l1 == 0) { for (l = 0; l < 4; ++l) {
j2--; this.c[l] = 1000;
i1 = i;
int j1 = k;
if (l == 0) {
i1 = i - 1;
} }
if (l1 == 1) {
j2++; if (l == 1) {
++i1;
} }
if (l1 == 2) {
j3--; if (l == 2) {
j1 = k - 1;
} }
if (l1 == 3) {
j3++; if (l == 3) {
++j1;
} }
if (k(world, j2, i3, j3) || world.c(j2, i3, j3) == bt && world.b(j2, i3, j3) == 0) {
continue; if (!this.k(world, i1, j, j1) && (world.getMaterial(i1, j, j1) != this.material || world.getData(i1, j, j1) != 0)) {
if (!this.k(world, i1, j - 1, j1)) {
this.c[l] = 0;
} else {
this.c[l] = this.b(world, i1, j, j1, 1, l);
}
} }
if (!k(world, j2, i3 - 1, j3)) { }
c[l1] = 0;
l = this.c[0];
for (i1 = 1; i1 < 4; ++i1) {
if (this.c[i1] < l) {
l = this.c[i1];
}
}
for (i1 = 0; i1 < 4; ++i1) {
this.b[i1] = this.c[i1] == l;
}
return this.b;
}
private boolean k(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k);
if (l != Block.WOODEN_DOOR.id && l != Block.IRON_DOOR_BLOCK.id && l != Block.SIGN_POST.id && l != Block.LADDER.id && l != Block.SUGAR_CANE_BLOCK.id) {
if (l == 0) {
return false;
} else { } else {
c[l1] = b(world, j2, i3, j3, 1, l1); Material material = Block.byId[l].material;
return material.isBuildable();
} }
} } else {
int i2 = c[0];
for (int k2 = 1; k2 < 4; k2++) {
if (c[k2] < i2) {
i2 = c[k2];
}
}
for (int l2 = 0; l2 < 4; l2++) {
b[l2] = c[l2] == i2;
}
return b;
}
private boolean k(World world, int i1, int j1, int k1) {
int l1 = world.a(i1, j1, k1);
if (l1 == Block.aE.bi || l1 == Block.aL.bi || l1 == Block.aD.bi || l1 == Block.aF.bi || l1 == Block.aX.bi) {
return true; return true;
} }
if (l1 == 0) {
return false;
}
Material material = Block.m[l1].bt;
return material.a();
} }
protected int e(World world, int i1, int j1, int k1, int l1) { protected int e(World world, int i, int j, int k, int l) {
int i2 = g(world, i1, j1, k1); int i1 = this.g(world, i, j, k);
if (i2 < 0) { if (i1 < 0) {
return l1; return l;
}
if (i2 == 0) {
a++;
}
if (i2 >= 8) {
i2 = 0;
}
return l1 >= 0 && i2 >= l1 ? l1 : i2;
}
private boolean l(World world, int i1, int j1, int k1) {
Material material = world.c(i1, j1, k1);
if (material == bt) {
return false;
}
if (material == Material.g) {
return false;
} else { } else {
return !k(world, i1, j1, k1); if (i1 == 0) {
++this.a;
}
if (i1 >= 8) {
i1 = 0;
}
return l >= 0 && i1 >= l ? l : i1;
} }
} }
public void e(World world, int i1, int j1, int k1) { private boolean l(World world, int i, int j, int k) {
super.e(world, i1, j1, k1); Material material = world.getMaterial(i, j, k);
if (world.a(i1, j1, k1) == bi) {
world.i(i1, j1, k1, bi); return material == this.material ? false : (material == Material.LAVA ? false : !this.k(world, i, j, k));
}
public void e(World world, int i, int j, int k) {
super.e(world, i, j, k);
if (world.getTypeId(i, j, k) == this.id) {
world.i(i, j, k, this.id);
} }
} }
} }

View File

@ -17,58 +17,52 @@ public class BlockFurnace extends BlockContainer {
private final boolean a; private final boolean a;
protected BlockFurnace(int i, boolean flag) { protected BlockFurnace(int i, boolean flag) {
super(i, Material.d); super(i, Material.STONE);
a = flag; this.a = flag;
bh = 45; this.textureId = 45;
} }
public int a(int i, Random random) { public int a(int i, Random random) {
return Block.aB.bi; return Block.FURNACE.id;
} }
public void e(World world, int i, int j, int k) { public void e(World world, int i, int j, int k) {
super.e(world, i, j, k); super.e(world, i, j, k);
g(world, i, j, k); this.g(world, i, j, k);
} }
private void g(World world, int i, int j, int k) { private void g(World world, int i, int j, int k) {
int l = world.a(i, j, k - 1); int l = world.getTypeId(i, j, k - 1);
int i1 = world.a(i, j, k + 1); int i1 = world.getTypeId(i, j, k + 1);
int j1 = world.a(i - 1, j, k); int j1 = world.getTypeId(i - 1, j, k);
int k1 = world.a(i + 1, j, k); int k1 = world.getTypeId(i + 1, j, k);
byte byte0 = 3; byte b0 = 3;
if (Block.o[l] && !Block.o[i1]) { if (Block.o[l] && !Block.o[i1]) {
byte0 = 3; b0 = 3;
} }
if (Block.o[i1] && !Block.o[l]) { if (Block.o[i1] && !Block.o[l]) {
byte0 = 2; b0 = 2;
} }
if (Block.o[j1] && !Block.o[k1]) { if (Block.o[j1] && !Block.o[k1]) {
byte0 = 5; b0 = 5;
} }
if (Block.o[k1] && !Block.o[j1]) { if (Block.o[k1] && !Block.o[j1]) {
byte0 = 4; b0 = 4;
} }
world.c(i, j, k, ((int) (byte0)));
world.c(i, j, k, b0);
} }
public int a(int i) { public int a(int i) {
if (i == 1) { return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId));
return bh + 17;
}
if (i == 0) {
return bh + 17;
}
if (i == 3) {
return bh - 1;
} else {
return bh;
}
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.z) { if (world.isStatic) {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Furnace // CraftBukkit start - Interact Furnace
@ -76,52 +70,56 @@ public class BlockFurnace extends BlockContainer {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT; Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity(); LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) { BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k); TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
entityplayer.a(tileentityfurnace); entityhuman.a(tileentityfurnace);
return true; return true;
} }
} }
public static void a(boolean flag, World world, int i, int j, int k) { public static void a(boolean flag, World world, int i, int j, int k) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
TileEntity tileentity = world.m(i, j, k); TileEntity tileentity = world.getTileEntity(i, j, k);
if (flag) { if (flag) {
world.e(i, j, k, Block.aC.bi); world.e(i, j, k, Block.BURNING_FURNACE.id);
} else { } else {
world.e(i, j, k, Block.aB.bi); world.e(i, j, k, Block.FURNACE.id);
} }
world.c(i, j, k, l); world.c(i, j, k, l);
world.a(i, j, k, tileentity); world.setTileEntity(i, j, k, tileentity);
} }
protected TileEntity a_() { protected TileEntity a_() {
return ((TileEntity) (new TileEntityFurnace())); return new TileEntityFurnace();
} }
public void a(World world, int i, int j, int k, EntityLiving entityliving) { public void a(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.b((double) ((entityliving.v * 4F) / 360F) + 0.5D) & 3; int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) { if (l == 0) {
world.c(i, j, k, 2); world.c(i, j, k, 2);
} }
if (l == 1) { if (l == 1) {
world.c(i, j, k, 5); world.c(i, j, k, 5);
} }
if (l == 2) { if (l == 2) {
world.c(i, j, k, 3); world.c(i, j, k, 3);
} }
if (l == 3) { if (l == 3) {
world.c(i, j, k, 4); world.c(i, j, k, 4);
} }

View File

@ -13,15 +13,15 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockJukeBox extends Block { public class BlockJukeBox extends Block {
protected BlockJukeBox(int i, int j) { protected BlockJukeBox(int i, int j) {
super(i, j, Material.c); super(i, j, Material.WOOD);
} }
public int a(int i) { public int a(int i) {
return bh + (i != 1 ? 0 : 1); return this.textureId + (i == 1 ? 1 : 0);
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if (l > 0) { if (l > 0) {
// CraftBukkit start - Interact Jukebox // CraftBukkit start - Interact Jukebox
@ -29,17 +29,17 @@ public class BlockJukeBox extends Block {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT; Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity(); LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) { BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
f(world, i, j, k, l); this.f(world, i, j, k, l);
return true; return true;
} else { } else {
return false; return false;
@ -47,26 +47,26 @@ public class BlockJukeBox extends Block {
} }
public void f(World world, int i, int j, int k, int l) { public void f(World world, int i, int j, int k, int l) {
world.a(((String) (null)), i, j, k); world.a((String) null, i, j, k);
world.c(i, j, k, 0); world.c(i, j, k, 0);
int i1 = (Item.aY.ba + l) - 1; int i1 = Item.GOLD_RECORD.id + l - 1;
float f1 = 0.7F; float f = 0.7F;
double d = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; double d0 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.20000000000000001D + 0.59999999999999998D; double d1 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
double d2 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D; double d2 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) i + d, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0)); EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
entityitem.c = 10; entityitem.c = 10;
world.a(((Entity) (entityitem))); world.a((Entity) entityitem);
} }
public void a(World world, int i, int j, int k, int l, float f1) { public void a(World world, int i, int j, int k, int l, float f) {
if (world.z) { if (!world.isStatic) {
return; if (l > 0) {
this.f(world, i, j, k, l);
}
super.a(world, i, j, k, l, f);
} }
if (l > 0) {
f(world, i, j, k, l);
}
super.a(world, i, j, k, l, f1);
} }
} }

View File

@ -12,28 +12,28 @@ import org.bukkit.event.block.LeavesDecayEvent;
public class BlockLeaves extends BlockLeavesBase { public class BlockLeaves extends BlockLeavesBase {
private int c; private int c;
int b[]; int[] b;
protected BlockLeaves(int i, int j) { protected BlockLeaves(int i, int j) {
super(i, j, Material.h, false); super(i, j, Material.LEAVES, false);
c = j; this.c = j;
a(true); this.a(true);
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
int l = 1; byte b0 = 1;
int i1 = l + 1; int l = b0 + 1;
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { if (world.a(i - l, j - l, k - l, i + l, j + l, k + l)) {
for (int j1 = -l; j1 <= l; j1++) { for (int i1 = -b0; i1 <= b0; ++i1) {
for (int k1 = -l; k1 <= l; k1++) { for (int j1 = -b0; j1 <= b0; ++j1) {
for (int l1 = -l; l1 <= l; l1++) { for (int k1 = -b0; k1 <= b0; ++k1) {
int i2 = world.a(i + j1, j + k1, k + l1); int l1 = world.getTypeId(i + i1, j + j1, k + k1);
if (i2 == Block.K.bi) { if (l1 == Block.LEAVES.id) {
int j2 = world.b(i + j1, j + k1, k + l1); int i2 = world.getData(i + i1, j + j1, k + k1);
world.d(i + j1, j + k1, k + l1, j2 | 4); world.d(i + i1, j + j1, k + k1, i2 | 4);
} }
} }
} }
@ -42,77 +42,84 @@ public class BlockLeaves extends BlockLeavesBase {
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
if (world.z) { if (!world.isStatic) {
return; int l = world.getData(i, j, k);
}
int l = world.b(i, j, k);
if ((l & 4) != 0) { if ((l & 4) != 0) {
byte byte0 = 4; byte b0 = 4;
int i1 = byte0 + 1; int i1 = b0 + 1;
byte byte1 = 32; byte b1 = 32;
int j1 = byte1 * byte1; int j1 = b1 * b1;
int k1 = byte1 / 2; int k1 = b1 / 2;
if (b == null) { if (this.b == null) {
b = new int[byte1 * byte1 * byte1]; this.b = new int[b1 * b1 * b1];
} }
if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
for (int l1 = -byte0; l1 <= byte0; l1++) {
for (int k2 = -byte0; k2 <= byte0; k2++) {
for (int i3 = -byte0; i3 <= byte0; i3++) {
int k3 = world.a(i + l1, j + k2, k + i3);
if (k3 == Block.J.bi) { int l1;
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
continue; if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
int i2;
int j2;
int k2;
for (l1 = -b0; l1 <= b0; ++l1) {
for (i2 = -b0; i2 <= b0; ++i2) {
for (j2 = -b0; j2 <= b0; ++j2) {
k2 = world.getTypeId(i + l1, j + i2, k + j2);
if (k2 == Block.LOG.id) {
this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
} else if (k2 == Block.LEAVES.id) {
this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
} else {
this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
}
} }
if (k3 == Block.K.bi) { }
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2; }
} else {
b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1; for (l1 = 1; l1 <= 4; ++l1) {
for (i2 = -b0; i2 <= b0; ++i2) {
for (j2 = -b0; j2 <= b0; ++j2) {
for (k2 = -b0; k2 <= b0; ++k2) {
if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) {
if (this.b[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
this.b[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (this.b[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
this.b[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
}
if (this.b[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) {
this.b[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
}
if (this.b[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) {
this.b[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
}
if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) {
this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
}
if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) {
this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
}
}
}
} }
} }
} }
} }
for (int i2 = 1; i2 <= 4; i2++) { l1 = this.b[k1 * j1 + k1 * b1 + k1];
for (int l2 = -byte0; l2 <= byte0; l2++) { if (l1 >= 0) {
for (int j3 = -byte0; j3 <= byte0; j3++) { world.c(i, j, k, l & -5);
for (int l3 = -byte0; l3 <= byte0; l3++) { } else {
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) { this.g(world, i, j, k);
continue;
}
if (b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
} }
} }
int j2 = b[k1 * j1 + k1 * byte1 + k1];
if (j2 >= 0) {
world.c(i, j, k, l & -5);
} else {
g(world, i, j, k);
}
} }
} }
@ -126,20 +133,20 @@ public class BlockLeaves extends BlockLeavesBase {
if (event.isCancelled()) return; if (event.isCancelled()) return;
// CraftBukkit end // CraftBukkit end
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
public int a(Random random) { public int a(Random random) {
return random.nextInt(16) != 0 ? 0 : 1; return random.nextInt(16) == 0 ? 1 : 0;
} }
public int a(int i, Random random) { public int a(int i, Random random) {
return Block.y.bi; return Block.SAPLING.id;
} }
public boolean a() { public boolean a() {
return !a; return !this.a;
} }
public void b(World world, int i, int j, int k, Entity entity) { public void b(World world, int i, int j, int k, Entity entity) {

View File

@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockLever extends Block { public class BlockLever extends Block {
protected BlockLever(int i, int j) { protected BlockLever(int i, int j) {
super(i, j, Material.n); super(i, j, Material.ORIENTABLE);
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
@ -27,41 +27,34 @@ public class BlockLever extends Block {
} }
public boolean a(World world, int i, int j, int k) { public boolean a(World world, int i, int j, int k) {
if (world.d(i - 1, j, k)) { return world.d(i - 1, j, k) ? true : (world.d(i + 1, j, k) ? true : (world.d(i, j, k - 1) ? true : (world.d(i, j, k + 1) ? true : world.d(i, j - 1, k))));
return true;
}
if (world.d(i + 1, j, k)) {
return true;
}
if (world.d(i, j, k - 1)) {
return true;
}
if (world.d(i, j, k + 1)) {
return true;
}
return world.d(i, j - 1, k);
} }
public void c(World world, int i, int j, int k, int l) { public void c(World world, int i, int j, int k, int l) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
int j1 = i1 & 8; int j1 = i1 & 8;
i1 &= 7; i1 &= 7;
if (l == 1 && world.d(i, j - 1, k)) { if (l == 1 && world.d(i, j - 1, k)) {
i1 = 5 + world.l.nextInt(2); i1 = 5 + world.l.nextInt(2);
} }
if (l == 2 && world.d(i, j, k + 1)) { if (l == 2 && world.d(i, j, k + 1)) {
i1 = 4; i1 = 4;
} }
if (l == 3 && world.d(i, j, k - 1)) { if (l == 3 && world.d(i, j, k - 1)) {
i1 = 3; i1 = 3;
} }
if (l == 4 && world.d(i + 1, j, k)) { if (l == 4 && world.d(i + 1, j, k)) {
i1 = 2; i1 = 2;
} }
if (l == 5 && world.d(i - 1, j, k)) { if (l == 5 && world.d(i - 1, j, k)) {
i1 = 1; i1 = 1;
} }
world.c(i, j, k, i1 + j1); world.c(i, j, k, i1 + j1);
} }
@ -77,39 +70,45 @@ public class BlockLever extends Block {
} else if (world.d(i, j - 1, k)) { } else if (world.d(i, j - 1, k)) {
world.c(i, j, k, 5 + world.l.nextInt(2)); world.c(i, j, k, 5 + world.l.nextInt(2));
} }
g(world, i, j, k);
this.g(world, i, j, k);
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
if (g(world, i, j, k)) { if (this.g(world, i, j, k)) {
int i1 = world.b(i, j, k) & 7; int i1 = world.getData(i, j, k) & 7;
boolean flag = false; boolean flag = false;
if (!world.d(i - 1, j, k) && i1 == 1) { if (!world.d(i - 1, j, k) && i1 == 1) {
flag = true; flag = true;
} }
if (!world.d(i + 1, j, k) && i1 == 2) { if (!world.d(i + 1, j, k) && i1 == 2) {
flag = true; flag = true;
} }
if (!world.d(i, j, k - 1) && i1 == 3) { if (!world.d(i, j, k - 1) && i1 == 3) {
flag = true; flag = true;
} }
if (!world.d(i, j, k + 1) && i1 == 4) { if (!world.d(i, j, k + 1) && i1 == 4) {
flag = true; flag = true;
} }
if (!world.d(i, j - 1, k) && i1 == 5) { if (!world.d(i, j - 1, k) && i1 == 5) {
flag = true; flag = true;
} }
if (flag) { if (flag) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
} }
} }
private boolean g(World world, int i, int j, int k) { private boolean g(World world, int i, int j, int k) {
if (!a(world, i, j, k)) { if (!this.a(world, i, j, k)) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
return false; return false;
} else { } else {
@ -118,129 +117,119 @@ public class BlockLever extends Block {
} }
public void a(IBlockAccess iblockaccess, int i, int j, int k) { public void a(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.b(i, j, k) & 7; int l = iblockaccess.getData(i, j, k) & 7;
float f = 0.1875F; float f = 0.1875F;
if (l == 1) { if (l == 1) {
a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
} else if (l == 2) { } else if (l == 2) {
a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
} else if (l == 3) { } else if (l == 3) {
a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
} else if (l == 4) { } else if (l == 4) {
a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
} else { } else {
float f1 = 0.25F; f = 0.25F;
this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
a(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
} }
} }
public void b(World world, int i, int j, int k, EntityPlayer entityplayer) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
a(world, i, j, k, entityplayer); this.a(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.z) { if (world.isStatic) {
return true; return true;
} } else {
// CraftBukkit start - Interact Lever
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
// CraftBukkit start - Interact Lever BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
CraftWorld craftWorld = ((WorldServer) world).getWorld(); server.getPluginManager().callEvent(event);
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
// CraftBukkit the client updates the doors before the server does it's thing. // CraftBukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data. // Forcibly send correct data.
if (bie.isCancelled()) { if (event.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world)); ((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
return true; return true;
}
// CraftBukkit end
int l = world.b(i, j, k);
int i1 = l & 7;
int j1 = 8 - (l & 8);
// CraftBukkit start
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
server.getPluginManager().callEvent(bre);
// CraftBukkit end
if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
world.c(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k);
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F);
world.h(i, j, k, bi);
if (i1 == 1) {
world.h(i - 1, j, k, bi);
} else if (i1 == 2) {
world.h(i + 1, j, k, bi);
} else if (i1 == 3) {
world.h(i, j, k - 1, bi);
} else if (i1 == 4) {
world.h(i, j, k + 1, bi);
} else {
world.h(i, j - 1, k, bi);
} }
// CraftBukkit end
int l = world.getData(i, j, k);
int i1 = l & 7;
int j1 = 8 - (l & 8);
// CraftBukkit start
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
server.getPluginManager().callEvent(eventRedstone);
if ((eventRedstone.getNewCurrent() > 0) == (j1 == 8)) {
// CraftBukkit end
world.c(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k);
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 > 0 ? 0.6F : 0.5F);
world.h(i, j, k, this.id);
if (i1 == 1) {
world.h(i - 1, j, k, this.id);
} else if (i1 == 2) {
world.h(i + 1, j, k, this.id);
} else if (i1 == 3) {
world.h(i, j, k - 1, this.id);
} else if (i1 == 4) {
world.h(i, j, k + 1, this.id);
} else {
world.h(i, j - 1, k, this.id);
}
} // CraftBukkit
return true;
} }
return true;
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) > 0) { if ((l & 8) > 0) {
world.h(i, j, k, bi); world.h(i, j, k, this.id);
int i1 = l & 7; int i1 = l & 7;
if (i1 == 1) { if (i1 == 1) {
world.h(i - 1, j, k, bi); world.h(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, bi); world.h(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, bi); world.h(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, bi); world.h(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
} }
} }
super.b(world, i, j, k); super.b(world, i, j, k);
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return (iblockaccess.b(i, j, k) & 8) > 0; return (iblockaccess.getData(i, j, k) & 8) > 0;
} }
public boolean d(World world, int i, int j, int k, int l) { public boolean d(World world, int i, int j, int k, int l) {
int i1 = world.b(i, j, k); int i1 = world.getData(i, j, k);
if ((i1 & 8) == 0) { if ((i1 & 8) == 0) {
return false; return false;
} } else {
int j1 = i1 & 7; int j1 = i1 & 7;
if (j1 == 5 && l == 1) { return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5)));
return true;
} }
if (j1 == 4 && l == 2) {
return true;
}
if (j1 == 3 && l == 3) {
return true;
}
if (j1 == 2 && l == 4) {
return true;
}
return j1 == 1 && l == 5;
} }
public boolean c() { public boolean c() {

View File

@ -20,12 +20,12 @@ public class BlockPressurePlate extends Block {
private EnumMobType a; private EnumMobType a;
protected BlockPressurePlate(int i, int j, EnumMobType enummobtype) { protected BlockPressurePlate(int i, int j, EnumMobType enummobtype) {
super(i, j, Material.d); super(i, j, Material.STONE);
a = enummobtype; this.a = enummobtype;
a(true); this.a(true);
float f = 0.0625F; float f = 0.0625F;
a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
} }
public int b() { public int b() {
@ -52,129 +52,118 @@ public class BlockPressurePlate extends Block {
if (!world.d(i, j - 1, k)) { if (!world.d(i, j - 1, k)) {
flag = true; flag = true;
} }
if (flag) { if (flag) {
a_(world, i, j, k, world.b(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.e(i, j, k, 0);
} }
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
if (world.z) { if (!world.isStatic) {
return; if (world.getData(i, j, k) != 0) {
} this.g(world, i, j, k);
if (world.b(i, j, k) == 0) { }
return;
} else {
g(world, i, j, k);
return;
} }
} }
public void a(World world, int i, int j, int k, Entity entity) { public void a(World world, int i, int j, int k, Entity entity) {
if (world.z) { if (!world.isStatic) {
return; if (world.getData(i, j, k) != 1) {
}
if (world.b(i, j, k) == 1) {
return;
} else {
// CraftBukkit start - Interact Pressure Plate
if (entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) world).getServer();
CraftWorld craftWorld = ((WorldServer) world).getWorld();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
org.bukkit.entity.LivingEntity who = (entity == null)?null:(LivingEntity) entity.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) { // CraftBukkit start - Interact Pressure Plate
return; if (entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) world).getServer();
CraftWorld craftWorld = ((WorldServer) world).getWorld();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
org.bukkit.entity.LivingEntity who = (entity == null) ? null : (LivingEntity) entity.getBukkitEntity();
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
} }
} // CraftBukkit end
// CraftBukkit end
g(world, i, j, k); this.g(world, i, j, k);
return; }
} }
} }
private void g(World world, int i, int j, int k) { private void g(World world, int i, int j, int k) {
boolean flag = world.b(i, j, k) == 1; boolean flag = world.getData(i, j, k) == 1;
boolean flag1 = false; boolean flag1 = false;
float f = 0.125F; float f = 0.125F;
List list = null; List list = null;
if (a == EnumMobType.a) { if (this.a == EnumMobType.EVERYTHING) {
list = world.b(((Entity) (null)), AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); list = world.b((Entity) null, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
} }
if (a == EnumMobType.b) {
list = world.a(net.minecraft.server.EntityLiving.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); if (this.a == EnumMobType.MOBS) {
list = world.a(EntityLiving.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
} }
if (a == EnumMobType.c) {
list = world.a(net.minecraft.server.EntityPlayer.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f)); if (this.a == EnumMobType.PLAYERS) {
list = world.a(EntityHuman.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
} }
if (list.size() > 0) { if (list.size() > 0) {
flag1 = true; flag1 = true;
} }
// Craftbukkit start
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag1 ? 15 : 0);
((WorldServer) world).getServer().getPluginManager().callEvent(bre);
flag1 = bre.getNewCurrent() > 0;
// Craftbukkit end
if (flag1 && !flag) { if (flag1 && !flag) {
world.c(i, j, k, 1); world.c(i, j, k, 1);
world.h(i, j, k, bi); world.h(i, j, k, this.id);
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
} }
if (!flag1 && flag) { if (!flag1 && flag) {
world.c(i, j, k, 0); world.c(i, j, k, 0);
world.h(i, j, k, bi); world.h(i, j, k, this.id);
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
} }
if (flag1) { if (flag1) {
world.i(i, j, k, bi); world.i(i, j, k, this.id);
} }
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if (l > 0) { if (l > 0) {
world.h(i, j, k, bi); world.h(i, j, k, this.id);
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
} }
super.b(world, i, j, k); super.b(world, i, j, k);
} }
public void a(IBlockAccess iblockaccess, int i, int j, int k) { public void a(IBlockAccess iblockaccess, int i, int j, int k) {
boolean flag = iblockaccess.b(i, j, k) == 1; boolean flag = iblockaccess.getData(i, j, k) == 1;
float f = 0.0625F; float f = 0.0625F;
if (flag) { if (flag) {
a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
} else { } else {
a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f); this.a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
} }
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
return iblockaccess.b(i, j, k) > 0; return iblockaccess.getData(i, j, k) > 0;
} }
public boolean d(World world, int i, int j, int k, int l) { public boolean d(World world, int i, int j, int k, int l) {
if (world.b(i, j, k) == 0) { return world.getData(i, j, k) == 0 ? false : l == 1;
return false;
} else {
return l == 1;
}
} }
public boolean c() { public boolean c() {

View File

@ -1,26 +1,35 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Random;
// CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
// CraftBukkit end
public class BlockRedstoneTorch extends BlockTorch { public class BlockRedstoneTorch extends BlockTorch {
private boolean a; private boolean a = false;
private static List b = new ArrayList(); private static List b = new ArrayList();
private boolean a(World world, int i, int j, int k, boolean flag) { private boolean a(World world, int i, int j, int k, boolean flag) {
if (flag) { if (flag) {
b.add(((new RedstoneUpdateInfo(i, j, k, world.e)))); b.add(new RedstoneUpdateInfo(i, j, k, world.e));
} }
int l = 0; int l = 0;
for (int i1 = 0; i1 < b.size(); i1++) { for (int i1 = 0; i1 < b.size(); ++i1) {
RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) b.get(i1); RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) b.get(i1);
if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k && ++l >= 8) { if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k) {
return true; ++l;
if (l >= 8) {
return true;
}
} }
} }
@ -29,9 +38,8 @@ public class BlockRedstoneTorch extends BlockTorch {
protected BlockRedstoneTorch(int i, int j, boolean flag) { protected BlockRedstoneTorch(int i, int j, boolean flag) {
super(i, j); super(i, j);
a = false; this.a = flag;
a = flag; this.a(true);
a(true);
} }
public int b() { public int b() {
@ -39,119 +47,94 @@ public class BlockRedstoneTorch extends BlockTorch {
} }
public void e(World world, int i, int j, int k) { public void e(World world, int i, int j, int k) {
if (world.b(i, j, k) == 0) { if (world.getData(i, j, k) == 0) {
super.e(world, i, j, k); super.e(world, i, j, k);
} }
if (a) {
world.h(i, j - 1, k, bi); if (this.a) {
world.h(i, j + 1, k, bi); world.h(i, j - 1, k, this.id);
world.h(i - 1, j, k, bi); world.h(i, j + 1, k, this.id);
world.h(i + 1, j, k, bi); world.h(i - 1, j, k, this.id);
world.h(i, j, k - 1, bi); world.h(i + 1, j, k, this.id);
world.h(i, j, k + 1, bi); world.h(i, j, k - 1, this.id);
world.h(i, j, k + 1, this.id);
} }
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
if (a) { if (this.a) {
world.h(i, j - 1, k, bi); world.h(i, j - 1, k, this.id);
world.h(i, j + 1, k, bi); world.h(i, j + 1, k, this.id);
world.h(i - 1, j, k, bi); world.h(i - 1, j, k, this.id);
world.h(i + 1, j, k, bi); world.h(i + 1, j, k, this.id);
world.h(i, j, k - 1, bi); world.h(i, j, k - 1, this.id);
world.h(i, j, k + 1, bi); world.h(i, j, k + 1, this.id);
} }
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!a) { if (!this.a) {
return false; return false;
} } else {
int i1 = iblockaccess.b(i, j, k); int i1 = iblockaccess.getData(i, j, k);
if (i1 == 5 && l == 1) { return i1 == 5 && l == 1 ? false : (i1 == 3 && l == 3 ? false : (i1 == 4 && l == 2 ? false : (i1 == 1 && l == 5 ? false : i1 != 2 || l != 4)));
return false;
} }
if (i1 == 3 && l == 3) {
return false;
}
if (i1 == 4 && l == 2) {
return false;
}
if (i1 == 1 && l == 5) {
return false;
}
return i1 != 2 || l != 4;
} }
private boolean g(World world, int i, int j, int k) { private boolean g(World world, int i, int j, int k) {
int l = world.b(i, j, k); int l = world.getData(i, j, k);
if (l == 5 && world.k(i, j - 1, k, 0)) { return l == 5 && world.k(i, j - 1, k, 0) ? true : (l == 3 && world.k(i, j, k - 1, 2) ? true : (l == 4 && world.k(i, j, k + 1, 3) ? true : (l == 1 && world.k(i - 1, j, k, 4) ? true : l == 2 && world.k(i + 1, j, k, 5))));
return true;
}
if (l == 3 && world.k(i, j, k - 1, 2)) {
return true;
}
if (l == 4 && world.k(i, j, k + 1, 3)) {
return true;
}
if (l == 1 && world.k(i - 1, j, k, 4)) {
return true;
}
return l == 2 && world.k(i + 1, j, k, 5);
} }
public void a(World world, int i, int j, int k, Random random) { public void a(World world, int i, int j, int k, Random random) {
boolean flag = g(world, i, j, k); boolean flag = this.g(world, i, j, k);
for (; b.size() > 0 && world.e - ((RedstoneUpdateInfo) b.get(0)).d > 100L; b.remove(0)) { while (b.size() > 0 && world.e - ((RedstoneUpdateInfo) b.get(0)).d > 100L) {
; b.remove(0);
} }
// Craftbukkit start // Craftbukkit start
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag ? 0 : 15); BlockRedstoneEvent event = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag ? 0 : 15);
((WorldServer) world).getServer().getPluginManager().callEvent(bre); ((WorldServer) world).getServer().getPluginManager().callEvent(event);
if ((bre.getNewCurrent() != 0) == flag) { if ((event.getNewCurrent() != 0) == flag) {
return; return;
} }
// Craftbukkit end // Craftbukkit end
if (a) { if (this.a) {
if (flag) { if (flag) {
world.b(i, j, k, Block.aP.bi, world.b(i, j, k)); world.b(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k));
if (a(world, i, j, k, true)) { if (this.a(world, i, j, k, true)) {
world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F); world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
for (int l = 0; l < 5; l++) {
double d1 = (double) i + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
double d2 = (double) j + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
double d3 = (double) k + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
world.a("smoke", d1, d2, d3, 0.0D, 0.0D, 0.0D); for (int l = 0; l < 5; ++l) {
double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D;
double d1 = (double) j + random.nextDouble() * 0.6D + 0.2D;
double d2 = (double) k + random.nextDouble() * 0.6D + 0.2D;
world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
} }
} }
} }
} else if (!flag && !a(world, i, j, k, false)) { } else if (!flag && !this.a(world, i, j, k, false)) {
world.b(i, j, k, Block.aQ.bi, world.b(i, j, k)); world.b(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k));
} }
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
super.b(world, i, j, k, l); super.b(world, i, j, k, l);
world.i(i, j, k, bi); world.i(i, j, k, this.id);
} }
public boolean d(World world, int i, int j, int k, int l) { public boolean d(World world, int i, int j, int k, int l) {
if (l == 0) { return l == 0 ? this.b((IBlockAccess) world, i, j, k, l) : false;
return b(((IBlockAccess) (world)), i, j, k, l);
} else {
return false;
}
} }
public int a(int i, Random random) { public int a(int i, Random random) {
return Block.aQ.bi; return Block.REDSTONE_TORCH_ON.id;
} }
public boolean c() { public boolean c() {

View File

@ -2,24 +2,23 @@ package net.minecraft.server;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
// CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.plugin.PluginLoader; // CraftBukkit end
public class BlockRedstoneWire extends Block { public class BlockRedstoneWire extends Block {
private boolean a; private boolean a = true;
private Set b; private Set b = new HashSet();
public BlockRedstoneWire(int i, int j) { public BlockRedstoneWire(int i, int j) {
super(i, j, Material.n); super(i, j, Material.ORIENTABLE);
a = true; this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
b = ((Set) (new HashSet()));
a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
} }
public AxisAlignedBB d(World world, int i, int j, int k) { public AxisAlignedBB d(World world, int i, int j, int k) {
@ -35,60 +34,67 @@ public class BlockRedstoneWire extends Block {
} }
private void g(World world, int i, int j, int k) { private void g(World world, int i, int j, int k) {
a(world, i, j, k, i, j, k); this.a(world, i, j, k, i, j, k);
ArrayList arraylist = new ArrayList(((java.util.Collection) (b))); ArrayList arraylist = new ArrayList(this.b);
b.clear(); this.b.clear();
for (int l = 0; l < ((List) (arraylist)).size(); l++) {
ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(l);
world.h(chunkposition.a, chunkposition.b, chunkposition.c, bi); for (int l = 0; l < arraylist.size(); ++l) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);
world.h(chunkposition.a, chunkposition.b, chunkposition.c, this.id);
} }
} }
private void a(World world, int i, int j, int k, int l, int i1, int j1) { private void a(World world, int i, int j, int k, int l, int i1, int j1) {
int k1 = world.b(i, j, k); int k1 = world.getData(i, j, k);
int l1 = 0; int l1 = 0;
a = false; this.a = false;
boolean flag = world.p(i, j, k); boolean flag = world.p(i, j, k);
a = true; this.a = true;
int i2;
int j2;
int k2;
if (flag) { if (flag) {
l1 = 15; l1 = 15;
} else { } else {
for (int i2 = 0; i2 < 4; i2++) { for (i2 = 0; i2 < 4; ++i2) {
int k2 = i; j2 = i;
int i3 = k; k2 = k;
if (i2 == 0) { if (i2 == 0) {
k2--; j2 = i - 1;
} }
if (i2 == 1) { if (i2 == 1) {
k2++; ++j2;
} }
if (i2 == 2) { if (i2 == 2) {
i3--; k2 = k - 1;
} }
if (i2 == 3) { if (i2 == 3) {
i3++; ++k2;
} }
if (k2 != l || j != i1 || i3 != j1) {
l1 = f(world, k2, j, i3, l1); if (j2 != l || j != i1 || k2 != j1) {
l1 = this.f(world, j2, j, k2, l1);
} }
if (world.d(k2, j, i3) && !world.d(i, j + 1, k)) {
if (k2 != l || j + 1 != i1 || i3 != j1) { if (world.d(j2, j, k2) && !world.d(i, j + 1, k)) {
l1 = f(world, k2, j + 1, i3, l1); if (j2 != l || j + 1 != i1 || k2 != j1) {
l1 = this.f(world, j2, j + 1, k2, l1);
} }
continue; } else if (!world.d(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) {
} l1 = this.f(world, j2, j - 1, k2, l1);
if (!world.d(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) {
l1 = f(world, k2, j - 1, i3, l1);
} }
} }
if (l1 > 0) { if (l1 > 0) {
l1--; --l1;
} else { } else {
l1 = 0; l1 = 0;
} }
@ -97,250 +103,238 @@ public class BlockRedstoneWire extends Block {
// Craftbukkit start // Craftbukkit start
if (k1 != l1) { if (k1 != l1) {
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1); BlockRedstoneEvent event = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1);
((WorldServer) world).getServer().getPluginManager().callEvent(bre); ((WorldServer) world).getServer().getPluginManager().callEvent(event);
l1 = bre.getNewCurrent(); l1 = event.getNewCurrent();
} }
// Craftbukkit end // Craftbukkit end
if (k1 != l1) { if (k1 != l1) {
world.i = true; world.i = true;
world.c(i, j, k, l1); world.c(i, j, k, l1);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.i = false; world.i = false;
for (int j2 = 0; j2 < 4; j2++) {
int l2 = i;
int j3 = k;
int k3 = j - 1;
if (j2 == 0) { for (i2 = 0; i2 < 4; ++i2) {
l2--; j2 = i;
} k2 = k;
if (j2 == 1) { int l2 = j - 1;
l2++;
}
if (j2 == 2) {
j3--;
}
if (j2 == 3) {
j3++;
}
if (world.d(l2, j, j3)) {
k3 += 2;
}
int l3 = 0;
l3 = f(world, l2, j, j3, -1); if (i2 == 0) {
l1 = world.b(i, j, k); j2 = i - 1;
}
if (i2 == 1) {
++j2;
}
if (i2 == 2) {
k2 = k - 1;
}
if (i2 == 3) {
++k2;
}
if (world.d(j2, j, k2)) {
l2 += 2;
}
boolean flag1 = false;
int i3 = this.f(world, j2, j, k2, -1);
l1 = world.getData(i, j, k);
if (l1 > 0) { if (l1 > 0) {
l1--; --l1;
} }
if (l3 >= 0 && l3 != l1) {
a(world, l2, j, j3, i, j, k); if (i3 >= 0 && i3 != l1) {
this.a(world, j2, j, k2, i, j, k);
} }
l3 = f(world, l2, k3, j3, -1);
l1 = world.b(i, j, k); i3 = this.f(world, j2, l2, k2, -1);
l1 = world.getData(i, j, k);
if (l1 > 0) { if (l1 > 0) {
l1--; --l1;
} }
if (l3 >= 0 && l3 != l1) {
a(world, l2, k3, j3, i, j, k); if (i3 >= 0 && i3 != l1) {
this.a(world, j2, l2, k2, i, j, k);
} }
} }
if (k1 == 0 || l1 == 0) { if (k1 == 0 || l1 == 0) {
b.add(((new ChunkPosition(i, j, k)))); this.b.add(new ChunkPosition(i, j, k));
b.add(((new ChunkPosition(i - 1, j, k)))); this.b.add(new ChunkPosition(i - 1, j, k));
b.add(((new ChunkPosition(i + 1, j, k)))); this.b.add(new ChunkPosition(i + 1, j, k));
b.add(((new ChunkPosition(i, j - 1, k)))); this.b.add(new ChunkPosition(i, j - 1, k));
b.add(((new ChunkPosition(i, j + 1, k)))); this.b.add(new ChunkPosition(i, j + 1, k));
b.add(((new ChunkPosition(i, j, k - 1)))); this.b.add(new ChunkPosition(i, j, k - 1));
b.add(((new ChunkPosition(i, j, k + 1)))); this.b.add(new ChunkPosition(i, j, k + 1));
} }
} }
} }
private void h(World world, int i, int j, int k) { private void h(World world, int i, int j, int k) {
if (world.a(i, j, k) != bi) { if (world.getTypeId(i, j, k) == this.id) {
return; world.h(i, j, k, this.id);
} else { world.h(i - 1, j, k, this.id);
world.h(i, j, k, bi); world.h(i + 1, j, k, this.id);
world.h(i - 1, j, k, bi); world.h(i, j, k - 1, this.id);
world.h(i + 1, j, k, bi); world.h(i, j, k + 1, this.id);
world.h(i, j, k - 1, bi); world.h(i, j - 1, k, this.id);
world.h(i, j, k + 1, bi); world.h(i, j + 1, k, this.id);
world.h(i, j - 1, k, bi);
world.h(i, j + 1, k, bi);
return;
} }
} }
public void e(World world, int i, int j, int k) { public void e(World world, int i, int j, int k) {
super.e(world, i, j, k); super.e(world, i, j, k);
if (world.z) { if (!world.isStatic) {
return; this.g(world, i, j, k);
} world.h(i, j + 1, k, this.id);
g(world, i, j, k); world.h(i, j - 1, k, this.id);
world.h(i, j + 1, k, bi); this.h(world, i - 1, j, k);
world.h(i, j - 1, k, bi); this.h(world, i + 1, j, k);
h(world, i - 1, j, k); this.h(world, i, j, k - 1);
h(world, i + 1, j, k); this.h(world, i, j, k + 1);
h(world, i, j, k - 1); if (world.d(i - 1, j, k)) {
h(world, i, j, k + 1); this.h(world, i - 1, j + 1, k);
if (world.d(i - 1, j, k)) { } else {
h(world, i - 1, j + 1, k); this.h(world, i - 1, j - 1, k);
} else { }
h(world, i - 1, j - 1, k);
} if (world.d(i + 1, j, k)) {
if (world.d(i + 1, j, k)) { this.h(world, i + 1, j + 1, k);
h(world, i + 1, j + 1, k); } else {
} else { this.h(world, i + 1, j - 1, k);
h(world, i + 1, j - 1, k); }
}
if (world.d(i, j, k - 1)) { if (world.d(i, j, k - 1)) {
h(world, i, j + 1, k - 1); this.h(world, i, j + 1, k - 1);
} else { } else {
h(world, i, j - 1, k - 1); this.h(world, i, j - 1, k - 1);
} }
if (world.d(i, j, k + 1)) {
h(world, i, j + 1, k + 1); if (world.d(i, j, k + 1)) {
} else { this.h(world, i, j + 1, k + 1);
h(world, i, j - 1, k + 1); } else {
this.h(world, i, j - 1, k + 1);
}
} }
} }
public void b(World world, int i, int j, int k) { public void b(World world, int i, int j, int k) {
super.b(world, i, j, k); super.b(world, i, j, k);
if (world.z) { if (!world.isStatic) {
return; world.h(i, j + 1, k, this.id);
} world.h(i, j - 1, k, this.id);
world.h(i, j + 1, k, bi); this.g(world, i, j, k);
world.h(i, j - 1, k, bi); this.h(world, i - 1, j, k);
g(world, i, j, k); this.h(world, i + 1, j, k);
h(world, i - 1, j, k); this.h(world, i, j, k - 1);
h(world, i + 1, j, k); this.h(world, i, j, k + 1);
h(world, i, j, k - 1); if (world.d(i - 1, j, k)) {
h(world, i, j, k + 1); this.h(world, i - 1, j + 1, k);
if (world.d(i - 1, j, k)) { } else {
h(world, i - 1, j + 1, k); this.h(world, i - 1, j - 1, k);
} else { }
h(world, i - 1, j - 1, k);
} if (world.d(i + 1, j, k)) {
if (world.d(i + 1, j, k)) { this.h(world, i + 1, j + 1, k);
h(world, i + 1, j + 1, k); } else {
} else { this.h(world, i + 1, j - 1, k);
h(world, i + 1, j - 1, k); }
}
if (world.d(i, j, k - 1)) { if (world.d(i, j, k - 1)) {
h(world, i, j + 1, k - 1); this.h(world, i, j + 1, k - 1);
} else { } else {
h(world, i, j - 1, k - 1); this.h(world, i, j - 1, k - 1);
} }
if (world.d(i, j, k + 1)) {
h(world, i, j + 1, k + 1); if (world.d(i, j, k + 1)) {
} else { this.h(world, i, j + 1, k + 1);
h(world, i, j - 1, k + 1); } else {
this.h(world, i, j - 1, k + 1);
}
} }
} }
private int f(World world, int i, int j, int k, int l) { private int f(World world, int i, int j, int k, int l) {
if (world.a(i, j, k) != bi) { if (world.getTypeId(i, j, k) != this.id) {
return l; return l;
}
int i1 = world.b(i, j, k);
if (i1 > l) {
return i1;
} else { } else {
return l; int i1 = world.getData(i, j, k);
return i1 > l ? i1 : l;
} }
} }
public void b(World world, int i, int j, int k, int l) { public void b(World world, int i, int j, int k, int l) {
if (world.z) { if (!world.isStatic) {
return; int i1 = world.getData(i, j, k);
} boolean flag = this.a(world, i, j, k);
int i1 = world.b(i, j, k);
boolean flag = a(world, i, j, k);
if (!flag) { if (!flag) {
a_(world, i, j, k, i1); this.a_(world, i, j, k, i1);
world.e(i, j, k, 0); world.e(i, j, k, 0);
} else { } else {
g(world, i, j, k); this.g(world, i, j, k);
}
super.b(world, i, j, k, l);
} }
super.b(world, i, j, k, l);
} }
public int a(int i, Random random) { public int a(int i, Random random) {
return Item.aA.ba; return Item.REDSTONE.id;
} }
public boolean d(World world, int i, int j, int k, int l) { public boolean d(World world, int i, int j, int k, int l) {
if (!a) { return !this.a ? false : this.b((IBlockAccess) world, i, j, k, l);
return false;
} else {
return b(((IBlockAccess) (world)), i, j, k, l);
}
} }
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
if (!a) { if (!this.a) {
return false; return false;
} } else if (iblockaccess.getData(i, j, k) == 0) {
if (iblockaccess.b(i, j, k) == 0) {
return false; return false;
} } else if (l == 1) {
if (l == 1) {
return true; return true;
} } else {
boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k); boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k);
boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k); boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k);
boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1); boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1);
boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1); boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1);
if (!iblockaccess.d(i, j + 1, k)) { if (!iblockaccess.d(i, j + 1, k)) {
if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) { if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) {
flag = true; flag = true;
} }
if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) {
flag1 = true; if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) {
} flag1 = true;
if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) { }
flag2 = true;
} if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) {
if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) { flag2 = true;
flag3 = true; }
if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) {
flag3 = true;
}
} }
return !flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5 ? true : (l == 2 && flag2 && !flag && !flag1 ? true : (l == 3 && flag3 && !flag && !flag1 ? true : (l == 4 && flag && !flag2 && !flag3 ? true : l == 5 && flag1 && !flag2 && !flag3)));
} }
if (!flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5) {
return true;
}
if (l == 2 && flag2 && !flag && !flag1) {
return true;
}
if (l == 3 && flag3 && !flag && !flag1) {
return true;
}
if (l == 4 && flag && !flag2 && !flag3) {
return true;
}
return l == 5 && flag1 && !flag2 && !flag3;
} }
public boolean c() { public boolean c() {
return a; return this.a;
} }
public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) { public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
int l = iblockaccess.a(i, j, k); int l = iblockaccess.getTypeId(i, j, k);
if (l == Block.av.bi) { return l == Block.REDSTONE_WIRE.id ? true : (l == 0 ? false : Block.byId[l].c());
return true;
}
if (l == 0) {
return false;
}
return Block.m[l].c();
} }
} }

View File

@ -1,64 +1,66 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import java.util.Random;
// CraftBukkit end // CraftBukkit end
public class BlockStationary extends BlockFluids { public class BlockStationary extends BlockFluids {
protected BlockStationary(int k, Material material) { protected BlockStationary(int i, Material material) {
super(k, material); super(i, material);
a(false); this.a(false);
if (material == Material.g) { if (material == Material.LAVA) {
a(true); this.a(true);
} }
} }
public void b(World world, int k, int l, int i1, int j1) { public void b(World world, int i, int j, int k, int l) {
super.b(world, k, l, i1, j1); super.b(world, i, j, k, l);
if (world.a(k, l, i1) == bi) { if (world.getTypeId(i, j, k) == this.id) {
i(world, k, l, i1); this.i(world, i, j, k);
} }
} }
private void i(World world, int k, int l, int i1) { private void i(World world, int i, int j, int k) {
int j1 = world.b(k, l, i1); int l = world.getData(i, j, k);
world.i = true; world.i = true;
world.a(k, l, i1, bi - 1, j1); world.setTypeIdAndData(i, j, k, this.id - 1, l);
world.b(k, l, i1, k, l, i1); world.b(i, j, k, i, j, k);
world.i(k, l, i1, bi - 1); world.i(i, j, k, this.id - 1);
world.i = false; world.i = false;
} }
public void a(World world, int k, int l, int i1, Random random) { public void a(World world, int i, int j, int k, Random random) {
if (bt == Material.g) { if (this.material == Material.LAVA) {
int j1 = random.nextInt(3); int l = random.nextInt(3);
for (int k1 = 0; k1 < j1; k1++) { // CraftBukkit start: prevent lava putting something on fire.
Server server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
Player thePlayer = null;
// CraftBukkit end
for (int i1 = 0; i1 < l; ++i1) {
i += random.nextInt(3) - 1;
++j;
k += random.nextInt(3) - 1; k += random.nextInt(3) - 1;
l++; int j1 = world.getTypeId(i, j, k);
i1 += random.nextInt(3) - 1;
int l1 = world.a(k, l, i1);
if (l1 == 0) { if (j1 == 0) {
// this checks if an adjacent block is flammable before lighting this block. if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) {
// perhaps we can reduce spam by checking this earlier.
if (j(world, k - 1, l, i1) || j(world, k + 1, l, i1) || j(world, k, l, i1 - 1) || j(world, k, l, i1 + 1) || j(world, k, l - 1, i1) || j(world, k, l + 1, i1)) {
// CraftBukkit start: prevent lava putting something on fire. // CraftBukkit start: prevent lava putting something on fire.
Server server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
org.bukkit.block.Block theBlock = cworld.getBlockAt(k, l, i1); org.bukkit.block.Block theBlock = cworld.getBlockAt(k, l, i1);
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
Player thePlayer = null; if (theBlock.getTypeId() != Block.FIRE.id){
if (theBlock.getTypeId() != Block.ar.bi){
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer); BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -66,19 +68,18 @@ public class BlockStationary extends BlockFluids {
} }
} }
// CraftBukkit end // CraftBukkit end
world.e(k, l, i1, Block.ar.bi);
world.e(i, j, k, Block.FIRE.id);
return; return;
} }
continue; } else if (Block.byId[j1].material.isSolid()) {
}
if (Block.m[l1].bt.c()) {
return; return;
} }
} }
} }
} }
private boolean j(World world, int k, int l, int i1) { private boolean j(World world, int i, int j, int k) {
return world.c(k, l, i1).e(); return world.getMaterial(i, j, k).isBurnable();
} }
} }

View File

@ -12,26 +12,16 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockWorkbench extends Block { public class BlockWorkbench extends Block {
protected BlockWorkbench(int i) { protected BlockWorkbench(int i) {
super(i, Material.c); super(i, Material.WOOD);
bh = 59; this.textureId = 59;
} }
public int a(int i) { public int a(int i) {
if (i == 1) { return i == 1 ? this.textureId - 16 : (i == 0 ? Block.WOOD.a(0) : (i != 2 && i != 4 ? this.textureId : this.textureId + 1));
return bh - 16;
}
if (i == 0) {
return Block.x.a(0);
}
if (i == 2 || i == 4) {
return bh + 1;
} else {
return bh;
}
} }
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) { public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.z) { if (world.isStatic) {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Workbench // CraftBukkit start - Interact Workbench
@ -39,17 +29,17 @@ public class BlockWorkbench extends Block {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT; Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity(); LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) { BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
entityplayer.a(i, j, k); entityhuman.a(i, j, k);
return true; return true;
} }
} }

View File

@ -1,7 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
@ -13,57 +18,55 @@ import org.bukkit.event.world.ChunkLoadEvent;
public class ChunkProviderServer implements IChunkProvider { public class ChunkProviderServer implements IChunkProvider {
private Set a; private Set a = new HashSet();
private Chunk b; private Chunk b;
private IChunkProvider c; private IChunkProvider c;
private IChunkLoader d; private IChunkLoader d;
private Map e; private Map e = new HashMap();
private List f; private List f = new ArrayList();
private WorldServer g; private WorldServer g;
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
a = ((Set) (new HashSet())); this.b = new EmptyChunk(worldserver, new byte['\u8000'], 0, 0);
e = ((Map) (new HashMap())); this.g = worldserver;
f = ((List) (new ArrayList())); this.d = ichunkloader;
b = ((Chunk) (new EmptyChunk(((World) (worldserver)), new byte[32768], 0, 0))); this.c = ichunkprovider;
g = worldserver;
d = ichunkloader;
c = ichunkprovider;
} }
public boolean a(int i, int j) { public boolean a(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
return e.containsKey(((chunkcoordinates))); return this.e.containsKey(chunkcoordinates);
} }
public void c(int i, int j) { public void c(int i, int j) {
int k = (i * 16 + 8) - g.m; int k = i * 16 + 8 - this.g.spawnX;
int l = (j * 16 + 8) - g.o; int l = j * 16 + 8 - this.g.spawnZ;
char c1 = '\200'; short short1 = 128;
if (k < -c1 || k > c1 || l < -c1 || l > c1) { if (k < -short1 || k > short1 || l < -short1 || l > short1) {
a.add(((new ChunkCoordinates(i, j)))); this.a.add(new ChunkCoordinates(i, j));
} }
} }
public Chunk d(int i, int j) { public Chunk d(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
a.remove(((new ChunkCoordinates(i, j)))); this.a.remove(new ChunkCoordinates(i, j));
Chunk chunk = (Chunk) e.get(((chunkcoordinates))); Chunk chunk = (Chunk) this.e.get(chunkcoordinates);
if (chunk == null) { if (chunk == null) {
chunk = e(i, j); chunk = this.e(i, j);
if (chunk == null) { if (chunk == null) {
if (c == null) { if (this.c == null) {
chunk = b; chunk = this.b;
} else { } else {
chunk = c.b(i, j); chunk = this.c.b(i, j);
} }
} }
e.put(((chunkcoordinates)), ((chunk)));
f.add(((chunk))); this.e.put(chunkcoordinates, chunk);
this.f.add(chunk);
if (chunk != null) { if (chunk != null) {
chunk.c(); chunk.c();
chunk.d(); chunk.d();
@ -83,84 +86,80 @@ public class ChunkProviderServer implements IChunkProvider {
} }
// CraftBukkit end // CraftBukkit end
if (!chunk.n && a(i + 1, j + 1) && a(i, j + 1) && a(i + 1, j)) { if (!chunk.n && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) {
a(((IChunkProvider) (this)), i, j); this.a(this, i, j);
} }
if (a(i - 1, j) && !b(i - 1, j).n && a(i - 1, j + 1) && a(i, j + 1) && a(i - 1, j)) {
a(((IChunkProvider) (this)), i - 1, j); if (this.a(i - 1, j) && !this.b(i - 1, j).n && this.a(i - 1, j + 1) && this.a(i, j + 1) && this.a(i - 1, j)) {
this.a(this, i - 1, j);
} }
if (a(i, j - 1) && !b(i, j - 1).n && a(i + 1, j - 1) && a(i, j - 1) && a(i + 1, j)) {
a(((IChunkProvider) (this)), i, j - 1); if (this.a(i, j - 1) && !this.b(i, j - 1).n && this.a(i + 1, j - 1) && this.a(i, j - 1) && this.a(i + 1, j)) {
this.a(this, i, j - 1);
} }
if (a(i - 1, j - 1) && !b(i - 1, j - 1).n && a(i - 1, j - 1) && a(i, j - 1) && a(i - 1, j)) {
a(((IChunkProvider) (this)), i - 1, j - 1); if (this.a(i - 1, j - 1) && !this.b(i - 1, j - 1).n && this.a(i - 1, j - 1) && this.a(i, j - 1) && this.a(i - 1, j)) {
this.a(this, i - 1, j - 1);
} }
} }
return chunk; return chunk;
} }
public Chunk b(int i, int j) { public Chunk b(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j); ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
Chunk chunk = (Chunk) e.get(((chunkcoordinates))); Chunk chunk = (Chunk) this.e.get(chunkcoordinates);
if (chunk == null) { return chunk == null ? (this.g.x ? this.d(i, j) : this.b) : chunk;
if (g.x) {
return d(i, j);
} else {
return b;
}
} else {
return chunk;
}
} }
private Chunk e(int i, int j) { private Chunk e(int i, int j) {
if (d == null) { if (this.d == null) {
return null; return null;
} } else {
try { try {
Chunk chunk = d.a(((World) (g)), i, j); Chunk chunk = this.d.a(this.g, i, j);
if (chunk != null) { if (chunk != null) {
chunk.r = g.e; chunk.r = this.g.e;
}
return chunk;
} catch (Exception exception) {
exception.printStackTrace();
return null;
} }
return chunk;
} catch (Exception exception) {
exception.printStackTrace();
} }
return null;
} }
private void a(Chunk chunk) { private void a(Chunk chunk) {
if (d == null) { if (this.d != null) {
return; try {
} this.d.b(this.g, chunk);
try { } catch (Exception exception) {
d.b(((World) (g)), chunk); exception.printStackTrace();
} catch (Exception exception) { }
exception.printStackTrace();
} }
} }
private void b(Chunk chunk) { private void b(Chunk chunk) {
if (d == null) { if (this.d != null) {
return; try {
} chunk.r = this.g.e;
try { this.d.a(this.g, chunk);
chunk.r = g.e; } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
d.a(((World) (g)), chunk); ioexception.printStackTrace();
} catch (Throwable ioexception) { // CraftBukkit -- downcast to work }
ioexception.printStackTrace();
} }
} }
public void a(IChunkProvider ichunkprovider, int i, int j) { public void a(IChunkProvider ichunkprovider, int i, int j) {
Chunk chunk = b(i, j); Chunk chunk = this.b(i, j);
if (!chunk.n) { if (!chunk.n) {
chunk.n = true; chunk.n = true;
if (c != null) { if (this.c != null) {
c.a(ichunkprovider, i, j); this.c.a(ichunkprovider, i, j);
chunk.f(); chunk.f();
} }
} }
@ -169,55 +168,59 @@ public class ChunkProviderServer implements IChunkProvider {
public boolean a(boolean flag, IProgressUpdate iprogressupdate) { public boolean a(boolean flag, IProgressUpdate iprogressupdate) {
int i = 0; int i = 0;
for (int j = 0; j < f.size(); j++) { for (int j = 0; j < this.f.size(); ++j) {
Chunk chunk = (Chunk) f.get(j); Chunk chunk = (Chunk) this.f.get(j);
if (flag && !chunk.p) { if (flag && !chunk.p) {
a(chunk); this.a(chunk);
} }
if (!chunk.a(flag)) {
continue; if (chunk.a(flag)) {
} this.b(chunk);
b(chunk); chunk.o = false;
chunk.o = false; ++i;
if (++i == 24 && !flag) { if (i == 24 && !flag) {
return false; return false;
}
} }
} }
if (flag) { if (flag) {
if (d == null) { if (this.d == null) {
return true; return true;
} }
d.b();
this.d.b();
} }
return true; return true;
} }
public boolean a() { public boolean a() {
if (!g.C) { if (!this.g.C) {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; ++i) {
if (!a.isEmpty()) { if (!this.a.isEmpty()) {
ChunkCoordinates chunkcoordinates = (ChunkCoordinates) a.iterator().next(); ChunkCoordinates chunkcoordinates = (ChunkCoordinates) this.a.iterator().next();
Chunk chunk = b(chunkcoordinates.a, chunkcoordinates.b); Chunk chunk = this.b(chunkcoordinates.a, chunkcoordinates.b);
chunk.e(); chunk.e();
b(chunk); this.b(chunk);
a(chunk); this.a(chunk);
a.remove(((chunkcoordinates))); this.a.remove(chunkcoordinates);
e.remove(((chunkcoordinates))); this.e.remove(chunkcoordinates);
f.remove(((chunk))); this.f.remove(chunk);
} }
} }
if (d != null) { if (this.d != null) {
d.a(); this.d.a();
} }
} }
return c.a();
return this.c.a();
} }
public boolean b() { public boolean b() {
return !g.C; return !this.g.C;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -5,22 +5,19 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals; import org.bukkit.craftbukkit.entity.CraftAnimals;
// CraftBukkit end // CraftBukkit end
public abstract class EntityAnimals extends EntityCreature implements IAnimals { public abstract class EntityAnimal extends EntityCreature implements IAnimal {
public EntityAnimals(World world) { public EntityAnimal(World world) {
super(world); super(world);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftAnimals(server, this); this.bukkitEntity = new CraftAnimals(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected float a(int i, int j, int k) { protected float a(int i, int j, int k) {
if (l.a(i, j - 1, k) == Block.u.bi) { return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id ? 10.0F : this.world.l(i, j, k) - 0.5F;
return 10F;
} else {
return l.l(i, j, k) - 0.5F;
}
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -32,11 +29,11 @@ public abstract class EntityAnimals extends EntityCreature implements IAnimals {
} }
public boolean b() { public boolean b() {
int i = MathHelper.b(p); int i = MathHelper.b(this.locX);
int j = MathHelper.b(z.b); int j = MathHelper.b(this.boundingBox.b);
int k = MathHelper.b(r); int k = MathHelper.b(this.locZ);
return l.a(i, j - 1, k) == Block.u.bi && l.j(i, j, k) > 8 && super.b(); return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id && this.world.j(i, j, k) > 8 && super.b();
} }
public int c() { public int c() {

View File

@ -10,278 +10,280 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end // CraftBukkit end
public class EntityArrow extends Entity { public class EntityArrow extends Entity {
private int c; private int c = -1;
private int d; private int d = -1;
private int e; private int e = -1;
private int f; private int f = 0;
private boolean ak; private boolean ak = false;
public int a; public int a = 0;
public EntityLiving b; public EntityLiving b;
private int al; private int al;
private int am; private int am = 0;
public EntityArrow(World world) { public EntityArrow(World world) {
super(world); super(world);
c = -1; this.a(0.5F, 0.5F);
d = -1;
e = -1;
f = 0;
ak = false;
a = 0;
am = 0;
a(0.5F, 0.5F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftArrow(server, this); this.bukkitEntity = new CraftArrow(server, this);
// CraftBukkit end // CraftBukkit end
} }
public EntityArrow(World world, double d1, double d2, double d3) { public EntityArrow(World world, double d0, double d1, double d2) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end this.a(0.5F, 0.5F);
this.a(d0, d1, d2);
a(d1, d2, d3); this.height = 0.0F;
H = 0.0F;
} }
public EntityArrow(World world, EntityLiving entityliving) { public EntityArrow(World world, EntityLiving entityliving) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end this.b = entityliving;
this.a(0.5F, 0.5F);
b = entityliving; this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w); this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F; this.locY -= 0.10000000149011612D;
q -= 0.10000000149011612D; this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F; this.a(this.locX, this.locY, this.locZ);
a(p, q, r); this.height = 0.0F;
H = 0.0F; this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F));
s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F); this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F));
u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F); this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F));
t = -MathHelper.a((w / 180F) * 3.141593F); this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
a(s, t, u, 1.5F, 1.0F);
} }
protected void a() {} protected void a() {}
public void a(double d1, double d2, double d3, float f1, float f2) { public void a(double d0, double d1, double d2, float f, float f1) {
float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d1 /= f3; d0 /= (double) f2;
d2 /= f3; d1 /= (double) f2;
d3 /= f3; d2 /= (double) f2;
d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d1 *= f1; d0 *= (double) f;
d2 *= f1; d1 *= (double) f;
d3 *= f1; d2 *= (double) f;
s = d1; this.motX = d0;
t = d2; this.motY = d1;
u = d3; this.motZ = d2;
float f4 = MathHelper.a(d1 * d1 + d3 * d3); float f3 = MathHelper.a(d0 * d0 + d2 * d2);
x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D); this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
al = 0; this.al = 0;
} }
public void b_() { public void b_() {
super.b_(); super.b_();
if (y == 0.0F && x == 0.0F) { if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
float f1 = MathHelper.a(s * s + u * u); float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
x = v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); this.lastYaw = this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
y = w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
} }
if (a > 0) {
a--;
}
if (ak) {
int i = l.a(c, d, e);
if (i != f) { if (this.a > 0) {
ak = false; --this.a;
s *= W.nextFloat() * 0.2F; }
t *= W.nextFloat() * 0.2F;
u *= W.nextFloat() * 0.2F; if (this.ak) {
al = 0; int i = this.world.getTypeId(this.c, this.d, this.e);
am = 0;
} else { if (i == this.f) {
al++; ++this.al;
if (al == 1200) { if (this.al == 1200) {
q(); this.q();
} }
return; return;
} }
} else {
am++;
}
Vec3D vec3d = Vec3D.b(p, q, r);
Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
MovingObjectPosition movingobjectposition = l.a(vec3d, vec3d1);
vec3d = Vec3D.b(p, q, r); this.ak = false;
vec3d1 = Vec3D.b(p + s, q + t, r + u); 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.al = 0;
this.am = 0;
} else {
++this.am;
}
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) { if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
Entity entity = null;
List list = l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
double d1 = 0.0D;
for (int j = 0; j < list.size(); j++) { Entity entity = null;
List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
float f1;
for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j); Entity entity1 = (Entity) list.get(j);
if (!entity1.c_() || entity1 == b && am < 5) { if (entity1.c_() && (entity1 != this.b || this.am >= 5)) {
continue; f1 = 0.3F;
} AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f1, (double) f1, (double) f1);
float f5 = 0.3F; MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
AxisAlignedBB axisalignedbb = entity1.z.b(f5, f5, f5);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 == null) { if (movingobjectposition1 != null) {
continue; double d1 = vec3d.a(movingobjectposition1.f);
}
double d2 = vec3d.a(movingobjectposition1.f);
if (d2 < d1 || d1 == 0.0D) { if (d1 < d0 || d0 == 0.0D) {
entity = entity1; entity = entity1;
d1 = d2; d0 = d1;
}
}
} }
} }
if (entity != null) { if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity); movingobjectposition = new MovingObjectPosition(entity);
} }
float f2;
if (movingobjectposition != null) { if (movingobjectposition != null) {
if (movingobjectposition.g != null) { if (movingobjectposition.g != null) {
// CraftBukkit start // CraftBukkit start
boolean bounce; boolean stick;
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
//TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE //TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE
// or leave as DamageCause.ENTITY_ATTACK // or leave as DamageCause.ENTITY_ATTACK
org.bukkit.entity.Entity shooter = (b == null)?null:b.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.b == null) ? null : this.b.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity(); org.bukkit.entity.Entity projectile = this.getBukkitEntity();
// TODO deal with arrows being fired from a non-entity // TODO deal with arrows being fired from a non-entity
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 4; int damage = 4;
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(edbpe); server.getPluginManager().callEvent(event);
if(!edbpe.isCancelled()) { if(!event.isCancelled()) {
// this function returns if the arrow should stick in or not, i.e. !bounce // this function returns if the arrow should stick in or not, i.e. !bounce
bounce = !movingobjectposition.g.a(((Entity) (b)), edbpe.getDamage()); stick = movingobjectposition.g.a(this.b, event.getDamage());
} else { } else {
// event was cancelled, get if the arrow should bounce or not // event was cancelled, get if the arrow should bounce or not
bounce = edbpe.getBounce(); stick = !event.getBounce();
} }
} else { } else {
bounce = !movingobjectposition.g.a(((Entity) (b)), 4); stick = movingobjectposition.g.a(this.b, 4);
} }
if (!bounce) { if (stick) {
// CraftBukkit end // CraftBukkit end
l.a(((Entity) (this)), "random.drr", 1.0F, 1.2F / (W.nextFloat() * 0.2F + 0.9F)); this.world.a(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
q(); this.q();
} else { } else {
s *= -0.10000000149011612D; this.motX *= -0.10000000149011612D;
t *= -0.10000000149011612D; this.motY *= -0.10000000149011612D;
u *= -0.10000000149011612D; this.motZ *= -0.10000000149011612D;
v += 180F; this.yaw += 180.0F;
x += 180F; this.lastYaw += 180.0F;
am = 0; this.am = 0;
} }
} else { } else {
c = movingobjectposition.b; this.c = movingobjectposition.b;
d = movingobjectposition.c; this.d = movingobjectposition.c;
e = movingobjectposition.d; this.e = movingobjectposition.d;
f = l.a(c, d, e); this.f = this.world.getTypeId(this.c, this.d, this.e);
s = (float) (movingobjectposition.f.a - p); this.motX = (double) ((float) (movingobjectposition.f.a - this.locX));
t = (float) (movingobjectposition.f.b - q); this.motY = (double) ((float) (movingobjectposition.f.b - this.locY));
u = (float) (movingobjectposition.f.c - r); this.motZ = (double) ((float) (movingobjectposition.f.c - this.locZ));
float f2 = MathHelper.a(s * s + t * t + u * u); f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
p -= (s / (double) f2) * 0.05000000074505806D; this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
q -= (t / (double) f2) * 0.05000000074505806D; this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
r -= (u / (double) f2) * 0.05000000074505806D; this.world.a(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
l.a(((Entity) (this)), "random.drr", 1.0F, 1.2F / (W.nextFloat() * 0.2F + 0.9F)); this.ak = true;
ak = true; this.a = 7;
a = 7;
} }
} }
p += s;
q += t;
r += u;
float f3 = MathHelper.a(s * s + u * u);
v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); this.locX += this.motX;
for (w = (float) ((Math.atan2(t, f3) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) { this.locY += this.motY;
; this.locZ += this.motZ;
} f2 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
for (; w - y >= 180F; y += 360F) { this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
;
}
for (; v - x < -180F; x -= 360F) {
;
}
for (; v - x >= 180F; x += 360F) {
;
}
w = y + (w - y) * 0.2F;
v = x + (v - x) * 0.2F;
float f4 = 0.99F;
float f6 = 0.03F;
if (v()) { for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
for (int k = 0; k < 4; k++) { ;
float f7 = 0.25F; }
l.a("bubble", p - s * (double) f7, q - t * (double) f7, r - u * (double) f7, s, t, u); while (this.pitch - this.lastPitch >= 180.0F) {
this.lastPitch += 360.0F;
}
while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
}
while (this.yaw - this.lastYaw >= 180.0F) {
this.lastYaw += 360.0F;
}
this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.03F;
if (this.v()) {
for (int k = 0; k < 4; ++k) {
float f4 = 0.25F;
this.world.a("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);
} }
f4 = 0.8F; f3 = 0.8F;
} }
s *= f4;
t *= f4; this.motX *= (double) f3;
u *= f4; this.motY *= (double) f3;
t -= f6; this.motZ *= (double) f3;
a(p, q, r); this.motY -= (double) f1;
this.a(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("xTile", (short) c); nbttagcompound.a("xTile", (short) this.c);
nbttagcompound.a("yTile", (short) d); nbttagcompound.a("yTile", (short) this.d);
nbttagcompound.a("zTile", (short) e); nbttagcompound.a("zTile", (short) this.e);
nbttagcompound.a("inTile", (byte) f); nbttagcompound.a("inTile", (byte) this.f);
nbttagcompound.a("shake", (byte) a); nbttagcompound.a("shake", (byte) this.a);
nbttagcompound.a("inGround", (byte) (ak ? 1 : 0)); nbttagcompound.a("inGround", (byte) (this.ak ? 1 : 0));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
c = ((int) (nbttagcompound.c("xTile"))); this.c = nbttagcompound.c("xTile");
d = ((int) (nbttagcompound.c("yTile"))); this.d = nbttagcompound.c("yTile");
e = ((int) (nbttagcompound.c("zTile"))); this.e = nbttagcompound.c("zTile");
f = nbttagcompound.b("inTile") & 0xff; this.f = nbttagcompound.b("inTile") & 255;
a = nbttagcompound.b("shake") & 0xff; this.a = nbttagcompound.b("shake") & 255;
ak = nbttagcompound.b("inGround") == 1; this.ak = nbttagcompound.b("inGround") == 1;
} }
public void b(EntityPlayer entityplayer) { public void b(EntityHuman entityhuman) {
if (l.z) { if (!this.world.isStatic) {
return; if (this.ak && this.b == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
} this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (ak && b == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) { entityhuman.c(this, 1);
l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F); this.q();
entityplayer.c(((Entity) (this)), 1); }
q();
} }
} }
} }

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Location; import org.bukkit.Location;
@ -19,7 +18,7 @@ import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleMoveEvent;
// CraftBukkit end // CraftBukkit end
public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit public class EntityBoat extends Entity {
public int a; public int a;
public int b; public int b;
@ -31,59 +30,6 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
private double al; private double al;
private double am; private double am;
// CraftBukkit start
/**@deprecated*/
private CraftBoat boat;
/**@deprecated*/
public CraftEntity getCraftEntity() {
return boat;
}
// CraftBukkit end
public EntityBoat(World world) {
super(world);
a = 0;
b = 0;
c = 1;
i = true;
a(1.5F, 0.6F);
H = J / 2.0F;
M = false;
handleCreation(world); // CraftBukkit
// CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer();
this.bukkitEntity = new CraftBoat(server, this);
// CraftBukkit end
}
protected void a() {}
public AxisAlignedBB d(Entity entity) {
return entity.z;
}
public AxisAlignedBB u() {
return z;
}
public boolean z() {
return true;
}
public EntityBoat(World world, double d1, double d2, double d3) {
this(world);
a(d1, d2 + (double) H, d3);
s = 0.0D;
t = 0.0D;
u = 0.0D;
m = d1;
n = d2;
o = d3;
handleCreation(world); // CraftBukkit
}
// CraftBukkit start // CraftBukkit start
private void handleCreation(World world) { private void handleCreation(World world) {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
@ -92,261 +38,17 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle); VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
} }
// CraftBukkit end
public double k() {
return (double) J * 0.0D - 0.30000001192092896D;
}
public boolean a(Entity entity, int i) {
// CraftBukkit start
Type eventType = Type.VEHICLE_DAMAGE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
org.bukkit.entity.Entity attacker = (entity == null)?null:entity.getBukkitEntity();
int damage = i;
VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage);
((WorldServer) l).getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
// CraftBukkit end
if (this.l.z || G) {
return true;
}
c = -c;
b = 10;
a += i * 10;
y();
if (a > 40) {
for (int j = 0; j < 3; j++) {
a(Block.x.bi, 1, 0.0F);
}
for (int l = 0; l < 2; l++) {
a(Item.B.ba, 1, 0.0F);
}
q();
}
return true;
}
public boolean c_() {
return !G;
}
public void b_() {
// CraftBukkit start
double prevX = p;
double prevY = q;
double prevZ = r;
float prevYaw = v;
float prevPitch = w;
// CraftBukkit end
super.b_();
if (b > 0) {
b--;
}
if (a > 0) {
a--;
}
m = p;
n = q;
o = r;
int i = 5;
double d1 = 0.0D;
for (int j = 0; j < i; j++) {
double d2 = (z.b + ((z.e - z.b) * (double) (j + 0)) / (double) i) - 0.125D;
double d3 = (z.b + ((z.e - z.b) * (double) (j + 1)) / (double) i) - 0.125D;
AxisAlignedBB axisalignedbb = AxisAlignedBB.b(z.a, d2, z.c, z.d, d3, z.f);
if (this.l.b(axisalignedbb, Material.f)) {
d1 += 1.0D / (double) i;
}
}
if (this.l.z) {
if (d > 0) {
double d4 = p + (e - p) / (double) d;
double d7 = q + (f - q) / (double) d;
double d10 = r + (ak - r) / (double) d;
double d13;
for (d13 = al - (double) v; d13 < -180D; d13 += 360D) {
;
}
for (; d13 >= 180D; d13 -= 360D) {
;
}
v += ((float) (d13 / (double) d));
w += ((float) ((am - (double) w) / (double) d));
d--;
a(d4, d7, d10);
b(v, w);
} else {
double d5 = p + s;
double d8 = q + t;
double d11 = r + u;
a(d5, d8, d11);
if (A) {
s *= 0.5D;
t *= 0.5D;
u *= 0.5D;
}
s *= 0.99000000953674316D;
t *= 0.94999998807907104D;
u *= 0.99000000953674316D;
}
return;
}
double d6 = d1 * 2D - 1.0D;
t += 0.039999999105930328D * d6;
if (this.j != null) {
s += this.j.s * 0.20000000000000001D;
u += this.j.u * 0.20000000000000001D;
}
double d9 = 0.40000000000000002D;
if (s < -d9) {
s = -d9;
}
if (s > d9) {
s = d9;
}
if (u < -d9) {
u = -d9;
}
if (u > d9) {
u = d9;
}
if (A) {
s *= 0.5D;
t *= 0.5D;
u *= 0.5D;
}
c(s, t, u);
double d12 = Math.sqrt(s * s + u * u);
if (d12 > 0.14999999999999999D) {
double d14 = Math.cos(((double) v * 3.1415926535897931D) / 180D);
double d16 = Math.sin(((double) v * 3.1415926535897931D) / 180D);
for (int l = 0; (double) l < 1.0D + d12 * 60D; l++) {
double d18 = W.nextFloat() * 2.0F - 1.0F;
double d19 = (double) (W.nextInt(2) * 2 - 1) * 0.69999999999999996D;
if (W.nextBoolean()) {
double d20 = (p - d14 * d18 * 0.80000000000000004D) + d16 * d19;
double d22 = r - d16 * d18 * 0.80000000000000004D - d14 * d19;
this.l.a("splash", d20, q - 0.125D, d22, s, t, u);
} else {
double d21 = p + d14 + d16 * d18 * 0.69999999999999996D;
double d23 = (r + d16) - d14 * d18 * 0.69999999999999996D;
this.l.a("splash", d21, q - 0.125D, d23, s, t, u);
}
}
}
if (B && d12 > 0.14999999999999999D) {
if (!this.l.z) {
q();
for (int i1 = 0; i1 < 3; i1++) {
a(Block.x.bi, 1, 0.0F);
}
for (int j1 = 0; j1 < 2; j1++) {
a(Item.B.ba, 1, 0.0F);
}
}
} else {
s *= 0.99000000953674316D;
t *= 0.94999998807907104D;
u *= 0.99000000953674316D;
}
w = 0.0F;
double d15 = v;
double d17 = m - p;
double d24 = o - r;
if (d17 * d17 + d24 * d24 > 0.001D) {
d15 = (float) ((Math.atan2(d24, d17) * 180D) / 3.1415926535897931D);
}
double d25;
for (d25 = d15 - (double) v; d25 >= 180D; d25 -= 360D) {
;
}
for (; d25 < -180D; d25 += 360D) {
;
}
if (d25 > 20D) {
d25 = 20D;
}
if (d25 < -20D) {
d25 = -20D;
}
v += ((float) (d25));
b(v, w);
// CraftBukkit start
CraftServer server = ((WorldServer)l).getServer();
CraftWorld world = ((WorldServer)l).getWorld();
Type eventType = Type.VEHICLE_MOVE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
Location to = new Location(world, p, q, r, v, w);
VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to);
server.getPluginManager().callEvent(event);
// CraftBukkit end
List list = this.l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if (list != null && list.size() > 0) {
for (int k1 = 0; k1 < list.size(); k1++) {
Entity entity = (Entity) list.get(k1);
if (entity != this.j && entity.z() && (entity instanceof EntityBoat)) {
entity.c(((Entity) (this)));
}
}
}
if (this.j != null && this.j.G) {
this.j = null;
}
}
public void E() {
if (j == null) {
return;
} else {
double d1 = Math.cos(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D;
double d2 = Math.sin(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D;
j.a(p + d1, q + k() + j.F(), r + d2);
return;
}
}
// CraftBukkit start
public void c(Entity entity) { public void c(Entity entity) {
CraftServer server = ((WorldServer)l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.VEHICLE_COLLISION_ENTITY; Type eventType = Type.VEHICLE_COLLISION_ENTITY;
Vehicle vehicle = (Vehicle) this.getBukkitEntity(); Vehicle vehicle = (Vehicle) this.getBukkitEntity();
org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity(); org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
server.getPluginManager().callEvent(collsionEvent);
if (collsionEvent.isCancelled()) { VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return; return;
} }
@ -354,31 +56,344 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
} }
// CraftBukkit end // CraftBukkit end
protected void a(NBTTagCompound nbttagcompound) {} public EntityBoat(World world) {
super(world);
this.a = 0;
this.b = 0;
this.c = 1;
this.i = true;
this.a(1.5F, 0.6F);
this.height = this.width / 2.0F;
this.M = false;
protected void b(NBTTagCompound nbttagcompound) {} // CraftBukkit start
handleCreation(world);
CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftBoat(server, this);
// CraftBukkit end
}
public boolean a(EntityPlayer entityplayer) { protected void a() {}
if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
return true; public AxisAlignedBB d(Entity entity) {
} return entity.boundingBox;
if (!l.z) { }
public AxisAlignedBB u() {
return this.boundingBox;
}
public boolean z() {
return true;
}
public EntityBoat(World world, double d0, double d1, double d2) {
this(world);
this.a(d0, d1 + (double) this.height, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
handleCreation(world); // CraftBukkit
}
public double k() {
return (double) this.width * 0.0D - 0.30000001192092896D;
}
public boolean a(Entity entity, int i) {
if (!this.world.isStatic && !this.dead) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer)l).getServer(); Type eventType = Type.VEHICLE_DAMAGE;
Type eventType = Type.VEHICLE_ENTER;
Vehicle vehicle = (Vehicle) this.getBukkitEntity(); Vehicle vehicle = (Vehicle) this.getBukkitEntity();
org.bukkit.entity.Entity player = entityplayer.getBukkitEntity(); org.bukkit.entity.Entity attacker = (entity == null) ? null : entity.getBukkitEntity();
int damage = i;
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
server.getPluginManager().callEvent(event); VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage);
((WorldServer) this.world).getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
entityplayer.e(((Entity) (this))); this.c = -this.c;
this.b = 10;
this.a += i * 10;
this.y();
if (this.a > 40) {
int j;
for (j = 0; j < 3; ++j) {
this.a(Block.WOOD.id, 1, 0.0F);
}
for (j = 0; j < 2; ++j) {
this.a(Item.STICK.id, 1, 0.0F);
}
this.q();
}
return true;
} else {
return true;
}
}
public boolean c_() {
return !this.dead;
}
public void b_() {
// CraftBukkit start
double prevX = this.locX;
double prevY = this.locY;
double prevZ = this.locZ;
float prevYaw = this.yaw;
float prevPitch = this.pitch;
// CraftBukkit end
super.b_();
if (this.b > 0) {
--this.b;
}
if (this.a > 0) {
--this.a;
}
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
byte b0 = 5;
double d0 = 0.0D;
for (int i = 0; i < b0; ++i) {
double d1 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 0) / (double) b0 - 0.125D;
double d2 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 1) / (double) b0 - 0.125D;
AxisAlignedBB axisalignedbb = AxisAlignedBB.b(this.boundingBox.a, d1, this.boundingBox.c, this.boundingBox.d, d2, this.boundingBox.f);
if (this.world.b(axisalignedbb, Material.WATER)) {
d0 += 1.0D / (double) b0;
}
}
double d3;
double d4;
double d5;
double d6;
if (this.world.isStatic) {
if (this.d > 0) {
d3 = this.locX + (this.e - this.locX) / (double) this.d;
d4 = this.locY + (this.f - this.locY) / (double) this.d;
d5 = this.locZ + (this.ak - this.locZ) / (double) this.d;
for (d6 = this.al - (double) this.yaw; d6 < -180.0D; d6 += 360.0D) {
;
}
while (d6 >= 180.0D) {
d6 -= 360.0D;
}
this.yaw = (float) ((double) this.yaw + d6 / (double) this.d);
this.pitch = (float) ((double) this.pitch + (this.am - (double) this.pitch) / (double) this.d);
--this.d;
this.a(d3, d4, d5);
this.b(this.yaw, this.pitch);
} else {
d3 = this.locX + this.motX;
d4 = this.locY + this.motY;
d5 = this.locZ + this.motZ;
this.a(d3, d4, d5);
if (this.onGround) {
this.motX *= 0.5D;
this.motY *= 0.5D;
this.motZ *= 0.5D;
}
this.motX *= 0.9900000095367432D;
this.motY *= 0.949999988079071D;
this.motZ *= 0.9900000095367432D;
}
} else {
d3 = d0 * 2.0D - 1.0D;
this.motY += 0.03999999910593033D * d3;
if (this.passenger != null) {
this.motX += this.passenger.motX * 0.2D;
this.motZ += this.passenger.motZ * 0.2D;
}
d4 = 0.4D;
if (this.motX < -d4) {
this.motX = -d4;
}
if (this.motX > d4) {
this.motX = d4;
}
if (this.motZ < -d4) {
this.motZ = -d4;
}
if (this.motZ > d4) {
this.motZ = d4;
}
if (this.onGround) {
this.motX *= 0.5D;
this.motY *= 0.5D;
this.motZ *= 0.5D;
}
this.c(this.motX, this.motY, this.motZ);
d5 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
double d7;
if (d5 > 0.15D) {
d6 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D);
d7 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D);
for (int j = 0; (double) j < 1.0D + d5 * 60.0D; ++j) {
double d8 = (double) (this.random.nextFloat() * 2.0F - 1.0F);
double d9 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D;
double d10;
double d11;
if (this.random.nextBoolean()) {
d10 = this.locX - d6 * d8 * 0.8D + d7 * d9;
d11 = this.locZ - d7 * d8 * 0.8D - d6 * d9;
this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ);
} else {
d10 = this.locX + d6 + d7 * d8 * 0.7D;
d11 = this.locZ + d7 - d6 * d8 * 0.7D;
this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ);
}
}
}
if (this.B && d5 > 0.15D) {
if (!this.world.isStatic) {
this.q();
int k;
for (k = 0; k < 3; ++k) {
this.a(Block.WOOD.id, 1, 0.0F);
}
for (k = 0; k < 2; ++k) {
this.a(Item.STICK.id, 1, 0.0F);
}
}
} else {
this.motX *= 0.9900000095367432D;
this.motY *= 0.949999988079071D;
this.motZ *= 0.9900000095367432D;
}
this.pitch = 0.0F;
d6 = (double) this.yaw;
d7 = this.lastX - this.locX;
double d12 = this.lastZ - this.locZ;
if (d7 * d7 + d12 * d12 > 0.0010D) {
d6 = (double) ((float) (Math.atan2(d12, d7) * 180.0D / 3.141592653589793D));
}
double d13;
for (d13 = d6 - (double) this.yaw; d13 >= 180.0D; d13 -= 360.0D) {
;
}
while (d13 < -180.0D) {
d13 += 360.0D;
}
if (d13 > 20.0D) {
d13 = 20.0D;
}
if (d13 < -20.0D) {
d13 = -20.0D;
}
this.yaw = (float) ((double) this.yaw + d13);
this.b(this.yaw, this.pitch);
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
CraftWorld world = ((WorldServer) this.world).getWorld();
Type eventType = Type.VEHICLE_MOVE;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
Location to = new Location(world, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to);
server.getPluginManager().callEvent(event);
// CraftBukkit end
List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if (list != null && list.size() > 0) {
for (int l = 0; l < list.size(); ++l) {
Entity entity = (Entity) list.get(l);
if (entity != this.passenger && entity.z() && entity instanceof EntityBoat) {
entity.c((Entity) this);
}
}
}
if (this.passenger != null && this.passenger.dead) {
this.passenger = null;
}
}
}
public void E() {
if (this.passenger != null) {
double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D;
double d1 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D;
this.passenger.a(this.locX + d0, this.locY + this.k() + this.passenger.F(), this.locZ + d1);
}
}
protected void a(NBTTagCompound nbttagcompound) {}
protected void b(NBTTagCompound nbttagcompound) {}
public boolean a(EntityHuman entityhuman) {
if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true;
} else {
if (!this.world.isStatic) {
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.VEHICLE_ENTER;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
org.bukkit.entity.Entity player = entityhuman.getBukkitEntity();
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
// CraftBukkit end
entityhuman.e(this);
}
return true;
} }
return true;
} }
} }

View File

@ -1,65 +1,64 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftChicken; import org.bukkit.craftbukkit.entity.CraftChicken;
// CraftBukkit end // CraftBukkit end
public class EntityChicken extends EntityAnimals { public class EntityChicken extends EntityAnimal {
public boolean a; public boolean a = false;
public float b; public float b = 0.0F;
public float c; public float c = 0.0F;
public float f; public float f;
public float ak; public float ak;
public float al; public float al = 1.0F;
public int am; public int am;
public EntityChicken(World world) { public EntityChicken(World world) {
super(world); super(world);
a = false; this.texture = "/mob/chicken.png";
b = 0.0F; this.a(0.3F, 0.4F);
c = 0.0F; this.health = 4;
al = 1.0F; this.am = this.random.nextInt(6000) + 6000;
aP = "/mob/chicken.png";
a(0.3F, 0.4F);
aZ = 4;
am = W.nextInt(6000) + 6000;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftChicken(server, this); this.bukkitEntity = new CraftChicken(server, this);
// CraftBukkit end // CraftBukkit end
} }
public void o() { public void o() {
super.o(); super.o();
ak = b; this.ak = this.b;
f = c; this.f = this.c;
c += ((float) ((double) (A ? -1 : 4) * 0.29999999999999999D)); this.c = (float) ((double) this.c + (double) (this.onGround ? -1 : 4) * 0.3D);
if (c < 0.0F) { if (this.c < 0.0F) {
c = 0.0F; this.c = 0.0F;
} }
if (c > 1.0F) {
c = 1.0F; if (this.c > 1.0F) {
this.c = 1.0F;
} }
if (!A && al < 1.0F) {
al = 1.0F; if (!this.onGround && this.al < 1.0F) {
this.al = 1.0F;
} }
al *= 0.90000000000000002D;
if (!A && t < 0.0D) { this.al = (float) ((double) this.al * 0.9D);
t *= 0.59999999999999998D; if (!this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
} }
b += al * 2.0F;
if (!l.z && --am <= 0) { this.b += this.al * 2.0F;
l.a(((Entity) (this)), "mob.chickenplop", 1.0F, (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F); if (!this.world.isStatic && --this.am <= 0) {
a(Item.aN.ba, 1); this.world.a(this, "mob.chickenplop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
am = W.nextInt(6000) + 6000; this.a(Item.EGG.id, 1);
this.am = this.random.nextInt(6000) + 6000;
} }
} }
protected void a(float f1) {} protected void a(float f) {}
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
@ -82,6 +81,6 @@ public class EntityChicken extends EntityAnimals {
} }
protected int h() { protected int h() {
return Item.J.ba; return Item.FEATHER.id;
} }
} }

View File

@ -5,14 +5,15 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCow; import org.bukkit.craftbukkit.entity.CraftCow;
// CraftBukkit end // CraftBukkit end
public class EntityCow extends EntityAnimals { public class EntityCow extends EntityAnimal {
public EntityCow(World world) { public EntityCow(World world) {
super(world); super(world);
aP = "/mob/cow.png"; this.texture = "/mob/cow.png";
a(0.9F, 1.3F); this.a(0.9F, 1.3F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftCow(server, this); this.bukkitEntity = new CraftCow(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -42,14 +43,14 @@ public class EntityCow extends EntityAnimals {
} }
protected int h() { protected int h() {
return Item.aD.ba; return Item.LEATHER.id;
} }
public boolean a(EntityPlayer entityplayer) { public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityplayer.an.e(); ItemStack itemstack = entityhuman.inventory.e();
if (itemstack != null && itemstack.c == Item.au.ba) { if (itemstack != null && itemstack.id == Item.BUCKET.id) {
entityplayer.an.a(entityplayer.an.c, new ItemStack(Item.aE)); entityhuman.inventory.a(entityhuman.inventory.c, new ItemStack(Item.MILK_BUCKET));
return true; return true;
} else { } else {
return false; return false;

View File

@ -1,11 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCreature;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end // CraftBukkit end
@ -14,155 +15,159 @@ public class EntityCreature extends EntityLiving {
private PathEntity a; private PathEntity a;
protected Entity d; protected Entity d;
protected boolean e; protected boolean e = false;
public EntityCreature(World world) { public EntityCreature(World world) {
super(world); super(world);
e = false;
// CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer();
this.bukkitEntity = new CraftCreature(server, this);
// CraftBukkit end
} }
protected void d() { protected void d() {
e = false; this.e = false;
float f = 16F; float f = 16.0F;
if (d == null) { if (this.d == null) {
// CraftBukkit start // CraftBukkit start
Entity target = l(); Entity target = this.l();
if(target != null) { if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER);
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if(!event.isCancelled()) { if (!event.isCancelled()) {
if(event.getTarget() == null) { if (event.getTarget() == null) {
d = null; this.d = null;
} else { } else {
d = ((CraftEntity) event.getTarget()).getHandle(); this.d = ((CraftEntity) event.getTarget()).getHandle();
} }
} }
} }
// CraftBukkit end // CraftBukkit end
if (d != null) { if (this.d != null) {
a = l.a(((Entity) (this)), d, f); this.a = this.world.a(this, this.d, f);
} }
} else if (!d.B()) { } else if (!this.d.B()) {
// CraftBukkit start // CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED);
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if(!event.isCancelled()) { if (!event.isCancelled()) {
if(event.getTarget() == null) { if (event.getTarget() == null) {
d = null; this.d = null;
} else { } else {
d = ((CraftEntity) event.getTarget()).getHandle(); this.d = ((CraftEntity) event.getTarget()).getHandle();
} }
} }
// CraftBukkit end // CraftBukkit end
} else { } else {
float f1 = d.a(((Entity) (this))); float f1 = this.d.a((Entity) this);
if (i(d)) { if (this.i(this.d)) {
a(d, f1); this.a(this.d, f1);
} }
} }
if (!e && d != null && (a == null || W.nextInt(20) == 0)) {
a = l.a(((Entity) (this)), d, f); if (!this.e && this.d != null && (this.a == null || this.random.nextInt(20) == 0)) {
} else if (a == null && W.nextInt(80) == 0 || W.nextInt(80) == 0) { this.a = this.world.a(this, this.d, f);
} else if (this.a == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0) {
boolean flag = false; boolean flag = false;
int i = -1;
int j = -1; int j = -1;
int k = -1; int k = -1;
int i1 = -1; float f2 = -99999.0F;
float f2 = -99999F;
for (int j1 = 0; j1 < 10; j1++) { for (int l = 0; l < 10; ++l) {
int k1 = MathHelper.b((p + (double) W.nextInt(13)) - 6D); int i1 = MathHelper.b(this.locX + (double) this.random.nextInt(13) - 6.0D);
int l1 = MathHelper.b((q + (double) W.nextInt(7)) - 3D); int j1 = MathHelper.b(this.locY + (double) this.random.nextInt(7) - 3.0D);
int i2 = MathHelper.b((r + (double) W.nextInt(13)) - 6D); int k1 = MathHelper.b(this.locZ + (double) this.random.nextInt(13) - 6.0D);
float f3 = a(k1, l1, i2); float f3 = this.a(i1, j1, k1);
if (f3 > f2) { if (f3 > f2) {
f2 = f3; f2 = f3;
j = k1; i = i1;
k = l1; j = j1;
i1 = i2; k = k1;
flag = true; flag = true;
} }
} }
if (flag) { if (flag) {
a = l.a(((Entity) (this)), j, k, i1, 10F); this.a = this.world.a(this, i, j, k, 10.0F);
} }
} }
int i = MathHelper.b(z.b);
boolean flag1 = v();
boolean flag2 = x();
w = 0.0F; int l1 = MathHelper.b(this.boundingBox.b);
if (a == null || W.nextInt(100) == 0) { boolean flag1 = this.v();
boolean flag2 = this.x();
this.pitch = 0.0F;
if (this.a != null && this.random.nextInt(100) != 0) {
Vec3D vec3d = this.a.a(this);
double d0 = (double) (this.length * 2.0F);
while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) {
this.a.a();
if (this.a.b()) {
vec3d = null;
this.a = null;
} else {
vec3d = this.a.a(this);
}
}
this.bA = false;
if (vec3d != null) {
double d1 = vec3d.a - this.locX;
double d2 = vec3d.c - this.locZ;
double d3 = vec3d.b - (double) l1;
float f4 = (float) (Math.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F;
float f5 = f4 - this.yaw;
for (this.by = this.bC; f5 < -180.0F; f5 += 360.0F) {
;
}
while (f5 >= 180.0F) {
f5 -= 360.0F;
}
if (f5 > 30.0F) {
f5 = 30.0F;
}
if (f5 < -30.0F) {
f5 = -30.0F;
}
this.yaw += f5;
if (this.e && this.d != null) {
double d4 = this.d.locX - this.locX;
double d5 = this.d.locZ - this.locZ;
float f6 = this.yaw;
this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
f5 = (f6 - this.yaw + 90.0F) * 3.1415927F / 180.0F;
this.bx = -MathHelper.a(f5) * this.by * 1.0F;
this.by = MathHelper.b(f5) * this.by * 1.0F;
}
if (d3 > 0.0D) {
this.bA = true;
}
}
if (this.d != null) {
this.b(this.d, 30.0F);
}
if (this.B) {
this.bA = true;
}
if (this.random.nextFloat() < 0.8F && (flag1 || flag2)) {
this.bA = true;
}
} else {
super.d(); super.d();
a = null; this.a = null;
return;
}
Vec3D vec3d = a.a(((Entity) (this)));
for (double d1 = I * 2.0F; vec3d != null && vec3d.d(p, vec3d.b, r) < d1 * d1;) {
a.a();
if (a.b()) {
vec3d = null;
a = null;
} else {
vec3d = a.a(((Entity) (this)));
}
}
bA = false;
if (vec3d != null) {
double d2 = vec3d.a - p;
double d3 = vec3d.c - r;
double d4 = vec3d.b - (double) i;
float f4 = (float) ((Math.atan2(d3, d2) * 180D) / 3.1415927410125732D) - 90F;
float f5 = f4 - v;
by = bC;
for (; f5 < -180F; f5 += 360F) {
;
}
for (; f5 >= 180F; f5 -= 360F) {
;
}
if (f5 > 30F) {
f5 = 30F;
}
if (f5 < -30F) {
f5 = -30F;
}
v += f5;
if (e && d != null) {
double d5 = d.p - p;
double d6 = d.r - r;
float f7 = v;
v = (float) ((Math.atan2(d6, d5) * 180D) / 3.1415927410125732D) - 90F;
float f6 = (((f7 - v) + 90F) * 3.141593F) / 180F;
bx = -MathHelper.a(f6) * by * 1.0F;
by = MathHelper.b(f6) * by * 1.0F;
}
if (d4 > 0.0D) {
bA = true;
}
}
if (d != null) {
b(d, 30F);
}
if (B) {
bA = true;
}
if (W.nextFloat() < 0.8F && (flag1 || flag2)) {
bA = true;
} }
} }
@ -177,10 +182,10 @@ public class EntityCreature extends EntityLiving {
} }
public boolean b() { public boolean b() {
int i = MathHelper.b(p); int i = MathHelper.b(this.locX);
int j = MathHelper.b(z.b); int j = MathHelper.b(this.boundingBox.b);
int k = MathHelper.b(r); int k = MathHelper.b(this.locZ);
return super.b() && a(i, j, k) >= 0.0F; return super.b() && this.a(i, j, k) >= 0.0F;
} }
} }

View File

@ -1,29 +1,29 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCreeper; import org.bukkit.craftbukkit.entity.CraftCreeper;
// CraftBukkit end // CraftBukkit end
public class EntityCreeper extends EntityMobs {
public class EntityCreeper extends EntityMonster {
int a; int a;
int b; int b;
public EntityCreeper(World world) { public EntityCreeper(World world) {
super(world); super(world);
aP = "/mob/creeper.png"; this.texture = "/mob/creeper.png";
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftCreeper(server, this); this.bukkitEntity = new CraftCreeper(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected void a() { protected void a() {
super.a(); super.a();
af.a(16, ((Byte.valueOf((byte) -1)))); this.datawatcher.a(16, Byte.valueOf((byte) -1));
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -35,21 +35,24 @@ public class EntityCreeper extends EntityMobs {
} }
public void b_() { public void b_() {
b = a; this.b = this.a;
if (l.z) { if (this.world.isStatic) {
int i = K(); int i = this.K();
if (i > 0 && a == 0) { if (i > 0 && this.a == 0) {
l.a(((Entity) (this)), "random.fuse", 1.0F, 0.5F); this.world.a(this, "random.fuse", 1.0F, 0.5F);
} }
a += i;
if (a < 0) { this.a += i;
a = 0; if (this.a < 0) {
this.a = 0;
} }
if (a >= 30) {
a = 30; if (this.a >= 30) {
this.a = 30;
} }
} }
super.b_(); super.b_();
} }
@ -64,42 +67,44 @@ public class EntityCreeper extends EntityMobs {
public void f(Entity entity) { public void f(Entity entity) {
super.f(entity); super.f(entity);
if (entity instanceof EntitySkeleton) { if (entity instanceof EntitySkeleton) {
a(Item.aY.ba + W.nextInt(2), 1); this.a(Item.GOLD_RECORD.id + this.random.nextInt(2), 1);
} }
} }
protected void a(Entity entity, float f1) { protected void a(Entity entity, float f) {
int i = K(); int i = this.K();
if (i <= 0 && f1 < 3F || i > 0 && f1 < 7F) { if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) {
if (a == 0) { this.a(-1);
l.a(((Entity) (this)), "random.fuse", 1.0F, 0.5F); --this.a;
if (this.a < 0) {
this.a = 0;
} }
a(1);
a++;
if (a >= 30) {
l.a(((Entity) (this)), p, q, r, 3F);
q();
}
e = true;
} else { } else {
a(-1); if (this.a == 0) {
a--; this.world.a(this, "random.fuse", 1.0F, 0.5F);
if (a < 0) {
a = 0;
} }
this.a(1);
++this.a;
if (this.a >= 30) {
this.world.a(this, this.locX, this.locY, this.locZ, 3.0F);
this.q();
}
this.e = true;
} }
} }
protected int h() { protected int h() {
return Item.K.ba; return Item.SULPHUR.id;
} }
private int K() { private int K() {
return ((int) (af.a(16))); return this.datawatcher.a(16);
} }
private void a(int i) { private void a(int i) {
af.b(16, ((Byte.valueOf((byte) i)))); this.datawatcher.b(16, Byte.valueOf((byte) i));
} }
} }

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.entity.Egg; import org.bukkit.entity.Egg;
@ -18,28 +17,22 @@ import org.bukkit.event.player.PlayerEggThrowEvent;
public class EntityEgg extends Entity { public class EntityEgg extends Entity {
private int b; private int b = -1;
private int c; private int c = -1;
private int d; private int d = -1;
private int e; private int e = 0;
private boolean f; private boolean f = false;
public int a; public int a = 0;
private EntityLiving ak; private EntityLiving ak;
private int al; private int al;
private int am; private int am = 0;
public EntityEgg(World world) { public EntityEgg(World world) {
super(world); super(world);
b = -1; this.a(0.25F, 0.25F);
c = -1;
d = -1;
e = 0;
f = false;
a = 0;
am = 0;
a(0.25F, 0.25F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftEgg(server, this); this.bukkitEntity = new CraftEgg(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -47,117 +40,117 @@ public class EntityEgg extends Entity {
protected void a() {} protected void a() {}
public EntityEgg(World world, EntityLiving entityliving) { public EntityEgg(World world, EntityLiving entityliving) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end
ak = entityliving;
c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w);
p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
q -= 0.10000000149011612D;
r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
a(p, q, r);
H = 0.0F;
float f1 = 0.4F;
s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.ak = entityliving;
u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.a(0.25F, 0.25F);
t = -MathHelper.a((w / 180F) * 3.141593F) * f1; this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
a(s, t, u, 1.5F, 1.0F); this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ);
this.height = 0.0F;
float f = 0.4F;
this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
public EntityEgg(World world, double d1, double d2, double d3) { public EntityEgg(World world, double d0, double d1, double d2) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end this.al = 0;
this.a(0.25F, 0.25F);
al = 0; this.a(d0, d1, d2);
a(d1, d2, d3); this.height = 0.0F;
H = 0.0F;
} }
public void a(double d1, double d2, double d3, float f1, float f2) { public void a(double d0, double d1, double d2, float f, float f1) {
float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d1 /= f3; d0 /= (double) f2;
d2 /= f3; d1 /= (double) f2;
d3 /= f3; d2 /= (double) f2;
d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d1 *= f1; d0 *= (double) f;
d2 *= f1; d1 *= (double) f;
d3 *= f1; d2 *= (double) f;
s = d1; this.motX = d0;
t = d2; this.motY = d1;
u = d3; this.motZ = d2;
float f4 = MathHelper.a(d1 * d1 + d3 * d3); float f3 = MathHelper.a(d0 * d0 + d2 * d2);
x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D); this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
al = 0; this.al = 0;
} }
public void b_() { public void b_() {
O = p; this.O = this.locX;
P = q; this.P = this.locY;
Q = r; this.Q = this.locZ;
super.b_(); super.b_();
if (a > 0) { if (this.a > 0) {
a--; --this.a;
} }
if (f) {
int i = this.l.a(b, c, d);
if (i != e) { if (this.f) {
f = false; int i = this.world.getTypeId(this.b, this.c, this.d);
s *= W.nextFloat() * 0.2F;
t *= W.nextFloat() * 0.2F; if (i == this.e) {
u *= W.nextFloat() * 0.2F; ++this.al;
al = 0; if (this.al == 1200) {
am = 0; this.q();
} else {
al++;
if (al == 1200) {
q();
} }
return; return;
} }
} else {
am++;
}
Vec3D vec3d = Vec3D.b(p, q, r);
Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
vec3d = Vec3D.b(p, q, r); this.f = false;
vec3d1 = Vec3D.b(p + s, q + t, r + u); 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.al = 0;
this.am = 0;
} else {
++this.am;
}
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) { if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
if (!this.l.z) {
if (!this.world.isStatic) {
Entity entity = null; Entity entity = null;
List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D)); List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
double d1 = 0.0D; double d0 = 0.0D;
for (int l = 0; l < list.size(); l++) { for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(l); Entity entity1 = (Entity) list.get(j);
if (!entity1.c_() || entity1 == ak && am < 5) { if (entity1.c_() && (entity1 != this.ak || this.am >= 5)) {
continue; float f = 0.3F;
} AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
float f4 = 0.3F; MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
AxisAlignedBB axisalignedbb = entity1.z.b(f4, f4, f4);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 == null) { if (movingobjectposition1 != null) {
continue; double d1 = vec3d.a(movingobjectposition1.f);
}
double d2 = vec3d.a(movingobjectposition1.f);
if (d2 < d1 || d1 == 0.0D) { if (d1 < d0 || d0 == 0.0D) {
entity = entity1; entity = entity1;
d1 = d2; d0 = d1;
}
}
} }
} }
@ -165,54 +158,53 @@ public class EntityEgg extends Entity {
movingobjectposition = new MovingObjectPosition(entity); movingobjectposition = new MovingObjectPosition(entity);
} }
} }
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.g != null) {
// CraftBukkit start boolean stick;
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (ak == null)?null:ak.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.ak == null) ? null : this.ak.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity(); org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(edbpe); server.getPluginManager().callEvent(event);
if(!edbpe.isCancelled()) { if(!event.isCancelled()) {
// this function returns if the egg should stick or not, i.e. !bounce // this function returns if the egg should stick or not, i.e. !bounce
bounce = !movingobjectposition.g.a(((Entity) (ak)), edbpe.getDamage()); stick = movingobjectposition.g.a(this.ak, event.getDamage());
} else { } else {
// event was cancelled, get if the egg should bounce or not // event was cancelled, get if the egg should bounce or not
bounce = edbpe.getBounce(); stick = !event.getBounce();
} }
} else { } else {
bounce = !movingobjectposition.g.a(((Entity) (ak)), 0); stick = movingobjectposition.g.a(this.ak, 0);
} }
if (!bounce) {
// CraftBukkit end if (stick) {
; ; // Original code does nothing *yet*
} }
} }
// CraftBukkit start // CraftBukkit start
boolean hatching = !this.l.z && W.nextInt(8) == 0; boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0;
byte numHatching = (hatching && W.nextInt(32) == 0) ? (byte) 4 : (byte) 1; byte numHatching = (this.random.nextInt(32) == 0) ? (byte) 4 : (byte) 1;
if (!hatching) { if (!hatching) {
numHatching = 0; numHatching = 0;
} }
MobType hatchingType = MobType.CHICKEN; MobType hatchingType = MobType.CHICKEN;
if (ak instanceof EntityPlayerMP) { if (this.ak instanceof EntityPlayer) {
CraftServer server = ((WorldServer) l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.PLAYER_EGG_THROW; Type eventType = Type.PLAYER_EGG_THROW;
Player player = (ak == null)?null:(Player) ak.getBukkitEntity(); Player player = (this.ak == null) ? null : (Player) this.ak.getBukkitEntity();
PlayerEggThrowEvent event = new PlayerEggThrowEvent( PlayerEggThrowEvent event = new PlayerEggThrowEvent(eventType, player, (Egg)this.getBukkitEntity(), hatching, numHatching, hatchingType);
eventType, player, (Egg)this.bukkitEntity, hatching,
numHatching, hatchingType);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
hatching = event.isHatching(); hatching = event.isHatching();
numHatching = event.getNumHatches(); numHatching = event.getNumHatches();
@ -224,116 +216,124 @@ public class EntityEgg extends Entity {
Entity entity = null; Entity entity = null;
switch (hatchingType) { switch (hatchingType) {
case CHICKEN: case CHICKEN:
entity = new EntityChicken(this.l); entity = new EntityChicken(this.world);
break; break;
case COW: case COW:
entity = new EntityCow(this.l); entity = new EntityCow(this.world);
break; break;
case CREEPER: case CREEPER:
entity = new EntityCreeper(this.l); entity = new EntityCreeper(this.world);
break; break;
case GHAST: case GHAST:
entity = new EntityGhast(this.l); entity = new EntityGhast(this.world);
break; break;
case PIG: case PIG:
entity = new EntityPig(this.l); entity = new EntityPig(this.world);
break; break;
case PIG_ZOMBIE: case PIG_ZOMBIE:
entity = new EntityPigZombie(this.l); entity = new EntityPigZombie(this.world);
break; break;
case SHEEP: case SHEEP:
entity = new EntitySheep(this.l); entity = new EntitySheep(this.world);
break; break;
case SKELETON: case SKELETON:
entity = new EntitySkeleton(this.l); entity = new EntitySkeleton(this.world);
break; break;
case SPIDER: case SPIDER:
entity = new EntitySpider(this.l); entity = new EntitySpider(this.world);
break; break;
case ZOMBIE: case ZOMBIE:
entity = new EntityZombie(this.l); entity = new EntityZombie(this.world);
break; break;
case SQUID: case SQUID:
entity = new EntitySquid(this.l); entity = new EntitySquid(this.world);
break; break;
default: default:
entity = new EntityChicken(this.l); entity = new EntityChicken(this.world);
break; break;
} }
entity.c(p, q, r, v, 0.0F);
this.l.a(entity); entity.c(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
this.world.a(entity);
} }
} }
// CraftBukkit end // CraftBukkit end
for (int j = 0; j < 8; j++) { for (int l = 0; l < 8; ++l) {
this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D); this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
} }
q(); this.q();
} }
p += s;
q += t;
r += u;
float f1 = MathHelper.a(s * s + u * u);
v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); this.locX += this.motX;
for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) { this.locY += this.motY;
this.locZ += this.motZ;
float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
; ;
} }
for (; w - y >= 180F; y += 360F) {
; while (this.pitch - this.lastPitch >= 180.0F) {
this.lastPitch += 360.0F;
} }
for (; v - x < -180F; x -= 360F) {
; while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
} }
for (; v - x >= 180F; x += 360F) {
; while (this.yaw - this.lastYaw >= 180.0F) {
this.lastYaw += 360.0F;
} }
w = y + (w - y) * 0.2F;
v = x + (v - x) * 0.2F; this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.99F; float f2 = 0.99F;
float f5 = 0.03F; float f3 = 0.03F;
if (v()) { if (this.v()) {
for (int i1 = 0; i1 < 4; i1++) { for (int i1 = 0; i1 < 4; ++i1) {
float f3 = 0.25F; float f4 = 0.25F;
this.l.a("bubble", p - s * (double) f3, q - t * (double) f3, r - u * (double) f3, s, t, u); this.world.a("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);
} }
f2 = 0.8F; f2 = 0.8F;
} }
s *= f2;
t *= f2; this.motX *= (double) f2;
u *= f2; this.motY *= (double) f2;
t -= f5; this.motZ *= (double) f2;
a(p, q, r); this.motY -= (double) f3;
this.a(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("xTile", (short) b); nbttagcompound.a("xTile", (short) this.b);
nbttagcompound.a("yTile", (short) c); nbttagcompound.a("yTile", (short) this.c);
nbttagcompound.a("zTile", (short) d); nbttagcompound.a("zTile", (short) this.d);
nbttagcompound.a("inTile", (byte) e); nbttagcompound.a("inTile", (byte) this.e);
nbttagcompound.a("shake", (byte) a); nbttagcompound.a("shake", (byte) this.a);
nbttagcompound.a("inGround", (byte) (f ? 1 : 0)); nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
b = ((int) (nbttagcompound.c("xTile"))); this.b = nbttagcompound.c("xTile");
c = ((int) (nbttagcompound.c("yTile"))); this.c = nbttagcompound.c("yTile");
d = ((int) (nbttagcompound.c("zTile"))); this.d = nbttagcompound.c("zTile");
e = nbttagcompound.b("inTile") & 0xff; this.e = nbttagcompound.b("inTile") & 255;
a = nbttagcompound.b("shake") & 0xff; this.a = nbttagcompound.b("shake") & 255;
f = nbttagcompound.b("inGround") == 1; this.f = nbttagcompound.b("inGround") == 1;
} }
public void b(EntityPlayer entityplayer) { public void b(EntityHuman entityhuman) {
if (f && ak == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) { if (this.f && this.ak == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F); this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.c(((Entity) (this)), 1); entityhuman.c(this, 1);
q(); this.q();
} }
} }
} }

View File

@ -8,81 +8,81 @@ import org.bukkit.craftbukkit.entity.CraftFallingSand;
public class EntityFallingSand extends Entity { public class EntityFallingSand extends Entity {
public int a; public int a;
public int b; public int b = 0;
public EntityFallingSand(World world) { public EntityFallingSand(World world) {
super(world); super(world);
b = 0;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFallingSand(server, this); this.bukkitEntity = new CraftFallingSand(server, this);
// CraftBukkit end // CraftBukkit end
} }
public EntityFallingSand(World world, double d, double d1, double d2, int i) { public EntityFallingSand(World world, double d0, double d1, double d2, int i) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end this.a = i;
a = i;
this.i = true; this.i = true;
a(0.98F, 0.98F); this.a(0.98F, 0.98F);
H = J / 2.0F; this.height = this.width / 2.0F;
a(d, d1, d2); this.a(d0, d1, d2);
s = 0.0D; this.motX = 0.0D;
t = 0.0D; this.motY = 0.0D;
u = 0.0D; this.motZ = 0.0D;
M = false; this.M = false;
m = d; this.lastX = d0;
n = d1; this.lastY = d1;
o = d2; this.lastZ = d2;
} }
protected void a() {} protected void a() {}
public boolean c_() { public boolean c_() {
return !G; return !this.dead;
} }
public void b_() { public void b_() {
if (a == 0) { if (this.a == 0) {
q(); this.q();
return; } else {
} this.lastX = this.locX;
m = p; this.lastY = this.locY;
n = q; this.lastZ = this.locZ;
o = r; ++this.b;
b++; this.motY -= 0.03999999910593033D;
t -= 0.039999999105930328D; this.c(this.motX, this.motY, this.motZ);
c(s, t, u); this.motX *= 0.9800000190734863D;
s *= 0.98000001907348633D; this.motY *= 0.9800000190734863D;
t *= 0.98000001907348633D; this.motZ *= 0.9800000190734863D;
u *= 0.98000001907348633D; int i = MathHelper.b(this.locX);
int i = MathHelper.b(p); int j = MathHelper.b(this.locY);
int j = MathHelper.b(q); int k = MathHelper.b(this.locZ);
int k = MathHelper.b(r);
if (l.a(i, j, k) == a) { if (this.world.getTypeId(i, j, k) == this.a) {
l.e(i, j, k, 0); this.world.e(i, j, k, 0);
} }
if (A) {
s *= 0.69999998807907104D; if (this.onGround) {
u *= 0.69999998807907104D; this.motX *= 0.699999988079071D;
t *= -0.5D; this.motZ *= 0.699999988079071D;
q(); this.motY *= -0.5D;
if ((!l.a(a, i, j, k, true) || !l.e(i, j, k, a)) && !l.z) { this.q();
a(a, 1); if ((!this.world.a(this.a, i, j, k, true) || !this.world.e(i, j, k, this.a)) && !this.world.isStatic) {
this.a(this.a, 1);
}
} else if (this.b > 100 && !this.world.isStatic) {
this.a(this.a, 1);
this.q();
} }
} else if (b > 100 && !l.z) {
a(a, 1);
q();
} }
} }
protected void a(NBTTagCompound nbttagcompound) { protected void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Tile", (byte) a); nbttagcompound.a("Tile", (byte) this.a);
} }
protected void b(NBTTagCompound nbttagcompound) { protected void b(NBTTagCompound nbttagcompound) {
a = nbttagcompound.b("Tile") & 0xff; this.a = nbttagcompound.b("Tile") & 255;
} }
} }

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftFireball; import org.bukkit.craftbukkit.entity.CraftFireball;
@ -11,215 +10,218 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end // CraftBukkit end
public class EntityFireball extends Entity { public class EntityFireball extends Entity {
private int e; private int e = -1;
private int f; private int f = -1;
private int ak; private int ak = -1;
private int al; private int al = 0;
private boolean am; private boolean am = false;
public int a; public int a = 0;
private EntityLiving an; private EntityLiving an;
private int ao; private int ao;
private int ap; private int ap = 0;
public double b; public double b;
public double c; public double c;
public double d; public double d;
public EntityFireball(World world) { public EntityFireball(World world) {
super(world); super(world);
e = -1; this.a(1.0F, 1.0F);
f = -1;
ak = -1;
al = 0;
am = false;
a = 0;
ap = 0;
a(1.0F, 1.0F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFireball(server, this); this.bukkitEntity = new CraftFireball(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected void a() {} protected void a() {}
public EntityFireball(World world, EntityLiving entityliving, double d1, double d2, double d3) { public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end
an = entityliving;
c(entityliving.p, entityliving.q, entityliving.r, entityliving.v, entityliving.w);
a(p, q, r);
H = 0.0F;
s = t = u = 0.0D;
d1 += W.nextGaussian() * 0.40000000000000002D;
d2 += W.nextGaussian() * 0.40000000000000002D;
d3 += W.nextGaussian() * 0.40000000000000002D;
double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
b = (d1 / d4) * 0.10000000000000001D; this.an = entityliving;
c = (d2 / d4) * 0.10000000000000001D; this.a(1.0F, 1.0F);
d = (d3 / d4) * 0.10000000000000001D; this.c(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.a(this.locX, this.locY, this.locZ);
this.height = 0.0F;
this.motX = this.motY = this.motZ = 0.0D;
d0 += this.random.nextGaussian() * 0.4D;
d1 += this.random.nextGaussian() * 0.4D;
d2 += this.random.nextGaussian() * 0.4D;
double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
this.b = d0 / d3 * 0.1D;
this.c = d1 / d3 * 0.1D;
this.d = d2 / d3 * 0.1D;
} }
public void b_() { public void b_() {
super.b_(); super.b_();
Z = 10; this.fireTicks = 10;
if (a > 0) { if (this.a > 0) {
a--; --this.a;
} }
if (am) {
int i = l.a(e, f, ak);
if (i != al) { if (this.am) {
am = false; int i = this.world.getTypeId(this.e, this.f, this.ak);
s *= W.nextFloat() * 0.2F;
t *= W.nextFloat() * 0.2F; if (i == this.al) {
u *= W.nextFloat() * 0.2F; ++this.ao;
ao = 0; if (this.ao == 1200) {
ap = 0; this.q();
} else {
ao++;
if (ao == 1200) {
q();
} }
return; return;
} }
} else {
ap++;
}
Vec3D vec3d = Vec3D.b(p, q, r);
Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
MovingObjectPosition movingobjectposition = l.a(vec3d, vec3d1);
vec3d = Vec3D.b(p, q, r); this.am = false;
vec3d1 = Vec3D.b(p + s, q + t, r + u); 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.ao = 0;
this.ap = 0;
} else {
++this.ap;
}
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) { if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
Entity entity = null;
List list = l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
double d1 = 0.0D;
for (int j = 0; j < list.size(); j++) { Entity entity = null;
List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j); Entity entity1 = (Entity) list.get(j);
if (!entity1.c_() || entity1 == an && ap < 25) { if (entity1.c_() && (entity1 != this.an || this.ap >= 25)) {
continue; float f = 0.3F;
} AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
float f3 = 0.3F; MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
AxisAlignedBB axisalignedbb = entity1.z.b(f3, f3, f3);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 == null) { if (movingobjectposition1 != null) {
continue; double d1 = vec3d.a(movingobjectposition1.f);
}
double d2 = vec3d.a(movingobjectposition1.f);
if (d2 < d1 || d1 == 0.0D) { if (d1 < d0 || d0 == 0.0D) {
entity = entity1; entity = entity1;
d1 = d2; d0 = d1;
}
}
} }
} }
if (entity != null) { if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity); movingobjectposition = new MovingObjectPosition(entity);
} }
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.g != null) {
// CraftBukkit start boolean stick;
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (an == null)?null:an.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.an == null) ? null : this.an.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity(); org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(edbpe); server.getPluginManager().callEvent(event);
if(!edbpe.isCancelled()) { if(!event.isCancelled()) {
// this function returns if the fireball should stick or not, i.e. !bounce // this function returns if the fireball should stick or not, i.e. !bounce
bounce = !movingobjectposition.g.a(((Entity) (an)), edbpe.getDamage()); stick = movingobjectposition.g.a(this.an, event.getDamage());
} else { } else {
// event was cancelled, get if the fireball should bounce or not // event was cancelled, get if the fireball should bounce or not
bounce = edbpe.getBounce(); stick = !event.getBounce();
} }
} else { } else {
bounce = !movingobjectposition.g.a(((Entity) (an)), 0); stick = movingobjectposition.g.a(this.an, 0);
} }
if (!bounce) { if (stick) {
// CraftBukkit end // CraftBukkit end
; ;
} }
} }
l.a(((Entity) (null)), p, q, r, 1.0F, true); // CraftBukkit end
q();
}
p += s;
q += t;
r += u;
float f1 = MathHelper.a(s * s + u * u);
v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); this.world.a((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true);
for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) { this.q();
}
this.locX += this.motX;
this.locY += this.motY;
this.locZ += this.motZ;
float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
; ;
} }
for (; w - y >= 180F; y += 360F) {
; while (this.pitch - this.lastPitch >= 180.0F) {
this.lastPitch += 360.0F;
} }
for (; v - x < -180F; x -= 360F) {
; while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
} }
for (; v - x >= 180F; x += 360F) {
; while (this.yaw - this.lastYaw >= 180.0F) {
this.lastYaw += 360.0F;
} }
w = y + (w - y) * 0.2F;
v = x + (v - x) * 0.2F; this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.95F; float f2 = 0.95F;
if (v()) { if (this.v()) {
for (int k = 0; k < 4; k++) { for (int k = 0; k < 4; ++k) {
float f4 = 0.25F; float f3 = 0.25F;
l.a("bubble", p - s * (double) f4, q - t * (double) f4, r - u * (double) f4, s, t, u); this.world.a("bubble", this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ);
} }
f2 = 0.8F; f2 = 0.8F;
} }
s += b;
t += c; this.motX += this.b;
u += d; this.motY += this.c;
s *= f2; this.motZ += this.d;
t *= f2; this.motX *= (double) f2;
u *= f2; this.motY *= (double) f2;
l.a("smoke", p, q + 0.5D, r, 0.0D, 0.0D, 0.0D); this.motZ *= (double) f2;
a(p, q, r); this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
this.a(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("xTile", (short) e); nbttagcompound.a("xTile", (short) this.e);
nbttagcompound.a("yTile", (short) f); nbttagcompound.a("yTile", (short) this.f);
nbttagcompound.a("zTile", (short) ak); nbttagcompound.a("zTile", (short) this.ak);
nbttagcompound.a("inTile", (byte) al); nbttagcompound.a("inTile", (byte) this.al);
nbttagcompound.a("shake", (byte) a); nbttagcompound.a("shake", (byte) this.a);
nbttagcompound.a("inGround", (byte) (am ? 1 : 0)); nbttagcompound.a("inGround", (byte) (this.am ? 1 : 0));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
e = ((int) (nbttagcompound.c("xTile"))); this.e = nbttagcompound.c("xTile");
f = ((int) (nbttagcompound.c("yTile"))); this.f = nbttagcompound.c("yTile");
ak = ((int) (nbttagcompound.c("zTile"))); this.ak = nbttagcompound.c("zTile");
al = nbttagcompound.b("inTile") & 0xff; this.al = nbttagcompound.b("inTile") & 255;
a = nbttagcompound.b("shake") & 0xff; this.a = nbttagcompound.b("shake") & 255;
am = nbttagcompound.b("inGround") == 1; this.am = nbttagcompound.b("inGround") == 1;
} }
public boolean c_() { public boolean c_() {
@ -227,18 +229,19 @@ public class EntityFireball extends Entity {
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
y(); this.y();
if (entity != null) { if (entity != null) {
Vec3D vec3d = entity.G(); Vec3D vec3d = entity.G();
if (vec3d != null) { if (vec3d != null) {
s = vec3d.a; this.motX = vec3d.a;
t = vec3d.b; this.motY = vec3d.b;
u = vec3d.c; this.motZ = vec3d.c;
b = s * 0.10000000000000001D; this.b = this.motX * 0.1D;
c = t * 0.10000000000000001D; this.c = this.motY * 0.1D;
d = u * 0.10000000000000001D; this.d = this.motZ * 0.1D;
} }
return true; return true;
} else { } else {
return false; return false;

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftFish; import org.bukkit.craftbukkit.entity.CraftFish;
@ -13,17 +12,17 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntityFish extends Entity { public class EntityFish extends Entity {
private int d; private int d = -1;
private int e; private int e = -1;
private int f; private int f = -1;
private int ak; private int ak = 0;
private boolean al; private boolean al = false;
public int a; public int a = 0;
public EntityPlayer b; public EntityHuman b;
private int am; private int am;
private int an; private int an = 0;
private int ao; private int ao = 0;
public Entity c; public Entity c = null;
private int ap; private int ap;
private double aq; private double aq;
private double ar; private double ar;
@ -33,332 +32,345 @@ public class EntityFish extends Entity {
public EntityFish(World world) { public EntityFish(World world) {
super(world); super(world);
d = -1; this.a(0.25F, 0.25F);
e = -1;
f = -1;
ak = 0;
al = false;
a = 0;
an = 0;
ao = 0;
c = null;
a(0.25F, 0.25F);
//CraftBukkit start //CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFish(server, this); this.bukkitEntity = new CraftFish(server, this);
//CraftBukkit end //CraftBukkit end
} }
protected void a() {} protected void a() {}
public EntityFish(World world, EntityPlayer entityplayer) { public EntityFish(World world, EntityHuman entityhuman) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end
b = entityplayer;
b.aE = this;
c(entityplayer.p, (entityplayer.q + 1.6200000000000001D) - (double) entityplayer.H, entityplayer.r, entityplayer.v, entityplayer.w);
p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
q -= 0.10000000149011612D;
r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
a(p, q, r);
H = 0.0F;
float f1 = 0.4F;
s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.b = entityhuman;
u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.b.hookedFish = this;
t = -MathHelper.a((w / 180F) * 3.141593F) * f1; this.a(0.25F, 0.25F);
a(s, t, u, 1.5F, 1.0F); this.c(entityhuman.locX, entityhuman.locY + 1.62D - (double) entityhuman.height, entityhuman.locZ, entityhuman.yaw, entityhuman.pitch);
this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ);
this.height = 0.0F;
float f = 0.4F;
this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
public void a(double d1, double d2, double d3, float f1, float f2) { public void a(double d0, double d1, double d2, float f, float f1) {
float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d1 /= f3; d0 /= (double) f2;
d2 /= f3; d1 /= (double) f2;
d3 /= f3; d2 /= (double) f2;
d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d1 *= f1; d0 *= (double) f;
d2 *= f1; d1 *= (double) f;
d3 *= f1; d2 *= (double) f;
s = d1; this.motX = d0;
t = d2; this.motY = d1;
u = d3; this.motZ = d2;
float f4 = MathHelper.a(d1 * d1 + d3 * d3); float f3 = MathHelper.a(d0 * d0 + d2 * d2);
x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D); this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
am = 0; this.am = 0;
} }
public void b_() { public void b_() {
super.b_(); super.b_();
if (ap > 0) { if (this.ap > 0) {
double d1 = p + (aq - p) / (double) ap; double d0 = this.locX + (this.aq - this.locX) / (double) this.ap;
double d2 = q + (ar - q) / (double) ap; double d1 = this.locY + (this.ar - this.locY) / (double) this.ap;
double d3 = r + (as - r) / (double) ap; double d2 = this.locZ + (this.as - this.locZ) / (double) this.ap;
double d4;
for (d4 = at - (double) v; d4 < -180D; d4 += 360D) { double d3;
for (d3 = this.at - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) {
; ;
} }
for (; d4 >= 180D; d4 -= 360D) {
;
}
v += ((float) (d4 / (double) ap));
w += ((float) ((au - (double) w) / (double) ap));
ap--;
a(d1, d2, d3);
b(v, w);
return;
}
if (!this.l.z) {
ItemStack itemstack = b.P();
if (b.G || !b.B() || itemstack == null || itemstack.a() != Item.aP || b(((Entity) (b))) > 1024D) { while (d3 >= 180.0D) {
q(); d3 -= 360.0D;
b.aE = null;
return;
} }
if (c != null) {
if (c.G) { this.yaw = (float) ((double) this.yaw + d3 / (double) this.ap);
c = null; this.pitch = (float) ((double) this.pitch + (this.au - (double) this.pitch) / (double) this.ap);
} else { --this.ap;
p = c.p; this.a(d0, d1, d2);
q = c.z.b + (double) c.J * 0.80000000000000004D; this.b(this.yaw, this.pitch);
r = c.r; } else {
if (!this.world.isStatic) {
ItemStack itemstack = this.b.P();
// CraftBukkit - cast this.b to Entity
if (this.b.dead || !this.b.B() || itemstack == null || itemstack.a() != Item.FISHING_ROD || this.b((Entity) this.b) > 1024.0D) {
this.q();
this.b.hookedFish = null;
return; return;
} }
}
}
if (a > 0) {
a--;
}
if (al) {
int i = this.l.a(d, e, f);
if (i != ak) { if (this.c != null) {
al = false; if (!this.c.dead) {
s *= W.nextFloat() * 0.2F; this.locX = this.c.locX;
t *= W.nextFloat() * 0.2F; this.locY = this.c.boundingBox.b + (double) this.c.width * 0.8D;
u *= W.nextFloat() * 0.2F; this.locZ = this.c.locZ;
am = 0; return;
an = 0;
} else {
am++;
if (am == 1200) {
q();
}
return;
}
} else {
an++;
}
Vec3D vec3d = Vec3D.b(p, q, r);
Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
vec3d = Vec3D.b(p, q, r);
vec3d1 = Vec3D.b(p + s, q + t, r + u);
if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
Entity entity = null;
List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
double d5 = 0.0D;
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
if (!entity1.c_() || entity1 == b && an < 5) {
continue;
}
float f3 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.z.b(f3, f3, f3);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 == null) {
continue;
}
double d6 = vec3d.a(movingobjectposition1.f);
if (d6 < d5 || d5 == 0.0D) {
entity = entity1;
d5 = d6;
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null) {
if (movingobjectposition.g != null) {
// CraftBukkit start
// TODO add EntityDamagedByProjectileEvent : fishing hook?
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer();
org.bukkit.entity.Entity shooter = (b == null)?null:b.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0;
// TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(edbpe);
if(!edbpe.isCancelled()) {
// this function returns if the fish should stick or not, i.e. !bounce
bounce = !movingobjectposition.g.a(((Entity) (b)), edbpe.getDamage());
} else {
// event was cancelled, get if the fish should bounce or not
bounce = edbpe.getBounce();
} }
} else {
bounce = !movingobjectposition.g.a(((Entity) (b)), 0); this.c = null;
} }
if (!bounce) { }
// CraftBukkit end
c = movingobjectposition.g; if (this.a > 0) {
--this.a;
}
if (this.al) {
int i = this.world.getTypeId(this.d, this.e, this.f);
if (i == this.ak) {
++this.am;
if (this.am == 1200) {
this.q();
}
return;
} }
this.al = false;
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.am = 0;
this.an = 0;
} else { } else {
al = true; ++this.an;
} }
}
if (al) {
return;
}
c(s, t, u);
float f1 = MathHelper.a(s * s + u * u);
v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) { Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
; MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
}
for (; w - y >= 180F; y += 360F) {
;
}
for (; v - x < -180F; x -= 360F) {
;
}
for (; v - x >= 180F; x += 360F) {
;
}
w = y + (w - y) * 0.2F;
v = x + (v - x) * 0.2F;
float f2 = 0.92F;
if (A || B) { vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
f2 = 0.5F; vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
} if (movingobjectposition != null) {
int k = 5; vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
double d8 = 0.0D;
for (int l = 0; l < k; l++) {
double d9 = ((z.b + ((z.e - z.b) * (double) (l + 0)) / (double) k) - 0.125D) + 0.125D;
double d10 = ((z.b + ((z.e - z.b) * (double) (l + 1)) / (double) k) - 0.125D) + 0.125D;
AxisAlignedBB axisalignedbb1 = AxisAlignedBB.b(z.a, d9, z.c, z.d, d10, z.f);
if (this.l.b(axisalignedbb1, Material.f)) {
d8 += 1.0D / (double) k;
} }
}
if (d8 > 0.0D) { Entity entity = null;
if (ao > 0) { List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
ao--; double d4 = 0.0D;
} else if (W.nextInt(500) == 0) {
ao = W.nextInt(30) + 10;
t -= 0.20000000298023224D;
this.l.a(((Entity) (this)), "random.splash", 0.25F, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F);
float f4 = MathHelper.b(z.b);
for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) { double d5;
float f5 = (W.nextFloat() * 2.0F - 1.0F) * I;
float f7 = (W.nextFloat() * 2.0F - 1.0F) * I;
this.l.a("bubble", p + (double) f5, f4 + 1.0F, r + (double) f7, s, t - (double) (W.nextFloat() * 0.2F), u); for (int j = 0; j < list.size(); ++j) {
} Entity entity1 = (Entity) list.get(j);
for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) { if (entity1.c_() && (entity1 != this.b || this.an >= 5)) {
float f6 = (W.nextFloat() * 2.0F - 1.0F) * I; float f = 0.3F;
float f8 = (W.nextFloat() * 2.0F - 1.0F) * I; AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
this.l.a("splash", p + (double) f6, f4 + 1.0F, r + (double) f8, s, t, u); if (movingobjectposition1 != null) {
d5 = vec3d.a(movingobjectposition1.f);
if (d5 < d4 || d4 == 0.0D) {
entity = entity1;
d4 = d5;
}
}
} }
} }
}
if (ao > 0) {
t -= (double) (W.nextFloat() * W.nextFloat() * W.nextFloat()) * 0.20000000000000001D;
}
double d7 = d8 * 2D - 1.0D;
t += 0.039999999105930328D * d7; if (entity != null) {
if (d8 > 0.0D) { movingobjectposition = new MovingObjectPosition(entity);
f2 = (float) ((double) f2 * 0.90000000000000002D); }
t *= 0.80000000000000004D;
if (movingobjectposition != null) {
if (movingobjectposition.g != null) {
// CraftBukkit start
// TODO add EntityDamagedByProjectileEvent : fishing hook?
boolean stick;
if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (this.b == null) ? null : this.b.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0;
// TODO @see EntityArrow#162
EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(event);
if(!event.isCancelled()) {
// this function returns if the fish should stick or not, i.e. !bounce
stick = movingobjectposition.g.a(this.b, event.getDamage());
} else {
// event was cancelled, get if the fish should bounce or not
stick = !event.getBounce();
}
} else {
stick = movingobjectposition.g.a(this.b, 0);
}
if (!stick) {
c = movingobjectposition.g;
}
// CraftBukkit end
} else {
this.al = true;
}
}
if (!this.al) {
this.c(this.motX, this.motY, this.motZ);
float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
;
}
while (this.pitch - this.lastPitch >= 180.0F) {
this.lastPitch += 360.0F;
}
while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
}
while (this.yaw - this.lastYaw >= 180.0F) {
this.lastYaw += 360.0F;
}
this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.92F;
if (this.onGround || this.B) {
f2 = 0.5F;
}
byte b0 = 5;
double d6 = 0.0D;
for (int k = 0; k < b0; ++k) {
double d7 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (k + 0) / (double) b0 - 0.125D + 0.125D;
double d8 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (k + 1) / (double) b0 - 0.125D + 0.125D;
AxisAlignedBB axisalignedbb1 = AxisAlignedBB.b(this.boundingBox.a, d7, this.boundingBox.c, this.boundingBox.d, d8, this.boundingBox.f);
if (this.world.b(axisalignedbb1, Material.WATER)) {
d6 += 1.0D / (double) b0;
}
}
if (d6 > 0.0D) {
if (this.ao > 0) {
--this.ao;
} else if (this.random.nextInt(500) == 0) {
this.ao = this.random.nextInt(30) + 10;
this.motY -= 0.20000000298023224D;
this.world.a(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
float f3 = (float) MathHelper.b(this.boundingBox.b);
int l;
float f4;
float f5;
for (l = 0; (float) l < 1.0F + this.length * 20.0F; ++l) {
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
this.world.a("bubble", this.locX + (double) f4, (double) (f3 + 1.0F), this.locZ + (double) f5, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ);
}
for (l = 0; (float) l < 1.0F + this.length * 20.0F; ++l) {
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
this.world.a("splash", this.locX + (double) f4, (double) (f3 + 1.0F), this.locZ + (double) f5, this.motX, this.motY, this.motZ);
}
}
}
if (this.ao > 0) {
this.motY -= (double) (this.random.nextFloat() * this.random.nextFloat() * this.random.nextFloat()) * 0.2D;
}
d5 = d6 * 2.0D - 1.0D;
this.motY += 0.03999999910593033D * d5;
if (d6 > 0.0D) {
f2 = (float) ((double) f2 * 0.9D);
this.motY *= 0.8D;
}
this.motX *= (double) f2;
this.motY *= (double) f2;
this.motZ *= (double) f2;
this.a(this.locX, this.locY, this.locZ);
}
} }
s *= f2;
t *= f2;
u *= f2;
a(p, q, r);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("xTile", (short) d); nbttagcompound.a("xTile", (short) this.d);
nbttagcompound.a("yTile", (short) e); nbttagcompound.a("yTile", (short) this.e);
nbttagcompound.a("zTile", (short) f); nbttagcompound.a("zTile", (short) this.f);
nbttagcompound.a("inTile", (byte) ak); nbttagcompound.a("inTile", (byte) this.ak);
nbttagcompound.a("shake", (byte) a); nbttagcompound.a("shake", (byte) this.a);
nbttagcompound.a("inGround", (byte) (al ? 1 : 0)); nbttagcompound.a("inGround", (byte) (this.al ? 1 : 0));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
d = ((int) (nbttagcompound.c("xTile"))); this.d = nbttagcompound.c("xTile");
e = ((int) (nbttagcompound.c("yTile"))); this.e = nbttagcompound.c("yTile");
f = ((int) (nbttagcompound.c("zTile"))); this.f = nbttagcompound.c("zTile");
ak = nbttagcompound.b("inTile") & 0xff; this.ak = nbttagcompound.b("inTile") & 255;
a = nbttagcompound.b("shake") & 0xff; this.a = nbttagcompound.b("shake") & 255;
al = nbttagcompound.b("inGround") == 1; this.al = nbttagcompound.b("inGround") == 1;
} }
public int d() { public int d() {
byte byte0 = 0; byte b0 = 0;
if (c != null) { if (this.c != null) {
double d1 = b.p - p; double d0 = this.b.locX - this.locX;
double d2 = b.q - q; double d1 = this.b.locY - this.locY;
double d3 = b.r - r; double d2 = this.b.locZ - this.locZ;
double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
double d5 = 0.10000000000000001D; double d4 = 0.1D;
c.s += d1 * d5; this.c.motX += d0 * d4;
c.t += d2 * d5 + (double) MathHelper.a(d4) * 0.080000000000000002D; this.c.motY += d1 * d4 + (double) MathHelper.a(d3) * 0.08D;
c.u += d3 * d5; this.c.motZ += d2 * d4;
byte0 = 3; b0 = 3;
} else if (ao > 0) { } else if (this.ao > 0) {
EntityItem entityitem = new EntityItem(l, p, q, r, new ItemStack(Item.aS)); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH));
double d6 = b.p - p; double d5 = this.b.locX - this.locX;
double d7 = b.q - q; double d6 = this.b.locY - this.locY;
double d8 = b.r - r; double d7 = this.b.locZ - this.locZ;
double d9 = MathHelper.a(d6 * d6 + d7 * d7 + d8 * d8); double d8 = (double) MathHelper.a(d5 * d5 + d6 * d6 + d7 * d7);
double d10 = 0.10000000000000001D; double d9 = 0.1D;
entityitem.s = d6 * d10; entityitem.motX = d5 * d9;
entityitem.t = d7 * d10 + (double) MathHelper.a(d9) * 0.080000000000000002D; entityitem.motY = d6 * d9 + (double) MathHelper.a(d8) * 0.08D;
entityitem.u = d8 * d10; entityitem.motZ = d7 * d9;
l.a(((Entity) (entityitem))); this.world.a((Entity) entityitem);
byte0 = 1; b0 = 1;
} }
if (al) {
byte0 = 2; if (this.al) {
b0 = 2;
} }
q();
b.aE = null; this.q();
return ((int) (byte0)); this.b.hookedFish = null;
return b0;
} }
} }

View File

@ -9,8 +9,9 @@ public class EntityFlying extends EntityLiving {
public EntityFlying(World world) { public EntityFlying(World world) {
super(world); super(world);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFlying(server, this); this.bukkitEntity = new CraftFlying(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -18,56 +19,60 @@ public class EntityFlying extends EntityLiving {
protected void a(float f) {} protected void a(float f) {}
public void c(float f, float f1) { public void c(float f, float f1) {
if (v()) { if (this.v()) {
a(f, f1, 0.02F); this.a(f, f1, 0.02F);
c(s, t, u); this.c(this.motX, this.motY, this.motZ);
s *= 0.80000001192092896D; this.motX *= 0.800000011920929D;
t *= 0.80000001192092896D; this.motY *= 0.800000011920929D;
u *= 0.80000001192092896D; this.motZ *= 0.800000011920929D;
} else if (x()) { } else if (this.x()) {
a(f, f1, 0.02F); this.a(f, f1, 0.02F);
c(s, t, u); this.c(this.motX, this.motY, this.motZ);
s *= 0.5D; this.motX *= 0.5D;
t *= 0.5D; this.motY *= 0.5D;
u *= 0.5D; this.motZ *= 0.5D;
} else { } else {
float f2 = 0.91F; float f2 = 0.91F;
if (A) { if (this.onGround) {
f2 = 0.5460001F; f2 = 0.54600006F;
int i = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r)); int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (i > 0) { if (i > 0) {
f2 = Block.m[i].bu * 0.91F; f2 = Block.byId[i].frictionFactor * 0.91F;
} }
} }
float f3 = 0.1627714F / (f2 * f2 * f2);
a(f, f1, A ? 0.1F * f3 : 0.02F); float f3 = 0.16277136F / (f2 * f2 * f2);
this.a(f, f1, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F; f2 = 0.91F;
if (A) { if (this.onGround) {
f2 = 0.5460001F; f2 = 0.54600006F;
int j = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r)); int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (j > 0) { if (j > 0) {
f2 = Block.m[j].bu * 0.91F; f2 = Block.byId[j].frictionFactor * 0.91F;
} }
} }
c(s, t, u);
s *= f2; this.c(this.motX, this.motY, this.motZ);
t *= f2; this.motX *= (double) f2;
u *= f2; this.motY *= (double) f2;
this.motZ *= (double) f2;
} }
bl = bm;
double d = p - m; this.bl = this.bm;
double d1 = r - o; double d0 = this.locX - this.lastX;
float f4 = MathHelper.a(d * d + d1 * d1) * 4F; double d1 = this.locZ - this.lastZ;
float f4 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F;
if (f4 > 1.0F) { if (f4 > 1.0F) {
f4 = 1.0F; f4 = 1.0F;
} }
bm += (f4 - bm) * 0.4F;
bn += bm; this.bm += (f4 - this.bm) * 0.4F;
this.bn += this.bm;
} }
public boolean m() { public boolean m() {

View File

@ -1,122 +1,122 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftGhast; import org.bukkit.craftbukkit.entity.CraftGhast;
// CraftBukkit end // CraftBukkit end
public class EntityGhast extends EntityFlying implements IMobs { public class EntityGhast extends EntityFlying implements IMonster {
public int a; public int a = 0;
public double b; public double b;
public double c; public double c;
public double d; public double d;
private Entity ak; private Entity ak = null;
private int al; private int al = 0;
public int e; public int e = 0;
public int f; public int f = 0;
public EntityGhast(World world) { public EntityGhast(World world) {
super(world); super(world);
a = 0; this.texture = "/mob/ghast.png";
ak = null; this.a(4.0F, 4.0F);
al = 0; this.ae = true;
e = 0;
f = 0;
aP = "/mob/ghast.png";
a(4F, 4F);
ae = true;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftGhast(server, this); this.bukkitEntity = new CraftGhast(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected void d() { protected void d() {
if (l.k == 0) { if (this.world.k == 0) {
q(); this.q();
} }
e = f;
double d1 = b - p;
double d2 = c - q;
double d3 = d - r;
double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
if (d4 < 1.0D || d4 > 60D) { this.e = this.f;
b = p + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F); double d0 = this.b - this.locX;
c = q + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F); double d1 = this.c - this.locY;
d = r + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F); double d2 = this.d - this.locZ;
double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
if (d3 < 1.0D || d3 > 60.0D) {
this.b = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.c = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
this.d = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
} }
if (a-- <= 0) {
a += W.nextInt(5) + 2; if (this.a-- <= 0) {
if (a(b, c, d, d4)) { this.a += this.random.nextInt(5) + 2;
s += (d1 / d4) * 0.10000000000000001D; if (this.a(this.b, this.c, this.d, d3)) {
t += (d2 / d4) * 0.10000000000000001D; this.motX += d0 / d3 * 0.1D;
u += (d3 / d4) * 0.10000000000000001D; this.motY += d1 / d3 * 0.1D;
this.motZ += d2 / d3 * 0.1D;
} else { } else {
b = p; this.b = this.locX;
c = q; this.c = this.locY;
d = r; this.d = this.locZ;
} }
} }
if (ak != null && ak.G) {
ak = null; if (this.ak != null && this.ak.dead) {
this.ak = null;
} }
if (ak == null || al-- <= 0) {
ak = ((Entity) (l.a(((Entity) (this)), 100D))); if (this.ak == null || this.al-- <= 0) {
if (ak != null) { this.ak = this.world.a(this, 100.0D);
al = 20; if (this.ak != null) {
this.al = 20;
} }
} }
double d5 = 64D;
if (ak != null && ak.b(((Entity) (this))) < d5 * d5) { double d4 = 64.0D;
double d6 = ak.p - p;
double d7 = (ak.z.b + (double) (ak.J / 2.0F)) - (q + (double) (J / 2.0F));
double d8 = ak.r - r;
aI = v = (-(float) Math.atan2(d6, d8) * 180F) / 3.141593F; if (this.ak != null && this.ak.b((Entity) this) < d4 * d4) {
if (i(ak)) { double d5 = this.ak.locX - this.locX;
if (f == 10) { double d6 = this.ak.boundingBox.b + (double) (this.ak.width / 2.0F) - (this.locY + (double) (this.width / 2.0F));
l.a(((Entity) (this)), "mob.ghast.charge", i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F); double d7 = this.ak.locZ - this.locZ;
this.aI = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F;
if (this.i(this.ak)) {
if (this.f == 10) {
this.world.a(this, "mob.ghast.charge", this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
} }
f++;
if (f == 20) {
l.a(((Entity) (this)), "mob.ghast.fireball", i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
EntityFireball entityfireball = new EntityFireball(l, ((EntityLiving) (this)), d6, d7, d8);
double d9 = 4D;
Vec3D vec3d = c(1.0F);
entityfireball.p = p + vec3d.a * d9; ++this.f;
entityfireball.q = q + (double) (J / 2.0F) + 0.5D; if (this.f == 20) {
entityfireball.r = r + vec3d.c * d9; this.world.a(this, "mob.ghast.fireball", this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
l.a(((Entity) (entityfireball))); EntityFireball entityfireball = new EntityFireball(this.world, this, d5, d6, d7);
f = -40; double d8 = 4.0D;
Vec3D vec3d = this.c(1.0F);
entityfireball.locX = this.locX + vec3d.a * d8;
entityfireball.locY = this.locY + (double) (this.width / 2.0F) + 0.5D;
entityfireball.locZ = this.locZ + vec3d.c * d8;
this.world.a((Entity) entityfireball);
this.f = -40;
} }
} else if (f > 0) { } else if (this.f > 0) {
f--; --this.f;
} }
} else { } else {
aI = v = (-(float) Math.atan2(s, u) * 180F) / 3.141593F; this.aI = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F;
if (f > 0) { if (this.f > 0) {
f--; --this.f;
} }
} }
aP = f <= 10 ? "/mob/ghast.png" : "/mob/ghast_fire.png";
this.texture = this.f > 10 ? "/mob/ghast_fire.png" : "/mob/ghast.png";
} }
private boolean a(double d1, double d2, double d3, double d4) { private boolean a(double d0, double d1, double d2, double d3) {
double d5 = (b - p) / d4; double d4 = (this.b - this.locX) / d3;
double d6 = (c - q) / d4; double d5 = (this.c - this.locY) / d3;
double d7 = (d - r) / d4; double d6 = (this.d - this.locZ) / d3;
AxisAlignedBB axisalignedbb = z.b(); AxisAlignedBB axisalignedbb = this.boundingBox.b();
for (int k = 1; (double) k < d4; k++) { for (int i = 1; (double) i < d3; ++i) {
axisalignedbb.d(d5, d6, d7); axisalignedbb.d(d4, d5, d6);
if (l.a(((Entity) (this)), axisalignedbb).size() > 0) { if (this.world.a((Entity) this, axisalignedbb).size() > 0) {
return false; return false;
} }
} }
@ -137,15 +137,15 @@ public class EntityGhast extends EntityFlying implements IMobs {
} }
protected int h() { protected int h() {
return Item.K.ba; return Item.SULPHUR.id;
} }
protected float i() { protected float i() {
return 10F; return 10.0F;
} }
public boolean b() { public boolean b() {
return W.nextInt(20) == 0 && super.b() && l.k > 0; return this.random.nextInt(20) == 0 && super.b() && this.world.k > 0;
} }
public int j() { public int j() {

View File

@ -0,0 +1,28 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftGiant;
// CraftBukkit stop
public class EntityGiantZombie extends EntityMonster {
public EntityGiantZombie(World world) {
super(world);
this.texture = "/mob/zombie.png";
this.bC = 0.5F;
this.c = 50;
this.health *= 10;
this.height *= 6.0F;
this.a(this.length * 6.0F, this.width * 6.0F);
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftGiant(server, this);
// CraftBukkit end
}
protected float a(int i, int j, int k) {
return this.world.l(i, j, k) - 0.5F;
}
}

View File

@ -0,0 +1,391 @@
package net.minecraft.server;
import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end
public abstract class EntityHuman extends EntityLiving {
public InventoryPlayer inventory = new InventoryPlayer(this);
public Container defaultContainer;
public Container activeContainer;
public byte aq = 0;
public int ar = 0;
public float as;
public float at;
public boolean au = false;
public int av = 0;
public String name;
public int dimension;
public double ay;
public double az;
public double aA;
public double aB;
public double aC;
public double aD;
private int a = 0;
public EntityFish hookedFish = null;
public EntityHuman(World world) {
super(world);
this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic);
this.activeContainer = this.defaultContainer;
this.height = 1.62F;
this.c((double) world.spawnX + 0.5D, (double) (world.spawnY + 1), (double) world.spawnZ + 0.5D, 0.0F, 0.0F);
this.health = 20;
this.aS = "humanoid";
this.aR = 180.0F;
this.maxFireTicks = 20;
this.texture = "/mob/char.png";
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftHumanEntity(server, this);
// CraftBukkit end
}
public void b_() {
super.b_();
if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.b(this)) {
this.L();
this.activeContainer = this.defaultContainer;
}
this.ay = this.aB;
this.az = this.aC;
this.aA = this.aD;
double d0 = this.locX - this.aB;
double d1 = this.locY - this.aC;
double d2 = this.locZ - this.aD;
double d3 = 10.0D;
if (d0 > d3) {
this.ay = this.aB = this.locX;
}
if (d2 > d3) {
this.aA = this.aD = this.locZ;
}
if (d1 > d3) {
this.az = this.aC = this.locY;
}
if (d0 < -d3) {
this.ay = this.aB = this.locX;
}
if (d2 < -d3) {
this.aA = this.aD = this.locZ;
}
if (d1 < -d3) {
this.az = this.aC = this.locY;
}
this.aB += d0 * 0.25D;
this.aD += d2 * 0.25D;
this.aC += d1 * 0.25D;
}
protected void L() {
this.activeContainer = this.defaultContainer;
}
public void D() {
super.D();
this.as = this.at;
this.at = 0.0F;
}
protected void d() {
if (this.au) {
++this.av;
if (this.av == 8) {
this.av = 0;
this.au = false;
}
} else {
this.av = 0;
}
this.aY = (float) this.av / 8.0F;
}
public void o() {
if (this.world.k == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) {
this.d(1);
}
this.inventory.f();
this.as = this.at;
super.o();
float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
float f1 = (float) Math.atan(-this.motY * 0.20000000298023224D) * 15.0F;
if (f > 0.1F) {
f = 0.1F;
}
if (!this.onGround || this.health <= 0) {
f = 0.0F;
}
if (this.onGround || this.health <= 0) {
f1 = 0.0F;
}
this.at += (f - this.at) * 0.4F;
this.bh += (f1 - this.bh) * 0.8F;
if (this.health > 0) {
List list = this.world.b((Entity) this, this.boundingBox.b(1.0D, 0.0D, 1.0D));
if (list != null) {
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
if (!entity.dead) {
this.j(entity);
}
}
}
}
}
private void j(Entity entity) {
entity.b(this);
}
public void f(Entity entity) {
super.f(entity);
this.a(0.2F, 0.2F);
this.a(this.locX, this.locY, this.locZ);
this.motY = 0.10000000149011612D;
if (this.name.equals("Notch")) {
this.a(new ItemStack(Item.APPLE, 1), true);
}
this.inventory.h();
if (entity != null) {
this.motX = (double) (-MathHelper.b((this.bd + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
this.motZ = (double) (-MathHelper.a((this.bd + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
} else {
this.motX = this.motZ = 0.0D;
}
this.height = 0.1F;
}
public void b(Entity entity, int i) {
this.ar += i;
}
public void O() {
this.a(this.inventory.b(this.inventory.c, 1), false);
}
public void b(ItemStack itemstack) {
this.a(itemstack, false);
}
public void a(ItemStack itemstack, boolean flag) {
if (itemstack != null) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.w(), this.locZ, itemstack);
entityitem.c = 40;
float f = 0.1F;
float f1;
if (flag) {
f1 = this.random.nextFloat() * 0.5F;
float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;
entityitem.motX = (double) (-MathHelper.a(f2) * f1);
entityitem.motZ = (double) (MathHelper.b(f2) * f1);
entityitem.motY = 0.20000000298023224D;
} else {
f = 0.3F;
entityitem.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
entityitem.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
entityitem.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
f = 0.02F;
f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
f *= this.random.nextFloat();
entityitem.motX += Math.cos((double) f1) * (double) f;
entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.motZ += Math.sin((double) f1) * (double) f;
}
this.a(entityitem);
}
}
protected void a(EntityItem entityitem) {
this.world.a((Entity) entityitem);
}
public float a(Block block) {
float f = this.inventory.a(block);
if (this.a(Material.WATER)) {
f /= 5.0F;
}
if (!this.onGround) {
f /= 5.0F;
}
return f;
}
public boolean b(Block block) {
return this.inventory.b(block);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Inventory");
this.inventory.b(nbttaglist);
this.dimension = nbttagcompound.d("Dimension");
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
nbttagcompound.a("Inventory", (NBTBase) this.inventory.a(new NBTTagList()));
nbttagcompound.a("Dimension", this.dimension);
}
public void a(IInventory iinventory) {}
public void a(int i, int j, int k) {}
public void c(Entity entity, int i) {}
public float w() {
return 0.12F;
}
public boolean a(Entity entity, int i) {
this.bw = 0;
if (this.health <= 0) {
return false;
} else {
if (entity instanceof EntityMonster || entity instanceof EntityArrow) {
if (this.world.k == 0) {
i = 0;
}
if (this.world.k == 1) {
i = i / 3 + 1;
}
if (this.world.k == 3) {
i = i * 3 / 2;
}
}
return i == 0 ? false : super.a(entity, i);
}
}
protected void e(int i) {
int j = 25 - this.inventory.g();
int k = i * j + this.a;
this.inventory.c(i);
i = k / 25;
this.a = k % 25;
super.e(i);
}
public void a(TileEntityFurnace tileentityfurnace) {}
public void a(TileEntityDispenser tileentitydispenser) {}
public void a(TileEntitySign tileentitysign) {}
public void g(Entity entity) {
if (!entity.a(this)) {
ItemStack itemstack = this.P();
if (itemstack != null && entity instanceof EntityLiving) {
itemstack.b((EntityLiving) entity);
if (itemstack.count <= 0) {
itemstack.a(this);
this.Q();
}
}
}
}
public ItemStack P() {
return this.inventory.e();
}
public void Q() {
this.inventory.a(this.inventory.c, (ItemStack) null);
}
public double F() {
return (double) (this.height - 0.5F);
}
public void K() {
this.av = -1;
this.au = true;
}
public void h(Entity entity) {
int i = this.inventory.a(entity);
if (i > 0) {
// CraftBukkit start
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damager = this.getBukkitEntity();
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damageDone = i;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(event);
if (event.isCancelled()){
return;
}
entity.a(this, event.getDamage());
} else {
entity.a(this, i);
}
// CraftBukkit end
ItemStack itemstack = this.P();
if (itemstack != null && entity instanceof EntityLiving) {
itemstack.a((EntityLiving) entity);
if (itemstack.count <= 0) {
itemstack.a(this);
this.Q();
}
}
}
}
public void a(ItemStack itemstack) {}
public void q() {
super.q();
this.defaultContainer.a(this);
if (this.activeContainer != null) {
this.activeContainer.a(this);
}
}
}

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftItem; import org.bukkit.craftbukkit.entity.CraftItem;
@ -11,34 +9,31 @@ public class EntityItem extends Entity {
public ItemStack a; public ItemStack a;
private int e; private int e;
public int b; public int b = 0;
public int c; public int c;
private int f; private int f = 5;
public float d; public float d = (float) (Math.random() * 3.141592653589793D * 2.0D);
public EntityItem(World world, double d1, double d2, double d3, ItemStack itemstack) { public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) {
// CraftBukkit start super(world);
this(world); this.a(0.25F, 0.25F);
// CraftBukkit end this.height = this.width / 2.0F;
a(d1, d2, d3); this.a(d0, d1, d2);
a = itemstack; this.a = itemstack;
v = (float) (Math.random() * 360D); this.yaw = (float) (Math.random() * 360.0D);
s = (float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D); this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
t = 0.20000000298023224D; this.motY = 0.20000000298023224D;
u = (float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D); this.motZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
M = false; this.M = false;
} }
public EntityItem(World world) { public EntityItem(World world) {
super(world); super(world);
b = 0; this.a(0.25F, 0.25F);
f = 5; this.height = this.width / 2.0F;
d = (float) (Math.random() * 3.1415926535897931D * 2D);
a(0.25F, 0.25F);
H = J / 2.0F;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftItem(server, this); this.bukkitEntity = new CraftItem(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -47,152 +42,167 @@ public class EntityItem extends Entity {
public void b_() { public void b_() {
super.b_(); super.b_();
if (c > 0) { if (this.c > 0) {
c--; --this.c;
} }
m = p;
n = q;
o = r;
t -= 0.039999999105930328D;
if (l.c(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) == Material.g) {
t = 0.20000000298023224D;
s = (W.nextFloat() - W.nextFloat()) * 0.2F;
u = (W.nextFloat() - W.nextFloat()) * 0.2F;
l.a(((Entity) (this)), "random.fizz", 0.4F, 2.0F + W.nextFloat() * 0.4F);
}
g(p, q, r);
c(s, t, u);
float f1 = 0.98F;
if (A) { this.lastX = this.locX;
f1 = 0.5880001F; this.lastY = this.locY;
int i = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r)); this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D;
if (this.world.getMaterial(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) == Material.LAVA) {
this.motY = 0.20000000298023224D;
this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
this.world.a(this, "random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
}
this.g(this.locX, this.locY, this.locZ);
this.c(this.motX, this.motY, this.motZ);
float f = 0.98F;
if (this.onGround) {
f = 0.58800006F;
int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (i > 0) { if (i > 0) {
f1 = Block.m[i].bu * 0.98F; f = Block.byId[i].frictionFactor * 0.98F;
} }
} }
s *= f1;
t *= 0.98000001907348633D; this.motX *= (double) f;
u *= f1; this.motY *= 0.9800000190734863D;
if (A) { this.motZ *= (double) f;
t *= -0.5D; if (this.onGround) {
this.motY *= -0.5D;
} }
e++;
b++; ++this.e;
if (b >= 6000) { ++this.b;
q(); if (this.b >= 6000) {
this.q();
} }
} }
public boolean v() { public boolean v() {
return l.a(z, Material.f, ((Entity) (this))); return this.world.a(this.boundingBox, Material.WATER, this);
} }
private boolean g(double d1, double d2, double d3) { private boolean g(double d0, double d1, double d2) {
int i = MathHelper.b(d1); int i = MathHelper.b(d0);
int j = MathHelper.b(d2); int j = MathHelper.b(d1);
int k = MathHelper.b(d3); int k = MathHelper.b(d2);
double d4 = d1 - (double) i; double d3 = d0 - (double) i;
double d5 = d2 - (double) j; double d4 = d1 - (double) j;
double d6 = d3 - (double) k; double d5 = d2 - (double) k;
if (Block.o[l.a(i, j, k)]) { if (Block.o[this.world.getTypeId(i, j, k)]) {
boolean flag = !Block.o[l.a(i - 1, j, k)]; boolean flag = !Block.o[this.world.getTypeId(i - 1, j, k)];
boolean flag1 = !Block.o[l.a(i + 1, j, k)]; boolean flag1 = !Block.o[this.world.getTypeId(i + 1, j, k)];
boolean flag2 = !Block.o[l.a(i, j - 1, k)]; boolean flag2 = !Block.o[this.world.getTypeId(i, j - 1, k)];
boolean flag3 = !Block.o[l.a(i, j + 1, k)]; boolean flag3 = !Block.o[this.world.getTypeId(i, j + 1, k)];
boolean flag4 = !Block.o[l.a(i, j, k - 1)]; boolean flag4 = !Block.o[this.world.getTypeId(i, j, k - 1)];
boolean flag5 = !Block.o[l.a(i, j, k + 1)]; boolean flag5 = !Block.o[this.world.getTypeId(i, j, k + 1)];
byte byte0 = -1; byte b0 = -1;
double d7 = 9999D; double d6 = 9999.0D;
if (flag && d4 < d7) { if (flag && d3 < d6) {
d7 = d4; d6 = d3;
byte0 = 0; b0 = 0;
} }
if (flag1 && 1.0D - d4 < d7) {
d7 = 1.0D - d4;
byte0 = 1;
}
if (flag2 && d5 < d7) {
d7 = d5;
byte0 = 2;
}
if (flag3 && 1.0D - d5 < d7) {
d7 = 1.0D - d5;
byte0 = 3;
}
if (flag4 && d6 < d7) {
d7 = d6;
byte0 = 4;
}
if (flag5 && 1.0D - d6 < d7) {
double d8 = 1.0D - d6;
byte0 = 5; if (flag1 && 1.0D - d3 < d6) {
d6 = 1.0D - d3;
b0 = 1;
} }
float f1 = W.nextFloat() * 0.2F + 0.1F;
if (byte0 == 0) { if (flag2 && d4 < d6) {
s = -f1; d6 = d4;
b0 = 2;
} }
if (byte0 == 1) {
s = f1; if (flag3 && 1.0D - d4 < d6) {
d6 = 1.0D - d4;
b0 = 3;
} }
if (byte0 == 2) {
t = -f1; if (flag4 && d5 < d6) {
d6 = d5;
b0 = 4;
} }
if (byte0 == 3) {
t = f1; if (flag5 && 1.0D - d5 < d6) {
d6 = 1.0D - d5;
b0 = 5;
} }
if (byte0 == 4) {
u = -f1; float f = this.random.nextFloat() * 0.2F + 0.1F;
if (b0 == 0) {
this.motX = (double) (-f);
} }
if (byte0 == 5) {
u = f1; if (b0 == 1) {
this.motX = (double) f;
}
if (b0 == 2) {
this.motY = (double) (-f);
}
if (b0 == 3) {
this.motY = (double) f;
}
if (b0 == 4) {
this.motZ = (double) (-f);
}
if (b0 == 5) {
this.motZ = (double) f;
} }
} }
return false; return false;
} }
protected void b(int i) { protected void b(int i) {
a(((Entity) (null)), i); this.a((Entity) null, i);
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
y(); this.y();
f -= i; this.f -= i;
if (f <= 0) { if (this.f <= 0) {
q(); this.q();
} }
return false; return false;
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Health", (short) f); nbttagcompound.a("Health", (short) ((byte) this.f));
nbttagcompound.a("Age", (short) b); nbttagcompound.a("Age", (short) this.b);
nbttagcompound.a("Item", a.a(new NBTTagCompound())); nbttagcompound.a("Item", this.a.a(new NBTTagCompound()));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
f = nbttagcompound.c("Health") & 0xff; this.f = nbttagcompound.c("Health") & 255;
b = ((int) (nbttagcompound.c("Age"))); this.b = nbttagcompound.c("Age");
NBTTagCompound nbttagcompound1 = nbttagcompound.j("Item"); NBTTagCompound nbttagcompound1 = nbttagcompound.j("Item");
a = new ItemStack(nbttagcompound1); this.a = new ItemStack(nbttagcompound1);
} }
public void b(EntityPlayer entityplayer) { public void b(EntityHuman entityhuman) {
if (l.z) { if (!this.world.isStatic) {
return; int i = this.a.count;
}
int i = a.a;
if (c == 0 && entityplayer.an.a(a)) { if (this.c == 0 && entityhuman.inventory.a(this.a)) {
l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F); this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.c(((Entity) (this)), i); entityhuman.c(this, i);
q(); this.q();
}
} }
} }
} }

View File

@ -1,100 +0,0 @@
package net.minecraft.server;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
public class EntityList {
private static Map a = new HashMap();
private static Map b = new HashMap();
private static Map c = new HashMap();
private static Map d = new HashMap();
public EntityList() {}
private static void a(Class class1, String s, int i) {
a.put(((s)), ((class1)));
b.put(((class1)), ((s)));
c.put(((Integer.valueOf(i))), ((class1)));
d.put(((class1)), ((Integer.valueOf(i))));
}
public static Entity a(String s, World world) {
Entity entity = null;
try {
Class class1 = (Class) a.get(((s)));
if (class1 != null) {
entity = (Entity) class1.getConstructor(new Class[] {
net.minecraft.server.World.class
}).newInstance(new Object[] {
world
});
}
} catch (Exception exception) {
exception.printStackTrace();
}
return entity;
}
public static Entity a(NBTTagCompound nbttagcompound, World world) {
Entity entity = null;
try {
Class class1 = (Class) a.get(((nbttagcompound.h("id"))));
if (class1 != null) {
entity = (Entity) class1.getConstructor(new Class[] {
net.minecraft.server.World.class
}).newInstance(new Object[] {
world
});
}
} catch (Exception exception) {
exception.printStackTrace();
}
if (entity != null) {
entity.e(nbttagcompound);
} else {
System.out.println((new StringBuilder()).append("Skipping Entity with id ").append(nbttagcompound.h("id")).toString());
}
return entity;
}
public static int a(Entity entity) {
return ((Integer) d.get(((((entity)).getClass())))).intValue();
}
public static String b(Entity entity) {
return (String) b.get(((((entity)).getClass())));
}
static {
a(net.minecraft.server.EntityArrow.class, "Arrow", 10);
a(net.minecraft.server.EntitySnowball.class, "Snowball", 11);
a(net.minecraft.server.EntityItem.class, "Item", 1);
a(net.minecraft.server.EntityPainting.class, "Painting", 9);
a(net.minecraft.server.EntityLiving.class, "Mob", 48);
a(net.minecraft.server.EntityMobs.class, "Monster", 49);
a(net.minecraft.server.EntityCreeper.class, "Creeper", 50);
a(net.minecraft.server.EntitySkeleton.class, "Skeleton", 51);
a(net.minecraft.server.EntitySpider.class, "Spider", 52);
a(net.minecraft.server.EntityZombieSimple.class, "Giant", 53);
a(net.minecraft.server.EntityZombie.class, "Zombie", 54);
a(net.minecraft.server.EntitySlime.class, "Slime", 55);
a(net.minecraft.server.EntityGhast.class, "Ghast", 56);
a(net.minecraft.server.EntityPigZombie.class, "PigZombie", 57);
a(net.minecraft.server.EntityPig.class, "Pig", 90);
a(net.minecraft.server.EntitySheep.class, "Sheep", 91);
a(net.minecraft.server.EntityCow.class, "Cow", 92);
a(net.minecraft.server.EntityChicken.class, "Chicken", 93);
a(net.minecraft.server.EntitySquid.class, "Squid", 94);
a(net.minecraft.server.EntityTNTPrimed.class, "PrimedTnt", 20);
a(net.minecraft.server.EntityFallingSand.class, "FallingSand", 21);
a(net.minecraft.server.EntityMinecart.class, "Minecart", 40);
a(net.minecraft.server.EntityBoat.class, "Boat", 41);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +0,0 @@
package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end
public class EntityMobs extends EntityCreature implements IMobs {
protected int c;
public EntityMobs(World world) {
super(world);
c = 2;
aZ = 20;
// CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer();
this.bukkitEntity = new CraftMonster(server, this);
// CraftBukkit end
}
public void o() {
float f = b(1.0F);
if (f > 0.5F) {
bw += 2;
}
super.o();
}
public void b_() {
super.b_();
if (l.k == 0) {
q();
}
}
protected Entity l() {
EntityPlayer entityplayer = l.a(((Entity) (this)), 16D);
if (entityplayer != null && i(((Entity) (entityplayer)))) {
return ((Entity) (entityplayer));
} else {
return null;
}
}
public boolean a(Entity entity, int i) {
if (super.a(entity, i)) {
if (j == entity || k == entity) {
return true;
}
if (entity != this) {
// CraftBukkit start
org.bukkit.entity.Entity bukkitTarget = null;
if(entity != null) {
bukkitTarget = entity.getBukkitEntity();
}
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
CraftServer server = ((WorldServer) this.l).getServer();
server.getPluginManager().callEvent(event);
if(!event.isCancelled()) {
if(event.getTarget() == null) {
d = null;
} else {
d = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
}
return true;
} else {
return false;
}
}
protected void a(Entity entity, float f) {
if ((double) f < 2.5D && entity.z.e > z.b && entity.z.b < z.e) {
bf = 20;
// CraftBukkit start
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) l).getServer();
org.bukkit.entity.Entity damager = this.getBukkitEntity();
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damageDone = c;
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbee);
if (!edbee.isCancelled()){
entity.a(((Entity) (this)), edbee.getDamage());
}
} else {
entity.a(((Entity) (this)), c);
}
// CraftBukkit end
}
}
protected float a(int i, int j, int k) {
return 0.5F - l.l(i, j, k);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
}
public boolean b() {
int i = MathHelper.b(p);
int j = MathHelper.b(z.b);
int k = MathHelper.b(r);
if (l.a(EnumSkyBlock.a, i, j, k) > W.nextInt(32)) {
return false;
} else {
int i1 = l.j(i, j, k);
return i1 <= W.nextInt(8) && super.b();
}
}
}

View File

@ -0,0 +1,132 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end
public class EntityMonster extends EntityCreature implements IMonster {
protected int c = 2;
public EntityMonster(World world) {
super(world);
this.health = 20;
// CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftMonster(server, this);
// CraftBukkit end
}
public void o() {
float f = this.b(1.0F);
if (f > 0.5F) {
this.bw += 2;
}
super.o();
}
public void b_() {
super.b_();
if (this.world.k == 0) {
this.q();
}
}
protected Entity l() {
EntityHuman entityhuman = this.world.a(this, 16.0D);
return entityhuman != null && this.i(entityhuman) ? entityhuman : null;
}
public boolean a(Entity entity, int i) {
if (super.a(entity, i)) {
if (this.passenger != entity && this.vehicle != entity) {
if (entity != this) {
// CraftBukkit start
org.bukkit.entity.Entity bukkitTarget = null;
if (entity != null) {
bukkitTarget = entity.getBukkitEntity();
}
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
d = null;
} else {
d = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
}
return true;
} else {
return true;
}
} else {
return false;
}
}
protected void a(Entity entity, float f) {
if ((double) f < 2.5D && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
this.attackTicks = 20;
// CraftBukkit start
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damager = this.getBukkitEntity();
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damageDone = this.c;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()){
entity.a(this, event.getDamage());
}
} else {
entity.a(this, this.c);
}
// CraftBukkit end
}
}
protected float a(int i, int j, int k) {
return 0.5F - this.world.l(i, j, k);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
}
public boolean b() {
int i = MathHelper.b(this.locX);
int j = MathHelper.b(this.boundingBox.b);
int k = MathHelper.b(this.locZ);
if (this.world.a(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) {
return false;
} else {
int l = this.world.j(i, j, k);
return l <= this.random.nextInt(8) && super.b();
}
}
}

View File

@ -1,6 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.*; import java.util.ArrayList;
import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -18,158 +19,175 @@ public class EntityPainting extends Entity {
public EntityPainting(World world) { public EntityPainting(World world) {
super(world); super(world);
f = 0; this.f = 0;
a = 0; this.a = 0;
H = 0.0F; this.height = 0.0F;
a(0.5F, 0.5F); this.a(0.5F, 0.5F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPainting(server, this); this.bukkitEntity = new CraftPainting(server, this);
// CraftBukkit end // CraftBukkit end
} }
public EntityPainting(World world, int i, int j, int k, int l) { public EntityPainting(World world, int i, int j, int k, int l) {
this(world); this(world);
b = i; this.b = i;
c = j; this.c = j;
d = k; this.d = k;
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
EnumArt aenumart[] = EnumArt.values(); EnumArt[] aenumart = EnumArt.values();
int i1 = aenumart.length; int i1 = aenumart.length;
for (int j1 = 0; j1 < i1; j1++) { for (int j1 = 0; j1 < i1; ++j1) {
EnumArt enumart = aenumart[j1]; EnumArt enumart = aenumart[j1];
e = enumart; this.e = enumart;
a(l); this.a(l);
if (d()) { if (this.d()) {
((List) (arraylist)).add(((enumart))); arraylist.add(enumart);
} }
} }
if (((List) (arraylist)).size() > 0) { if (arraylist.size() > 0) {
e = (EnumArt) ((List) (arraylist)).get(W.nextInt(((List) (arraylist)).size())); this.e = (EnumArt) arraylist.get(this.random.nextInt(arraylist.size()));
} }
a(l);
this.a(l);
} }
protected void a() {} protected void a() {}
public void a(int i) { public void a(int i) {
a = i; this.a = i;
x = v = i * 90; this.lastYaw = this.yaw = (float) (i * 90);
float f1 = e.A; float f = (float) this.e.A;
float f2 = e.B; float f1 = (float) this.e.B;
float f3 = e.A; float f2 = (float) this.e.A;
if (i == 0 || i == 2) { if (i != 0 && i != 2) {
f3 = 0.5F; f = 0.5F;
} else { } else {
f1 = 0.5F; f2 = 0.5F;
} }
f1 /= 32F;
f2 /= 32F; f /= 32.0F;
f3 /= 32F; f1 /= 32.0F;
float f4 = (float) b + 0.5F; f2 /= 32.0F;
float f5 = (float) c + 0.5F; float f3 = (float) this.b + 0.5F;
float f6 = (float) d + 0.5F; float f4 = (float) this.c + 0.5F;
float f7 = 0.5625F; float f5 = (float) this.d + 0.5F;
float f6 = 0.5625F;
if (i == 0) { if (i == 0) {
f6 -= f7; f5 -= f6;
} }
if (i == 1) {
f4 -= f7;
}
if (i == 2) {
f6 += f7;
}
if (i == 3) {
f4 += f7;
}
if (i == 0) {
f4 -= d(e.A);
}
if (i == 1) {
f6 += d(e.A);
}
if (i == 2) {
f4 += d(e.A);
}
if (i == 3) {
f6 -= d(e.A);
}
f5 += d(e.B);
a((double)f4, (double)f5, (double)f6); // CraftBukkit -- forcecast all arguments to double
float f8 = -0.00625F;
z.c(f4 - f1 - f8, f5 - f2 - f8, f6 - f3 - f8, f4 + f1 + f8, f5 + f2 + f8, f6 + f3 + f8); if (i == 1) {
f3 -= f6;
}
if (i == 2) {
f5 += f6;
}
if (i == 3) {
f3 += f6;
}
if (i == 0) {
f3 -= this.d(this.e.A);
}
if (i == 1) {
f5 += this.d(this.e.A);
}
if (i == 2) {
f3 += this.d(this.e.A);
}
if (i == 3) {
f5 -= this.d(this.e.A);
}
f4 += this.d(this.e.B);
this.a((double) f3, (double) f4, (double) f5);
float f7 = -0.00625F;
this.boundingBox.c((double) (f3 - f - f7), (double) (f4 - f1 - f7), (double) (f5 - f2 - f7), (double) (f3 + f + f7), (double) (f4 + f1 + f7), (double) (f5 + f2 + f7));
} }
private float d(int i) { private float d(int i) {
if (i == 32) { return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F);
return 0.5F;
}
return i != 64 ? 0.0F : 0.5F;
} }
public void b_() { public void b_() {
if (f++ == 100 && !l.z) { if (this.f++ == 100 && !this.world.isStatic) {
f = 0; this.f = 0;
if (!d()) { if (!this.d()) {
q(); this.q();
l.a(((Entity) (new EntityItem(l, p, q, r, new ItemStack(Item.aq))))); this.world.a((Entity) (new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))));
} }
} }
} }
public boolean d() { public boolean d() {
if (this.l.a(((Entity) (this)), z).size() > 0) { if (this.world.a((Entity) this, this.boundingBox).size() > 0) {
return false; return false;
} } else {
int i = e.A / 16; int i = this.e.A / 16;
int j = e.B / 16; int j = this.e.B / 16;
int k = b; int k = this.b;
int l = c; int l = this.c;
int i1 = d; int i1 = this.d;
if (a == 0) { if (this.a == 0) {
k = MathHelper.b(p - (double) ((float) e.A / 32F)); k = MathHelper.b(this.locX - (double) ((float) this.e.A / 32.0F));
} }
if (a == 1) {
i1 = MathHelper.b(r - (double) ((float) e.A / 32F));
}
if (a == 2) {
k = MathHelper.b(p - (double) ((float) e.A / 32F));
}
if (a == 3) {
i1 = MathHelper.b(r - (double) ((float) e.A / 32F));
}
l = MathHelper.b(q - (double) ((float) e.B / 32F));
for (int j1 = 0; j1 < i; j1++) {
for (int k1 = 0; k1 < j; k1++) {
Material material;
if (a == 0 || a == 2) { if (this.a == 1) {
material = this.l.c(k + j1, l + k1, d); i1 = MathHelper.b(this.locZ - (double) ((float) this.e.A / 32.0F));
} else { }
material = this.l.c(b, l + k1, i1 + j1);
if (this.a == 2) {
k = MathHelper.b(this.locX - (double) ((float) this.e.A / 32.0F));
}
if (this.a == 3) {
i1 = MathHelper.b(this.locZ - (double) ((float) this.e.A / 32.0F));
}
l = MathHelper.b(this.locY - (double) ((float) this.e.B / 32.0F));
int j1;
for (int k1 = 0; k1 < i; ++k1) {
for (j1 = 0; j1 < j; ++j1) {
Material material;
if (this.a != 0 && this.a != 2) {
material = this.world.getMaterial(this.b, l + j1, i1 + k1);
} else {
material = this.world.getMaterial(k + k1, l + j1, this.d);
}
if (!material.isBuildable()) {
return false;
}
} }
if (!material.a()) { }
List list = this.world.b((Entity) this, this.boundingBox);
for (j1 = 0; j1 < list.size(); ++j1) {
if (list.get(j1) instanceof EntityPainting) {
return false; return false;
} }
} }
return true;
} }
List list = this.l.b(((Entity) (this)), z);
for (int l1 = 0; l1 < list.size(); l1++) {
if (list.get(l1) instanceof EntityPainting) {
return false;
}
}
return true;
} }
public boolean c_() { public boolean c_() {
@ -177,42 +195,44 @@ public class EntityPainting extends Entity {
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
if (!G && !l.z) { if (!this.dead && !this.world.isStatic) {
q(); this.q();
y(); this.y();
l.a(((Entity) (new EntityItem(l, p, q, r, new ItemStack(Item.aq))))); this.world.a((Entity) (new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))));
} }
return true; return true;
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Dir", (byte) a); nbttagcompound.a("Dir", (byte) this.a);
nbttagcompound.a("Motive", e.z); nbttagcompound.a("Motive", this.e.z);
nbttagcompound.a("TileX", b); nbttagcompound.a("TileX", this.b);
nbttagcompound.a("TileY", c); nbttagcompound.a("TileY", this.c);
nbttagcompound.a("TileZ", d); nbttagcompound.a("TileZ", this.d);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
a = ((int) (nbttagcompound.b("Dir"))); this.a = nbttagcompound.b("Dir");
b = nbttagcompound.d("TileX"); this.b = nbttagcompound.d("TileX");
c = nbttagcompound.d("TileY"); this.c = nbttagcompound.d("TileY");
d = nbttagcompound.d("TileZ"); this.d = nbttagcompound.d("TileZ");
String s = nbttagcompound.h("Motive"); String s = nbttagcompound.h("Motive");
EnumArt aenumart[] = EnumArt.values(); EnumArt[] aenumart = EnumArt.values();
int i = aenumart.length; int i = aenumart.length;
for (int j = 0; j < i; j++) { for (int j = 0; j < i; ++j) {
EnumArt enumart = aenumart[j]; EnumArt enumart = aenumart[j];
if (enumart.z.equals(((s)))) { if (enumart.z.equals(s)) {
e = enumart; this.e = enumart;
} }
} }
if (e == null) { if (this.e == null) {
e = EnumArt.a; this.e = EnumArt.KEBAB;
} }
a(a);
this.a(this.a);
} }
} }

View File

@ -5,30 +5,31 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPig; import org.bukkit.craftbukkit.entity.CraftPig;
// CraftBukkit end // CraftBukkit end
public class EntityPig extends EntityAnimals { public class EntityPig extends EntityAnimal {
public EntityPig(World world) { public EntityPig(World world) {
super(world); super(world);
aP = "/mob/pig.png"; this.texture = "/mob/pig.png";
a(0.9F, 0.9F); this.a(0.9F, 0.9F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPig(server, this); this.bukkitEntity = new CraftPig(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected void a() { protected void a() {
af.a(16, ((Byte.valueOf((byte) 0)))); this.datawatcher.a(16, Byte.valueOf((byte) 0));
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
nbttagcompound.a("Saddle", K()); nbttagcompound.a("Saddle", this.K());
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
a(nbttagcompound.l("Saddle")); this.a(nbttagcompound.l("Saddle"));
} }
protected String e() { protected String e() {
@ -43,9 +44,9 @@ public class EntityPig extends EntityAnimals {
return "mob.pigdeath"; return "mob.pigdeath";
} }
public boolean a(EntityPlayer entityplayer) { public boolean a(EntityHuman entityhuman) {
if (K() && !l.z && (j == null || j == entityplayer)) { if (this.K() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) {
entityplayer.e(((Entity) (this))); entityhuman.e(this);
return true; return true;
} else { } else {
return false; return false;
@ -53,18 +54,18 @@ public class EntityPig extends EntityAnimals {
} }
protected int h() { protected int h() {
return Item.ao.ba; return Item.PORK.id;
} }
public boolean K() { public boolean K() {
return (af.a(16) & 1) != 0; return (this.datawatcher.a(16) & 1) != 0;
} }
public void a(boolean flag) { public void a(boolean flag) {
if (flag) { if (flag) {
af.b(16, ((Byte.valueOf((byte) 1)))); this.datawatcher.b(16, Byte.valueOf((byte) 1));
} else { } else {
af.b(16, ((Byte.valueOf((byte) 0)))); this.datawatcher.b(16, Byte.valueOf((byte) 0));
} }
} }
} }

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -13,52 +12,48 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
public class EntityPigZombie extends EntityZombie { public class EntityPigZombie extends EntityZombie {
private int a; private int a = 0;
private int b; private int b = 0;
private static final ItemStack f; private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1);
public EntityPigZombie(World world) { public EntityPigZombie(World world) {
super(world); super(world);
a = 0; this.texture = "/mob/pigzombie.png";
b = 0; this.bC = 0.5F;
aP = "/mob/pigzombie.png"; this.c = 5;
bC = 0.5F; this.ae = true;
c = 5;
ae = true;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPigZombie(server, this); this.bukkitEntity = new CraftPigZombie(server, this);
// CraftBukkit end // CraftBukkit end
} }
public void b_() { public void b_() {
bC = d == null ? 0.5F : 0.95F; this.bC = this.d != null ? 0.95F : 0.5F;
if (b > 0 && --b == 0) { if (this.b > 0 && --this.b == 0) {
l.a(((Entity) (this)), "mob.zombiepig.zpigangry", i() * 2.0F, ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) * 1.8F); this.world.a(this, "mob.zombiepig.zpigangry", this.i() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
} }
super.b_(); super.b_();
} }
public boolean b() { public boolean b() {
return l.k > 0 && l.a(z) && l.a(((Entity) (this)), z).size() == 0 && !l.b(z); return this.world.k > 0 && this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
nbttagcompound.a("Anger", (short) a); nbttagcompound.a("Anger", (short) this.a);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
a = ((int) (nbttagcompound.c("Anger"))); this.a = nbttagcompound.c("Anger");
} }
protected Entity l() { protected Entity l() {
if (a == 0) { return this.a == 0 ? null : super.l();
return null;
} else {
return super.l();
}
} }
public void o() { public void o() {
@ -66,10 +61,10 @@ public class EntityPigZombie extends EntityZombie {
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityHuman) {
List list = l.b(((Entity) (this)), z.b(32D, 32D, 32D)); List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D));
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j); Entity entity1 = (Entity) list.get(j);
if (entity1 instanceof EntityPigZombie) { if (entity1 instanceof EntityPigZombie) {
@ -79,27 +74,28 @@ public class EntityPigZombie extends EntityZombie {
} }
} }
g(entity); this.g(entity);
} }
return super.a(entity, i); return super.a(entity, i);
} }
private void g(Entity entity) { private void g(Entity entity) {
// CraftBukkit start // CraftBukkit start
org.bukkit.entity.Entity bukkitTarget = null; org.bukkit.entity.Entity bukkitTarget = null;
if(entity != null) { if (entity != null) {
bukkitTarget = entity.getBukkitEntity(); bukkitTarget = entity.getBukkitEntity();
} }
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if(!event.isCancelled()) { if (!event.isCancelled()) {
if(event.getTarget() == null) { if (event.getTarget() == null) {
d = null; this.d = null;
} else { } else {
d = ((CraftEntity) event.getTarget()).getHandle(); this.d = ((CraftEntity) event.getTarget()).getHandle();
a = 400 + W.nextInt(400); this.a = 400 + this.random.nextInt(400);
b = W.nextInt(40); this.b = this.random.nextInt(40);
} }
} }
// CraftBukkit end // CraftBukkit end
@ -118,10 +114,6 @@ public class EntityPigZombie extends EntityZombie {
} }
protected int h() { protected int h() {
return Item.ap.ba; return Item.GRILLED_PORK.id;
}
static {
f = new ItemStack(Item.E, 1);
} }
} }

View File

@ -1,383 +1,288 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Set;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end // CraftBukkit end
public abstract class EntityPlayer extends EntityLiving { public class EntityPlayer extends EntityHuman implements ICrafting {
public InventoryPlayer an; public NetServerHandler a;
public CraftingInventoryCB ao; public MinecraftServer b;
public CraftingInventoryCB ap; public ItemInWorldManager c;
public byte aq; public double d;
public int ar; public double e;
public float as; public List f = new LinkedList();
public float at; public Set ak = new HashSet();
public boolean au; public double al;
public int av; private int bD = -99999999;
public String aw; private int bE = 60;
public int ax; private ItemStack[] bF = new ItemStack[] { null, null, null, null, null};
public double ay; private int bG = 0;
public double az; public boolean am;
public double aA;
public double aB;
public double aC;
public double aD;
private int a;
public EntityFish aE;
public EntityPlayer(World world) { public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
super(world); super(world);
an = new InventoryPlayer(this); int i = world.spawnX;
aq = 0; int j = world.spawnZ;
ar = 0; int k = world.spawnY;
au = false;
av = 0; if (!world.q.e) {
a = 0; i += this.random.nextInt(20) - 10;
aE = null; k = world.e(i, j);
ao = ((CraftingInventoryCB) (new CraftingInventoryPlayerCB(an, !world.z))); j += this.random.nextInt(20) - 10;
ap = ao; }
H = 1.62F;
c((double) world.m + 0.5D, world.n + 1, (double) world.o + 0.5D, 0.0F, 0.0F); this.c((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
aZ = 20; this.b = minecraftserver;
aS = "humanoid"; this.S = 0.0F;
aR = 180F; iteminworldmanager.a = this;
Y = 20; this.name = s;
aP = "/mob/char.png"; this.c = iteminworldmanager;
this.height = 0.0F;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftHumanEntity(server, this); this.bukkitEntity = new CraftPlayer(server, this);
// CraftBukkit end // CraftBukkit end
} }
public void l() {
this.activeContainer.a((ICrafting) this);
}
public ItemStack[] I() {
return this.bF;
}
public void b_() { public void b_() {
super.b_(); --this.bE;
if (!l.z && ap != null && !ap.b(this)) { this.activeContainer.a();
L();
ap = ao;
}
ay = aB;
az = aC;
aA = aD;
double d1 = p - aB;
double d2 = q - aC;
double d3 = r - aD;
double d4 = 10D;
if (d1 > d4) { for (int i = 0; i < 5; ++i) {
ay = aB = p; ItemStack itemstack = this.a(i);
}
if (d3 > d4) {
aA = aD = r;
}
if (d2 > d4) {
az = aC = q;
}
if (d1 < -d4) {
ay = aB = p;
}
if (d3 < -d4) {
aA = aD = r;
}
if (d2 < -d4) {
az = aC = q;
}
aB += d1 * 0.25D;
aD += d3 * 0.25D;
aC += d2 * 0.25D;
}
protected void L() { if (itemstack != this.bF[i]) {
ap = ao; this.b.k.a(this, new Packet5EntityEquipment(this.id, i, itemstack));
} this.bF[i] = itemstack;
public void D() {
super.D();
as = at;
at = 0.0F;
}
protected void d() {
if (au) {
av++;
if (av == 8) {
av = 0;
au = false;
}
} else {
av = 0;
}
aY = (float) av / 8F;
}
public void o() {
if (l.k == 0 && aZ < 20 && (X % 20) * 12 == 0) {
d(1);
}
an.f();
as = at;
super.o();
float f1 = MathHelper.a(s * s + u * u);
float f2 = (float) Math.atan(-t * 0.20000000298023224D) * 15F;
if (f1 > 0.1F) {
f1 = 0.1F;
}
if (!A || aZ <= 0) {
f1 = 0.0F;
}
if (A || aZ <= 0) {
f2 = 0.0F;
}
at += (f1 - at) * 0.4F;
bh += (f2 - bh) * 0.8F;
if (aZ > 0) {
List list = l.b(((Entity) (this)), z.b(1.0D, 0.0D, 1.0D));
if (list != null) {
for (int i = 0; i < list.size(); i++) {
Entity entity = (Entity) list.get(i);
if (!entity.G) {
j(entity);
}
}
} }
} }
} }
private void j(Entity entity) { public ItemStack a(int i) {
entity.b(this); return i == 0 ? this.inventory.e() : this.inventory.b[i - 1];
} }
public void f(Entity entity) { public void f(Entity entity) {
super.f(entity); this.inventory.h();
a(0.2F, 0.2F);
a(p, q, r);
t = 0.10000000149011612D;
if (aw.equals("Notch")) {
a(new ItemStack(Item.h, 1), true);
}
an.h();
if (entity != null) {
s = -MathHelper.b(((bd + v) * 3.141593F) / 180F) * 0.1F;
u = -MathHelper.a(((bd + v) * 3.141593F) / 180F) * 0.1F;
} else {
s = u = 0.0D;
}
H = 0.1F;
}
public void b(Entity entity, int i) {
ar += i;
}
public void O() {
a(an.b(an.c, 1), false);
}
public void b(ItemStack itemstack) {
a(itemstack, false);
}
public void a(ItemStack itemstack, boolean flag) {
if (itemstack == null) {
return;
}
EntityItem entityitem = new EntityItem(l, p, (q - 0.30000001192092896D) + (double) w(), r, itemstack);
entityitem.c = 40;
float f1 = 0.1F;
if (flag) {
float f3 = W.nextFloat() * 0.5F;
float f5 = W.nextFloat() * 3.141593F * 2.0F;
entityitem.s = -MathHelper.a(f5) * f3;
entityitem.u = MathHelper.b(f5) * f3;
entityitem.t = 0.20000000298023224D;
} else {
float f2 = 0.3F;
entityitem.s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
entityitem.u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
entityitem.t = -MathHelper.a((w / 180F) * 3.141593F) * f2 + 0.1F;
f2 = 0.02F;
float f4 = W.nextFloat() * 3.141593F * 2.0F;
f2 *= W.nextFloat();
entityitem.s += Math.cos(f4) * (double) f2;
entityitem.t += (W.nextFloat() - W.nextFloat()) * 0.1F;
entityitem.u += Math.sin(f4) * (double) f2;
}
a(entityitem);
}
protected void a(EntityItem entityitem) {
l.a(((Entity) (entityitem)));
}
public float a(Block block) {
float f1 = an.a(block);
if (a(Material.f)) {
f1 /= 5F;
}
if (!A) {
f1 /= 5F;
}
return f1;
}
public boolean b(Block block) {
return an.b(block);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Inventory");
an.b(nbttaglist);
ax = nbttagcompound.d("Dimension");
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
nbttagcompound.a("Inventory", ((NBTBase) (an.a(new NBTTagList()))));
nbttagcompound.a("Dimension", ax);
}
public void a(IInventory iinventory) {}
public void a(int i, int k, int l) {}
public void c(Entity entity, int i) {}
public float w() {
return 0.12F;
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
bw = 0; if (this.bE > 0) {
if (aZ <= 0) {
return false;
}
if ((entity instanceof EntityMobs) || (entity instanceof EntityArrow)) {
if (l.k == 0) {
i = 0;
}
if (l.k == 1) {
i = i / 3 + 1;
}
if (l.k == 3) {
i = (i * 3) / 2;
}
}
if (i == 0) {
return false; return false;
} else { } else {
if (!this.b.n) {
if (entity instanceof EntityHuman) {
return false;
}
if (entity instanceof EntityArrow) {
EntityArrow entityarrow = (EntityArrow) entity;
if (entityarrow.b instanceof EntityHuman) {
return false;
}
}
}
return super.a(entity, i); return super.a(entity, i);
} }
} }
protected void e(int i) { public void d(int i) {
int k = 25 - an.g(); super.d(i);
int l = i * k + a;
an.c(i);
i = l / 25;
a = l % 25;
super.e(i);
} }
public void a(TileEntityFurnace tileentityfurnace) {} public void n() {
super.b_();
ChunkCoordIntPair chunkcoordintpair = null;
double d0 = 0.0D;
public void a(TileEntityDispenser tileentitydispenser) {} for (int i = 0; i < this.f.size(); ++i) {
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) this.f.get(i);
double d1 = chunkcoordintpair1.a(this);
public void a(TileEntitySign tileentitysign) {} if (i == 0 || d1 < d0) {
chunkcoordintpair = chunkcoordintpair1;
public void g(Entity entity) { d0 = chunkcoordintpair1.a(this);
if (entity.a(this)) { }
return;
} }
ItemStack itemstack = P();
if (itemstack != null && (entity instanceof EntityLiving)) { if (chunkcoordintpair != null) {
itemstack.b((EntityLiving) entity); boolean flag = false;
if (itemstack.a <= 0) {
itemstack.a(this); if (d0 < 1024.0D) {
Q(); flag = true;
}
if (this.a.b() < 2) {
flag = true;
}
if (flag) {
this.f.remove(chunkcoordintpair);
this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.b.e)));
List list = this.b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
for (int j = 0; j < list.size(); ++j) {
this.a((TileEntity) list.get(j));
}
}
}
if (this.health != this.bD) {
this.a.b((Packet) (new Packet8UpdateHealth(this.health)));
this.bD = this.health;
}
}
private void a(TileEntity tileentity) {
if (tileentity != null) {
Packet packet = tileentity.g();
if (packet != null) {
this.a.b(packet);
} }
} }
} }
public ItemStack P() { public void o() {
return an.e(); this.motX = this.motY = this.motZ = 0.0D;
this.bA = false;
super.o();
} }
public void Q() { public void c(Entity entity, int i) {
an.a(an.c, ((ItemStack) (null))); if (!entity.dead) {
} if (entity instanceof EntityItem) {
this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
}
public double F() { if (entity instanceof EntityArrow) {
return (double) (H - 0.5F); this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
}
}
super.c(entity, i);
this.activeContainer.a();
} }
public void K() { public void K() {
av = -1; if (!this.au) {
au = true; this.av = -1;
this.au = true;
this.b.k.a(this, new Packet18ArmAnimation(this, 1));
}
} }
public void h(Entity entity) { public float w() {
int i = an.a(entity); return 1.62F;
}
if (i > 0) { public void e(Entity entity) {
// CraftBukkit start // CraftBukkit start
if(entity instanceof EntityLiving) { setPassengerOf(entity);
CraftServer server = ((WorldServer) l).getServer(); }
org.bukkit.entity.Entity damager = this.getBukkitEntity();
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damageDone = i;
EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbee);
if (!edbee.isCancelled()){ public void setPassengerOf(Entity entity) {
entity.a(((Entity) this), edbee.getDamage()); // e(null) doesn't really fly for overloaded methods,
} else { // so this method is needed
return;
}
} else {
entity.a(((Entity) (this)), i);
}
// CraftBukkit end
ItemStack itemstack = P();
if (itemstack != null && (entity instanceof EntityLiving)) { super.setPassengerOf(entity);
itemstack.a((EntityLiving) entity); // CraftBukkit end
if (itemstack.a <= 0) { this.a.b((Packet) (new Packet39AttachEntity(this, this.vehicle)));
itemstack.a(this); this.a.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
Q(); }
}
protected void a(double d0, boolean flag) {}
public void b(double d0, boolean flag) {
super.a(d0, flag);
}
private void U() {
this.bG = this.bG % 100 + 1;
}
public void a(int i, int j, int k) {
this.U();
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 1, "Crafting", 9)));
this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k);
this.activeContainer.f = this.bG;
this.activeContainer.a((ICrafting) this);
}
public void a(IInventory iinventory) {
this.U();
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 0, iinventory.b(), iinventory.h_())));
this.activeContainer = new ContainerChest(this.inventory, iinventory);
this.activeContainer.f = this.bG;
this.activeContainer.a((ICrafting) this);
}
public void a(TileEntityFurnace tileentityfurnace) {
this.U();
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 2, tileentityfurnace.b(), tileentityfurnace.h_())));
this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace);
this.activeContainer.f = this.bG;
this.activeContainer.a((ICrafting) this);
}
public void a(TileEntityDispenser tileentitydispenser) {
this.U();
this.a.b((Packet) (new Packet100OpenWindow(this.bG, 3, tileentitydispenser.b(), tileentitydispenser.h_())));
this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser);
this.activeContainer.f = this.bG;
this.activeContainer.a((ICrafting) this);
}
public void a(Container container, int i, ItemStack itemstack) {
if (!(container.a(i) instanceof SlotResult)) {
if (!this.am) {
this.a.b((Packet) (new Packet103SetSlot(container.f, i, itemstack)));
} }
} }
} }
public void a(Container container, List list) {
this.a.b((Packet) (new Packet104WindowItems(container.f, list)));
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
}
public void a(Container container, int i, int j) {
this.a.b((Packet) (new Packet105CraftProgressBar(container.f, i, j)));
}
public void a(ItemStack itemstack) {} public void a(ItemStack itemstack) {}
public void q() { public void L() {
super.q(); this.a.b((Packet) (new Packet101CloseWindow(this.activeContainer.f)));
ao.a(this); this.N();
if (ap != null) { }
ap.a(this);
public void M() {
if (!this.am) {
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
} }
} }
public void N() {
this.activeContainer.a((EntityHuman) this);
this.activeContainer = this.defaultContainer;
}
} }

View File

@ -1,292 +0,0 @@
package net.minecraft.server;
import java.util.*;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
// CraftBukkit end
public class EntityPlayerMP extends EntityPlayer implements ICrafting {
public NetServerHandler a;
public MinecraftServer b;
public ItemInWorldManager c;
public double d;
public double e;
public List f;
public Set ak;
public double al;
private int bD;
private int bE;
private ItemStack bF[] = {
null, null, null, null, null
};
private int bG;
public boolean am;
public EntityPlayerMP(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
super(world);
f = ((List) (new LinkedList()));
ak = ((Set) (new HashSet()));
bD = 0xfa0a1f01;
bE = 60;
bG = 0;
int i = world.m;
int j = world.o;
int k = world.n;
if (!world.q.e) {
i += W.nextInt(20) - 10;
k = world.e(i, j);
j += W.nextInt(20) - 10;
}
c((double) i + 0.5D, k, (double) j + 0.5D, 0.0F, 0.0F);
b = minecraftserver;
S = 0.0F;
iteminworldmanager.a = ((EntityPlayer) (this));
aw = s;
c = iteminworldmanager;
H = 0.0F;
// CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer();
this.bukkitEntity = new CraftPlayer(server, this);
// CraftBukkit end
}
public void l() {
ap.a(((ICrafting) (this)));
}
public ItemStack[] I() {
return bF;
}
public void b_() {
bE--;
ap.a();
for (int i = 0; i < 5; i++) {
ItemStack itemstack = a(i);
if (itemstack != bF[i]) {
b.k.a(((Entity) (this)), ((Packet) (new Packet5PlayerInventory(g, i, itemstack))));
bF[i] = itemstack;
}
}
}
public ItemStack a(int i) {
if (i == 0) {
return an.e();
} else {
return an.b[i - 1];
}
}
public void f(Entity entity) {
an.h();
}
public boolean a(Entity entity, int i) {
if (bE > 0) {
return false;
}
if (!b.n) {
if (entity instanceof EntityPlayer) {
return false;
}
if (entity instanceof EntityArrow) {
EntityArrow entityarrow = (EntityArrow) entity;
if (entityarrow.b instanceof EntityPlayer) {
return false;
}
}
}
return super.a(entity, i);
}
public void d(int i) {
super.d(i);
}
public void n() {
super.b_();
ChunkCoordIntPair chunkcoordintpair = null;
double d1 = 0.0D;
for (int i = 0; i < f.size(); i++) {
ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) f.get(i);
double d2 = chunkcoordintpair1.a(((Entity) (this)));
if (i == 0 || d2 < d1) {
chunkcoordintpair = chunkcoordintpair1;
d1 = chunkcoordintpair1.a(((Entity) (this)));
}
}
if (chunkcoordintpair != null) {
boolean flag = false;
if (d1 < 1024D) {
flag = true;
}
if (a.b() < 2) {
flag = true;
}
if (flag) {
f.remove(((chunkcoordintpair)));
a.b(((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, ((World) (b.e))))));
List list = b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
for (int j = 0; j < list.size(); j++) {
a((TileEntity) list.get(j));
}
}
}
if (aZ != bD) {
a.b(((Packet) (new Packet8(aZ))));
bD = aZ;
}
}
private void a(TileEntity tileentity) {
if (tileentity != null) {
Packet packet = tileentity.g();
if (packet != null) {
a.b(packet);
}
}
}
public void o() {
s = t = u = 0.0D;
bA = false;
super.o();
}
public void c(Entity entity, int i) {
if (!entity.G) {
if (entity instanceof EntityItem) {
b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
}
if (entity instanceof EntityArrow) {
b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
}
}
super.c(entity, i);
ap.a();
}
public void K() {
if (!au) {
av = -1;
au = true;
b.k.a(((Entity) (this)), ((Packet) (new Packet18ArmAnimation(((Entity) (this)), 1))));
}
}
public float w() {
return 1.62F;
}
public void e(Entity entity) {
// CraftBukkit start
setPassengerOf(entity);
}
public void setPassengerOf(Entity entity) {
// e(null) doesn't really fly for overloaded methods,
// so this method is needed
// CraftBukkit end
super.setPassengerOf(entity);
a.b(((Packet) (new Packet39(((Entity) (this)), k))));
a.a(p, q, r, v, w);
}
protected void a(double d1, boolean flag) {}
public void b(double d1, boolean flag) {
super.a(d1, flag);
}
private void U() {
bG = bG % 100 + 1;
}
public void a(int i, int j, int k) {
U();
a.b(((Packet) (new Packet100(bG, 1, "Crafting", 9))));
ap = ((CraftingInventoryCB) (new CraftingInventoryWorkbenchCB(an, l, i, j, k)));
ap.f = bG;
ap.a(((ICrafting) (this)));
}
public void a(IInventory iinventory) {
U();
a.b(((Packet) (new Packet100(bG, 0, iinventory.b(), iinventory.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryChestCB(((IInventory) (an)), iinventory)));
ap.f = bG;
ap.a(((ICrafting) (this)));
}
public void a(TileEntityFurnace tileentityfurnace) {
U();
a.b(((Packet) (new Packet100(bG, 2, tileentityfurnace.b(), tileentityfurnace.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryFurnaceCB(((IInventory) (an)), tileentityfurnace)));
ap.f = bG;
ap.a(((ICrafting) (this)));
}
public void a(TileEntityDispenser tileentitydispenser) {
U();
a.b(((Packet) (new Packet100(bG, 3, tileentitydispenser.b(), tileentitydispenser.h_()))));
ap = ((CraftingInventoryCB) (new CraftingInventoryDispenserCB(((IInventory) (an)), tileentitydispenser)));
ap.f = bG;
ap.a(((ICrafting) (this)));
}
public void a(CraftingInventoryCB craftinginventorycb, int i, ItemStack itemstack) {
if (craftinginventorycb.a(i) instanceof SlotCrafting) {
return;
}
if (am) {
return;
} else {
a.b(((Packet) (new Packet103(craftinginventorycb.f, i, itemstack))));
return;
}
}
public void a(CraftingInventoryCB craftinginventorycb, List list) {
a.b(((Packet) (new Packet104(craftinginventorycb.f, list))));
a.b(((Packet) (new Packet103(-1, -1, an.i()))));
}
public void a(CraftingInventoryCB craftinginventorycb, int i, int j) {
a.b(((Packet) (new Packet105(craftinginventorycb.f, i, j))));
}
public void a(ItemStack itemstack) {}
public void L() {
a.b(((Packet) (new Packet101(ap.f))));
N();
}
public void M() {
if (am) {
return;
} else {
a.b(((Packet) (new Packet103(-1, -1, an.i()))));
return;
}
}
public void N() {
ap.a(((EntityPlayer) (this)));
ap = ao;
}
}

View File

@ -7,85 +7,53 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSheep; import org.bukkit.craftbukkit.entity.CraftSheep;
// CraftBukkit end // CraftBukkit end
public class EntitySheep extends EntityAnimals { public class EntitySheep extends EntityAnimal {
public static final float a[][] = { public static final float[][] a = new float[][] { { 1.0F, 1.0F, 1.0F}, { 0.95F, 0.7F, 0.2F}, { 0.9F, 0.5F, 0.85F}, { 0.6F, 0.7F, 0.95F}, { 0.9F, 0.9F, 0.2F}, { 0.5F, 0.8F, 0.1F}, { 0.95F, 0.7F, 0.8F}, { 0.3F, 0.3F, 0.3F}, { 0.6F, 0.6F, 0.6F}, { 0.3F, 0.6F, 0.7F}, { 0.7F, 0.4F, 0.9F}, { 0.2F, 0.4F, 0.8F}, { 0.5F, 0.4F, 0.3F}, { 0.4F, 0.5F, 0.2F}, { 0.8F, 0.3F, 0.3F}, { 0.1F, 0.1F, 0.1F}};
{
1.0F, 1.0F, 1.0F
}, {
0.95F, 0.7F, 0.2F
}, {
0.9F, 0.5F, 0.85F
}, {
0.6F, 0.7F, 0.95F
}, {
0.9F, 0.9F, 0.2F
}, {
0.5F, 0.8F, 0.1F
}, {
0.95F, 0.7F, 0.8F
}, {
0.3F, 0.3F, 0.3F
}, {
0.6F, 0.6F, 0.6F
}, {
0.3F, 0.6F, 0.7F
}, {
0.7F, 0.4F, 0.9F
}, {
0.2F, 0.4F, 0.8F
}, {
0.5F, 0.4F, 0.3F
}, {
0.4F, 0.5F, 0.2F
}, {
0.8F, 0.3F, 0.3F
}, {
0.1F, 0.1F, 0.1F
}
};
public EntitySheep(World world) { public EntitySheep(World world) {
super(world); super(world);
aP = "/mob/sheep.png"; this.texture = "/mob/sheep.png";
a(0.9F, 1.3F); this.a(0.9F, 1.3F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSheep(server, this); this.bukkitEntity = new CraftSheep(server, this);
// CraftBukkit end // CraftBukkit end
} }
protected void a() { protected void a() {
super.a(); super.a();
af.a(16, ((new Byte((byte) 0)))); this.datawatcher.a(16, new Byte((byte) 0));
} }
public boolean a(Entity entity, int i) { public boolean a(Entity entity, int i) {
if (!l.z && !f_() && (entity instanceof EntityLiving)) { if (!this.world.isStatic && !this.f_() && entity instanceof EntityLiving) {
a(true); this.a(true);
int j = 1 + W.nextInt(3); int j = 1 + this.random.nextInt(3);
for (int k = 0; k < j; k++) { for (int k = 0; k < j; ++k) {
EntityItem entityitem = a(new ItemStack(Block.ab.bi, 1, e_()), 1.0F); EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.e_()), 1.0F);
entityitem.t += W.nextFloat() * 0.05F; entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
entityitem.s += (W.nextFloat() - W.nextFloat()) * 0.1F; entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.u += (W.nextFloat() - W.nextFloat()) * 0.1F; entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
} }
} }
return super.a(entity, i); return super.a(entity, i);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
nbttagcompound.a("Sheared", f_()); nbttagcompound.a("Sheared", this.f_());
nbttagcompound.a("Color", (byte) e_()); nbttagcompound.a("Color", (byte) this.e_());
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
a(nbttagcompound.l("Sheared")); this.a(nbttagcompound.l("Sheared"));
a(((int) (nbttagcompound.b("Color")))); this.a(nbttagcompound.b("Color"));
} }
protected String e() { protected String e() {
@ -101,38 +69,32 @@ public class EntitySheep extends EntityAnimals {
} }
public int e_() { public int e_() {
return af.a(16) & 0xf; return this.datawatcher.a(16) & 15;
} }
public void a(int i) { public void a(int i) {
byte byte0 = af.a(16); byte b0 = this.datawatcher.a(16);
af.b(16, ((Byte.valueOf((byte) (byte0 & 0xf0 | i & 0xf))))); this.datawatcher.b(16, Byte.valueOf((byte) (b0 & 240 | i & 15)));
} }
public boolean f_() { public boolean f_() {
return (af.a(16) & 0x10) != 0; return (this.datawatcher.a(16) & 16) != 0;
} }
public void a(boolean flag) { public void a(boolean flag) {
byte byte0 = af.a(16); byte b0 = this.datawatcher.a(16);
if (flag) { if (flag) {
af.b(16, ((Byte.valueOf((byte) (byte0 | 0x10))))); this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 16)));
} else { } else {
af.b(16, ((Byte.valueOf((byte) (byte0 & 0xffffffef))))); this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -17)));
} }
} }
public static int a(Random random) { public static int a(Random random) {
int i = random.nextInt(100); int i = random.nextInt(100);
if (i < 5) { return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : 0));
return 15;
}
if (i < 10) {
return 7;
}
return i >= 15 ? 0 : 8;
} }
} }

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftSkeleton; import org.bukkit.craftbukkit.entity.CraftSkeleton;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -9,15 +7,16 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
// CraftBukkit end // CraftBukkit end
public class EntitySkeleton extends EntityMobs { public class EntitySkeleton extends EntityMonster {
private static final ItemStack a; private static final ItemStack a = new ItemStack(Item.BOW, 1);
public EntitySkeleton(World world) { public EntitySkeleton(World world) {
super(world); super(world);
aP = "/mob/skeleton.png"; this.texture = "/mob/skeleton.png";
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSkeleton(server, this); this.bukkitEntity = new CraftSkeleton(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -35,44 +34,46 @@ public class EntitySkeleton extends EntityMobs {
} }
public void o() { public void o() {
if (l.b()) { if (this.world.b()) {
float f1 = b(1.0F); float f = this.b(1.0F);
if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) { if (f > 0.5F && this.world.i(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.ENTITY_COMBUST; Type eventType = Type.ENTITY_COMBUST;
org.bukkit.entity.Entity entity = this.getBukkitEntity(); org.bukkit.entity.Entity entity = this.getBukkitEntity();
EntityCombustEvent event = new EntityCombustEvent(eventType, entity); EntityCombustEvent event = new EntityCombustEvent(eventType, entity);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
Z = 300; this.fireTicks = 300;
} }
// CraftBukkit end // CraftBukkit end
} }
} }
super.o(); super.o();
} }
protected void a(Entity entity, float f1) { protected void a(Entity entity, float f) {
if (f1 < 10F) { if (f < 10.0F) {
double d = entity.p - p; double d0 = entity.locX - this.locX;
double d1 = entity.r - r; double d1 = entity.locZ - this.locZ;
if (bf == 0) { if (this.attackTicks == 0) {
EntityArrow entityarrow = new EntityArrow(l, ((EntityLiving) (this))); EntityArrow entityarrow = new EntityArrow(this.world, this);
entityarrow.q += 1.3999999761581421D; ++entityarrow.locY;
double d2 = entity.q - 0.20000000298023224D - entityarrow.q; double d2 = entity.locY - 0.20000000298023224D - entityarrow.locY;
float f2 = MathHelper.a(d * d + d1 * d1) * 0.2F; float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F;
l.a(((Entity) (this)), "random.bow", 1.0F, 1.0F / (W.nextFloat() * 0.4F + 0.8F)); this.world.a(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
l.a(((Entity) (entityarrow))); this.world.a((Entity) entityarrow);
entityarrow.a(d, d2 + (double) f2, d1, 0.6F, 12F); entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F);
bf = 30; this.attackTicks = 30;
} }
v = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
e = true; this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.e = true;
} }
} }
@ -85,23 +86,22 @@ public class EntitySkeleton extends EntityMobs {
} }
protected int h() { protected int h() {
return Item.j.ba; return Item.ARROW.id;
} }
protected void g_() { protected void g_() {
int i = W.nextInt(3); int i = this.random.nextInt(3);
for (int j = 0; j < i; j++) { int j;
a(Item.j.ba, 1);
for (j = 0; j < i; ++j) {
this.a(Item.ARROW.id, 1);
} }
i = W.nextInt(3); i = this.random.nextInt(3);
for (int k = 0; k < i; k++) {
a(Item.aV.ba, 1);
}
}
static { for (j = 0; j < i; ++j) {
a = new ItemStack(Item.i, 1); this.a(Item.BONE.id, 1);
}
} }
} }

View File

@ -1,118 +1,122 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSlime; import org.bukkit.craftbukkit.entity.CraftSlime;
// CraftBukkit stop // CraftBukkit stop
public class EntitySlime extends EntityLiving implements IMobs { public class EntitySlime extends EntityLiving implements IMonster {
public float a; public float a;
public float b; public float b;
private int d; private int d = 0;
public int c; public int c = 1;
public EntitySlime(World world) { public EntitySlime(World world) {
super(world); super(world);
d = 0; this.texture = "/mob/slime.png";
c = 1; this.c = 1 << this.random.nextInt(3);
aP = "/mob/slime.png"; this.height = 0.0F;
c = 1 << W.nextInt(3); this.d = this.random.nextInt(20) + 10;
H = 0.0F; this.a(this.c);
d = W.nextInt(20) + 10;
a(c);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSlime(server, this); this.bukkitEntity = new CraftSlime(server, this);
// CraftBukkit end // CraftBukkit end
} }
public void a(int j) { public void a(int i) {
c = j; this.c = i;
a(0.6F * (float) j, 0.6F * (float) j); this.a(0.6F * (float) i, 0.6F * (float) i);
aZ = j * j; this.health = i * i;
a(p, q, r); this.a(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
nbttagcompound.a("Size", c - 1); nbttagcompound.a("Size", this.c - 1);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
c = nbttagcompound.d("Size") + 1; this.c = nbttagcompound.d("Size") + 1;
} }
public void b_() { public void b_() {
b = a; this.b = this.a;
boolean flag = A; boolean flag = this.onGround;
super.b_(); super.b_();
if (A && !flag) { if (this.onGround && !flag) {
for (int j = 0; j < c * 8; j++) { for (int i = 0; i < this.c * 8; ++i) {
float f1 = W.nextFloat() * 3.141593F * 2.0F; float f = this.random.nextFloat() * 3.1415927F * 2.0F;
float f2 = W.nextFloat() * 0.5F + 0.5F; float f1 = this.random.nextFloat() * 0.5F + 0.5F;
float f3 = MathHelper.a(f1) * (float) c * 0.5F * f2; float f2 = MathHelper.a(f) * (float) this.c * 0.5F * f1;
float f4 = MathHelper.b(f1) * (float) c * 0.5F * f2; float f3 = MathHelper.b(f) * (float) this.c * 0.5F * f1;
l.a("slime", p + (double) f3, z.b, r + (double) f4, 0.0D, 0.0D, 0.0D); this.world.a("slime", this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D);
} }
if (c > 2) { if (this.c > 2) {
l.a(((Entity) (this)), "mob.slime", i(), ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) / 0.8F); this.world.a(this, "mob.slime", this.i(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
} }
a = -0.5F;
this.a = -0.5F;
} }
a = a * 0.6F;
this.a *= 0.6F;
} }
protected void d() { protected void d() {
EntityPlayer entityplayer = l.a(((Entity) (this)), 16D); EntityHuman entityhuman = this.world.a(this, 16.0D);
if (entityplayer != null) { if (entityhuman != null) {
b(((Entity) (entityplayer)), 10F); this.b(entityhuman, 10.0F);
} }
if (A && d-- <= 0) {
d = W.nextInt(20) + 10; if (this.onGround && this.d-- <= 0) {
if (entityplayer != null) { this.d = this.random.nextInt(20) + 10;
d /= 3; if (entityhuman != null) {
this.d /= 3;
} }
bA = true;
if (c > 1) { this.bA = true;
l.a(((Entity) (this)), "mob.slime", i(), ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) * 0.8F); if (this.c > 1) {
this.world.a(this, "mob.slime", this.i(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
} }
a = 1.0F;
bx = 1.0F - W.nextFloat() * 2.0F; this.a = 1.0F;
by = 1 * c; this.bx = 1.0F - this.random.nextFloat() * 2.0F;
this.by = (float) (1 * this.c);
} else { } else {
bA = false; this.bA = false;
if (A) { if (this.onGround) {
bx = by = 0.0F; this.bx = this.by = 0.0F;
} }
} }
} }
public void q() { public void q() {
if (c > 1 && aZ == 0) { if (this.c > 1 && this.health == 0) {
for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; ++i) {
float f1 = (((float) (j % 2) - 0.5F) * (float) c) / 4F; float f = ((float) (i % 2) - 0.5F) * (float) this.c / 4.0F;
float f2 = (((float) (j / 2) - 0.5F) * (float) c) / 4F; float f1 = ((float) (i / 2) - 0.5F) * (float) this.c / 4.0F;
EntitySlime entityslime = new EntitySlime(l); EntitySlime entityslime = new EntitySlime(this.world);
entityslime.a(c / 2); entityslime.a(this.c / 2);
entityslime.c(p + (double) f1, q + 0.5D, r + (double) f2, W.nextFloat() * 360F, 0.0F); entityslime.c(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
l.a(((Entity) (entityslime))); this.world.a((Entity) entityslime);
} }
} }
super.q(); super.q();
} }
public void b(EntityPlayer entityplayer) { public void b(EntityHuman entityhuman) {
if (c > 1 && i(((Entity) (entityplayer))) && (double) a(((Entity) (entityplayer))) < 0.59999999999999998D * (double) c && entityplayer.a(((Entity) (this)), c)) { // CraftBukkit - add cast to Entity VVVVVVVV
l.a(((Entity) (this)), "mob.slimeattack", 1.0F, (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F); if (this.c > 1 && this.i(entityhuman) && (double) this.a((Entity) entityhuman) < 0.6D * (double) this.c && entityhuman.a(this, this.c)) {
this.world.a(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
} }
} }
@ -125,17 +129,13 @@ public class EntitySlime extends EntityLiving implements IMobs {
} }
protected int h() { protected int h() {
if (c == 1) { return this.c == 1 ? Item.SLIME_BALL.id : 0;
return Item.aK.ba;
} else {
return 0;
}
} }
public boolean b() { public boolean b() {
Chunk chunk = l.b(MathHelper.b(p), MathHelper.b(r)); Chunk chunk = this.world.b(MathHelper.b(this.locX), MathHelper.b(this.locZ));
return (c == 1 || l.k > 0) && W.nextInt(10) == 0 && chunk.a(0x3ad8025fL).nextInt(10) == 0 && q < 16D; return (this.c == 1 || this.world.k > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 16.0D;
} }
protected float i() { protected float i() {

View File

@ -1,7 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -13,28 +12,22 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntitySnowball extends Entity { public class EntitySnowball extends Entity {
private int b; private int b = -1;
private int c; private int c = -1;
private int d; private int d = -1;
private int e; private int e = 0;
private boolean f; private boolean f = false;
public int a; public int a = 0;
private EntityLiving ak; private EntityLiving ak;
private int al; private int al;
private int am; private int am = 0;
public EntitySnowball(World world) { public EntitySnowball(World world) {
super(world); super(world);
b = -1; this.a(0.25F, 0.25F);
c = -1;
d = -1;
e = 0;
f = false;
a = 0;
am = 0;
a(0.25F, 0.25F);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSnowball(server, this); this.bukkitEntity = new CraftSnowball(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -42,117 +35,117 @@ public class EntitySnowball extends Entity {
protected void a() {} protected void a() {}
public EntitySnowball(World world, EntityLiving entityliving) { public EntitySnowball(World world, EntityLiving entityliving) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end
ak = entityliving;
c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w);
p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
q -= 0.10000000149011612D;
r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
a(p, q, r);
H = 0.0F;
float f1 = 0.4F;
s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.ak = entityliving;
u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1; this.a(0.25F, 0.25F);
t = -MathHelper.a((w / 180F) * 3.141593F) * f1; this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
a(s, t, u, 1.5F, 1.0F); this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ);
this.height = 0.0F;
float f = 0.4F;
this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
public EntitySnowball(World world, double d1, double d2, double d3) { public EntitySnowball(World world, double d0, double d1, double d2) {
// CraftBukkit start this(world); // CraftBukkit super->this so we assign the entity
this(world);
// CraftBukkit end this.al = 0;
this.a(0.25F, 0.25F);
al = 0; this.a(d0, d1, d2);
a(d1, d2, d3); this.height = 0.0F;
H = 0.0F;
} }
public void a(double d1, double d2, double d3, float f1, float f2) { public void a(double d0, double d1, double d2, float f, float f1) {
float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3); float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d1 /= f3; d0 /= (double) f2;
d2 /= f3; d1 /= (double) f2;
d3 /= f3; d2 /= (double) f2;
d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2; d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
d1 *= f1; d0 *= (double) f;
d2 *= f1; d1 *= (double) f;
d3 *= f1; d2 *= (double) f;
s = d1; this.motX = d0;
t = d2; this.motY = d1;
u = d3; this.motZ = d2;
float f4 = MathHelper.a(d1 * d1 + d3 * d3); float f3 = MathHelper.a(d0 * d0 + d2 * d2);
x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D); this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D); this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
al = 0; this.al = 0;
} }
public void b_() { public void b_() {
O = p; this.O = this.locX;
P = q; this.P = this.locY;
Q = r; this.Q = this.locZ;
super.b_(); super.b_();
if (a > 0) { if (this.a > 0) {
a--; --this.a;
} }
if (f) {
int i = this.l.a(b, c, d);
if (i != e) { if (this.f) {
f = false; int i = this.world.getTypeId(this.b, this.c, this.d);
s *= W.nextFloat() * 0.2F;
t *= W.nextFloat() * 0.2F; if (i == this.e) {
u *= W.nextFloat() * 0.2F; ++this.al;
al = 0; if (this.al == 1200) {
am = 0; this.q();
} else {
al++;
if (al == 1200) {
q();
} }
return; return;
} }
} else {
am++;
}
Vec3D vec3d = Vec3D.b(p, q, r);
Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
vec3d = Vec3D.b(p, q, r); this.f = false;
vec3d1 = Vec3D.b(p + s, q + t, r + u); 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.al = 0;
this.am = 0;
} else {
++this.am;
}
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) { if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
if (!this.l.z) {
if (!this.world.isStatic) {
Entity entity = null; Entity entity = null;
List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D)); List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
double d1 = 0.0D; double d0 = 0.0D;
for (int k = 0; k < list.size(); k++) { for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(k); Entity entity1 = (Entity) list.get(j);
if (!entity1.c_() || entity1 == ak && am < 5) { if (entity1.c_() && (entity1 != this.ak || this.am >= 5)) {
continue; float f = 0.3F;
} AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
float f4 = 0.3F; MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
AxisAlignedBB axisalignedbb = entity1.z.b(f4, f4, f4);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 == null) { if (movingobjectposition1 != null) {
continue; double d1 = vec3d.a(movingobjectposition1.f);
}
double d2 = vec3d.a(movingobjectposition1.f);
if (d2 < d1 || d1 == 0.0D) { if (d1 < d0 || d0 == 0.0D) {
entity = entity1; entity = entity1;
d1 = d2; d0 = d1;
}
}
} }
} }
@ -160,105 +153,114 @@ public class EntitySnowball extends Entity {
movingobjectposition = new MovingObjectPosition(entity); movingobjectposition = new MovingObjectPosition(entity);
} }
} }
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.g != null) {
// CraftBukkit start boolean stick;
boolean bounce;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.g instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (ak == null)?null:ak.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.ak == null) ? null : this.ak.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity(); org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0; int damage = 0;
// TODO @see EntityArrow#162 // TODO @see EntityArrow#162
EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage); EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
server.getPluginManager().callEvent(edbpe); server.getPluginManager().callEvent(event);
if(!edbpe.isCancelled()) { if(!event.isCancelled()) {
// this function returns if the snowball should stick or not, i.e. !bounce // this function returns if the snowball should stick or not, i.e. !bounce
bounce = !movingobjectposition.g.a(((Entity) (ak)), edbpe.getDamage()); stick = movingobjectposition.g.a(this.ak, event.getDamage());
} else { } else {
// event was cancelled, get if the snowball should bounce or not // event was cancelled, get if the snowball should bounce or not
bounce = edbpe.getBounce(); stick = !event.getBounce();
} }
} else { } else {
bounce = !movingobjectposition.g.a(((Entity) (ak)), 0); stick = movingobjectposition.g.a(this.ak, 0);
} }
if (!bounce) { if (stick) {
// CraftBukkit end
; ;
} }
} // CraftBukkit end
for (int j = 0; j < 8; j++) {
this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D);
} }
q(); for (int k = 0; k < 8; ++k) {
} this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
p += s; }
q += t;
r += u;
float f1 = MathHelper.a(s * s + u * u);
v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D); this.q();
for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) { }
this.locX += this.motX;
this.locY += this.motY;
this.locZ += this.motZ;
float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
; ;
} }
for (; w - y >= 180F; y += 360F) {
; while (this.pitch - this.lastPitch >= 180.0F) {
this.lastPitch += 360.0F;
} }
for (; v - x < -180F; x -= 360F) {
; while (this.yaw - this.lastYaw < -180.0F) {
this.lastYaw -= 360.0F;
} }
for (; v - x >= 180F; x += 360F) {
; while (this.yaw - this.lastYaw >= 180.0F) {
this.lastYaw += 360.0F;
} }
w = y + (w - y) * 0.2F;
v = x + (v - x) * 0.2F; this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.99F; float f2 = 0.99F;
float f5 = 0.03F; float f3 = 0.03F;
if (v()) { if (this.v()) {
for (int l = 0; l < 4; l++) { for (int l = 0; l < 4; ++l) {
float f3 = 0.25F; float f4 = 0.25F;
this.l.a("bubble", p - s * (double) f3, q - t * (double) f3, r - u * (double) f3, s, t, u); this.world.a("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);
} }
f2 = 0.8F; f2 = 0.8F;
} }
s *= f2;
t *= f2; this.motX *= (double) f2;
u *= f2; this.motY *= (double) f2;
t -= f5; this.motZ *= (double) f2;
a(p, q, r); this.motY -= (double) f3;
this.a(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("xTile", (short) b); nbttagcompound.a("xTile", (short) this.b);
nbttagcompound.a("yTile", (short) c); nbttagcompound.a("yTile", (short) this.c);
nbttagcompound.a("zTile", (short) d); nbttagcompound.a("zTile", (short) this.d);
nbttagcompound.a("inTile", (byte) e); nbttagcompound.a("inTile", (byte) this.e);
nbttagcompound.a("shake", (byte) a); nbttagcompound.a("shake", (byte) this.a);
nbttagcompound.a("inGround", (byte) (f ? 1 : 0)); nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
b = ((int) (nbttagcompound.c("xTile"))); this.b = nbttagcompound.c("xTile");
c = ((int) (nbttagcompound.c("yTile"))); this.c = nbttagcompound.c("yTile");
d = ((int) (nbttagcompound.c("zTile"))); this.d = nbttagcompound.c("zTile");
e = nbttagcompound.b("inTile") & 0xff; this.e = nbttagcompound.b("inTile") & 255;
a = nbttagcompound.b("shake") & 0xff; this.a = nbttagcompound.b("shake") & 255;
f = nbttagcompound.b("inGround") == 1; this.f = nbttagcompound.b("inGround") == 1;
} }
public void b(EntityPlayer entityplayer) { public void b(EntityHuman entityhuman) {
if (f && ak == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) { if (this.f && this.ak == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F); this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.c(((Entity) (this)), 1); entityhuman.c(this, 1);
q(); this.q();
} }
} }
} }

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
@ -10,30 +8,31 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit stop // CraftBukkit stop
public class EntitySpider extends EntityMobs { public class EntitySpider extends EntityMonster {
public EntitySpider(World world) { public EntitySpider(World world) {
super(world); super(world);
aP = "/mob/spider.png"; this.texture = "/mob/spider.png";
a(1.4F, 0.9F); this.a(1.4F, 0.9F);
bC = 0.8F; this.bC = 0.8F;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSpider(server, this); this.bukkitEntity = new CraftSpider(server, this);
// CraftBukkit end // CraftBukkit end
} }
public double k() { public double k() {
return (double) J * 0.75D - 0.5D; return (double) this.width * 0.75D - 0.5D;
} }
protected Entity l() { protected Entity l() {
float f1 = b(1.0F); float f = this.b(1.0F);
if (f1 < 0.5F) { if (f < 0.5F) {
double d = 16D; double d0 = 16.0D;
return ((Entity) (l.a(((Entity) (this)), d))); return this.world.a(this, d0);
} else { } else {
return null; return null;
} }
@ -51,16 +50,16 @@ public class EntitySpider extends EntityMobs {
return "mob.spiderdeath"; return "mob.spiderdeath";
} }
protected void a(Entity entity, float f1) { protected void a(Entity entity, float f) {
float f2 = b(1.0F); float f1 = this.b(1.0F);
if (f2 > 0.5F && W.nextInt(100) == 0) { if (f1 > 0.5F && this.random.nextInt(100) == 0) {
// CraftBukkit start // CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET);
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if(!event.isCancelled()) { if (!event.isCancelled()) {
if(event.getTarget() == null) { if (event.getTarget() == null) {
this.d = null; this.d = null;
} else { } else {
this.d = ((CraftEntity) event.getTarget()).getHandle(); this.d = ((CraftEntity) event.getTarget()).getHandle();
@ -68,19 +67,20 @@ public class EntitySpider extends EntityMobs {
return; return;
} }
// CraftBukkit end // CraftBukkit end
}
if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
if (A) {
double d = entity.p - p;
double d1 = entity.r - r;
float f3 = MathHelper.a(d * d + d1 * d1);
s = (d / (double) f3) * 0.5D * 0.80000001192092896D + s * 0.20000000298023224D;
u = (d1 / (double) f3) * 0.5D * 0.80000001192092896D + u * 0.20000000298023224D;
t = 0.40000000596046448D;
}
} else { } else {
super.a(entity, f1); if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) {
if (this.onGround) {
double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ;
float f2 = MathHelper.a(d0 * d0 + d1 * d1);
this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D;
this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D;
this.motY = 0.4000000059604645D;
}
} else {
super.a(entity, f);
}
} }
} }
@ -93,10 +93,10 @@ public class EntitySpider extends EntityMobs {
} }
protected int h() { protected int h() {
return Item.I.ba; return Item.STRING.id;
} }
public boolean m() { public boolean m() {
return B; return this.B;
} }
} }

View File

@ -1,50 +1,35 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSquid; import org.bukkit.craftbukkit.entity.CraftSquid;
// CraftBukkit stop // CraftBukkit stop
public class EntitySquid extends EntityWaterMob { public class EntitySquid extends EntityWaterAnimal {
public float a; public float a = 0.0F;
public float b; public float b = 0.0F;
public float c; public float c = 0.0F;
public float f; public float f = 0.0F;
public float ak; public float ak = 0.0F;
public float al; public float al = 0.0F;
public float am; public float am = 0.0F;
public float an; public float an = 0.0F;
private float ao; private float ao = 0.0F;
private float ap; private float ap = 0.0F;
private float aq; private float aq = 0.0F;
private float ar; private float ar = 0.0F;
private float as; private float as = 0.0F;
private float at; private float at = 0.0F;
public EntitySquid(World world) { public EntitySquid(World world) {
super(world); super(world);
a = 0.0F; this.texture = "/mob/squid.png";
b = 0.0F; this.a(0.95F, 0.95F);
c = 0.0F; this.ap = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
f = 0.0F;
ak = 0.0F;
al = 0.0F;
am = 0.0F;
an = 0.0F;
ao = 0.0F;
ap = 0.0F;
aq = 0.0F;
ar = 0.0F;
as = 0.0F;
at = 0.0F;
aP = "/mob/squid.png";
a(0.95F, 0.95F);
ap = (1.0F / (W.nextFloat() + 1.0F)) * 0.2F;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSquid(server, this); this.bukkitEntity = new CraftSquid(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -78,18 +63,18 @@ public class EntitySquid extends EntityWaterMob {
} }
protected void g_() { protected void g_() {
int j = W.nextInt(3) + 1; int i = this.random.nextInt(3) + 1;
for (int k = 0; k < j; k++) { for (int j = 0; j < i; ++j) {
a(new ItemStack(Item.aU, 1, 0), 0.0F); this.a(new ItemStack(Item.INK_SACK, 1, 0), 0.0F);
} }
} }
public boolean a(EntityPlayer entityplayer) { public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityplayer.an.e(); ItemStack itemstack = entityhuman.inventory.e();
if (itemstack != null && itemstack.c == Item.au.ba) { if (itemstack != null && itemstack.id == Item.BUCKET.id) {
entityplayer.an.a(entityplayer.an.c, new ItemStack(Item.aE)); entityhuman.inventory.a(entityhuman.inventory.c, new ItemStack(Item.MILK_BUCKET));
return true; return true;
} else { } else {
return false; return false;
@ -97,72 +82,76 @@ public class EntitySquid extends EntityWaterMob {
} }
public boolean v() { public boolean v() {
return l.a(z.b(0.0D, -0.60000002384185791D, 0.0D), Material.f, ((Entity) (this))); return this.world.a(this.boundingBox.b(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this);
} }
public void o() { public void o() {
super.o(); super.o();
b = a; this.b = this.a;
f = c; this.f = this.c;
al = ak; this.al = this.ak;
an = am; this.an = this.am;
ak += ap; this.ak += this.ap;
if (ak > 6.283185F) { if (this.ak > 6.2831855F) {
ak -= 6.283185F; this.ak -= 6.2831855F;
if (W.nextInt(10) == 0) { if (this.random.nextInt(10) == 0) {
ap = (1.0F / (W.nextFloat() + 1.0F)) * 0.2F; this.ap = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
} }
} }
if (v()) {
if (ak < 3.141593F) {
float f1 = ak / 3.141593F;
am = MathHelper.a(f1 * f1 * 3.141593F) * 3.141593F * 0.25F; if (this.v()) {
if ((double) f1 > 0.75D) { float f;
ao = 1.0F;
aq = 1.0F; if (this.ak < 3.1415927F) {
f = this.ak / 3.1415927F;
this.am = MathHelper.a(f * f * 3.1415927F) * 3.1415927F * 0.25F;
if ((double) f > 0.75D) {
this.ao = 1.0F;
this.aq = 1.0F;
} else { } else {
aq = aq * 0.8F; this.aq *= 0.8F;
} }
} else { } else {
am = 0.0F; this.am = 0.0F;
ao = ao * 0.9F; this.ao *= 0.9F;
aq = aq * 0.99F; this.aq *= 0.99F;
} }
if (!aW) {
s = ar * ao;
t = as * ao;
u = at * ao;
}
float f2 = MathHelper.a(s * s + u * u);
aI += ((-(float) Math.atan2(s, u) * 180F) / 3.141593F - aI) * 0.1F; if (!this.aW) {
v = aI; this.motX = (double) (this.ar * this.ao);
c = c + 3.141593F * aq * 1.5F; this.motY = (double) (this.as * this.ao);
a += ((-(float) Math.atan2(f2, t) * 180F) / 3.141593F - a) * 0.1F; this.motZ = (double) (this.at * this.ao);
} else {
am = MathHelper.e(MathHelper.a(ak)) * 3.141593F * 0.25F;
if (!aW) {
s = 0.0D;
t -= 0.080000000000000002D;
t *= 0.98000001907348633D;
u = 0.0D;
} }
a += ((float) ((double) (-90F - a) * 0.02D));
f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
this.aI += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aI) * 0.1F;
this.yaw = this.aI;
this.c += 3.1415927F * this.aq * 1.5F;
this.a += (-((float) Math.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.a) * 0.1F;
} else {
this.am = MathHelper.e(MathHelper.a(this.ak)) * 3.1415927F * 0.25F;
if (!this.aW) {
this.motX = 0.0D;
this.motY -= 0.08D;
this.motY *= 0.9800000190734863D;
this.motZ = 0.0D;
}
this.a = (float) ((double) this.a + (double) (-90.0F - this.a) * 0.02D);
} }
} }
public void c(float f1, float f2) { public void c(float f, float f1) {
c(s, t, u); this.c(this.motX, this.motY, this.motZ);
} }
protected void d() { protected void d() {
if (W.nextInt(50) == 0 || !ab || ar == 0.0F && as == 0.0F && at == 0.0F) { if (this.random.nextInt(50) == 0 || !this.ab || this.ar == 0.0F && this.as == 0.0F && this.at == 0.0F) {
float f1 = W.nextFloat() * 3.141593F * 2.0F; float f = this.random.nextFloat() * 3.1415927F * 2.0F;
ar = MathHelper.b(f1) * 0.2F; this.ar = MathHelper.b(f) * 0.2F;
as = -0.1F + W.nextFloat() * 0.2F; this.as = -0.1F + this.random.nextFloat() * 0.2F;
at = MathHelper.a(f1) * 0.2F; this.at = MathHelper.a(f) * 0.2F;
} }
} }
} }

View File

@ -11,70 +11,72 @@ public class EntityTNTPrimed extends Entity {
public EntityTNTPrimed(World world) { public EntityTNTPrimed(World world) {
super(world); super(world);
a = 0; this.a = 0;
i = true; this.i = true;
a(0.98F, 0.98F); this.a(0.98F, 0.98F);
H = J / 2.0F; this.height = this.width / 2.0F;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftTNTPrimed(server, this); this.bukkitEntity = new CraftTNTPrimed(server, this);
// CraftBukkit end // CraftBukkit end
} }
public EntityTNTPrimed(World world, double d1, double d2, double d3) { public EntityTNTPrimed(World world, double d0, double d1, double d2) {
this(world); this(world);
a(d1, d2, d3); this.a(d0, d1, d2);
float f = (float) (Math.random() * 3.1415927410125732D * 2D); float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
s = -MathHelper.a((f * 3.141593F) / 180F) * 0.02F; this.motX = (double) (-MathHelper.a(f * 3.1415927F / 180.0F) * 0.02F);
t = 0.20000000298023224D; this.motY = 0.20000000298023224D;
u = -MathHelper.b((f * 3.141593F) / 180F) * 0.02F; this.motZ = (double) (-MathHelper.b(f * 3.1415927F / 180.0F) * 0.02F);
M = false; this.M = false;
a = 80; this.a = 80;
m = d1; this.lastX = d0;
n = d2; this.lastY = d1;
o = d3; this.lastZ = d2;
} }
protected void a() {} protected void a() {}
public boolean c_() { public boolean c_() {
return !G; return !this.dead;
} }
public void b_() { public void b_() {
m = p; this.lastX = this.locX;
n = q; this.lastY = this.locY;
o = r; this.lastZ = this.locZ;
t -= 0.039999999105930328D; this.motY -= 0.03999999910593033D;
c(s, t, u); this.c(this.motX, this.motY, this.motZ);
s *= 0.98000001907348633D; this.motX *= 0.9800000190734863D;
t *= 0.98000001907348633D; this.motY *= 0.9800000190734863D;
u *= 0.98000001907348633D; this.motZ *= 0.9800000190734863D;
if (A) { if (this.onGround) {
s *= 0.69999998807907104D; this.motX *= 0.699999988079071D;
u *= 0.69999998807907104D; this.motZ *= 0.699999988079071D;
t *= -0.5D; this.motY *= -0.5D;
} }
if (a-- <= 0) {
q(); if (this.a-- <= 0) {
d(); this.q();
this.d();
} else { } else {
l.a("smoke", p, q + 0.5D, r, 0.0D, 0.0D, 0.0D); this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
} }
} }
private void d() { private void d() {
float f = 4F; float f = 4.0F;
l.a(((Entity) (null)), p, q, r, f); this.world.a((Entity) null, this.locX, this.locY, this.locZ, f);
} }
protected void a(NBTTagCompound nbttagcompound) { protected void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Fuse", (byte) a); nbttagcompound.a("Fuse", (byte) this.a);
} }
protected void b(NBTTagCompound nbttagcompound) { protected void b(NBTTagCompound nbttagcompound) {
a = ((int) (nbttagcompound.b("Fuse"))); this.a = nbttagcompound.b("Fuse");
} }
} }

View File

@ -1,155 +0,0 @@
package net.minecraft.server;
import java.util.*;
public class EntityTracker {
private Set a;
private MCHashTable b;
private MinecraftServer c;
private int d;
public EntityTracker(MinecraftServer minecraftserver) {
a = ((Set) (new HashSet()));
b = new MCHashTable();
c = minecraftserver;
d = minecraftserver.f.a();
}
public void a(Entity entity) {
if (entity instanceof EntityPlayerMP) {
a(entity, 512, 2);
EntityPlayerMP entityplayermp = (EntityPlayerMP) entity;
Iterator iterator = a.iterator();
do {
if (!iterator.hasNext()) {
break;
}
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
if (entitytrackerentry.a != entityplayermp) {
entitytrackerentry.b(entityplayermp);
}
} while (true);
} else if (entity instanceof EntityFish) {
a(entity, 64, 5, true);
} else if (entity instanceof EntityArrow) {
a(entity, 64, 5, true);
} else if (entity instanceof EntitySnowball) {
a(entity, 64, 5, true);
} else if (entity instanceof EntityEgg) {
a(entity, 64, 5, true);
} else if (entity instanceof EntityItem) {
a(entity, 64, 20, true);
} else if (entity instanceof EntityMinecart) {
a(entity, 160, 5, true);
} else if (entity instanceof EntityBoat) {
a(entity, 160, 5, true);
} else if (entity instanceof EntitySquid) {
a(entity, 160, 3, true);
} else if (entity instanceof IAnimals) {
a(entity, 160, 3);
} else if (entity instanceof EntityTNTPrimed) {
a(entity, 160, 10, true);
} else if (entity instanceof EntityFallingSand) {
a(entity, 160, 20, true);
} else if (entity instanceof EntityPainting) {
a(entity, 160, 0x7fffffff, false);
}
}
public void a(Entity entity, int i, int j) {
a(entity, i, j, false);
}
public void a(Entity entity, int i, int j, boolean flag) {
if (i > d) {
i = d;
}
if (b.b(entity.g)) {
throw new IllegalStateException("Entity is already tracked!");
} else {
EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j, flag);
a.add(((entitytrackerentry)));
b.a(entity.g, ((entitytrackerentry)));
entitytrackerentry.b(c.e.d);
return;
}
}
public void b(Entity entity) {
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) entity;
EntityTrackerEntry entitytrackerentry1;
for (Iterator iterator = a.iterator(); iterator.hasNext(); entitytrackerentry1.a(entityplayermp)) {
entitytrackerentry1 = (EntityTrackerEntry) iterator.next();
}
}
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.d(entity.g);
if (entitytrackerentry != null) {
a.remove(((entitytrackerentry)));
entitytrackerentry.a();
}
}
public void a() {
ArrayList arraylist = new ArrayList();
Iterator iterator = a.iterator();
do {
if (!iterator.hasNext()) {
break;
}
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
entitytrackerentry.a(c.e.d);
if (entitytrackerentry.m && (entitytrackerentry.a instanceof EntityPlayerMP)) {
((List) (arraylist)).add((((EntityPlayerMP) entitytrackerentry.a)));
}
} while (true);
label0:
for (int i = 0; i < ((List) (arraylist)).size(); i++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) ((List) (arraylist)).get(i);
Iterator iterator1 = a.iterator();
do {
if (!iterator1.hasNext()) {
continue label0;
}
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next();
if (entitytrackerentry1.a != entityplayermp) {
entitytrackerentry1.b(entityplayermp);
}
} while (true);
}
}
public void a(Entity entity, Packet packet) {
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.a(entity.g);
if (entitytrackerentry != null) {
entitytrackerentry.a(packet);
}
}
public void b(Entity entity, Packet packet) {
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.a(entity.g);
if (entitytrackerentry != null) {
entitytrackerentry.b(packet);
}
}
public void a(EntityPlayerMP entityplayermp) {
EntityTrackerEntry entitytrackerentry;
for (Iterator iterator = a.iterator(); iterator.hasNext(); entitytrackerentry.c(entityplayermp)) {
entitytrackerentry = (EntityTrackerEntry) iterator.next();
}
}
}

View File

@ -1,252 +0,0 @@
package net.minecraft.server;
import java.util.*;
public class EntityTrackerEntry {
public Entity a;
public int b;
public int c;
public int d;
public int e;
public int f;
public int g;
public int h;
public double i;
public double j;
public double k;
public int l;
private double o;
private double p;
private double q;
private boolean r;
private boolean s;
public boolean m;
public Set n;
public EntityTrackerEntry(Entity entity, int i1, int j1, boolean flag) {
l = 0;
r = false;
m = false;
n = ((Set) (new HashSet()));
a = entity;
b = i1;
c = j1;
s = flag;
d = MathHelper.b(entity.p * 32D);
e = MathHelper.b(entity.q * 32D);
f = MathHelper.b(entity.r * 32D);
g = MathHelper.d((entity.v * 256F) / 360F);
h = MathHelper.d((entity.w * 256F) / 360F);
}
public boolean equals(Object obj) {
if (obj instanceof EntityTrackerEntry) {
return ((EntityTrackerEntry) obj).a.g == a.g;
} else {
return false;
}
}
public int hashCode() {
return a.g;
}
public void a(List list) {
m = false;
if (!r || a.d(o, p, q) > 16D) {
o = a.p;
p = a.q;
q = a.r;
r = true;
m = true;
b(list);
}
if (++l % c == 0) {
int i1 = MathHelper.b(a.p * 32D);
int j1 = MathHelper.b(a.q * 32D);
int k1 = MathHelper.b(a.r * 32D);
int l1 = MathHelper.d((a.v * 256F) / 360F);
int i2 = MathHelper.d((a.w * 256F) / 360F);
boolean flag = i1 != d || j1 != e || k1 != f;
boolean flag1 = l1 != g || i2 != h;
int j2 = i1 - d;
int k2 = j1 - e;
int l2 = k1 - f;
Object obj = null;
if (j2 < -128 || j2 >= 128 || k2 < -128 || k2 >= 128 || l2 < -128 || l2 >= 128) {
obj = ((new Packet34EntityTeleport(a.g, i1, j1, k1, (byte) l1, (byte) i2)));
} else if (flag && flag1) {
obj = ((new Packet33RelEntityMoveLook(a.g, (byte) j2, (byte) k2, (byte) l2, (byte) l1, (byte) i2)));
} else if (flag) {
obj = ((new Packet31RelEntityMove(a.g, (byte) j2, (byte) k2, (byte) l2)));
} else if (flag1) {
obj = ((new Packet32EntityLook(a.g, (byte) l1, (byte) i2)));
} else {
obj = ((new Packet30Entity(a.g)));
}
if (s) {
double d1 = a.s - i;
double d2 = a.t - j;
double d3 = a.u - k;
double d4 = 0.02D;
double d5 = d1 * d1 + d2 * d2 + d3 * d3;
if (d5 > d4 * d4 || d5 > 0.0D && a.s == 0.0D && a.t == 0.0D && a.u == 0.0D) {
i = a.s;
j = a.t;
k = a.u;
a(((Packet) (new Packet28(a.g, i, j, k))));
}
}
if (obj != null) {
a(((Packet) (obj)));
}
DataWatcher datawatcher = a.p();
if (datawatcher.a()) {
b(((Packet) (new Packet40(a.g, datawatcher))));
}
d = i1;
e = j1;
f = k1;
g = l1;
h = i2;
}
if (a.E) {
b(((Packet) (new Packet28(a))));
a.E = false;
}
}
public void a(Packet packet) {
EntityPlayerMP entityplayermp;
for (Iterator iterator = n.iterator(); iterator.hasNext(); entityplayermp.a.b(packet)) {
entityplayermp = (EntityPlayerMP) iterator.next();
}
}
public void b(Packet packet) {
a(packet);
if (a instanceof EntityPlayerMP) {
((EntityPlayerMP) a).a.b(packet);
}
}
public void a() {
a(((Packet) (new Packet29DestroyEntity(a.g))));
}
public void a(EntityPlayerMP entityplayermp) {
if (n.contains(((entityplayermp)))) {
n.remove(((entityplayermp)));
}
}
public void b(EntityPlayerMP entityplayermp) {
if (entityplayermp == a) {
return;
}
double d1 = entityplayermp.p - (double) (d / 32);
double d2 = entityplayermp.r - (double) (f / 32);
if (d1 >= (double) (-b) && d1 <= (double) b && d2 >= (double) (-b) && d2 <= (double) b) {
if (!n.contains(((entityplayermp)))) {
n.add(((entityplayermp)));
entityplayermp.a.b(b());
if (s) {
entityplayermp.a.b(((Packet) (new Packet28(a.g, a.s, a.t, a.u))));
}
ItemStack aitemstack[] = a.I();
if (aitemstack != null) {
for (int i1 = 0; i1 < aitemstack.length; i1++) {
entityplayermp.a.b(((Packet) (new Packet5PlayerInventory(a.g, i1, aitemstack[i1]))));
}
}
}
} else if (n.contains(((entityplayermp)))) {
n.remove(((entityplayermp)));
entityplayermp.a.b(((Packet) (new Packet29DestroyEntity(a.g))));
}
}
public void b(List list) {
for (int i1 = 0; i1 < list.size(); i1++) {
b((EntityPlayerMP) list.get(i1));
}
}
private Packet b() {
if (a instanceof EntityItem) {
EntityItem entityitem = (EntityItem) a;
Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem);
entityitem.p = (double) packet21pickupspawn.b / 32D;
entityitem.q = (double) packet21pickupspawn.c / 32D;
entityitem.r = (double) packet21pickupspawn.d / 32D;
return ((Packet) (packet21pickupspawn));
}
if (a instanceof EntityPlayerMP) {
return ((Packet) (new Packet20NamedEntitySpawn((EntityPlayer) a)));
}
if (a instanceof EntityMinecart) {
EntityMinecart entityminecart = (EntityMinecart) a;
if (entityminecart.d == 0) {
return ((Packet) (new Packet23VehicleSpawn(a, 10)));
}
if (entityminecart.d == 1) {
return ((Packet) (new Packet23VehicleSpawn(a, 11)));
}
if (entityminecart.d == 2) {
return ((Packet) (new Packet23VehicleSpawn(a, 12)));
}
}
if (a instanceof EntityBoat) {
return ((Packet) (new Packet23VehicleSpawn(a, 1)));
}
if (a instanceof IAnimals) {
return ((Packet) (new Packet24MobSpawn((EntityLiving) a)));
}
if (a instanceof EntityFish) {
return ((Packet) (new Packet23VehicleSpawn(a, 90)));
}
if (a instanceof EntityArrow) {
return ((Packet) (new Packet23VehicleSpawn(a, 60)));
}
if (a instanceof EntitySnowball) {
return ((Packet) (new Packet23VehicleSpawn(a, 61)));
}
if (a instanceof EntityEgg) {
return ((Packet) (new Packet23VehicleSpawn(a, 62)));
}
if (a instanceof EntityTNTPrimed) {
return ((Packet) (new Packet23VehicleSpawn(a, 50)));
}
if (a instanceof EntityFallingSand) {
EntityFallingSand entityfallingsand = (EntityFallingSand) a;
if (entityfallingsand.a == Block.E.bi) {
return ((Packet) (new Packet23VehicleSpawn(a, 70)));
}
if (entityfallingsand.a == Block.F.bi) {
return ((Packet) (new Packet23VehicleSpawn(a, 71)));
}
}
if (a instanceof EntityPainting) {
return ((Packet) (new Packet25((EntityPainting) a)));
} else {
throw new IllegalArgumentException((new StringBuilder()).append("Don't know how to add ").append(((((a)).getClass()))).append("!").toString());
}
}
public void c(EntityPlayerMP entityplayermp) {
if (n.contains(((entityplayermp)))) {
n.remove(((entityplayermp)));
entityplayermp.a.b(((Packet) (new Packet29DestroyEntity(a.g))));
}
}
}

View File

@ -5,12 +5,13 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftWaterMob; import org.bukkit.craftbukkit.entity.CraftWaterMob;
// CraftBukkit stop // CraftBukkit stop
public class EntityWaterMob extends EntityCreature implements IAnimals { public class EntityWaterAnimal extends EntityCreature implements IAnimal {
public EntityWaterMob(World world) { public EntityWaterAnimal(World world) {
super(world); super(world);
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftWaterMob(server, this); this.bukkitEntity = new CraftWaterMob(server, this);
// CraftBukkit end // CraftBukkit end
} }
@ -28,7 +29,7 @@ public class EntityWaterMob extends EntityCreature implements IAnimals {
} }
public boolean b() { public boolean b() {
return l.a(z); return this.world.a(this.boundingBox);
} }
public int c() { public int c() {

View File

@ -7,34 +7,36 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
// CraftBukkit end // CraftBukkit end
public class EntityZombie extends EntityMobs { public class EntityZombie extends EntityMonster {
public EntityZombie(World world) { public EntityZombie(World world) {
super(world); super(world);
aP = "/mob/zombie.png"; this.texture = "/mob/zombie.png";
bC = 0.5F; this.bC = 0.5F;
c = 5; this.c = 5;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftZombie(server, this); this.bukkitEntity = new CraftZombie(server, this);
// CraftBukkit end // CraftBukkit end
} }
public void o() { public void o() {
if (l.b()) { if (this.world.b()) {
float f1 = b(1.0F); float f = this.b(1.0F);
if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) { if (f > 0.5F && this.world.i(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) l).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity()); EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
Z = 300; this.fireTicks = 300;
} }
// CraftBukkit end // CraftBukkit end
} }
} }
super.o(); super.o();
} }
@ -51,6 +53,6 @@ public class EntityZombie extends EntityMobs {
} }
protected int h() { protected int h() {
return Item.J.ba; return Item.FEATHER.id;
} }
} }

View File

@ -1,27 +0,0 @@
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftGiant;
// CraftBukkit stop
public class EntityZombieSimple extends EntityMobs {
public EntityZombieSimple(World world) {
super(world);
aP = "/mob/zombie.png";
bC = 0.5F;
c = 50;
aZ *= 10;
H *= 6F;
a(I * 6F, J * 6F);
// CraftBukkit start
CraftServer server = ((WorldServer) this.l).getServer();
this.bukkitEntity = new CraftGiant(server, this);
// CraftBukkit end
}
protected float a(int i, int j, int k) {
return l.l(i, j, k) - 0.5F;
}
}

View File

@ -1,127 +1,127 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.Location; import org.bukkit.Location;
// CraftBukkit end // CraftBukkit end
import java.util.*;
public class Explosion { public class Explosion {
public boolean a; public boolean a = false;
private Random h; private Random h = new Random();
private World i; private World i;
public double b; public double b;
public double c; public double c;
public double d; public double d;
public Entity e; public Entity e;
public float f; public float f;
public Set g; public Set g = new HashSet();
public Explosion(World world, Entity entity, double d1, double d2, double d3, float f1) {
a = false;
h = new Random();
g = ((Set) (new HashSet()));
i = world;
e = entity;
f = f1;
b = d1;
c = d2;
d = d3;
public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) {
this.i = world;
this.e = entity;
this.f = f;
this.b = d0;
this.c = d1;
this.d = d2;
} }
public void a() { public void a() {
float f1 = f; float f = this.f;
int j = 16; byte b0 = 16;
for (int k = 0; k < j; k++) { int i;
for (int i1 = 0; i1 < j; i1++) { int j;
label0: int k;
for (int k1 = 0; k1 < j; k1++) { double d0;
if (k != 0 && k != j - 1 && i1 != 0 && i1 != j - 1 && k1 != 0 && k1 != j - 1) { double d1;
continue; double d2;
for (i = 0; i < b0; ++i) {
for (j = 0; j < b0; ++j) {
for (k = 0; k < b0; ++k) {
if (i == 0 || i == b0 - 1 || j == 0 || j == b0 - 1 || k == 0 || k == b0 - 1) {
double d3 = (double) ((float) i / ((float) b0 - 1.0F) * 2.0F - 1.0F);
double d4 = (double) ((float) j / ((float) b0 - 1.0F) * 2.0F - 1.0F);
double d5 = (double) ((float) k / ((float) b0 - 1.0F) * 2.0F - 1.0F);
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
d3 /= d6;
d4 /= d6;
d5 /= d6;
float f1 = this.f * (0.7F + this.i.l.nextFloat() * 0.6F);
d0 = this.b;
d1 = this.c;
d2 = this.d;
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
int l = MathHelper.b(d0);
int i1 = MathHelper.b(d1);
int j1 = MathHelper.b(d2);
int k1 = this.i.getTypeId(l, i1, j1);
if (k1 > 0) {
f1 -= (Block.byId[k1].a(this.e) + 0.3F) * f2;
}
if (f1 > 0.0F) {
this.g.add(new ChunkPosition(l, i1, j1));
}
d0 += d3 * (double) f2;
d1 += d4 * (double) f2;
d2 += d5 * (double) f2;
}
} }
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; this.f *= 2.0F;
int l = MathHelper.b(b - (double) f - 1.0D); i = MathHelper.b(this.b - (double) this.f - 1.0D);
int j1 = MathHelper.b(b + (double) f + 1.0D); j = MathHelper.b(this.b + (double) this.f + 1.0D);
int l1 = MathHelper.b(c - (double) f - 1.0D); k = MathHelper.b(this.c - (double) this.f - 1.0D);
int j3 = MathHelper.b(c + (double) f + 1.0D); int l1 = MathHelper.b(this.c + (double) this.f + 1.0D);
int k3 = MathHelper.b(d - (double) f - 1.0D); int i2 = MathHelper.b(this.d - (double) this.f - 1.0D);
int l3 = MathHelper.b(d + (double) f + 1.0D); int j2 = MathHelper.b(this.d + (double) this.f + 1.0D);
List list = i.b(e, AxisAlignedBB.b(l, l1, k3, j1, j3, l3)); List list = this.i.b(this.e, AxisAlignedBB.b((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
Vec3D vec3d = Vec3D.b(b, c, d); Vec3D vec3d = Vec3D.b(this.b, this.c, this.d);
for (int i4 = 0; i4 < list.size(); i4++) { for (int k2 = 0; k2 < list.size(); ++k2) {
Entity entity = (Entity) list.get(i4); Entity entity = (Entity) list.get(k2);
double d11 = entity.e(b, c, d) / (double) f; double d7 = entity.e(this.b, this.c, this.d) / (double) this.f;
if (d11 <= 1.0D) { if (d7 <= 1.0D) {
double d6 = entity.p - b; d0 = entity.locX - this.b;
double d8 = entity.q - c; d1 = entity.locY - this.c;
double d10 = entity.r - d; d2 = entity.locZ - this.d;
double d12 = MathHelper.a(d6 * d6 + d8 * d8 + d10 * d10); double d8 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d6 /= d12; d0 /= d8;
d8 /= d12; d1 /= d8;
d10 /= d12; d2 /= d8;
double d13 = i.a(vec3d, entity.z); double d9 = (double) this.i.a(vec3d, entity.boundingBox);
double d14 = (1.0D - d11) * d13; double d10 = (1.0D - d7) * d9;
// CraftBukkit start - explosion damage hook // CraftBukkit start - explosion damage hook
CraftServer server = ((WorldServer) i).getServer(); CraftServer server = ((WorldServer) this.i).getServer();
org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
DamageCause damageType; DamageCause damageType;
int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D); int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.f + 1.0D);
if(damagee == null){ if(damagee == null){
// nothing was hurt // nothing was hurt
@ -129,62 +129,61 @@ public class Explosion {
// TODO: get the x/y/z of the tnt block? // TODO: get the x/y/z of the tnt block?
// does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever // does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION; damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone); EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbbe); server.getPluginManager().callEvent(event);
if (!edbbe.isCancelled()) { if (!event.isCancelled()) {
entity.a(e, edbbe.getDamage()); entity.a(this.e, event.getDamage());
} }
} else { } else {
org.bukkit.entity.Entity damager = e.getBukkitEntity(); org.bukkit.entity.Entity damager = this.e.getBukkitEntity();
damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION; damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(edbbe);
if (!edbbe.isCancelled()) { EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
entity.a(e, edbbe.getDamage()); server.getPluginManager().callEvent(event);
double d15 = d14;
entity.s += d6 * d15; if (!event.isCancelled()) {
entity.t += d8 * d15; entity.a(this.e, event.getDamage());
entity.u += d10 * d15;
entity.motX += d0 * d10;
entity.motY += d1 * d10;
entity.motZ += d2 * d10;
} }
} }
// CraftBukkit end // CraftBukkit end
} }
} }
f = f1; this.f = f;
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
((List) (arraylist)).addAll(((java.util.Collection) (g))); arraylist.addAll(this.g);
if (a) { if (this.a) {
for (int j4 = ((List) (arraylist)).size() - 1; j4 >= 0; j4--) { for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(j4); ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
int i2 = chunkposition.a; int i3 = chunkposition.a;
int k4 = chunkposition.b; int j3 = chunkposition.b;
int l4 = chunkposition.c; int k3 = chunkposition.c;
int i5 = i.a(i2, k4, l4); int l3 = this.i.getTypeId(i3, j3, k3);
int j5 = i.a(i2, k4 - 1, l4); int i4 = this.i.getTypeId(i3, j3 - 1, k3);
if (i5 == 0 && Block.o[j5] && h.nextInt(3) == 0) { if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) {
i.e(i2, k4, l4, Block.ar.bi); this.i.e(i3, j3, k3, Block.FIRE.id);
} }
} }
} }
} }
public void b() { public void b() {
i.a(b, c, d, "random.explode", 4F, (1.0F + (i.l.nextFloat() - i.l.nextFloat()) * 0.2F) * 0.7F); this.i.a(this.b, this.c, this.d, "random.explode", 4.0F, (1.0F + (this.i.l.nextFloat() - this.i.l.nextFloat()) * 0.2F) * 0.7F);
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
((List) (arraylist)).addAll(((java.util.Collection) (g))); arraylist.addAll(this.g);
// CraftBukkit start // CraftBukkit start
Server server = ((WorldServer) i).getServer(); Server server = ((WorldServer) this.i).getServer();
CraftWorld world = ((WorldServer) i).getWorld(); CraftWorld world = ((WorldServer) this.i).getWorld();
org.bukkit.entity.Entity splode = (e == null) ? null : e.getBukkitEntity(); org.bukkit.entity.Entity splode = (this.e == null) ? null : this.e.getBukkitEntity();
Location location = new Location(world, b, c, d); Location location = new Location(world, this.b, this.c, this.d);
List<org.bukkit.block.Block> blocklist = new ArrayList<org.bukkit.block.Block>(); List<org.bukkit.block.Block> blocklist = new ArrayList<org.bukkit.block.Block>();
for (int j = arraylist.size() - 1; j >= 0; j--) { for (int j = arraylist.size() - 1; j >= 0; j--) {
@ -194,48 +193,49 @@ public class Explosion {
blocklist.add(blox); blocklist.add(blox);
} }
} }
org.bukkit.event.Event.Type eventType = EntityExplodeEvent.Type.ENTITY_EXPLODE; org.bukkit.event.Event.Type eventType = EntityExplodeEvent.Type.ENTITY_EXPLODE;
EntityExplodeEvent eee = new EntityExplodeEvent(eventType, splode, location, blocklist); EntityExplodeEvent event = new EntityExplodeEvent(eventType, splode, location, blocklist);
server.getPluginManager().callEvent(eee); server.getPluginManager().callEvent(event);
if (eee.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
// CraftBukkit end // CraftBukkit end
for (int j = ((List) (arraylist)).size() - 1; j >= 0; j--) {
ChunkPosition chunkposition = (ChunkPosition) ((List) (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++) { for (int i = arraylist.size() - 1; i >= 0; --i) {
double d1 = (float) k + i.l.nextFloat(); ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i);
double d2 = (float) l + i.l.nextFloat(); int j = chunkposition.a;
double d3 = (float) i1 + i.l.nextFloat(); int k = chunkposition.b;
double d4 = d1 - b; int l = chunkposition.c;
double d5 = d2 - c; int i1 = this.i.getTypeId(j, k, l);
double d6 = d3 - d;
double d7 = MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
d4 /= d7; for (int j1 = 0; j1 < 1; ++j1) {
d5 /= d7; double d0 = (double) ((float) j + this.i.l.nextFloat());
d6 /= d7; double d1 = (double) ((float) k + this.i.l.nextFloat());
double d8 = 0.5D / (d7 / (double) f + 0.10000000000000001D); double d2 = (double) ((float) l + this.i.l.nextFloat());
double d3 = d0 - this.b;
double d4 = d1 - this.c;
double d5 = d2 - this.d;
double d6 = (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5);
d8 *= i.l.nextFloat() * i.l.nextFloat() + 0.3F; d3 /= d6;
d4 *= d8; d4 /= d6;
d5 *= d8; d5 /= d6;
d6 *= d8; double d7 = 0.5D / (d6 / (double) this.f + 0.1D);
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); d7 *= (double) (this.i.l.nextFloat() * this.i.l.nextFloat() + 0.3F);
d3 *= d7;
d4 *= d7;
d5 *= d7;
this.i.a("explode", (d0 + this.b * 1.0D) / 2.0D, (d1 + this.c * 1.0D) / 2.0D, (d2 + this.d * 1.0D) / 2.0D, d3, d4, d5);
this.i.a("smoke", d0, d1, d2, d3, d4, d5);
} }
if (j1 > 0) { if (i1 > 0) {
Block.m[j1].a(i, k, l, i1, i.b(k, l, i1), 0.3F); Block.byId[i1].a(this.i, j, k, l, this.i.getData(j, k, l), 0.3F);
i.e(k, l, i1, 0); this.i.e(j, k, l, 0);
Block.m[j1].a_(i, k, l, i1); Block.byId[i1].a_(this.i, j, k, l);
} }
} }
} }

View File

@ -1,22 +1,22 @@
package net.minecraft.server; package net.minecraft.server;
public interface IInventory { public interface IInventory {
public abstract int h_(); int h_();
public abstract ItemStack a(int i); ItemStack a(int i);
public abstract ItemStack b(int i, int j); ItemStack b(int i, int j);
public abstract void a(int i, ItemStack itemstack); void a(int i, ItemStack itemstack);
public abstract String b(); String b();
public abstract int c(); int c();
public abstract void d(); void d();
public abstract boolean a_(EntityPlayer entityplayer); boolean a_(EntityHuman entityhuman);
public abstract ItemStack[] getContents(); // CraftBukkit public abstract ItemStack[] getContents(); // CraftBukkit
} }

View File

@ -1,53 +1,51 @@
package net.minecraft.server; package net.minecraft.server;
public class InventoryCraftResult implements IInventory { public class InventoryCraftResult implements IInventory {
private ItemStack a[]; private ItemStack[] a = new ItemStack[1];
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return a;
} }
// CraftBukkit end // CraftBukkit end
public InventoryCraftResult() { public InventoryCraftResult() {}
a = new ItemStack[1];
} public int h_() {
return 1;
public int h_() { }
return 1;
} public ItemStack a(int i) {
return this.a[i];
public ItemStack a(int i) { }
return a[i];
} public String b() {
return "Result";
public String b() { }
return "Result";
} public ItemStack b(int i, int j) {
if (this.a[i] != null) {
public ItemStack b(int i, int j) { ItemStack itemstack = this.a[i];
if (a[i] != null) {
ItemStack itemstack = a[i]; this.a[i] = null;
return itemstack;
a[i] = null; } else {
return itemstack; return null;
} else { }
return null; }
}
} public void a(int i, ItemStack itemstack) {
this.a[i] = itemstack;
public void a(int i, ItemStack itemstack) { }
a[i] = itemstack;
} public int c() {
return 64;
public int c() { }
return 64;
} public void d() {}
public void d() {} public boolean a_(EntityHuman entityhuman) {
return true;
public boolean a_(EntityPlayer entityplayer) { }
return true; }
}
}

View File

@ -1,84 +1,82 @@
package net.minecraft.server; package net.minecraft.server;
public class InventoryCrafting implements IInventory { public class InventoryCrafting implements IInventory {
private ItemStack a[]; private ItemStack[] a;
private int b; private int b;
private CraftingInventoryCB c; private Container c;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return a;
} }
// CraftBukkit end // CraftBukkit end
public InventoryCrafting(CraftingInventoryCB craftinginventorycb, int i, int j) { public InventoryCrafting(Container container, int i, int j) {
int k = i * j; int k = i * j;
a = new ItemStack[k]; this.a = new ItemStack[k];
c = craftinginventorycb; this.c = container;
b = i; this.b = i;
} }
public int h_() { public int h_() {
return a.length; return this.a.length;
} }
public ItemStack a(int i) { public ItemStack a(int i) {
if (i >= h_()) { return i >= this.h_() ? null : this.a[i];
return null; }
} else {
return a[i]; public ItemStack a(int i, int j) {
} if (i >= 0 && i < this.b) {
} int k = i + j * this.b;
public ItemStack a(int i, int j) { return this.a(k);
if (i < 0 || i >= b) { } else {
return null; return null;
} else { }
int k = i + j * b; }
return a(k); public String b() {
} return "Crafting";
} }
public String b() { public ItemStack b(int i, int j) {
return "Crafting"; if (this.a[i] != null) {
} ItemStack itemstack;
public ItemStack b(int i, int j) { if (this.a[i].count <= j) {
if (a[i] != null) { itemstack = this.a[i];
if (a[i].a <= j) { this.a[i] = null;
ItemStack itemstack = a[i]; this.c.a((IInventory) this);
return itemstack;
a[i] = null; } else {
c.a(((IInventory) (this))); itemstack = this.a[i].a(j);
return itemstack; if (this.a[i].count == 0) {
} this.a[i] = null;
ItemStack itemstack1 = a[i].a(j); }
if (a[i].a == 0) { this.c.a((IInventory) this);
a[i] = null; return itemstack;
} }
c.a(((IInventory) (this))); } else {
return itemstack1; return null;
} else { }
return null; }
}
} public void a(int i, ItemStack itemstack) {
this.a[i] = itemstack;
public void a(int i, ItemStack itemstack) { this.c.a((IInventory) this);
a[i] = itemstack; }
c.a(((IInventory) (this)));
} public int c() {
return 64;
public int c() { }
return 64;
} public void d() {}
public void d() {} public boolean a_(EntityHuman entityhuman) {
return true;
public boolean a_(EntityPlayer entityplayer) { }
return true; }
}
}

View File

@ -1,69 +1,61 @@
package net.minecraft.server; package net.minecraft.server;
public class InventoryLargeChest implements IInventory { public class InventoryLargeChest implements IInventory {
private String a; private String a;
private IInventory b; private IInventory b;
private IInventory c; private IInventory c;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
ItemStack[] result = new ItemStack[h_()]; ItemStack[] result = new ItemStack[h_()];
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
result[i] = a(i); result[i] = a(i);
} }
return result; return result;
} }
// CraftBukkit end // CraftBukkit end
public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) { public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
a = s; this.a = s;
b = iinventory; this.b = iinventory;
c = iinventory1; this.c = iinventory1;
} }
public int h_() { public int h_() {
return b.h_() + c.h_(); return this.b.h_() + this.c.h_();
} }
public String b() { public String b() {
return a; return this.a;
} }
public ItemStack a(int i) { public ItemStack a(int i) {
if (i >= b.h_()) { return i >= this.b.h_() ? this.c.a(i - this.b.h_()) : this.b.a(i);
return c.a(i - b.h_()); }
} else {
return b.a(i); public ItemStack b(int i, int j) {
} return i >= this.b.h_() ? this.c.b(i - this.b.h_(), j) : this.b.b(i, j);
} }
public ItemStack b(int i, int j) { public void a(int i, ItemStack itemstack) {
if (i >= b.h_()) { if (i >= this.b.h_()) {
return c.b(i - b.h_(), j); this.c.a(i - this.b.h_(), itemstack);
} else { } else {
return b.b(i, j); this.b.a(i, itemstack);
} }
} }
public void a(int i, ItemStack itemstack) { public int c() {
if (i >= b.h_()) { return this.b.c();
c.a(i - b.h_(), itemstack); }
} else {
b.a(i, itemstack); public void d() {
} this.b.d();
} this.c.d();
}
public int c() {
return b.c(); public boolean a_(EntityHuman entityhuman) {
} return this.b.a_(entityhuman) && this.c.a_(entityhuman);
}
public void d() { }
b.d();
c.d();
}
public boolean a_(EntityPlayer entityplayer) {
return b.a_(entityplayer) && c.a_(entityplayer);
}
}

View File

@ -1,342 +1,344 @@
package net.minecraft.server; package net.minecraft.server;
public class InventoryPlayer implements IInventory { public class InventoryPlayer implements IInventory {
public ItemStack a[]; public ItemStack[] a = new ItemStack[36];
public ItemStack b[]; public ItemStack[] b = new ItemStack[4];
public int c; public int c = 0;
private EntityPlayer e; private EntityHuman e;
private ItemStack f; private ItemStack f;
public boolean d; public boolean d = false;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return a;
} }
public ItemStack[] getArmorContents() { public ItemStack[] getArmorContents() {
return b; return b;
} }
// CraftBukkit end // CraftBukkit end
public InventoryPlayer(EntityPlayer entityplayer) { public InventoryPlayer(EntityHuman entityhuman) {
a = new ItemStack[36]; this.e = entityhuman;
b = new ItemStack[4]; }
c = 0;
d = false; public ItemStack e() {
e = entityplayer; return this.a[this.c];
} }
public ItemStack e() { private int d(int i) {
return a[c]; for (int j = 0; j < this.a.length; ++j) {
} if (this.a[j] != null && this.a[j].id == i) {
return j;
private int d(int k) { }
for (int l = 0; l < a.length; l++) { }
if (a[l] != null && a[l].c == k) {
return l; return -1;
} }
}
private int c(ItemStack itemstack) {
return -1; for (int i = 0; i < this.a.length; ++i) {
} if (this.a[i] != null && this.a[i].id == itemstack.id && this.a[i].c() && this.a[i].count < this.a[i].b() && this.a[i].count < this.c() && (!this.a[i].e() || this.a[i].h() == itemstack.h())) {
return i;
private int c(ItemStack itemstack) { }
for (int k = 0; k < a.length; k++) { }
if (a[k] != null && a[k].c == itemstack.c && a[k].c() && a[k].a < a[k].b() && a[k].a < c() && (!a[k].e() || a[k].h() == itemstack.h())) {
return k; return -1;
} }
}
private int j() {
return -1; for (int i = 0; i < this.a.length; ++i) {
} if (this.a[i] == null) {
return i;
private int j() { }
for (int k = 0; k < a.length; k++) { }
if (a[k] == null) {
return k; return -1;
} }
}
private int d(ItemStack itemstack) {
return -1; int i = itemstack.id;
} int j = itemstack.count;
int k = this.c(itemstack);
private int d(ItemStack itemstack) {
int k = itemstack.c; if (k < 0) {
int l = itemstack.a; k = this.j();
int i1 = c(itemstack); }
if (i1 < 0) { if (k < 0) {
i1 = j(); return j;
} } else {
if (i1 < 0) { if (this.a[k] == null) {
return l; this.a[k] = new ItemStack(i, 0, itemstack.h());
} }
if (a[i1] == null) {
a[i1] = new ItemStack(k, 0, itemstack.h()); int l = j;
}
int j1 = l; if (j > this.a[k].b() - this.a[k].count) {
l = this.a[k].b() - this.a[k].count;
if (j1 > a[i1].b() - a[i1].a) { }
j1 = a[i1].b() - a[i1].a;
} if (l > this.c() - this.a[k].count) {
if (j1 > c() - a[i1].a) { l = this.c() - this.a[k].count;
j1 = c() - a[i1].a; }
}
if (j1 == 0) { if (l == 0) {
return l; return j;
} else { } else {
l -= j1; j -= l;
a[i1].a += j1; this.a[k].count += l;
a[i1].b = 5; this.a[k].b = 5;
return l; return j;
} }
} }
}
public void f() {
for (int k = 0; k < a.length; k++) { public void f() {
if (a[k] != null && a[k].b > 0) { for (int i = 0; i < this.a.length; ++i) {
a[k].b--; if (this.a[i] != null && this.a[i].b > 0) {
} --this.a[i].b;
} }
} }
}
public boolean b(int k) {
int l = d(k); public boolean b(int i) {
int j = this.d(i);
if (l < 0) {
return false; if (j < 0) {
} return false;
if (--a[l].a <= 0) { } else {
a[l] = null; if (--this.a[j].count <= 0) {
} this.a[j] = null;
return true; }
}
return true;
public boolean a(ItemStack itemstack) { }
if (!itemstack.f()) { }
itemstack.a = d(itemstack);
if (itemstack.a == 0) { public boolean a(ItemStack itemstack) {
return true; if (!itemstack.f()) {
} itemstack.count = this.d(itemstack);
} if (itemstack.count == 0) {
int k = j(); return true;
}
if (k >= 0) { }
a[k] = itemstack;
a[k].b = 5; int i = this.j();
return true;
} else { if (i >= 0) {
return false; this.a[i] = itemstack;
} this.a[i].b = 5;
} return true;
} else {
public ItemStack b(int k, int l) { return false;
ItemStack aitemstack[] = a; }
}
if (k >= a.length) {
aitemstack = b; public ItemStack b(int i, int j) {
k -= a.length; ItemStack[] aitemstack = this.a;
}
if (aitemstack[k] != null) { if (i >= this.a.length) {
if (aitemstack[k].a <= l) { aitemstack = this.b;
ItemStack itemstack = aitemstack[k]; i -= this.a.length;
}
aitemstack[k] = null;
return itemstack; if (aitemstack[i] != null) {
} ItemStack itemstack;
ItemStack itemstack1 = aitemstack[k].a(l);
if (aitemstack[i].count <= j) {
if (aitemstack[k].a == 0) { itemstack = aitemstack[i];
aitemstack[k] = null; aitemstack[i] = null;
} return itemstack;
return itemstack1; } else {
} else { itemstack = aitemstack[i].a(j);
return null; if (aitemstack[i].count == 0) {
} aitemstack[i] = null;
} }
public void a(int k, ItemStack itemstack) { return itemstack;
ItemStack aitemstack[] = a; }
} else {
if (k >= aitemstack.length) { return null;
k -= aitemstack.length; }
aitemstack = b; }
}
aitemstack[k] = itemstack; public void a(int i, ItemStack itemstack) {
} ItemStack[] aitemstack = this.a;
public float a(Block block) { if (i >= aitemstack.length) {
float f1 = 1.0F; i -= aitemstack.length;
aitemstack = this.b;
if (a[c] != null) { }
f1 *= a[c].a(block);
} aitemstack[i] = itemstack;
return f1; }
}
public float a(Block block) {
public NBTTagList a(NBTTagList nbttaglist) { float f = 1.0F;
for (int k = 0; k < a.length; k++) {
if (a[k] != null) { if (this.a[this.c] != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound(); f *= this.a[this.c].a(block);
}
nbttagcompound.a("Slot", (byte) k);
a[k].a(nbttagcompound); return f;
nbttaglist.a(((NBTBase) (nbttagcompound))); }
}
} public NBTTagList a(NBTTagList nbttaglist) {
int i;
for (int l = 0; l < b.length; l++) { NBTTagCompound nbttagcompound;
if (b[l] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); for (i = 0; i < this.a.length; ++i) {
if (this.a[i] != null) {
nbttagcompound1.a("Slot", (byte) (l + 100)); nbttagcompound = new NBTTagCompound();
b[l].a(nbttagcompound1); nbttagcompound.a("Slot", (byte) i);
nbttaglist.a(((NBTBase) (nbttagcompound1))); this.a[i].a(nbttagcompound);
} nbttaglist.a((NBTBase) nbttagcompound);
} }
}
return nbttaglist;
} for (i = 0; i < this.b.length; ++i) {
if (this.b[i] != null) {
public void b(NBTTagList nbttaglist) { nbttagcompound = new NBTTagCompound();
a = new ItemStack[36]; nbttagcompound.a("Slot", (byte) (i + 100));
b = new ItemStack[4]; this.b[i].a(nbttagcompound);
for (int k = 0; k < nbttaglist.b(); k++) { nbttaglist.a((NBTBase) nbttagcompound);
NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(k); }
int l = nbttagcompound.b("Slot") & 0xff; }
ItemStack itemstack = new ItemStack(nbttagcompound);
return nbttaglist;
if (itemstack.a() == null) { }
continue;
} public void b(NBTTagList nbttaglist) {
if (l >= 0 && l < a.length) { this.a = new ItemStack[36];
a[l] = itemstack; this.b = new ItemStack[4];
}
if (l >= 100 && l < b.length + 100) { for (int i = 0; i < nbttaglist.b(); ++i) {
b[l - 100] = itemstack; NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i);
} int j = nbttagcompound.b("Slot") & 255;
} ItemStack itemstack = new ItemStack(nbttagcompound);
}
if (itemstack.a() != null) {
public int h_() { if (j >= 0 && j < this.a.length) {
return a.length + 4; this.a[j] = itemstack;
} }
public ItemStack a(int k) { if (j >= 100 && j < this.b.length + 100) {
ItemStack aitemstack[] = a; this.b[j - 100] = itemstack;
}
if (k >= aitemstack.length) { }
k -= aitemstack.length; }
aitemstack = b; }
}
return aitemstack[k]; public int h_() {
} return this.a.length + 4;
}
public String b() {
return "Inventory"; public ItemStack a(int i) {
} ItemStack[] aitemstack = this.a;
public int c() { if (i >= aitemstack.length) {
return 64; i -= aitemstack.length;
} aitemstack = this.b;
}
public int a(Entity entity) {
ItemStack itemstack = a(c); return aitemstack[i];
}
if (itemstack != null) {
return itemstack.a(entity); public String b() {
} else { return "Inventory";
return 1; }
}
} public int c() {
return 64;
public boolean b(Block block) { }
if (block.bt != Material.d && block.bt != Material.e && block.bt != Material.t && block.bt != Material.s) {
return true; public int a(Entity entity) {
} ItemStack itemstack = this.a(this.c);
ItemStack itemstack = a(c);
return itemstack != null ? itemstack.a(entity) : 1;
if (itemstack != null) { }
return itemstack.b(block);
} else { public boolean b(Block block) {
return false; if (block.material != Material.STONE && block.material != Material.ORE && block.material != Material.SNOW_BLOCK && block.material != Material.SNOW_LAYER) {
} return true;
} } else {
ItemStack itemstack = this.a(this.c);
public int g() {
int k = 0; return itemstack != null ? itemstack.b(block) : false;
int l = 0; }
int i1 = 0; }
for (int j1 = 0; j1 < b.length; j1++) { public int g() {
if (b[j1] != null && (b[j1].a() instanceof ItemArmor)) { int i = 0;
int k1 = b[j1].i(); int j = 0;
int l1 = b[j1].g(); int k = 0;
int i2 = k1 - l1;
for (int l = 0; l < this.b.length; ++l) {
l += i2; if (this.b[l] != null && this.b[l].a() instanceof ItemArmor) {
i1 += k1; int i1 = this.b[l].i();
int j2 = ((ItemArmor) b[j1].a()).bh; int j1 = this.b[l].g();
int k1 = i1 - j1;
k += j2;
} j += k1;
} k += i1;
int l1 = ((ItemArmor) this.b[l].a()).bh;
if (i1 == 0) {
return 0; i += l1;
} else { }
return ((k - 1) * l) / i1 + 1; }
}
} if (k == 0) {
return 0;
public void c(int k) { } else {
for (int l = 0; l < b.length; l++) { return (i - 1) * j / k + 1;
if (b[l] == null || !(b[l].a() instanceof ItemArmor)) { }
continue; }
}
b[l].b(k); public void c(int i) {
if (b[l].a == 0) { for (int j = 0; j < this.b.length; ++j) {
b[l].a(e); if (this.b[j] != null && this.b[j].a() instanceof ItemArmor) {
b[l] = null; this.b[j].b(i);
} if (this.b[j].count == 0) {
} this.b[j].a(this.e);
this.b[j] = null;
} }
}
public void h() { }
for (int k = 0; k < a.length; k++) { }
if (a[k] != null) {
e.a(a[k], true); public void h() {
a[k] = null; int i;
}
} for (i = 0; i < this.a.length; ++i) {
if (this.a[i] != null) {
for (int l = 0; l < b.length; l++) { this.e.a(this.a[i], true);
if (b[l] != null) { this.a[i] = null;
e.a(b[l], true); }
b[l] = null; }
}
} for (i = 0; i < this.b.length; ++i) {
} if (this.b[i] != null) {
this.e.a(this.b[i], true);
public void d() { this.b[i] = null;
d = true; }
} }
}
public void b(ItemStack itemstack) {
f = itemstack; public void d() {
e.a(itemstack); this.d = true;
} }
public ItemStack i() { public void b(ItemStack itemstack) {
return f; this.f = itemstack;
} this.e.a(itemstack);
}
public boolean a_(EntityPlayer entityplayer) {
if (e.G) { public ItemStack i() {
return false; return this.f;
} }
return entityplayer.b(((Entity) (e))) <= 64D;
} public boolean a_(EntityHuman entityhuman) {
} return this.e.dead ? false : entityhuman.b((Entity) this.e) <= 64.0D;
}
}

View File

@ -17,14 +17,14 @@ public class ItemBlock extends Item {
public ItemBlock(int i) { public ItemBlock(int i) {
super(i); super(i);
a = i + 256; this.a = i + 256;
b(Block.m[i + 256].a(2)); this.b(Block.byId[i + 256].a(2));
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
// CraftBukkit start // CraftBukkit start
// Bail if we have nothing of the item in hand // Bail if we have nothing of the item in hand
if (itemstack.a == 0) { if (itemstack.count == 0) {
return false; return false;
} }
@ -33,95 +33,102 @@ public class ItemBlock extends Item {
BlockFace faceClicked = CraftBlock.notchToBlockFace(l); BlockFace faceClicked = CraftBlock.notchToBlockFace(l);
// CraftBukkit end // CraftBukkit end
if (world.a(i, j, k) == Block.aS.bi) { if (world.getTypeId(i, j, k) == Block.SNOW.id) {
l = 0; l = 0;
} else { } else {
if (l == 0) { if (l == 0) {
j--; --j;
} }
if (l == 1) { if (l == 1) {
j++; ++j;
} }
if (l == 2) { if (l == 2) {
k--; --k;
} }
if (l == 3) { if (l == 3) {
k++; ++k;
} }
if (l == 4) { if (l == 4) {
i--; --i;
} }
if (l == 5) { if (l == 5) {
i++; ++i;
} }
} }
if (itemstack.a == 0) { if (itemstack.count == 0) {
return false; return false;
} } else {
// CraftBukkit start
/* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
* rather than the block touching the face we clicked on.
*/
org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == Block.SNOW.id || blockClicked.getTypeId() == Block.STEP.id) ? blockClicked:blockClicked.getFace(faceClicked);
final BlockState replacedBlockState = new CraftBlockState(replacedBlock);
// CraftBukkit end
// CraftBukkit start if (world.a(this.a, i, j, k, false)) {
/* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself, Block block = Block.byId[this.a];
* rather than the block touching the face we clicked on.
*/
org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == 78 || blockClicked.getTypeId() == 44) ? blockClicked:blockClicked.getFace(faceClicked);
final BlockState replacedBlockState = new CraftBlockState(replacedBlock);
if (world.a(a, i, j, k, false)) { // CraftBukkit start - This executes the placement of the block
Block block = Block.m[a]; /*
* This replaces world.b(IIIII), we're doing this because we need to
* hook between the 'placement' and the informing to 'world' so we can
* sanely undo this.
*
* Whenever the call to 'world.b' changes we need to figure out again what to
* replace this with.
*/
if (world.setTypeIdAndData(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
org.bukkit.Server server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_PLACED;
org.bukkit.block.Block placedBlock = blockClicked.getFace(faceClicked) ;
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
Player thePlayer = (entityhuman ==null) ? null : (Player) entityhuman.getBukkitEntity();
// This executes the placement of the block int distanceFromSpawn = (int) Math.max(Math.abs(i - world.spawnX), Math.abs(k - world.spawnZ));
/*
* This replaces world.b(IIIII), we're doing this because we need to
* hook between the 'placement' and the informing to 'world' so we can
* sanely undo this.
*
* Whenever the call to 'world.b' changes we need to figure out again what to
* replace this with.
*/
if (world.a(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
org.bukkit.Server server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_PLACED;
org.bukkit.block.Block placedBlock = blockClicked.getFace(faceClicked) ;
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
Player thePlayer = (entityplayer ==null)?null:(Player)entityplayer.getBukkitEntity();
int distanceFromSpawn = (int) Math.max(Math.abs(i - world.m), Math.abs(k - world.o)); // CraftBukkit hardcoded Spawn distance for now
// TODO make spawn size configurable
boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
// CraftBukkit hardcoded Spawn distance for now BlockPlaceEvent event = new BlockPlaceEvent(eventType, placedBlock, replacedBlockState, blockClicked, itemInHand, thePlayer, canBuild);
// TODO make spawn size configurable server.getPluginManager().callEvent(event);
boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
BlockPlaceEvent bpe = new BlockPlaceEvent(eventType, placedBlock, replacedBlockState, blockClicked, itemInHand, thePlayer, canBuild); if (event.isCancelled() || !event.canBuild()) {
server.getPluginManager().callEvent(bpe); // CraftBukkit Undo!
if (bpe.isCancelled() || !bpe.canBuild()) { if (this.a == block.ICE.id) {
// CraftBukkit Undo! // Ice will explode if we set straight to 0
world.setTypeId(i, j, k, 20);
} else if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) {
// Half steps automatically set the block below to a double
world.setTypeId(i, j - 1, k, 44);
}
if (this.a == 79) { world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
// Ice will explode if we set straight to 0 } else {
world.b(i, j, k, 20); world.f(i, j, k, a); // <-- world.b does this on success (tell the world)
} else if ((this.a == 44) && (world.a(i, j - 1, k) == 43) && (world.a(i, j, k) == 0)) {
// Half steps automatically set the block below to a double Block.byId[this.a].c(world, i, j, k, l);
world.b(i, j - 1, k, 44); Block.byId[this.a].a(world, i, j, k, (EntityLiving) entityhuman);
world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.c(), (block.stepSound.a() + 1.0F) / 2.0F, block.stepSound.b() * 0.8F);
--itemstack.count;
} }
// CraftBukkit end
world.a(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
} else {
world.f(i, j, k, a); // <-- world.b does this on success (tell the world)
Block.m[a].c(world, i, j, k, l);
Block.m[a].a(world, i, j, k, ((EntityLiving) (entityplayer)));
world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.br.c(), (block.br.a() + 1.0F) / 2.0F, block.br.b() * 0.8F);
itemstack.a--;
} }
} }
return true;
} }
// CraftBukkit end
return true;
} }
public String a() { public String a() {
return Block.m[a].e(); return Block.byId[this.a].e();
} }
} }

View File

@ -15,59 +15,61 @@ public class ItemBoat extends Item {
public ItemBoat(int i) { public ItemBoat(int i) {
super(i); super(i);
bb = 1; this.maxStackSize = 1;
} }
public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) { public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F; float f = 1.0F;
float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f; float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f; float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f;
double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f; double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H; double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height;
double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f; double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
Vec3D vec3d = Vec3D.b(d, d1, d2); Vec3D vec3d = Vec3D.b(d0, d1, d2);
float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F); float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F); float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.01745329F); float f5 = -MathHelper.b(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.01745329F); float f6 = MathHelper.a(-f1 * 0.017453292F);
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f6; float f8 = f3 * f5;
float f9 = f3 * f5; double d3 = 5.0D;
double d3 = 5D; Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3);
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true); MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true);
if (movingobjectposition == null) { if (movingobjectposition == null) {
return itemstack; return itemstack;
} } else {
if (movingobjectposition.a == EnumMovingObjectType.a) { if (movingobjectposition.a == EnumMovingObjectType.TILE) {
int i = movingobjectposition.b; int i = movingobjectposition.b;
int j = movingobjectposition.c; int j = movingobjectposition.c;
int k = movingobjectposition.d; int k = movingobjectposition.d;
if (!world.z) { if (!world.isStatic) {
// CraftBukkit start - Boat placement // CraftBukkit start - Boat placement
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) { Type eventType = Type.PLAYER_ITEM;
return itemstack; Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
world.a((Entity) (new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.5F), (double) ((float) k + 0.5F))));
} }
// CraftBukkit end
world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F)))); --itemstack.count;
} }
itemstack.a--;
return itemstack;
} }
return itemstack;
} }
} }

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
@ -20,123 +18,137 @@ public class ItemBucket extends Item {
public ItemBucket(int i, int j) { public ItemBucket(int i, int j) {
super(i); super(i);
bb = 1; this.maxStackSize = 1;
bc = 64; this.durability = 64;
a = j; this.a = j;
} }
public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) { public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F; float f = 1.0F;
float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f; float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f; float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f;
double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f; double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H; double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height;
double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f; double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
Vec3D vec3d = Vec3D.b(d, d1, d2); Vec3D vec3d = Vec3D.b(d0, d1, d2);
float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F); float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F); float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.01745329F); float f5 = -MathHelper.b(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.01745329F); float f6 = MathHelper.a(-f1 * 0.017453292F);
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f6; float f8 = f3 * f5;
float f9 = f3 * f5; double d3 = 5.0D;
double d3 = 5D; Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3); MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, this.a == 0);
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, a == 0);
if (movingobjectposition == null) { if (movingobjectposition == null) {
return itemstack; return itemstack;
} } else {
if (movingobjectposition.a == EnumMovingObjectType.a) { if (movingobjectposition.a == EnumMovingObjectType.TILE) {
int i = movingobjectposition.b; int i = movingobjectposition.b;
int j = movingobjectposition.c; int j = movingobjectposition.c;
int k = movingobjectposition.d; int k = movingobjectposition.d;
if (!world.a(entityplayer, i, j, k)) { if (!world.a(entityhuman, i, j, k)) {
return itemstack; return itemstack;
} }
// CraftBukkit start - Click == placed when handling an empty bucket! // CraftBukkit start - Click == placed when handling an empty bucket!
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
// CraftBukkit end
if (a == 0) { Type eventType = Type.PLAYER_ITEM;
if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) { Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
// CraftBukkit start org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace); org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
craftServer.getPluginManager().callEvent(pie); BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
// CraftBukkit end
if (pie.isCancelled()) { if (this.a == 0) {
return itemstack; if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) {
} // CraftBukkit start
// CraftBukkit end PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
world.e(i, j, k, 0); craftServer.getPluginManager().callEvent(event);
return new ItemStack(Item.av);
}
if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
// CraftBukkit start
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) { if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
world.e(i, j, k, 0);
return new ItemStack(Item.aw);
}
} else {
if (a < 0) {
return new ItemStack(Item.au);
}
if (movingobjectposition.e == 0) {
j--;
}
if (movingobjectposition.e == 1) {
j++;
}
if (movingobjectposition.e == 2) {
k--;
}
if (movingobjectposition.e == 3) {
k++;
}
if (movingobjectposition.e == 4) {
i--;
}
if (movingobjectposition.e == 5) {
i++;
}
if (world.e(i, j, k) || !world.c(i, j, k).a()) {
if (world.q.d && a == Block.A.bi) {
world.a(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
for (int l = 0; l < 8; l++) {
world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
}
} else {
// CraftBukkit start - bucket empty.
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return itemstack; return itemstack;
} }
// CraftBukkit end // CraftBukkit end
world.b(i, j, k, a, 0);
world.e(i, j, k, 0);
return new ItemStack(Item.WATER_BUCKET);
}
if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) {
// CraftBukkit start
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
world.e(i, j, k, 0);
return new ItemStack(Item.LAVA_BUCKET);
}
} else {
if (this.a < 0) {
return new ItemStack(Item.BUCKET);
}
if (movingobjectposition.e == 0) {
--j;
}
if (movingobjectposition.e == 1) {
++j;
}
if (movingobjectposition.e == 2) {
--k;
}
if (movingobjectposition.e == 3) {
++k;
}
if (movingobjectposition.e == 4) {
--i;
}
if (movingobjectposition.e == 5) {
++i;
}
if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) {
if (world.q.d && this.a == Block.WATER.id) {
world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) {
world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
}
} else {
// CraftBukkit start - bucket empty.
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
world.b(i, j, k, this.a, 0);
}
return new ItemStack(Item.BUCKET);
} }
return new ItemStack(Item.au);
} }
} else if (this.a == 0 && movingobjectposition.g instanceof EntityCow) {
return new ItemStack(Item.MILK_BUCKET);
} }
} else if (a == 0 && (movingobjectposition.g instanceof EntityCow)) {
return new ItemStack(Item.aE); return itemstack;
} }
return itemstack;
} }
} }

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -19,59 +17,64 @@ public class ItemFlintAndSteel extends Item {
public ItemFlintAndSteel(int i) { public ItemFlintAndSteel(int i) {
super(i); super(i);
bb = 1; this.maxStackSize = 1;
bc = 64; this.durability = 64;
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
// CraftBukkit - store the clicked block // CraftBukkit start - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
// CraftBukkit end
if (l == 0) { if (l == 0) {
j--; --j;
} }
if (l == 1) { if (l == 1) {
j++; ++j;
} }
if (l == 2) { if (l == 2) {
k--; --k;
} }
if (l == 3) { if (l == 3) {
k++; ++k;
} }
if (l == 4) { if (l == 4) {
i--; --i;
} }
if (l == 5) { if (l == 5) {
i++; ++i;
} }
int i1 = world.a(i, j, k);
int i1 = world.getTypeId(i, j, k);
if (i1 == 0) { if (i1 == 0) {
// CraftBukkit start - Flint and steel // CraftBukkit start - Flint and steel
Type eventType = Type.PLAYER_ITEM; Type eventType = Type.PLAYER_ITEM;
Player thePlayer = (Player) entityplayer.getBukkitEntity(); Player thePlayer = (Player) entityhuman.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockFace = CraftBlock.notchToBlockFace(l); BlockFace blockFace = CraftBlock.notchToBlockFace(l);
PlayerItemEvent pie = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
boolean preventLighter = pie.isCancelled(); PlayerItemEvent event = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
boolean preventLighter = event.isCancelled();
IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL; IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL;
BlockIgniteEvent bie = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer); BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer);
craftServer.getPluginManager().callEvent(bie); craftServer.getPluginManager().callEvent(eventIgnite);
boolean preventFire = bie.isCancelled(); boolean preventFire = eventIgnite.isCancelled();
if (preventLighter) { if (preventLighter) {
return false; return false;
} }
if (preventFire) { if (preventFire) {
itemstack.b(1); itemstack.b(1);
return false; return false;
@ -79,8 +82,9 @@ public class ItemFlintAndSteel extends Item {
// CraftBukkit end // CraftBukkit end
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F);
world.e(i, j, k, Block.ar.bi); world.e(i, j, k, Block.FIRE.id);
} }
itemstack.b(1); itemstack.b(1);
return true; return true;
} }

View File

@ -1,7 +1,5 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -17,58 +15,60 @@ public class ItemHoe extends Item {
public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) { public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) {
super(i); super(i);
bb = 1; this.maxStackSize = 1;
bc = enumtoolmaterial.a(); this.durability = enumtoolmaterial.a();
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
int i1 = world.a(i, j, k); int i1 = world.getTypeId(i, j, k);
Material material = world.c(i, j + 1, k); Material material = world.getMaterial(i, j + 1, k);
if (!material.a() && i1 == Block.u.bi || i1 == Block.v.bi) { if ((material.isBuildable() || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) {
// CraftBukkit start - Hoes return false;
CraftWorld craftWorld = ((WorldServer) world).getWorld(); } else {
CraftServer craftServer = ((WorldServer) world).getServer(); Block block = Block.SOIL;
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
Block block = Block.aA; world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.c(), (block.stepSound.a() + 1.0F) / 2.0F, block.stepSound.b() * 0.8F);
if (world.isStatic) {
return true;
} else {
// CraftBukkit start - Hoes
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM;
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(1);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
world.e(i, j, k, block.id);
itemstack.b(1);
if (world.l.nextInt(8) == 0 && i1 == Block.GRASS.id) {
byte b0 = 1;
for (int j1 = 0; j1 < b0; ++j1) {
float f = 0.7F;
float f1 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = 1.2F;
float f3 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS));
entityitem.c = 10;
world.a((Entity) entityitem);
}
}
world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.br.c(), (block.br.a() + 1.0F) / 2.0F, block.br.b() * 0.8F);
if (world.z) {
return true; return true;
} }
world.e(i, j, k, block.bi);
itemstack.b(1);
if (world.l.nextInt(8) == 0 && i1 == Block.u.bi) {
int j1 = 1;
for (int k1 = 0; k1 < j1; k1++) {
float f = 0.7F;
float f1 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = 1.2F;
float f3 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
EntityItem entityitem = new EntityItem(world, (float) i + f1, (float) j + f2, (float) k + f3, new ItemStack(Item.Q));
entityitem.c = 10;
world.a(((Entity) (entityitem)));
}
}
return true;
} else {
return false;
} }
} }
} }

View File

@ -3,125 +3,121 @@ package net.minecraft.server;
public class ItemInWorldManager { public class ItemInWorldManager {
private World b; private World b;
public EntityPlayer a; public EntityHuman a;
private float c; private float c;
public float d; // CraftBukkit private -> public public float d = 0.0F; // CraftBukkit private -> public
private int e; private int e = 0;
private float f; private float f = 0.0F;
private int g; private int g;
private int h; private int h;
private int i; private int i;
public ItemInWorldManager(World world) { public ItemInWorldManager(World world) {
d = 0.0F; this.b = world;
e = 0;
f = 0.0F;
b = world;
} }
public void a(int j, int k, int l) { public void a(int i, int j, int k) {
int i1 = b.a(j, k, l); int l = this.b.getTypeId(i, j, k);
if (i1 > 0 && d == 0.0F) { if (l > 0 && this.d == 0.0F) {
Block.m[i1].b(b, j, k, l, a); Block.byId[l].b(this.b, i, j, k, this.a);
} }
if (i1 > 0 && Block.m[i1].a(a) >= 1.0F) {
c(j, k, l); if (l > 0 && Block.byId[l].a(this.a) >= 1.0F) {
this.c(i, j, k);
} }
} }
public void a() { public void a() {
d = 0.0F; this.d = 0.0F;
e = 0; this.e = 0;
} }
public void a(int j, int k, int l, int i1) { public void a(int i, int j, int k, int l) {
if (e > 0) { if (this.e > 0) {
e--; --this.e;
return;
}
if (j == g && k == h && l == i) {
int j1 = b.a(j, k, l);
if (j1 == 0) {
return;
}
Block block = Block.m[j1];
d += block.a(a);
f++;
if (d >= 1.0F) {
c(j, k, l);
d = 0.0F;
c = 0.0F;
f = 0.0F;
e = 5;
}
} else { } else {
d = 0.0F; if (i == this.g && j == this.h && k == this.i) {
c = 0.0F; int i1 = this.b.getTypeId(i, j, k);
f = 0.0F;
g = j; if (i1 == 0) {
h = k; return;
i = l; }
Block block = Block.byId[i1];
this.d += block.a(this.a);
++this.f;
if (this.d >= 1.0F) {
this.c(i, j, k);
this.d = 0.0F;
this.c = 0.0F;
this.f = 0.0F;
this.e = 5;
}
} else {
this.d = 0.0F;
this.c = 0.0F;
this.f = 0.0F;
this.g = i;
this.h = j;
this.i = k;
}
} }
} }
public boolean b(int j, int k, int l) { public boolean b(int i, int j, int k) {
Block block = Block.m[b.a(j, k, l)]; Block block = Block.byId[this.b.getTypeId(i, j, k)];
int i1 = b.b(j, k, l); int l = this.b.getData(i, j, k);
boolean flag = b.e(j, k, l, 0); boolean flag = this.b.e(i, j, k, 0);
if (block != null && flag) { if (block != null && flag) {
block.a(b, j, k, l, i1); block.a(this.b, i, j, k, l);
} }
return flag; return flag;
} }
public boolean c(int j, int k, int l) { public boolean c(int i, int j, int k) {
int i1 = b.a(j, k, l); int l = this.b.getTypeId(i, j, k);
int j1 = b.b(j, k, l); int i1 = this.b.getData(i, j, k);
boolean flag = b(j, k, l); boolean flag = this.b(i, j, k);
ItemStack itemstack = a.P(); ItemStack itemstack = this.a.P();
if (itemstack != null) { if (itemstack != null) {
itemstack.a(i1, j, k, l); itemstack.a(l, i, j, k);
if (itemstack.a == 0) { if (itemstack.count == 0) {
itemstack.a(a); itemstack.a(this.a);
a.Q(); this.a.Q();
} }
} }
if (flag && a.b(Block.m[i1])) {
Block.m[i1].g(b, j, k, l, j1); if (flag && this.a.b(Block.byId[l])) {
Block.byId[l].g(this.b, i, j, k, i1);
} }
return flag; return flag;
} }
public boolean a(EntityPlayer entityplayer, World world, ItemStack itemstack) { public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack) {
int j = itemstack.a; int i = itemstack.count;
ItemStack itemstack1 = itemstack.a(world, entityplayer); ItemStack itemstack1 = itemstack.a(world, entityhuman);
if (itemstack1 != itemstack || itemstack1 != null && itemstack1.a != j) { if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i)) {
entityplayer.an.a[entityplayer.an.c] = itemstack1;
if (itemstack1.a == 0) {
entityplayer.an.a[entityplayer.an.c] = null;
}
return true;
} else {
return false; return false;
} else {
entityhuman.inventory.a[entityhuman.inventory.c] = itemstack1;
if (itemstack1.count == 0) {
entityhuman.inventory.a[entityhuman.inventory.c] = null;
}
return true;
} }
} }
public boolean a(EntityPlayer entityplayer, World world, ItemStack itemstack, int j, int k, int l, int i1) { public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) {
int j1 = world.a(j, k, l); int i1 = world.getTypeId(i, j, k);
if (j1 > 0 && Block.m[j1].a(world, j, k, l, entityplayer)) { return i1 > 0 && Block.byId[i1].a(world, i, j, k, entityhuman) ? true : (itemstack == null ? false : itemstack.a(entityhuman, world, i, j, k, l));
return true;
}
if (itemstack == null) {
return false;
} else {
return itemstack.a(entityplayer, world, j, k, l, i1);
}
} }
} }

View File

@ -17,36 +17,38 @@ public class ItemMinecart extends Item {
public ItemMinecart(int i, int j) { public ItemMinecart(int i, int j) {
super(i); super(i);
bb = 1; this.maxStackSize = 1;
a = j; this.a = j;
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
int i1 = world.a(i, j, k); int i1 = world.getTypeId(i, j, k);
if (i1 == Block.aG.bi) { if (i1 == Block.RAILS.id) {
// CraftBukkit start - Minecarts if (!world.isStatic) {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
if (!world.z) { // CraftBukkit start - Minecarts
world.a(((Entity) (new EntityMinecart(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, a)))); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM;
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockFace = CraftBlock.notchToBlockFace(1);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
world.a((Entity) (new EntityMinecart(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.a)));
} }
itemstack.a--;
--itemstack.count;
return true; return true;
} else { } else {
return false; return false;

View File

@ -18,51 +18,60 @@ public class ItemRedstone extends Item {
super(i); super(i);
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
// CraftBukkit - store the clicked block // CraftBukkit start - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
// CraftBukkit end
if (l == 0) {
j--;
}
if (l == 1) {
j++;
}
if (l == 2) {
k--;
}
if (l == 3) {
k++;
}
if (l == 4) {
i--;
}
if (l == 5) {
i++;
}
if (!world.e(i, j, k)) {
return false;
}
if (Block.av.a(world, i, j, k)) {
// CraftBukkit start - Redstone
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
itemstack.a--; if (l == 0) {
world.e(i, j, k, Block.av.bi); --j;
}
if (l == 1) {
++j;
}
if (l == 2) {
--k;
}
if (l == 3) {
++k;
}
if (l == 4) {
--i;
}
if (l == 5) {
++i;
}
if (!world.isEmpty(i, j, k)) {
return false;
} else {
if (Block.REDSTONE_WIRE.a(world, i, j, k)) {
// CraftBukkit start - Redstone
Type eventType = Type.PLAYER_ITEM;
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
--itemstack.count;
world.e(i, j, k, Block.REDSTONE_WIRE.id);
}
return true;
} }
return true;
} }
} }

View File

@ -18,39 +18,40 @@ public class ItemSeeds extends Item {
public ItemSeeds(int i, int j) { public ItemSeeds(int i, int j) {
super(i); super(i);
a = j; this.a = j;
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
if (l != 1) { if (l != 1) {
return false; return false;
} } else {
int i1 = world.a(i, j, k); int i1 = world.getTypeId(i, j, k);
if (i1 == Block.aA.bi && world.e(i, j + 1, k)) { if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) {
// CraftBukkit start - Seeds // CraftBukkit start - Seeds
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer(); CraftServer craftServer = ((WorldServer) world).getServer();
Type eventType = Type.PLAYER_ITEM; Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity(); Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack); org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
BlockFace blockface = CraftBlock.notchToBlockFace(1); BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface); PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(pie); craftServer.getPluginManager().callEvent(event);
if (pie.isCancelled()) { if (event.isCancelled()) {
return false;
}
// CraftBukkit end
world.e(i, j + 1, k, this.a);
--itemstack.count;
return true;
} else {
return false; return false;
} }
// CraftBukkit end
world.e(i, j + 1, k, a);
itemstack.a--;
return true;
} else {
return false;
} }
} }
} }

View File

@ -15,68 +15,75 @@ public class ItemSign extends Item {
public ItemSign(int i) { public ItemSign(int i) {
super(i); super(i);
bc = 64; this.durability = 64;
bb = 1; this.maxStackSize = 1;
} }
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
if (l == 0) { if (l == 0) {
return false; return false;
} } else if (!world.getMaterial(i, j, k).isBuildable()) {
if (!world.c(i, j, k).a()) {
return false; return false;
}
// CraftBukkit - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (l == 1) {
j++;
}
if (l == 2) {
k--;
}
if (l == 3) {
k++;
}
if (l == 4) {
i--;
}
if (l == 5) {
i++;
}
if (!Block.aD.a(world, i, j, k)) {
return false;
}
// CraftBukkit start
// Signs
Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
if (l == 1) {
world.b(i, j, k, Block.aD.bi, MathHelper.b((double) (((entityplayer.v + 180F) * 16F) / 360F) + 0.5D) & 0xf);
} else { } else {
world.b(i, j, k, Block.aI.bi, l); // CraftBukkit start - store the clicked block
} CraftWorld craftWorld = ((WorldServer) world).getWorld();
itemstack.a--; CraftServer craftServer = ((WorldServer) world).getServer();
TileEntitySign tileentitysign = (TileEntitySign) world.m(i, j, k); org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
//CraftBukkit end
if (tileentitysign != null) { if (l == 1) {
entityplayer.a(tileentitysign); ++j;
}
if (l == 2) {
--k;
}
if (l == 3) {
++k;
}
if (l == 4) {
--i;
}
if (l == 5) {
++i;
}
if (!Block.SIGN_POST.a(world, i, j, k)) {
return false;
} else {
// CraftBukkit start
// Signs
Type eventType = Type.PLAYER_ITEM;
Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockface = CraftBlock.notchToBlockFace(1);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
// CraftBukkit end
if (l == 1) {
world.b(i, j, k, Block.SIGN_POST.id, MathHelper.b((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15);
} else {
world.b(i, j, k, Block.WALL_SIGN.id, l);
}
--itemstack.count;
TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k);
if (tileentitysign != null) {
entityhuman.a(tileentitysign);
}
return true;
}
} }
return true;
} }
} }

View File

@ -2,183 +2,170 @@ package net.minecraft.server;
public final class ItemStack { public final class ItemStack {
public int a; public int count;
public int b; public int b;
public int c; public int id;
public int d; // Craftbukkit - make public public int damage; // Craftbukkit - make public
public ItemStack(Block block) { public ItemStack(Block block) {
this(block, 1); this(block, 1);
} }
public ItemStack(Block block, int k) { public ItemStack(Block block, int i) {
this(block.bi, k, 0); this(block.id, i, 0);
} }
public ItemStack(Block block, int k, int l) { public ItemStack(Block block, int i, int j) {
this(block.bi, k, l); this(block.id, i, j);
} }
public ItemStack(Item item) { public ItemStack(Item item) {
this(item.ba, 1, 0); this(item.id, 1, 0);
} }
public ItemStack(Item item, int k) { public ItemStack(Item item, int i) {
this(item.ba, k, 0); this(item.id, i, 0);
} }
public ItemStack(Item item, int k, int l) { public ItemStack(Item item, int i, int j) {
this(item.ba, k, l); this(item.id, i, j);
} }
public ItemStack(int k, int l, int i1) { public ItemStack(int i, int j, int k) {
a = 0; this.count = 0;
c = k; this.id = i;
a = l; this.count = j;
d = i1; this.damage = k;
} }
public ItemStack(NBTTagCompound nbttagcompound) { public ItemStack(NBTTagCompound nbttagcompound) {
a = 0; this.count = 0;
b(nbttagcompound); this.b(nbttagcompound);
} }
public ItemStack a(int k) { public ItemStack a(int i) {
a -= k; this.count -= i;
return new ItemStack(c, k, d); return new ItemStack(this.id, i, this.damage);
} }
public Item a() { public Item a() {
return Item.c[c]; return Item.byId[this.id];
} }
public boolean a(EntityPlayer entityplayer, World world, int k, int l, int i1, int j1) { public boolean a(EntityHuman entityhuman, World world, int i, int j, int k, int l) {
return a().a(this, entityplayer, world, k, l, i1, j1); return this.a().a(this, entityhuman, world, i, j, k, l);
} }
public float a(Block block) { public float a(Block block) {
return a().a(this, block); return this.a().a(this, block);
} }
public ItemStack a(World world, EntityPlayer entityplayer) { public ItemStack a(World world, EntityHuman entityhuman) {
return a().a(this, world, entityplayer); return this.a().a(this, world, entityhuman);
} }
public NBTTagCompound a(NBTTagCompound nbttagcompound) { public NBTTagCompound a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("id", (short) c); nbttagcompound.a("id", (short) this.id);
nbttagcompound.a("Count", (byte) a); nbttagcompound.a("Count", (byte) this.count);
nbttagcompound.a("Damage", (short) d); nbttagcompound.a("Damage", (short) this.damage);
return nbttagcompound; return nbttagcompound;
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
c = ((int) (nbttagcompound.c("id"))); this.id = nbttagcompound.c("id");
a = ((int) (nbttagcompound.b("Count"))); this.count = nbttagcompound.b("Count");
d = ((int) (nbttagcompound.c("Damage"))); this.damage = nbttagcompound.c("Damage");
} }
public int b() { public int b() {
return a().b(); return this.a().b();
} }
public boolean c() { public boolean c() {
return b() > 1 && (!d() || !f()); return this.b() > 1 && (!this.d() || !this.f());
} }
public boolean d() { public boolean d() {
return Item.c[c].d() > 0; return Item.byId[this.id].d() > 0;
} }
public boolean e() { public boolean e() {
return Item.c[c].c(); return Item.byId[this.id].c();
} }
public boolean f() { public boolean f() {
return d() && d > 0; return this.d() && this.damage > 0;
} }
public int g() { public int g() {
return d; return this.damage;
} }
public int h() { public int h() {
return d; return this.damage;
} }
public int i() { public int i() {
return Item.c[c].d(); return Item.byId[this.id].d();
} }
public void b(int k) { public void b(int i) {
if (!d()) { if (this.d()) {
return; this.damage += i;
} if (this.damage > this.i()) {
d += k; --this.count;
if (d > i()) { if (this.count < 0) {
a--; this.count = 0;
if (a < 0) { }
a = 0;
this.damage = 0;
} }
d = 0;
} }
} }
public void a(EntityLiving entityliving) { public void a(EntityLiving entityliving) {
Item.c[c].a(this, entityliving); Item.byId[this.id].a(this, entityliving);
} }
public void a(int k, int l, int i1, int j1) { public void a(int i, int j, int k, int l) {
Item.c[c].a(this, k, l, i1, j1); Item.byId[this.id].a(this, i, j, k, l);
} }
public int a(Entity entity) { public int a(Entity entity) {
return Item.c[c].a(entity); return Item.byId[this.id].a(entity);
} }
public boolean b(Block block) { public boolean b(Block block) {
return Item.c[c].a(block); return Item.byId[this.id].a(block);
} }
public void a(EntityPlayer entityplayer) {} public void a(EntityHuman entityhuman) {}
public void b(EntityLiving entityliving) { public void b(EntityLiving entityliving) {
Item.c[c].b(this, entityliving); Item.byId[this.id].b(this, entityliving);
} }
public ItemStack j() { public ItemStack j() {
return new ItemStack(c, a, d); return new ItemStack(this.id, this.count, this.damage);
} }
public static boolean a(ItemStack itemstack, ItemStack itemstack1) { public static boolean a(ItemStack itemstack, ItemStack itemstack1) {
if (itemstack == null && itemstack1 == null) { return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? itemstack.c(itemstack1) : false);
return true;
}
if (itemstack == null || itemstack1 == null) {
return false;
} else {
return itemstack.c(itemstack1);
}
} }
private boolean c(ItemStack itemstack) { private boolean c(ItemStack itemstack) {
if (a != itemstack.a) { return this.count != itemstack.count ? false : (this.id != itemstack.id ? false : this.damage == itemstack.damage);
return false;
}
if (c != itemstack.c) {
return false;
}
return d == itemstack.d;
} }
public boolean a(ItemStack itemstack) { public boolean a(ItemStack itemstack) {
return c == itemstack.c && d == itemstack.d; return this.id == itemstack.id && this.damage == itemstack.damage;
} }
public static ItemStack b(ItemStack itemstack) { public static ItemStack b(ItemStack itemstack) {
return itemstack != null ? itemstack.j() : null; return itemstack == null ? null : itemstack.j();
} }
public String toString() { public String toString() {
return (new StringBuilder()).append(a).append("x").append(Item.c[c].a()).append("@").append(d).toString(); return this.count + "x" + Item.byId[this.id].a() + "@" + this.damage;
} }
} }

View File

@ -1,15 +1,14 @@
package net.minecraft.server; package net.minecraft.server;
import java.awt.GraphicsEnvironment;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -27,184 +26,187 @@ public class MinecraftServer implements ICommandListener, Runnable {
public PropertyManager d; public PropertyManager d;
public WorldServer e; public WorldServer e;
public ServerConfigurationManager f; public ServerConfigurationManager f;
private boolean o; private boolean o = true;
public boolean g; public boolean g = false;
int h; int h = 0;
public String i; public String i;
public int j; public int j;
private List p; private List p = new ArrayList();
private List q; private List q = Collections.synchronizedList(new ArrayList());
public EntityTracker k; public EntityTracker k;
public boolean l; public boolean l;
public boolean m; public boolean m;
public boolean n; public boolean n;
public CraftServer server; // CraftBukkit public MinecraftServer() {
public OptionSet options; // CraftBukkit
// CraftBukkit: Added arg "OptionSet options"
public MinecraftServer(final OptionSet options) {
o = true;
g = false;
h = 0;
p = ((List) (new ArrayList()));
q = Collections.synchronizedList(((List) (new ArrayList())));
new ThreadSleepForever(this); new ThreadSleepForever(this);
// CraftBukkit start
this.options = options; // CraftBukkit this.options = options;
} }
public CraftServer server;
public OptionSet options;
// CraftBukkit: added throws UnknownHostException
private boolean d() throws UnknownHostException { private boolean d() throws UnknownHostException {
// CraftBukkit end -- added throws UnknownHostException
ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); ThreadCommandReader threadcommandreader = new ThreadCommandReader(this);
((Thread) (threadcommandreader)).setDaemon(true); threadcommandreader.setDaemon(true);
((Thread) (threadcommandreader)).start(); threadcommandreader.start();
ConsoleLogManager.a(); ConsoleLogManager.a();
a.info("Starting minecraft server version Beta 1.2_01"); a.info("Starting minecraft server version Beta 1.2_01");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
a.warning("**** NOT ENOUGH RAM!"); a.warning("**** NOT ENOUGH RAM!");
a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
} }
a.info("Loading properties");
d = new PropertyManager(options);
String s = d.a("server-ip", "");
l = d.a("online-mode", true); a.info("Loading properties");
m = d.a("spawn-animals", true); this.d = new PropertyManager(new File("server.properties"));
n = d.a("pvp", true); String s = this.d.a("server-ip", "");
this.l = this.d.a("online-mode", true);
this.m = this.d.a("spawn-animals", true);
this.n = this.d.a("pvp", true);
InetAddress inetaddress = null; InetAddress inetaddress = null;
if (s.length() > 0) { if (s.length() > 0) {
inetaddress = InetAddress.getByName(s); inetaddress = InetAddress.getByName(s);
} }
int i1 = d.a("server-port", 25565);
a.info((new StringBuilder()).append("Starting Minecraft server on ").append(s.length() != 0 ? s : "*").append(":").append(i1).toString()); int i = this.d.a("server-port", 25565);
a.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i);
try { try {
c = new NetworkListenThread(this, inetaddress, i1); this.c = new NetworkListenThread(this, inetaddress, i);
// CraftBukkit: Be more generic; IOException -> Throwable // CraftBukkit: Be more generic; IOException -> Throwable
} catch (Throwable ioexception) { } catch (Throwable ioexception) {
a.warning("**** FAILED TO BIND TO PORT!"); a.warning("**** FAILED TO BIND TO PORT!");
a.log(Level.WARNING, (new StringBuilder()).append("The exception was: ").append(ioexception.toString()).toString()); a.log(Level.WARNING, "The exception was: " + ioexception.toString());
a.warning("Perhaps a server is already running on that port?"); a.warning("Perhaps a server is already running on that port?");
return false; return false;
} }
if (!l) {
if (!this.l) {
a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
a.warning("The server will make no attempt to authenticate usernames. Beware."); a.warning("The server will make no attempt to authenticate usernames. Beware.");
a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
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.");
} }
f = new ServerConfigurationManager(this);
k = new EntityTracker(this);
String s1 = d.a("level-name", "world");
a.info((new StringBuilder()).append("Preparing level \"").append(s1).append("\"").toString()); this.f = new ServerConfigurationManager(this);
c(s1); this.k = new EntityTracker(this);
String s1 = this.d.a("level-name", "world");
a.info("Preparing level \"" + s1 + "\"");
this.c(s1);
a.info("Done! For help, type \"help\" or \"?\""); a.info("Done! For help, type \"help\" or \"?\"");
return true; return true;
} }
private void c(String s) { private void c(String s) {
a.info("Preparing start region"); a.info("Preparing start region");
e = new WorldServer(this, new File("."), s, d.a("hellworld", false) ? -1 : 0); this.e = new WorldServer(this, new File("."), s, this.d.a("hellworld", false) ? -1 : 0);
e.a(((IWorldAccess) (new WorldManager(this)))); this.e.a(new WorldManager(this));
e.k = d.a("spawn-monsters", true) ? 1 : 0; this.e.k = this.d.a("spawn-monsters", true) ? 1 : 0;
e.a(d.a("spawn-monsters", true), m); this.e.a(this.d.a("spawn-monsters", true), this.m);
f.a(e); this.f.a(this.e);
char c1 = '\304'; short short1 = 196;
long l1 = System.currentTimeMillis(); long i = System.currentTimeMillis();
for (int i1 = -c1; i1 <= c1 && o; i1 += 16) { for (int j = -short1; j <= short1 && this.o; j += 16) {
for (int j1 = -c1; j1 <= c1 && o; j1 += 16) { for (int k = -short1; k <= short1 && this.o; k += 16) {
long l2 = System.currentTimeMillis(); long l = System.currentTimeMillis();
if (l2 < l1) { if (l < i) {
l1 = l2; i = l;
} }
if (l2 > l1 + 1000L) {
int k1 = (c1 * 2 + 1) * (c1 * 2 + 1);
int i2 = (i1 + c1) * (c1 * 2 + 1) + (j1 + 1);
a("Preparing spawn area", (i2 * 100) / k1); if (l > i + 1000L) {
l1 = l2; int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;
this.a("Preparing spawn area", j1 * 100 / i1);
i = l;
} }
e.A.d(e.m + i1 >> 4, e.o + j1 >> 4);
while (e.d() && o) { this.e.A.d(this.e.spawnX + j >> 4, this.e.spawnZ + k >> 4);
while (this.e.d() && this.o) {
; ;
} }
} }
} }
e(); this.e();
} }
private void a(String s, int i1) { private void a(String s, int i) {
i = s; this.i = s;
j = i1; this.j = i;
System.out.println((new StringBuilder()).append(s).append(": ").append(i1).append("%").toString()); a.info(s + ": " + i + "%");
} }
private void e() { private void e() {
i = null; this.i = null;
j = 0; this.j = 0;
server.loadPlugins(); // CraftBukkit server.loadPlugins(); // CraftBukkit
} }
private void f() { private void f() {
a.info("Saving chunks"); a.info("Saving chunks");
e.a(true, ((IProgressUpdate) (null))); this.e.a(true, (IProgressUpdate) null);
} }
private void g() { private void g() {
a.info("Stopping server"); a.info("Stopping server");
if(server != null) { if (this.f != null) {
server.disablePlugins(); this.f.d();
} }
if (f != null) { if (this.e != null) {
f.d(); this.f();
}
if (e != null) {
f();
} }
} }
public void a() { public void a() {
o = false; this.o = false;
} }
public void run() { public void run() {
try { try {
if (d()) { if (this.d()) {
long l1 = System.currentTimeMillis(); long i = System.currentTimeMillis();
long l2 = 0L; long j = 0L;
while (o) { while (this.o) {
long l3 = System.currentTimeMillis(); long k = System.currentTimeMillis();
long l4 = l3 - l1; long l = k - i;
if (l4 > 2000L) { if (l > 2000L) {
a.warning("Can't keep up! Did the system time change, or is the server overloaded?"); a.warning("Can\'t keep up! Did the system time change, or is the server overloaded?");
l4 = 2000L; l = 2000L;
} }
if (l4 < 0L) {
if (l < 0L) {
a.warning("Time ran backwards! Did the system time change?"); a.warning("Time ran backwards! Did the system time change?");
l4 = 0L; l = 0L;
} }
l2 += l4;
l1 = l3; j += l;
while (l2 > 50L) { i = k;
l2 -= 50L;
h(); while (j > 50L) {
j -= 50L;
this.h();
} }
Thread.sleep(1L); Thread.sleep(1L);
} }
} else { } else {
while (o) { while (this.o) {
b(); this.b();
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException interruptedexception) { } catch (InterruptedException interruptedexception) {
@ -214,9 +216,11 @@ public class MinecraftServer implements ICommandListener, Runnable {
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
a.log(Level.SEVERE, "Unexpected exception", ((Throwable) (exception))); a.log(Level.SEVERE, "Unexpected exception", exception);
while (o) {
b(); while (this.o) {
this.b();
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException interruptedexception1) { } catch (InterruptedException interruptedexception1) {
@ -225,8 +229,8 @@ public class MinecraftServer implements ICommandListener, Runnable {
} }
} finally { } finally {
try { try {
g(); this.g();
g = true; this.g = true;
} finally { } finally {
System.exit(0); System.exit(0);
} }
@ -235,62 +239,217 @@ public class MinecraftServer implements ICommandListener, Runnable {
private void h() { private void h() {
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
Iterator iterator = b.keySet().iterator();
for (Iterator iterator = b.keySet().iterator(); iterator.hasNext();) { while (iterator.hasNext()) {
String s = (String) iterator.next(); String s = (String) iterator.next();
int k1 = ((Integer) b.get(((s)))).intValue(); int i = ((Integer) b.get(s)).intValue();
if (k1 > 0) { if (i > 0) {
b.put(((s)), ((Integer.valueOf(k1 - 1)))); b.put(s, Integer.valueOf(i - 1));
} else { } else {
((List) (arraylist)).add(((s))); arraylist.add(s);
} }
} }
for (int i1 = 0; i1 < ((List) (arraylist)).size(); i1++) { int j;
b.remove(((List) (arraylist)).get(i1));
for (j = 0; j < arraylist.size(); ++j) {
b.remove(arraylist.get(j));
} }
AxisAlignedBB.a(); AxisAlignedBB.a();
Vec3D.a(); Vec3D.a();
h++; ++this.h;
if (h % 20 == 0) { if (this.h % 20 == 0) {
f.a(((Packet) (new Packet4UpdateTime(e.e)))); this.f.a((Packet) (new Packet4UpdateTime(this.e.e)));
} }
e.f();
while (e.d()) { this.e.f();
while (this.e.d()) {
; ;
} }
e.c();
c.a(); this.e.c();
f.b(); this.c.a();
k.a(); this.f.b();
for (int j1 = 0; j1 < p.size(); j1++) { this.k.a();
((IUpdatePlayerListBox) p.get(j1)).a();
for (j = 0; j < this.p.size(); ++j) {
((IUpdatePlayerListBox) this.p.get(j)).a();
} }
try { try {
b(); this.b();
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, "Unexpected exception while parsing console command", ((Throwable) (exception))); a.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
} }
} }
public void a(String s, ICommandListener icommandlistener) { public void a(String s, ICommandListener icommandlistener) {
q.add(((new ServerCommand(s, icommandlistener)))); this.q.add(new ServerCommand(s, icommandlistener));
} }
public void b() { public void b() {
do { while (this.q.size() > 0) {
if (q.size() <= 0) { ServerCommand servercommand = (ServerCommand) this.q.remove(0);
break;
}
ServerCommand servercommand = (ServerCommand) q.remove(0);
String s = servercommand.a; String s = servercommand.a;
ICommandListener icommandlistener = servercommand.b; ICommandListener icommandlistener = servercommand.b;
String s1 = icommandlistener.c(); String s1 = icommandlistener.c();
if (s.toLowerCase().startsWith("#help") || s.toLowerCase().startsWith("#?")) { if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) {
if (s.toLowerCase().startsWith("list")) {
icommandlistener.b("Connected players: " + this.f.c());
} else if (s.toLowerCase().startsWith("stop")) {
this.a(s1, "Stopping the server..");
this.o = false;
} else if (s.toLowerCase().startsWith("save-all")) {
this.a(s1, "Forcing save..");
this.e.a(true, (IProgressUpdate) null);
this.a(s1, "Save complete.");
} else if (s.toLowerCase().startsWith("save-off")) {
this.a(s1, "Disabling level saving..");
this.e.C = true;
} else if (s.toLowerCase().startsWith("save-on")) {
this.a(s1, "Enabling level saving..");
this.e.C = false;
} else {
String s2;
if (s.toLowerCase().startsWith("op ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.e(s2);
this.a(s1, "Opping " + s2);
this.f.a(s2, "§eYou are now op!");
} else if (s.toLowerCase().startsWith("deop ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.f(s2);
this.f.a(s2, "§eYou are no longer op!");
this.a(s1, "De-opping " + s2);
} else if (s.toLowerCase().startsWith("ban-ip ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.c(s2);
this.a(s1, "Banning ip " + s2);
} else if (s.toLowerCase().startsWith("pardon-ip ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.d(s2);
this.a(s1, "Pardoning ip " + s2);
} else {
EntityPlayer entityplayer;
if (s.toLowerCase().startsWith("ban ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.a(s2);
this.a(s1, "Banning " + s2);
entityplayer = this.f.h(s2);
if (entityplayer != null) {
entityplayer.a.a("Banned by admin");
}
} else if (s.toLowerCase().startsWith("pardon ")) {
s2 = s.substring(s.indexOf(" ")).trim();
this.f.b(s2);
this.a(s1, "Pardoning " + s2);
} else if (s.toLowerCase().startsWith("kick ")) {
s2 = s.substring(s.indexOf(" ")).trim();
entityplayer = null;
for (int i = 0; i < this.f.b.size(); ++i) {
EntityPlayer entityplayer1 = (EntityPlayer) this.f.b.get(i);
if (entityplayer1.name.equalsIgnoreCase(s2)) {
entityplayer = entityplayer1;
}
}
if (entityplayer != null) {
entityplayer.a.a("Kicked by admin");
this.a(s1, "Kicking " + entityplayer.name);
} else {
icommandlistener.b("Can\'t find user " + s2 + ". No kick.");
}
} else {
String[] astring;
EntityPlayer entityplayer2;
if (s.toLowerCase().startsWith("tp ")) {
astring = s.split(" ");
if (astring.length == 3) {
entityplayer = this.f.h(astring[1]);
entityplayer2 = this.f.h(astring[2]);
if (entityplayer == null) {
icommandlistener.b("Can\'t find user " + astring[1] + ". No tp.");
} else if (entityplayer2 == null) {
icommandlistener.b("Can\'t find user " + astring[2] + ". No tp.");
} else {
entityplayer.a.a(entityplayer2.locX, entityplayer2.locY, entityplayer2.locZ, entityplayer2.yaw, entityplayer2.pitch);
this.a(s1, "Teleporting " + astring[1] + " to " + astring[2] + ".");
}
} else {
icommandlistener.b("Syntax error, please provice a source and a target.");
}
} else if (s.toLowerCase().startsWith("give ")) {
astring = s.split(" ");
if (astring.length != 3 && astring.length != 4) {
return;
}
String s3 = astring[1];
entityplayer2 = this.f.h(s3);
if (entityplayer2 != null) {
try {
int j = Integer.parseInt(astring[2]);
if (Item.byId[j] != null) {
this.a(s1, "Giving " + entityplayer2.name + " some " + j);
int k = 1;
if (astring.length > 3) {
k = this.b(astring[3], 1);
}
if (k < 1) {
k = 1;
}
if (k > 64) {
k = 64;
}
entityplayer2.b(new ItemStack(j, k, 0));
} else {
icommandlistener.b("There\'s no item with id " + j);
}
} catch (NumberFormatException numberformatexception) {
icommandlistener.b("There\'s no item with id " + astring[2]);
}
} else {
icommandlistener.b("Can\'t find user " + s3);
}
} else if (s.toLowerCase().startsWith("say ")) {
s = s.substring(s.indexOf(" ")).trim();
a.info("[" + s1 + "] " + s);
this.f.a((Packet) (new Packet3Chat("§d[Server] " + s)));
} else if (s.toLowerCase().startsWith("tell ")) {
astring = s.split(" ");
if (astring.length >= 3) {
s = s.substring(s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim();
a.info("[" + s1 + "->" + astring[1] + "] " + s);
s = "§7" + s1 + " whispers " + s;
a.info(s);
if (!this.f.a(astring[1], (Packet) (new Packet3Chat(s)))) {
icommandlistener.b("There\'s no player by that name online.");
}
}
} else {
a.info("Unknown console command. Type \"help\" for help.");
}
}
}
}
} else {
icommandlistener.b("To run the server without a gui, start it like this:"); icommandlistener.b("To run the server without a gui, start it like this:");
icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui"); icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
icommandlistener.b("Console commands:"); icommandlistener.b("Console commands:");
@ -311,181 +470,39 @@ public class MinecraftServer implements ICommandListener, Runnable {
icommandlistener.b(" save-on re-enables terrain saving"); icommandlistener.b(" save-on re-enables terrain saving");
icommandlistener.b(" list lists all currently connected players"); icommandlistener.b(" list lists all currently connected players");
icommandlistener.b(" say <message> broadcasts a message to all players"); icommandlistener.b(" say <message> broadcasts a message to all players");
} else if (s.toLowerCase().startsWith("#list")) {
icommandlistener.b((new StringBuilder()).append("Connected players: ").append(f.c()).toString());
} else if (s.toLowerCase().startsWith("#stop")) {
a(s1, "Stopping the server..");
o = false;
} else if (s.toLowerCase().startsWith("#save-all")) {
a(s1, "Forcing save..");
e.a(true, ((IProgressUpdate) (null)));
a(s1, "Save complete.");
} else if (s.toLowerCase().startsWith("#save-off")) {
a(s1, "Disabling level saving..");
e.C = true;
} else if (s.toLowerCase().startsWith("#save-on")) {
a(s1, "Enabling level saving..");
e.C = false;
} else if (s.toLowerCase().startsWith("#op ")) {
String s2 = s.substring(s.indexOf(" ")).trim();
f.e(s2);
a(s1, (new StringBuilder()).append("Opping ").append(s2).toString());
f.a(s2, "\247eYou are now op!");
} else if (s.toLowerCase().startsWith("#deop ")) {
String s3 = s.substring(s.indexOf(" ")).trim();
f.f(s3);
f.a(s3, "\247eYou are no longer op!");
a(s1, (new StringBuilder()).append("De-opping ").append(s3).toString());
} else if (s.toLowerCase().startsWith("#ban-ip ")) {
String s4 = s.substring(s.indexOf(" ")).trim();
f.c(s4);
a(s1, (new StringBuilder()).append("Banning ip ").append(s4).toString());
} else if (s.toLowerCase().startsWith("#pardon-ip ")) {
String s5 = s.substring(s.indexOf(" ")).trim();
f.d(s5);
a(s1, (new StringBuilder()).append("Pardoning ip ").append(s5).toString());
} else if (s.toLowerCase().startsWith("#ban ")) {
String s6 = s.substring(s.indexOf(" ")).trim();
f.a(s6);
a(s1, (new StringBuilder()).append("Banning ").append(s6).toString());
EntityPlayerMP entityplayermp = f.h(s6);
if (entityplayermp != null) {
entityplayermp.a.a("Banned by admin");
}
} else if (s.toLowerCase().startsWith("#pardon ")) {
String s7 = s.substring(s.indexOf(" ")).trim();
f.b(s7);
a(s1, (new StringBuilder()).append("Pardoning ").append(s7).toString());
} else if (s.toLowerCase().startsWith("#kick ")) {
String s8 = s.substring(s.indexOf(" ")).trim();
EntityPlayerMP entityplayermp1 = null;
for (int i1 = 0; i1 < f.b.size(); i1++) {
EntityPlayerMP entityplayermp5 = (EntityPlayerMP) f.b.get(i1);
if (entityplayermp5.aw.equalsIgnoreCase(s8)) {
entityplayermp1 = entityplayermp5;
}
}
if (entityplayermp1 != null) {
entityplayermp1.a.a("Kicked by admin");
a(s1, (new StringBuilder()).append("Kicking ").append(entityplayermp1.aw).toString());
} else {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s8).append(". No kick.").toString());
}
} else if (s.toLowerCase().startsWith("#tp ")) {
String as[] = s.split(" ");
if (as.length == 3) {
EntityPlayerMP entityplayermp2 = f.h(as[1]);
EntityPlayerMP entityplayermp3 = f.h(as[2]);
if (entityplayermp2 == null) {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[1]).append(". No tp.").toString());
} else if (entityplayermp3 == null) {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[2]).append(". No tp.").toString());
} else {
entityplayermp2.a.a(entityplayermp3.p, entityplayermp3.q, entityplayermp3.r, entityplayermp3.v, entityplayermp3.w);
a(s1, (new StringBuilder()).append("Teleporting ").append(as[1]).append(" to ").append(as[2]).append(".").toString());
}
} else {
icommandlistener.b("Syntax error, please provice a source and a target.");
}
} else if (s.toLowerCase().startsWith("#give ")) {
String as1[] = s.split(" ");
if (as1.length != 3 && as1.length != 4) {
return;
}
String s9 = as1[1];
EntityPlayerMP entityplayermp4 = f.h(s9);
if (entityplayermp4 != null) {
try {
int j1 = Integer.parseInt(as1[2]);
if (Item.c[j1] != null) {
a(s1, (new StringBuilder()).append("Giving ").append(entityplayermp4.aw).append(" some ").append(j1).toString());
int k1 = 1;
if (as1.length > 3) {
k1 = b(as1[3], 1);
}
if (k1 < 1) {
k1 = 1;
}
if (k1 > 64) {
k1 = 64;
}
entityplayermp4.b(new ItemStack(j1, k1, 0));
} else {
icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(j1).toString());
}
} catch (NumberFormatException numberformatexception) {
icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(as1[2]).toString());
}
} else {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s9).toString());
}
} else if (s.toLowerCase().startsWith("#say ")) {
s = s.substring(s.indexOf(" ")).trim();
a.info((new StringBuilder()).append("[").append(s1).append("] ").append(s).toString());
f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247d[Server] ").append(s).toString()))));
} else if (s.toLowerCase().startsWith("#tell ")) {
String as2[] = s.split(" ");
if (as2.length >= 3) {
s = s.substring(s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim();
a.info((new StringBuilder()).append("[").append(s1).append("->").append(as2[1]).append("] ").append(s).toString());
s = (new StringBuilder()).append("\2477").append(s1).append(" whispers ").append(s).toString();
a.info(s);
if (!f.a(as2[1], ((Packet) (new Packet3Chat(s))))) {
icommandlistener.b("There's no player by that name online.");
}
}
} else {
a.info("Unknown console command. Type \"help\" for help.");
} }
} while (true); }
} }
private void a(String s, String s1) { private void a(String s, String s1) {
String s2 = (new StringBuilder()).append(s).append(": ").append(s1).toString(); String s2 = s + ": " + s1;
f.i((new StringBuilder()).append("\2477(").append(s2).append(")").toString()); this.f.i("§7(" + s2 + ")");
a.info(s2); a.info(s2);
} }
private int b(String s, int i1) { private int b(String s, int i) {
try { try {
return Integer.parseInt(s); return Integer.parseInt(s);
} catch (NumberFormatException numberformatexception) { } catch (NumberFormatException numberformatexception) {
return i1; return i;
} }
} }
public void a(IUpdatePlayerListBox iupdateplayerlistbox) { public void a(IUpdatePlayerListBox iupdateplayerlistbox) {
p.add(((iupdateplayerlistbox))); this.p.add(iupdateplayerlistbox);
} }
// Craftbukkit start - replaces main(String args[]) // Craftbukkit start - replaces main(String args[])
public static void main(final OptionSet options) { public static void main(final OptionSet options) {
try { try {
MinecraftServer minecraftserver = new MinecraftServer();
// CraftBukkit - remove gui // CraftBukkit - remove gui
MinecraftServer minecraftserver = new MinecraftServer(options);
(new ThreadServerApplication("Server thread", minecraftserver)).start(); (new ThreadServerApplication("Server thread", minecraftserver)).start();
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.SEVERE, "Failed to start the minecraft server", ((Throwable) (exception))); a.log(Level.SEVERE, "Failed to start the minecraft server", exception);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
package net.minecraft.server; package net.minecraft.server;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -10,26 +12,25 @@ import joptsimple.OptionSet; // CraftBukkit
public class PropertyManager { public class PropertyManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
private Properties b; private Properties b = new Properties();
private File c; private File c;
public PropertyManager(File file) { public PropertyManager(File file1) {
b = new Properties(); this.c = file1;
c = file; if (file1.exists()) {
if (file.exists()) {
try { try {
b.load(((java.io.InputStream) (new FileInputStream(file)))); this.b.load(new FileInputStream(file1));
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, (new StringBuilder()).append("Failed to load ").append(((file))).toString(), ((Throwable) (exception))); a.log(Level.WARNING, "Failed to load " + file1, exception);
a(); this.a();
} }
} else { } else {
a.log(Level.WARNING, (new StringBuilder()).append(((file))).append(" does not exist").toString()); a.log(Level.WARNING, file1 + " does not exist");
a(); this.a();
} }
} }
// Craftbukkit start // CraftBukkit start
private OptionSet options = null; private OptionSet options = null;
public PropertyManager(final OptionSet options) { public PropertyManager(final OptionSet options) {
@ -45,45 +46,48 @@ public class PropertyManager {
return value; return value;
} }
// Craftbukkit end // CraftBukkit end
public void a() { public void a() {
a.log(Level.INFO, "Generating new properties file"); a.log(Level.INFO, "Generating new properties file");
b(); this.b();
} }
public void b() { public void b() {
try { try {
b.store(((java.io.OutputStream) (new FileOutputStream(c))), "Minecraft server properties"); this.b.store(new FileOutputStream(this.c), "Minecraft server properties");
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, (new StringBuilder()).append("Failed to save ").append(((c))).toString(), ((Throwable) (exception))); a.log(Level.WARNING, "Failed to save " + this.c, exception);
a(); this.a();
} }
} }
public String a(String s, String s1) { public String a(String s, String s1) {
if (!b.containsKey(((s)))) { if (!this.b.containsKey(s)) {
b.setProperty(s, getOverride(s, s1)); // Craftbukkit this.b.setProperty(s, getOverride(s, s1)); // CraftBukkit
b(); this.b();
} }
return getOverride(s, b.getProperty(s, s1)); // Craftbukkit
return getOverride(s, this.b.getProperty(s, s1)); // CraftBukkit
} }
public int a(String s, int i) { public int a(String s, int i) {
try { try {
return getOverride(s, Integer.parseInt(a(s, String.valueOf(i)))); // Craftbukkit return getOverride(s, Integer.parseInt(this.a(s, "" + i))); // CraftBukkit
} catch (Exception exception) { } catch (Exception exception) {
b.setProperty(s, getOverride(s, i).toString()); // Craftbukkit i = getOverride(s, i); // CraftBukkit
this.b.setProperty(s, "" + i);
return i;
} }
return getOverride(s, i); // Craftbukkit
} }
public boolean a(String s, boolean flag) { public boolean a(String s, boolean flag) {
try { try {
return getOverride(s, Boolean.parseBoolean(a(s, String.valueOf(flag)))); // Craftbukkit return getOverride(s, Boolean.parseBoolean(this.a(s, "" + flag))); // CraftBukkit
} catch (Exception exception) { } catch (Exception exception) {
b.setProperty(s, getOverride(s, flag).toString()); // Craftbukkit flag = getOverride(s, flag); // CraftBukkit
this.b.setProperty(s, "" + flag);
return flag;
} }
return getOverride(s, flag); // Craftbukkit
} }
} }

View File

@ -1,7 +1,15 @@
package net.minecraft.server; package net.minecraft.server;
import java.io.*; import java.io.BufferedReader;
import java.util.*; import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
// CraftBukkit start // CraftBukkit start
@ -16,100 +24,89 @@ import org.bukkit.event.player.PlayerLoginEvent;
public class ServerConfigurationManager { public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public List b; public List b = new ArrayList();
private MinecraftServer c; private MinecraftServer c;
private PlayerManager d; private PlayerManager d;
private int e; private int e;
private Set f; private Set f = new HashSet();
private Set g; private Set g = new HashSet();
private Set h; private Set h = new HashSet();
private File i; private File i;
private File j; private File j;
private File k; private File k;
private PlayerNBTManager l; private PlayerNBTManager l;
private CraftServer server; // CraftBukkit
public ServerConfigurationManager(MinecraftServer minecraftserver) { public ServerConfigurationManager(MinecraftServer minecraftserver) {
// CraftBukkit 2 lines! this.c = minecraftserver;
minecraftserver.server = new CraftServer(minecraftserver, this); this.i = minecraftserver.a("banned-players.txt");
server = minecraftserver.server; this.j = minecraftserver.a("banned-ips.txt");
this.k = minecraftserver.a("ops.txt");
b = ((List) (new ArrayList())); this.d = new PlayerManager(minecraftserver);
f = ((Set) (new HashSet())); this.e = minecraftserver.d.a("max-players", 20);
g = ((Set) (new HashSet())); this.e();
h = ((Set) (new HashSet())); this.g();
c = minecraftserver; this.i();
i = minecraftserver.a("banned-players.txt"); this.f();
j = minecraftserver.a("banned-ips.txt"); this.h();
k = minecraftserver.a("ops.txt"); this.j();
d = new PlayerManager(minecraftserver);
e = minecraftserver.d.a("max-players", 20);
e();
g();
i();
f();
h();
j();
} }
public void a(WorldServer worldserver) { public void a(WorldServer worldserver) {
l = new PlayerNBTManager(new File(worldserver.t, "players")); this.l = new PlayerNBTManager(new File(worldserver.t, "players"));
} }
public int a() { public int a() {
return d.b(); return this.d.b();
} }
public void a(EntityPlayerMP entityplayermp) { public void a(EntityPlayer entityplayer) {
b.add(((entityplayermp))); this.b.add(entityplayer);
l.b(entityplayermp); this.l.b(entityplayer);
c.e.A.d((int) entityplayermp.p >> 4, (int) entityplayermp.r >> 4); this.c.e.A.d((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
for (; c.e.a(((Entity) (entityplayermp)), entityplayermp.z).size() != 0; entityplayermp.a(entityplayermp.p, entityplayermp.q + 1.0D, entityplayermp.r)) {
; while (this.c.e.a(entityplayer, entityplayer.boundingBox).size() != 0) {
entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
} }
c.e.a(((Entity) (entityplayermp)));
d.a(entityplayermp);
// CraftBukkit this.c.e.a(entityplayer);
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayermp))); this.d.a(entityplayer);
} }
public void b(EntityPlayerMP entityplayermp) { public void b(EntityPlayer entityplayer) {
d.c(entityplayermp); this.d.c(entityplayer);
} }
public void c(EntityPlayerMP entityplayermp) { public void c(EntityPlayer entityplayer) {
l.a(entityplayermp); this.l.a(entityplayer);
c.e.d(((Entity) (entityplayermp))); this.c.e.d(entityplayer);
b.remove(((entityplayermp))); this.b.remove(entityplayer);
d.b(entityplayermp); this.d.b(entityplayer);
// CraftBukkit // CraftBukkit start
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayermp))); server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayer))); // CraftBukkit
} }
private CraftServer server;
// CraftBukkit end
public EntityPlayerMP a(NetLoginHandler netloginhandler, String s, String s1) { public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) {
// CraftBukkit start - note: this entire method needs to be changed // CraftBukkit start - note: this entire method needs to be changed
// Instead of kicking then returning, we need to store the kick reason // Instead of kicking then returning, we need to store the kick reason
// in the event, check with plugins to see if it's ok, and THEN kick // in the event, check with plugins to see if it's ok, and THEN kick
// depending on the outcome. // depending on the outcome.
EntityPlayerMP entity = new EntityPlayerMP(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e)))); EntityPlayer entity = new EntityPlayer(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
Player player = (entity == null)?null:(Player)entity.getBukkitEntity(); Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player); PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
// CraftBukkit end
String s2 = ((netloginhandler.b.b())).toString(); String s2 = netloginhandler.b.b().toString();
s2 = s2.substring(s2.indexOf("/") + 1); s2 = s2.substring(s2.indexOf("/") + 1);
s2 = s2.substring(0, s2.indexOf(":")); s2 = s2.substring(0, s2.indexOf(":"));
// CraftBukkit start if (this.f.contains(s.trim().toLowerCase())) {
if (f.contains(s.trim().toLowerCase())) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!"); event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!");
} else if (g.contains(s2)) { } else if (this.g.contains(s2)) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!"); event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!");
} else if (b.size() >= e) { } else if (this.b.size() >= this.e) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!"); event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
} }
@ -118,201 +115,213 @@ public class ServerConfigurationManager {
netloginhandler.a(event.getKickMessage()); netloginhandler.a(event.getKickMessage());
return null; return null;
} }
// CraftBukkit end
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (entityplayermp.aw.equalsIgnoreCase(s)) { for (int i = 0; i < this.b.size(); ++i) {
entityplayermp.a.a("You logged in from another location"); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
if (entityplayer.name.equalsIgnoreCase(s)) {
entityplayer.a.a("You logged in from another location");
} }
} }
// CraftBukkit return new EntityPlayer(this.c, this.c.e, s, new ItemInWorldManager(this.c.e));
return entity; // CraftBukkit end
} }
public EntityPlayerMP d(EntityPlayerMP entityplayermp) { public EntityPlayer d(EntityPlayer entityplayer) {
c.k.a(entityplayermp); this.c.k.a(entityplayer);
c.k.b(((Entity) (entityplayermp))); this.c.k.b(entityplayer);
d.b(entityplayermp); this.d.b(entityplayer);
b.remove(((entityplayermp))); this.b.remove(entityplayer);
c.e.e(((Entity) (entityplayermp))); this.c.e.e(entityplayer);
EntityPlayerMP entityplayermp1 = new EntityPlayerMP(c, ((World) (c.e)), entityplayermp.aw, new ItemInWorldManager(((World) (c.e)))); EntityPlayer entityplayer1 = new EntityPlayer(this.c, this.c.e, entityplayer.name, new ItemInWorldManager(this.c.e));
entityplayermp1.g = entityplayermp.g; entityplayer1.id = entityplayer.id;
entityplayermp1.a = entityplayermp.a; entityplayer1.a = entityplayer.a;
c.e.A.d((int) entityplayermp1.p >> 4, (int) entityplayermp1.r >> 4); this.c.e.A.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
for (; c.e.a(((Entity) (entityplayermp1)), entityplayermp1.z).size() != 0; entityplayermp1.a(entityplayermp1.p, entityplayermp1.q + 1.0D, entityplayermp1.r)) {
; while (this.c.e.a(entityplayer1, entityplayer1.boundingBox).size() != 0) {
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
} }
entityplayermp1.a.b(((Packet) (new Packet9())));
entityplayermp1.a.a(entityplayermp1.p, entityplayermp1.q, entityplayermp1.r, entityplayermp1.v, entityplayermp1.w); entityplayer1.a.b((Packet) (new Packet9Respawn()));
d.a(entityplayermp1); entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
c.e.a(((Entity) (entityplayermp1))); this.d.a(entityplayer1);
b.add(((entityplayermp1))); this.c.e.a(entityplayer1);
entityplayermp1.l(); this.b.add(entityplayer1);
return entityplayermp1; entityplayer1.l();
return entityplayer1;
} }
public void b() { public void b() {
d.a(); this.d.a();
} }
public void a(int i1, int j1, int k1) { public void a(int i, int j, int k) {
d.a(i1, j1, k1); this.d.a(i, j, k);
} }
public void a(Packet packet) { public void a(Packet packet) {
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
entityplayermp.a.b(packet); entityplayer.a.b(packet);
} }
} }
public String c() { public String c() {
String s = ""; String s = "";
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
if (i1 > 0) { if (i > 0) {
s = (new StringBuilder()).append(s).append(", ").toString(); s = s + ", ";
} }
s = (new StringBuilder()).append(s).append(((EntityPlayerMP) b.get(i1)).aw).toString();
s = s + ((EntityPlayer) this.b.get(i)).name;
} }
return s; return s;
} }
public void a(String s) { public void a(String s) {
f.add(((s.toLowerCase()))); this.f.add(s.toLowerCase());
f(); this.f();
} }
public void b(String s) { public void b(String s) {
f.remove(((s.toLowerCase()))); this.f.remove(s.toLowerCase());
f(); this.f();
} }
private void e() { private void e() {
try { try {
f.clear(); this.f.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(i)))); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.i));
String s = "";
for (String s = ""; (s = bufferedreader.readLine()) != null;) { while ((s = bufferedreader.readLine()) != null) {
f.add(((s.trim().toLowerCase()))); this.f.add(s.trim().toLowerCase());
} }
bufferedreader.close(); bufferedreader.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ban list: ").append(((exception))).toString()); a.warning("Failed to load ban list: " + exception);
} }
} }
private void f() { private void f() {
try { try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(i, false)))); PrintWriter printwriter = new PrintWriter(new FileWriter(this.i, false));
String s; Iterator iterator = this.f.iterator();
for (Iterator iterator = f.iterator(); iterator.hasNext(); printwriter.println(s)) { while (iterator.hasNext()) {
s = (String) iterator.next(); String s = (String) iterator.next();
printwriter.println(s);
} }
printwriter.close(); printwriter.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ban list: ").append(((exception))).toString()); a.warning("Failed to save ban list: " + exception);
} }
} }
public void c(String s) { public void c(String s) {
g.add(((s.toLowerCase()))); this.g.add(s.toLowerCase());
h(); this.h();
} }
public void d(String s) { public void d(String s) {
g.remove(((s.toLowerCase()))); this.g.remove(s.toLowerCase());
h(); this.h();
} }
private void g() { private void g() {
try { try {
g.clear(); this.g.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(j)))); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j));
String s = "";
for (String s = ""; (s = bufferedreader.readLine()) != null;) { while ((s = bufferedreader.readLine()) != null) {
g.add(((s.trim().toLowerCase()))); this.g.add(s.trim().toLowerCase());
} }
bufferedreader.close(); bufferedreader.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString()); a.warning("Failed to load ip ban list: " + exception);
} }
} }
private void h() { private void h() {
try { try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(j, false)))); PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false));
String s; Iterator iterator = this.g.iterator();
for (Iterator iterator = g.iterator(); iterator.hasNext(); printwriter.println(s)) { while (iterator.hasNext()) {
s = (String) iterator.next(); String s = (String) iterator.next();
printwriter.println(s);
} }
printwriter.close(); printwriter.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString()); a.warning("Failed to save ip ban list: " + exception);
} }
} }
public void e(String s) { public void e(String s) {
h.add(((s.toLowerCase()))); this.h.add(s.toLowerCase());
j(); this.j();
} }
public void f(String s) { public void f(String s) {
h.remove(((s.toLowerCase()))); this.h.remove(s.toLowerCase());
j(); this.j();
} }
private void i() { private void i() {
try { try {
h.clear(); this.h.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(k)))); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k));
String s = "";
for (String s = ""; (s = bufferedreader.readLine()) != null;) { while ((s = bufferedreader.readLine()) != null) {
h.add(((s.trim().toLowerCase()))); this.h.add(s.trim().toLowerCase());
} }
bufferedreader.close(); bufferedreader.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString()); a.warning("Failed to load ip ban list: " + exception);
} }
} }
private void j() { private void j() {
try { try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(k, false)))); PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false));
String s; Iterator iterator = this.h.iterator();
for (Iterator iterator = h.iterator(); iterator.hasNext(); printwriter.println(s)) { while (iterator.hasNext()) {
s = (String) iterator.next(); String s = (String) iterator.next();
printwriter.println(s);
} }
printwriter.close(); printwriter.close();
} catch (Exception exception) { } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString()); a.warning("Failed to save ip ban list: " + exception);
} }
} }
public boolean g(String s) { public boolean g(String s) {
return h.contains(((s.trim().toLowerCase()))); return this.h.contains(s.trim().toLowerCase());
} }
public EntityPlayerMP h(String s) { public EntityPlayer h(String s) {
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
if (entityplayermp.aw.equalsIgnoreCase(s)) { if (entityplayer.name.equalsIgnoreCase(s)) {
return entityplayermp; return entityplayer;
} }
} }
@ -320,22 +329,22 @@ public class ServerConfigurationManager {
} }
public void a(String s, String s1) { public void a(String s, String s1) {
EntityPlayerMP entityplayermp = h(s); EntityPlayer entityplayer = this.h(s);
if (entityplayermp != null) { if (entityplayer != null) {
entityplayermp.a.b(((Packet) (new Packet3Chat(s1)))); entityplayer.a.b((Packet) (new Packet3Chat(s1)));
} }
} }
public void a(double d1, double d2, double d3, double d4, Packet packet) { public void a(double d0, double d1, double d2, double d3, Packet packet) {
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
double d5 = d1 - entityplayermp.p; double d4 = d0 - entityplayer.locX;
double d6 = d2 - entityplayermp.q; double d5 = d1 - entityplayer.locY;
double d7 = d3 - entityplayermp.r; double d6 = d2 - entityplayer.locZ;
if (d5 * d5 + d6 * d6 + d7 * d7 < d4 * d4) { if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) {
entityplayermp.a.b(packet); entityplayer.a.b(packet);
} }
} }
} }
@ -343,20 +352,20 @@ public class ServerConfigurationManager {
public void i(String s) { public void i(String s) {
Packet3Chat packet3chat = new Packet3Chat(s); Packet3Chat packet3chat = new Packet3Chat(s);
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
if (g(entityplayermp.aw)) { if (this.g(entityplayer.name)) {
entityplayermp.a.b(((Packet) (packet3chat))); entityplayer.a.b((Packet) packet3chat);
} }
} }
} }
public boolean a(String s, Packet packet) { public boolean a(String s, Packet packet) {
EntityPlayerMP entityplayermp = h(s); EntityPlayer entityplayer = this.h(s);
if (entityplayermp != null) { if (entityplayer != null) {
entityplayermp.a.b(packet); entityplayer.a.b(packet);
return true; return true;
} else { } else {
return false; return false;
@ -364,10 +373,10 @@ public class ServerConfigurationManager {
} }
public void d() { public void d() {
for (int i1 = 0; i1 < b.size(); i1++) { for (int i = 0; i < this.b.size(); ++i) {
l.a((EntityPlayerMP) b.get(i1)); this.l.a((EntityPlayer) this.b.get(i));
} }
} }
public void a(int i1, int j1, int k1, TileEntity tileentity) {} public void a(int i, int j, int k, TileEntity tileentity) {}
} }

View File

@ -9,14 +9,14 @@ public class Slot {
public int e; public int e;
public Slot(IInventory iinventory, int i, int j, int k) { public Slot(IInventory iinventory, int i, int j, int k) {
b = iinventory; this.b = iinventory;
a = i; this.a = i;
d = j; this.d = j;
e = k; this.e = k;
} }
public void b() { public void b() {
d(); this.d();
} }
public boolean a(ItemStack itemstack) { public boolean a(ItemStack itemstack) {
@ -24,27 +24,27 @@ public class Slot {
} }
public ItemStack c() { public ItemStack c() {
return b.a(a); return this.b.a(this.a);
} }
public void b(ItemStack itemstack) { public void b(ItemStack itemstack) {
b.a(a, itemstack); this.b.a(this.a, itemstack);
d(); this.d();
} }
public void d() { public void d() {
b.d(); this.b.d();
} }
public int a() { public int a() {
return b.c(); return this.b.c();
} }
public ItemStack a(int i) { public ItemStack a(int i) {
return b.b(a, i); return this.b.b(this.a, i);
} }
public boolean a(IInventory iinventory, int i) { public boolean a(IInventory iinventory, int i) {
return iinventory == b && i == a; return iinventory == this.b && i == this.a;
} }
} }

View File

@ -1,26 +0,0 @@
package net.minecraft.server;
import java.io.*;
public class ThreadCommandReader extends Thread {
final MinecraftServer a; /* synthetic field */
public ThreadCommandReader(MinecraftServer minecraftserver) {
super();
a = minecraftserver;
}
public void run() {
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new InputStreamReader(System.in))));
String s = null;
try {
while (!a.g && MinecraftServer.a(a) && (s = bufferedreader.readLine()) != null) {
a.a("#" + s, ((ICommandListener) (a)));
}
} catch (IOException ioexception) {
ioexception.printStackTrace();
}
}
}

View File

@ -2,7 +2,7 @@ package net.minecraft.server;
public class TileEntityChest extends TileEntity implements IInventory { public class TileEntityChest extends TileEntity implements IInventory {
private ItemStack e[]; private ItemStack[] e = new ItemStack[36];
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
@ -10,45 +10,46 @@ public class TileEntityChest extends TileEntity implements IInventory {
} }
// CraftBukkit end // CraftBukkit end
public TileEntityChest() { public TileEntityChest() {}
e = new ItemStack[36];
}
public int h_() { public int h_() {
return 27; return 27;
} }
public ItemStack a(int i) { public ItemStack a(int i) {
return e[i]; return this.e[i];
} }
public ItemStack b(int i, int j) { public ItemStack b(int i, int j) {
if (e[i] != null) { if (this.e[i] != null) {
if (e[i].a <= j) { ItemStack itemstack;
ItemStack itemstack = e[i];
e[i] = null; if (this.e[i].count <= j) {
d(); itemstack = this.e[i];
this.e[i] = null;
this.d();
return itemstack;
} else {
itemstack = this.e[i].a(j);
if (this.e[i].count == 0) {
this.e[i] = null;
}
this.d();
return itemstack; return itemstack;
} }
ItemStack itemstack1 = e[i].a(j);
if (e[i].a == 0) {
e[i] = null;
}
d();
return itemstack1;
} else { } else {
return null; return null;
} }
} }
public void a(int i, ItemStack itemstack) { public void a(int i, ItemStack itemstack) {
e[i] = itemstack; this.e[i] = itemstack;
if (itemstack != null && itemstack.a > c()) { if (itemstack != null && itemstack.count > this.c()) {
itemstack.a = c(); itemstack.count = this.c();
} }
d();
this.d();
} }
public String b() { public String b() {
@ -59,13 +60,14 @@ public class TileEntityChest extends TileEntity implements IInventory {
super.a(nbttagcompound); super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Items"); NBTTagList nbttaglist = nbttagcompound.k("Items");
e = new ItemStack[h_()]; this.e = new ItemStack[this.h_()];
for (int i = 0; i < nbttaglist.b(); i++) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound1.b("Slot") & 0xff;
if (j >= 0 && j < e.length) { for (int i = 0; i < nbttaglist.b(); ++i) {
e[j] = new ItemStack(nbttagcompound1); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound1.b("Slot") & 255;
if (j >= 0 && j < this.e.length) {
this.e[j] = new ItemStack(nbttagcompound1);
} }
} }
} }
@ -74,27 +76,24 @@ public class TileEntityChest extends TileEntity implements IInventory {
super.b(nbttagcompound); super.b(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < e.length; i++) { for (int i = 0; i < this.e.length; ++i) {
if (e[i] != null) { if (this.e[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i); nbttagcompound1.a("Slot", (byte) i);
e[i].a(nbttagcompound1); this.e[i].a(nbttagcompound1);
nbttaglist.a(((NBTBase) (nbttagcompound1))); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
nbttagcompound.a("Items", ((NBTBase) (nbttaglist))); nbttagcompound.a("Items", (NBTBase) nbttaglist);
} }
public int c() { public int c() {
return 64; return 64;
} }
public boolean a_(EntityPlayer entityplayer) { public boolean a_(EntityHuman entityhuman) {
if (a.m(b, c, d) != this) { return this.a.getTileEntity(this.b, this.c, this.d) != this ? false : entityhuman.d((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D) <= 64.0D;
return false;
}
return entityplayer.d((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D) <= 64D;
} }
} }

View File

@ -2,10 +2,10 @@ package net.minecraft.server;
public class TileEntityFurnace extends TileEntity implements IInventory { public class TileEntityFurnace extends TileEntity implements IInventory {
private ItemStack h[]; private ItemStack[] h = new ItemStack[3];
public int e; public int e = 0;
public int f; public int f = 0;
public int g; public int g = 0;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
@ -13,44 +13,41 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
} }
// CraftBukkit end // CraftBukkit end
public TileEntityFurnace() { public TileEntityFurnace() {}
h = new ItemStack[3];
e = 0;
f = 0;
g = 0;
}
public int h_() { public int h_() {
return h.length; return this.h.length;
} }
public ItemStack a(int j) { public ItemStack a(int i) {
return h[j]; return this.h[i];
} }
public ItemStack b(int j, int k) { public ItemStack b(int i, int j) {
if (h[j] != null) { if (this.h[i] != null) {
if (h[j].a <= k) { ItemStack itemstack;
ItemStack itemstack = h[j];
if (this.h[i].count <= j) {
itemstack = this.h[i];
this.h[i] = null;
return itemstack;
} else {
itemstack = this.h[i].a(j);
if (this.h[i].count == 0) {
this.h[i] = null;
}
h[j] = null;
return itemstack; return itemstack;
} }
ItemStack itemstack1 = h[j].a(k);
if (h[j].a == 0) {
h[j] = null;
}
return itemstack1;
} else { } else {
return null; return null;
} }
} }
public void a(int j, ItemStack itemstack) { public void a(int i, ItemStack itemstack) {
h[j] = itemstack; this.h[i] = itemstack;
if (itemstack != null && itemstack.a > c()) { if (itemstack != null && itemstack.count > this.c()) {
itemstack.a = c(); itemstack.count = this.c();
} }
} }
@ -62,38 +59,39 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
super.a(nbttagcompound); super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Items"); NBTTagList nbttaglist = nbttagcompound.k("Items");
h = new ItemStack[h_()]; this.h = new ItemStack[this.h_()];
for (int j = 0; j < nbttaglist.b(); j++) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(j);
byte byte0 = nbttagcompound1.b("Slot");
if (byte0 >= 0 && byte0 < h.length) { for (int i = 0; i < nbttaglist.b(); ++i) {
h[byte0] = new ItemStack(nbttagcompound1); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
byte b0 = nbttagcompound1.b("Slot");
if (b0 >= 0 && b0 < this.h.length) {
this.h[b0] = new ItemStack(nbttagcompound1);
} }
} }
e = ((int) (nbttagcompound.c("BurnTime"))); this.e = nbttagcompound.c("BurnTime");
g = ((int) (nbttagcompound.c("CookTime"))); this.g = nbttagcompound.c("CookTime");
f = a(h[1]); this.f = this.a(this.h[1]);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.a("BurnTime", (short) e); nbttagcompound.a("BurnTime", (short) this.e);
nbttagcompound.a("CookTime", (short) g); nbttagcompound.a("CookTime", (short) this.g);
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int j = 0; j < h.length; j++) { for (int i = 0; i < this.h.length; ++i) {
if (h[j] != null) { if (this.h[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) j); nbttagcompound1.a("Slot", (byte) i);
h[j].a(nbttagcompound1); this.h[i].a(nbttagcompound1);
nbttaglist.a(((NBTBase) (nbttagcompound1))); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
nbttagcompound.a("Items", ((NBTBase) (nbttaglist))); nbttagcompound.a("Items", (NBTBase) nbttaglist);
} }
public int c() { public int c() {
@ -101,109 +99,91 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
} }
public boolean e() { public boolean e() {
return e > 0; return this.e > 0;
} }
public void f() { public void f() {
boolean flag = e > 0; boolean flag = this.e > 0;
boolean flag1 = false; boolean flag1 = false;
if (e > 0) { if (this.e > 0) {
e--; --this.e;
} }
if (!a.z) {
if (e == 0 && i()) { if (!this.a.isStatic) {
f = e = a(h[1]); if (this.e == 0 && this.i()) {
if (e > 0) { this.f = this.e = this.a(this.h[1]);
if (this.e > 0) {
flag1 = true; flag1 = true;
if (h[1] != null) { if (this.h[1] != null) {
h[1].a--; --this.h[1].count;
if (h[1].a == 0) { if (this.h[1].count == 0) {
h[1] = null; this.h[1] = null;
} }
} }
} }
} }
if (e() && i()) {
g++; if (this.e() && this.i()) {
if (g == 200) { ++this.g;
g = 0; if (this.g == 200) {
h(); this.g = 0;
this.h();
flag1 = true; flag1 = true;
} }
} else { } else {
g = 0; this.g = 0;
} }
if (flag != (e > 0)) {
if (flag != this.e > 0) {
flag1 = true; flag1 = true;
BlockFurnace.a(e > 0, a, b, c, d); BlockFurnace.a(this.e > 0, this.a, this.b, this.c, this.d);
} }
} }
if (flag1) { if (flag1) {
d(); this.d();
} }
} }
private boolean i() { private boolean i() {
if (h[0] == null) { if (this.h[0] == null) {
return false; return false;
} } else {
ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba); ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id);
if (itemstack == null) { return itemstack == null ? false : (this.h[2] == null ? true : (!this.h[2].a(itemstack) ? false : (this.h[2].count < this.c() && this.h[2].count < this.h[2].b() ? true : this.h[2].count < itemstack.b())));
return false;
} }
if (h[2] == null) {
return true;
}
if (!h[2].a(itemstack)) {
return false;
}
if (h[2].a < c() && h[2].a < h[2].b()) {
return true;
}
return h[2].a < itemstack.b();
} }
public void h() { public void h() {
if (!i()) { if (this.i()) {
return; ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id);
}
ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba);
if (h[2] == null) { if (this.h[2] == null) {
h[2] = itemstack.j(); this.h[2] = itemstack.j();
} else if (h[2].c == itemstack.c) { } else if (this.h[2].id == itemstack.id) {
h[2].a++; ++this.h[2].count;
} }
h[0].a--;
if (h[0].a <= 0) { --this.h[0].count;
h[0] = null; if (this.h[0].count <= 0) {
this.h[0] = null;
}
} }
} }
private int a(ItemStack itemstack) { private int a(ItemStack itemstack) {
if (itemstack == null) { if (itemstack == null) {
return 0; return 0;
} } else {
int j = itemstack.a().ba; int i = itemstack.a().id;
if (j < 256 && Block.m[j].bt == Material.c) { return i < 256 && Block.byId[i].material == Material.WOOD ? 300 : (i == Item.STICK.id ? 100 : (i == Item.COAL.id ? 1600 : (i == Item.LAVA_BUCKET.id ? 20000 : 0)));
return 300;
} }
if (j == Item.B.ba) {
return 100;
}
if (j == Item.k.ba) {
return 1600;
}
return j != Item.aw.ba ? 0 : 20000;
} }
public boolean a_(EntityPlayer entityplayer) { public boolean a_(EntityHuman entityhuman) {
if (a.m(b, c, d) != this) { return this.a.getTileEntity(this.b, this.c, this.d) != this ? false : entityhuman.d((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D) <= 64.0D;
return false;
}
return entityplayer.d((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D) <= 64D;
} }
} }

View File

@ -1,108 +1,102 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List;
import java.util.Random;
public class TileEntityMobSpawner extends TileEntity { public class TileEntityMobSpawner extends TileEntity {
public int e; public int e = -1;
public String h; // CraftBukkit -> public public String h = "Pig"; // CraftBukkit private -> public
public double f; public double f;
public double g; public double g = 0.0D;
public TileEntityMobSpawner() { public TileEntityMobSpawner() {
e = -1; this.e = 20;
g = 0.0D;
h = "Pig";
e = 20;
} }
public void a(String s) { public void a(String s) {
h = s; this.h = s;
} }
public boolean a() { public boolean a() {
return a.a((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D, 16D) != null; return this.a.a((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D, 16.0D) != null;
} }
public void f() { public void f() {
g = f; this.g = this.f;
if (!a()) { if (this.a()) {
return; double d0 = (double) ((float) this.b + this.a.l.nextFloat());
} double d1 = (double) ((float) this.c + this.a.l.nextFloat());
double d = (float) b + a.l.nextFloat(); double d2 = (double) ((float) this.d + this.a.l.nextFloat());
double d2 = (float) c + a.l.nextFloat();
double d4 = (float) this.d + a.l.nextFloat();
a.a("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D); this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
a.a("flame", d, d2, d4, 0.0D, 0.0D, 0.0D); this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
for (f += 1000F / ((float) e + 200F); f > 360D;) {
f -= 360D;
g -= 360D;
}
if (e == -1) { for (this.f += (double) (1000.0F / ((float) this.e + 200.0F)); this.f > 360.0D; this.g -= 360.0D) {
b(); this.f -= 360.0D;
}
if (e > 0) {
e--;
return;
}
byte byte0 = 4;
for (int i = 0; i < byte0; i++) {
EntityLiving entityliving = (EntityLiving) EntityList.a(h, a);
if (entityliving == null) {
return;
}
int j = a.a(((entityliving)).getClass(), AxisAlignedBB.b(b, c, this.d, b + 1, c + 1, this.d + 1).b(8D, 4D, 8D)).size();
if (j >= 6) {
b();
return;
}
if (entityliving == null) {
continue;
}
double d6 = (double) b + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
double d7 = (c + a.l.nextInt(3)) - 1;
double d8 = (double) this.d + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
entityliving.c(d6, d7, d8, a.l.nextFloat() * 360F, 0.0F);
if (!entityliving.b()) {
continue;
}
a.a(((Entity) (entityliving)));
for (int k = 0; k < 20; k++) {
double d1 = (double) b + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
double d3 = (double) c + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
double d5 = (double) this.d + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
a.a("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D);
a.a("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D);
} }
entityliving.R(); if (this.e == -1) {
b(); this.b();
} }
super.f(); if (this.e > 0) {
--this.e;
} else {
byte b0 = 4;
for (int i = 0; i < b0; ++i) {
EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.h, this.a));
if (entityliving == null) {
return;
}
int j = this.a.a(entityliving.getClass(), AxisAlignedBB.b((double) this.b, (double) this.c, (double) this.d, (double) (this.b + 1), (double) (this.c + 1), (double) (this.d + 1)).b(8.0D, 4.0D, 8.0D)).size();
if (j >= 6) {
this.b();
return;
}
if (entityliving != null) {
double d3 = (double) this.b + (this.a.l.nextDouble() - this.a.l.nextDouble()) * 4.0D;
double d4 = (double) (this.c + this.a.l.nextInt(3) - 1);
double d5 = (double) this.d + (this.a.l.nextDouble() - this.a.l.nextDouble()) * 4.0D;
entityliving.c(d3, d4, d5, this.a.l.nextFloat() * 360.0F, 0.0F);
if (entityliving.b()) {
this.a.a((Entity) entityliving);
for (int k = 0; k < 20; ++k) {
d0 = (double) this.b + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
d1 = (double) this.c + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
d2 = (double) this.d + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
entityliving.R();
this.b();
}
}
}
super.f();
}
}
} }
private void b() { private void b() {
e = 200 + a.l.nextInt(600); this.e = 200 + this.a.l.nextInt(600);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
h = nbttagcompound.h("EntityId"); this.h = nbttagcompound.h("EntityId");
e = ((short) (nbttagcompound.c("Delay"))); this.e = nbttagcompound.c("Delay");
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.a("EntityId", h); nbttagcompound.a("EntityId", this.h);
nbttagcompound.a("Delay", (short) e); nbttagcompound.a("Delay", (short) this.e);
} }
} }

View File

@ -1,7 +1,9 @@
package net.minecraft.server; package net.minecraft.server;
import java.io.File; import java.io.File;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -15,99 +17,20 @@ import org.bukkit.event.block.BlockPhysicsEvent;
public class WorldServer extends World { public class WorldServer extends World {
public ChunkProviderServer A; public ChunkProviderServer A;
public boolean B; public boolean B = false;
public boolean C; public boolean C;
private MinecraftServer D; private MinecraftServer D;
private MCHashTable E; private EntityList E = new EntityList();
public WorldServer(MinecraftServer minecraftserver, File file, String s, int i) { public WorldServer(MinecraftServer minecraftserver, File file1, String s, int i) {
super(file, s, (new Random()).nextLong(), WorldProvider.a(i)); super(file1, s, (new Random()).nextLong(), WorldProvider.a(i));
B = false; this.D = minecraftserver;
E = new MCHashTable();
D = minecraftserver; // CraftBukkit start
world = new CraftWorld(this); // CraftBukkit world = new CraftWorld(this);
server = minecraftserver.server; // CraftBukkit server = minecraftserver.server;
} }
public void f() {
super.f();
}
public void a(Entity entity, boolean flag) {
if (!D.m && ((entity instanceof EntityAnimals) || (entity instanceof EntityWaterMob))) {
entity.q();
}
if (entity.j == null || !(entity.j instanceof EntityPlayer)) {
super.a(entity, flag);
}
}
public void b(Entity entity, boolean flag) {
super.a(entity, flag);
}
protected IChunkProvider a(File file) {
A = new ChunkProviderServer(this, q.a(file), q.c());
return ((IChunkProvider) (A));
}
public List d(int i, int j, int k, int l, int i1, int j1) {
ArrayList arraylist = new ArrayList();
for (int k1 = 0; k1 < c.size(); k1++) {
TileEntity tileentity = (TileEntity) c.get(k1);
if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) {
((List) (arraylist)).add(((tileentity)));
}
}
return ((List) (arraylist));
}
public boolean a(EntityPlayer entityplayer, int i, int j, int k) {
int l = (int) MathHelper.e(i - m);
int i1 = (int) MathHelper.e(k - o);
if (l > i1) {
i1 = l;
}
return i1 > 16 || D.f.g(entityplayer.aw);
}
protected void b(Entity entity) {
super.b(entity);
E.a(entity.g, ((entity)));
}
protected void c(Entity entity) {
super.c(entity);
E.d(entity.g);
}
public Entity a(int i) {
return (Entity) E.a(i);
}
public void a(Entity entity, byte byte0) {
Packet38 packet38 = new Packet38(entity.g, byte0);
D.k.b(entity, ((Packet) (packet38)));
}
public Explosion a(Entity entity, double d1, double d2, double d3, float f1, boolean flag) {
Explosion explosion = super.a(entity, d1, d2, d3, f1, flag);
D.f.a(d1, d2, d3, 64D, ((Packet) (new Packet60(d1, d2, d3, f1, explosion.g))));
return explosion;
}
public void c(int i, int j, int k, int l, int i1) {
super.c(i, j, k, l, i1);
D.f.a(i, j, k, 64D, ((Packet) (new Packet54(i, j, k, l, i1))));
}
// CraftBukkit start
private final CraftWorld world; private final CraftWorld world;
private final CraftServer server; private final CraftServer server;
@ -119,23 +42,23 @@ public class WorldServer extends World {
} }
@Override @Override
public boolean b(int i1, int j1, int k1, int l1) { public boolean setTypeId(int i, int j, int k, int l) {
boolean result = super.b(i1, j1, k1, l1); boolean result = super.setTypeId(i, j, k, l);
if ((result) && (world != null)) world.updateBlock(i1, j1, k1); if ((result) && (world != null)) world.updateBlock(i, j, k);
return result; return result;
} }
@Override @Override
public boolean a(int i1, int j1, int k1, int l1, int i2) { public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) {
boolean result = super.a(i1, j1, k1, l1, i2); boolean result = super.setTypeIdAndData(i, j, k, l, i1);
if ((result) && (world != null)) world.updateBlock(i1, j1, k1); if ((result) && (world != null)) world.updateBlock(i, j, k);
return result; return result;
} }
@Override @Override
public void a(int i1, int j1, int k1, TileEntity tileentity) { public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
super.a(i1, j1, k1, tileentity); super.setTileEntity(i, j, k, tileentity);
if (world != null) world.updateBlock(i1, j1, k1); if (world != null) world.updateBlock(i, j, k);
} }
public CraftWorld getWorld() { public CraftWorld getWorld() {
@ -147,72 +70,142 @@ public class WorldServer extends World {
} }
// CraftBukkit end // CraftBukkit end
public void f() {
super.f();
}
public void a(Entity entity, boolean flag) {
if (!this.D.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
entity.q();
}
if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) {
super.a(entity, flag);
}
}
public void b(Entity entity, boolean flag) {
super.a(entity, flag);
}
protected IChunkProvider a(File file1) {
this.A = new ChunkProviderServer(this, this.q.a(file1), this.q.c());
return this.A;
}
public List d(int i, int j, int k, int l, int i1, int j1) {
ArrayList arraylist = new ArrayList();
for (int k1 = 0; k1 < this.c.size(); ++k1) {
TileEntity tileentity = (TileEntity) this.c.get(k1);
if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) {
arraylist.add(tileentity);
}
}
return arraylist;
}
public boolean a(EntityHuman entityhuman, int i, int j, int k) {
int l = (int) MathHelper.e((float) (i - this.spawnX));
int i1 = (int) MathHelper.e((float) (k - this.spawnZ));
if (l > i1) {
i1 = l;
}
return i1 > 16 || this.D.f.g(entityhuman.name);
}
protected void b(Entity entity) {
super.b(entity);
this.E.a(entity.id, entity);
}
protected void c(Entity entity) {
super.c(entity);
this.E.d(entity.id);
}
public Entity a(int i) {
return (Entity) this.E.a(i);
}
public void a(Entity entity, byte b0) {
Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0);
this.D.k.b(entity, packet38entitystatus);
}
public Explosion a(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
Explosion explosion = super.a(entity, d0, d1, d2, f, flag);
this.D.f.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g));
return explosion;
}
public void c(int i, int j, int k, int l, int i1) {
super.c(i, j, k, l, i1);
this.D.f.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1));
}
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
// XXX: done because it calls private k() // XXX: done because it calls private k()
@Override @Override
public void h(int i1, int j1, int k1, int l1) { public void h(int i, int j, int k, int l) {
l(i1 - 1, j1, k1, l1); this.l(i - 1, j, k, l);
l(i1 + 1, j1, k1, l1); this.l(i + 1, j, k, l);
l(i1, j1 - 1, k1, l1); this.l(i, j - 1, k, l);
l(i1, j1 + 1, k1, l1); this.l(i, j + 1, k, l);
l(i1, j1, k1 - 1, l1); this.l(i, j, k - 1, l);
l(i1, j1, k1 + 1, l1); this.l(i, j, k + 1, l);
} }
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
private void l(int i1, int j1, int k1, int l1) { private void l(int i, int j, int k, int l) {
if (i || z) { if (!this.i && !this.isStatic) {
return; Block block = Block.byId[this.getTypeId(i, j, k)];
}
Block block = Block.m[a(i1, j1, k1)];
if (block != null) { if (block != null) {
// CraftBukkit start // CraftBukkit start
if (world != null) { if (world != null) {
BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i1, j1, k1), l1); BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i, j, k), l);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
}
} }
} // CraftBukkit stop
// CraftBukkit stop
block.b(this, i1, j1, k1, l1); block.b(this, i, j, k, l);
}
} }
} }
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
@Override @Override
public boolean a(int i1, int j1, int k1, int l1, boolean flag) { public boolean a(int i, int j, int k, int l, boolean flag) {
int i2 = a(j1, k1, l1); int i1 = this.getTypeId(j, k, l);
Block block = Block.m[i2]; Block block = Block.byId[i1];
Block block1 = Block.m[i1]; Block block1 = Block.byId[i];
AxisAlignedBB axisalignedbb = block1.d(this, j1, k1, l1); AxisAlignedBB axisalignedbb = block1.d(this, j, k, l);
if (flag) { if (flag) {
axisalignedbb = null; axisalignedbb = null;
} }
if (axisalignedbb != null && !a(axisalignedbb)) {
// Craftbukkit start - We dont want to allow the user to override the bounding box check
boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb) ? false : (block != Block.WATER && block != Block.STATIONARY_WATER && block != Block.LAVA && block != Block.STATIONARY_LAVA && block != Block.FIRE && block != Block.SNOW ? i > 0 && block == null && block1.a(this, j, k, l) : true);
if (!defaultReturn) {
return false; return false;
} }
// Craftbukkit start - We dont want to allow the user to override the bounding box check
boolean defaultReturn;
if (block == Block.A || block == Block.B || block == Block.C || block == Block.D || block == Block.ar || block == Block.aS) { BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j, k, l), i1, defaultReturn);
defaultReturn = true; server.getPluginManager().callEvent(event);
} else {
defaultReturn = (i1 > 0) && (block == null) && (block1.a(this, j1, k1, l1));
}
// Craftbukkit - If flag is true, it's natural, not user placement. Don't hook. return event.isBuildable();
if (!flag) {
BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j1, k1, l1), i1, defaultReturn);
server.getPluginManager().callEvent(event);
return event.isBuildable();
} else {
return defaultReturn;
}
// CraftBukkit end // CraftBukkit end
} }
} }

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.server.EntityPlayerMP; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PropertyManager; import net.minecraft.server.PropertyManager;
import net.minecraft.server.ServerConfigurationManager; import net.minecraft.server.ServerConfigurationManager;
@ -70,7 +70,7 @@ public final class CraftServer implements Server {
} }
public Player[] getOnlinePlayers() { public Player[] getOnlinePlayers() {
List<EntityPlayerMP> online = server.b; List<EntityPlayer> online = server.b;
Player[] players = new Player[online.size()]; Player[] players = new Player[online.size()];
for (int i = 0; i < players.length; i++) { for (int i = 0; i < players.length; i++) {
@ -109,7 +109,7 @@ public final class CraftServer implements Server {
return players.length; return players.length;
} }
public Player getPlayer(final EntityPlayerMP entity) { public Player getPlayer(final EntityPlayer entity) {
return entity.a.getPlayer(); return entity.a.getPlayer();
} }

View File

@ -37,7 +37,7 @@ public class CraftWorld implements World {
CraftBlock block = blockCache.get(loc); CraftBlock block = blockCache.get(loc);
if (block == null) { if (block == null) {
block = new CraftBlock(this, x, y, z, world.a(x, y, z), (byte)world.b(x, y, z)); block = new CraftBlock(this, x, y, z, world.getTypeId(x, y, z), (byte)world.getData(x, y, z));
blockCache.put(loc, block); blockCache.put(loc, block);
} else { } else {
block.update(); block.update();
@ -47,7 +47,7 @@ public class CraftWorld implements World {
} }
public int getBlockTypeIdAt(int x, int y, int z) { public int getBlockTypeIdAt(int x, int y, int z) {
return world.a(x, y, z); return world.getTypeId(x, y, z);
} }
public int getHighestBlockYAt(int x, int z) { public int getHighestBlockYAt(int x, int z) {
@ -55,7 +55,7 @@ public class CraftWorld implements World {
} }
public Location getSpawnLocation() { public Location getSpawnLocation() {
return new Location(this, world.m, world.e(world.m, world.o), world.o); return new Location(this, world.spawnX, world.e(world.spawnX, world.spawnZ), world.spawnZ);
} }
public Chunk getChunkAt(int x, int z) { public Chunk getChunkAt(int x, int z) {
@ -86,8 +86,8 @@ public class CraftWorld implements World {
public Block updateBlock(int x, int y, int z) { public Block updateBlock(int x, int y, int z) {
BlockCoordinate loc = new BlockCoordinate(x, y, z); BlockCoordinate loc = new BlockCoordinate(x, y, z);
CraftBlock block = (CraftBlock)blockCache.get(loc); CraftBlock block = (CraftBlock)blockCache.get(loc);
final int type = world.a(x, y, z); final int type = world.getTypeId(x, y, z);
final byte data = (byte)world.b(x, y, z); final byte data = (byte)world.getData(x, y, z);
if (block == null) { if (block == null) {
block = new CraftBlock(this, x, y, z, type, data); block = new CraftBlock(this, x, y, z, type, data);
@ -202,31 +202,8 @@ public class CraftWorld implements World {
return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); return treeGen.a(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
} }
/**@deprecated*/
public CraftEntity toCraftEntity(net.minecraft.server.Entity entity) {
if (entity instanceof CraftMappable) {
return ((CraftMappable)entity).getCraftEntity();
} else if (entity instanceof EntityItem) {
return new CraftItemDrop(world.getServer(), (EntityItem)entity);
} else if (entity instanceof EntityArrow) {
return new CraftArrow(world.getServer(), (EntityArrow)entity);
} else if (entity instanceof EntityEgg) {
return new CraftEgg(world.getServer(), (EntityEgg)entity);
} else if (entity instanceof EntityPlayerMP) {
return new CraftPlayer(world.getServer(), (EntityPlayerMP)entity);
} else if (entity instanceof EntitySnowball) {
return new CraftSnowball(world.getServer(), (EntitySnowball)entity);
} else if (entity instanceof EntityPlayer) {
return new CraftHumanEntity(world.getServer(), (EntityPlayer)entity);
} else if (entity instanceof EntityLiving) {
return new CraftLivingEntity(world.getServer(), (EntityLiving)entity);
} else {
return null;
}
}
public TileEntity getTileEntityAt(final int x, final int y, final int z) { public TileEntity getTileEntityAt(final int x, final int y, final int z) {
return world.m(x, y, z); return world.getTileEntity(x, y, z);
} }
public String getName() { public String getName() {

View File

@ -5,7 +5,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.Location; import org.bukkit.Location;
import net.minecraft.server.MobSpawnerBase;
import net.minecraft.server.BiomeBase;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
@ -306,31 +307,31 @@ public class CraftBlock implements Block {
public Biome getBiome() { public Biome getBiome() {
// TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk // TODO: This may not be 100% accurate; investigate into getting per-block instead of per-chunk
MobSpawnerBase base = world.getHandle().a().a(chunk.getX(), chunk.getZ()); BiomeBase base = world.getHandle().a().a(chunk.getX(), chunk.getZ());
if (base == MobSpawnerBase.a) { if (base == BiomeBase.RAINFOREST) {
return Biome.RAINFOREST; return Biome.RAINFOREST;
} else if (base == MobSpawnerBase.b) { } else if (base == BiomeBase.SWAMPLAND) {
return Biome.SWAMPLAND; return Biome.SWAMPLAND;
} else if (base == MobSpawnerBase.c) { } else if (base == BiomeBase.SEASONAL_FOREST) {
return Biome.SEASONAL_FOREST; return Biome.SEASONAL_FOREST;
} else if (base == MobSpawnerBase.d) { } else if (base == BiomeBase.FOREST) {
return Biome.FOREST; return Biome.FOREST;
} else if (base == MobSpawnerBase.e) { } else if (base == BiomeBase.SAVANNA) {
return Biome.SAVANNA; return Biome.SAVANNA;
} else if (base == MobSpawnerBase.f) { } else if (base == BiomeBase.SHRUBLAND) {
return Biome.SHRUBLAND; return Biome.SHRUBLAND;
} else if (base == MobSpawnerBase.g) { } else if (base == BiomeBase.TAIGA) {
return Biome.TAIGA; return Biome.TAIGA;
} else if (base == MobSpawnerBase.h) { } else if (base == BiomeBase.DESERT) {
return Biome.DESERT; return Biome.DESERT;
} else if (base == MobSpawnerBase.i) { } else if (base == BiomeBase.PLAINS) {
return Biome.PLAINS; return Biome.PLAINS;
} else if (base == MobSpawnerBase.j) { } else if (base == BiomeBase.ICE_DESERT) {
return Biome.ICE_DESERT; return Biome.ICE_DESERT;
} else if (base == MobSpawnerBase.k) { } else if (base == BiomeBase.TUNDRA) {
return Biome.TUNDRA; return Biome.TUNDRA;
} else if (base == MobSpawnerBase.l) { } else if (base == BiomeBase.HELL) {
return Biome.HELL; return Biome.HELL;
} }
@ -346,8 +347,8 @@ public class CraftBlock implements Block {
} }
public void update() { public void update() {
type = world.getHandle().a(x, y, z); type = world.getHandle().getTypeId(x, y, z);
data = (byte)world.getHandle().b(x, y, z); data = (byte)world.getHandle().getData(x, y, z);
light = (byte)world.getHandle().j(x, y, z); light = (byte)world.getHandle().j(x, y, z);
} }
} }

View File

@ -1,12 +1,12 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityAnimals; import net.minecraft.server.EntityAnimal;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
public class CraftAnimals extends CraftCreature implements Animals{ public class CraftAnimals extends CraftCreature implements Animals{
public CraftAnimals(CraftServer server, EntityAnimals entity) { public CraftAnimals(CraftServer server, EntityAnimal entity) {
super(server, entity); super(server, entity);
} }

View File

@ -17,21 +17,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public Location getLocation() { public Location getLocation() {
return new Location(getWorld(), entity.p, entity.q, entity.r, entity.v, entity.w); return new Location(getWorld(), entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
} }
public Vector getVelocity() { public Vector getVelocity() {
return new Vector(entity.s, entity.t, entity.u); return new Vector(entity.motX, entity.motY, entity.motZ);
} }
public void setVelocity(Vector vel) { public void setVelocity(Vector vel) {
entity.s = vel.getX(); entity.motX = vel.getX();
entity.t = vel.getY(); entity.motY = vel.getY();
entity.u = vel.getZ(); entity.motZ = vel.getZ();
} }
public World getWorld() { public World getWorld() {
return ((WorldServer)entity.l).getWorld(); return ((WorldServer)entity.world).getWorld();
} }
public void teleportTo(Location location) { public void teleportTo(Location location) {
@ -43,7 +43,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
} }
public int getEntityId() { public int getEntityId() {
return entity.g; return entity.id;
} }
public Entity getHandle() { public Entity getHandle() {

View File

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityZombieSimple; import net.minecraft.server.EntityGiantZombie;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Giant; import org.bukkit.entity.Giant;
public class CraftGiant extends CraftMonster implements Giant { public class CraftGiant extends CraftMonster implements Giant {
public CraftGiant(CraftServer server, EntityZombieSimple entity) { public CraftGiant(CraftServer server, EntityGiantZombie entity) {
super(server, entity); super(server, entity);
} }

View File

@ -1,7 +1,7 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityHuman;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
@ -10,28 +10,28 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private EntityPlayer entity; private EntityHuman entity;
private CraftInventoryPlayer inventory; private CraftInventoryPlayer inventory;
public CraftHumanEntity(final CraftServer server, final EntityPlayer entity) { public CraftHumanEntity(final CraftServer server, final EntityHuman entity) {
super(server, entity); super(server, entity);
this.entity = entity; this.entity = entity;
this.inventory = new CraftInventoryPlayer( entity.an ); this.inventory = new CraftInventoryPlayer( entity.inventory );
} }
public String getName() { public String getName() {
return entity.aw; return entity.name;
} }
@Override @Override
public EntityPlayer getHandle() { public EntityHuman getHandle() {
return entity; return entity;
} }
public void setHandle(final EntityPlayer entity) { public void setHandle(final EntityHuman entity) {
super.setHandle((EntityPlayer)entity); super.setHandle((EntityHuman)entity);
this.entity = entity; this.entity = entity;
this.inventory = new CraftInventoryPlayer( entity.an ); this.inventory = new CraftInventoryPlayer( entity.inventory );
} }
public CraftInventoryPlayer getInventory() { public CraftInventoryPlayer getInventory() {

View File

@ -24,7 +24,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public int getHealth() { public int getHealth() {
return entity.aZ; return entity.health;
} }
public void setHealth(int health) { public void setHealth(int health) {
@ -32,7 +32,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
throw new IllegalArgumentException("Health must be between 0 and 200"); throw new IllegalArgumentException("Health must be between 0 and 200");
} }
entity.aZ = health; entity.health = health;
} }
@Override @Override
@ -72,11 +72,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public boolean isInsideVehicle() { public boolean isInsideVehicle() {
return entity.k != null; return entity.vehicle != null;
} }
public boolean leaveVehicle() { public boolean leaveVehicle() {
if (entity.k == null) { if (entity.vehicle == null) {
return false; return false;
} }
@ -85,13 +85,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public Vehicle getVehicle() { public Vehicle getVehicle() {
if (entity.k == null) { if (entity.vehicle == null) {
return null; return null;
} }
org.bukkit.entity.Entity vehicle = (entity.k.getBukkitEntity()); org.bukkit.entity.Entity vehicle = (entity.vehicle.getBukkitEntity());
if (vehicle instanceof Vehicle) { if (vehicle instanceof Vehicle) {
return (Vehicle)vehicle; return (Vehicle) vehicle;
} }
return null; return null;

View File

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityMobs; import net.minecraft.server.EntityMonster;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
public class CraftMonster extends CraftCreature implements Monster { public class CraftMonster extends CraftCreature implements Monster {
public CraftMonster(CraftServer server, EntityMobs entity) { public CraftMonster(CraftServer server, EntityMonster entity) {
super(server, entity); super(server, entity);
} }

View File

@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.entity;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityPlayerMP;
import net.minecraft.server.Packet; import net.minecraft.server.Packet;
import net.minecraft.server.Packet3Chat; import net.minecraft.server.Packet3Chat;
import net.minecraft.server.Packet6SpawnPosition; import net.minecraft.server.Packet6SpawnPosition;
@ -12,10 +12,10 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class CraftPlayer extends CraftHumanEntity implements Player { public class CraftPlayer extends CraftHumanEntity implements Player {
private EntityPlayerMP entity; private EntityPlayer entity;
private String name; private String name;
public CraftPlayer(CraftServer server, EntityPlayerMP entity) { public CraftPlayer(CraftServer server, EntityPlayer entity) {
super(server, entity); super(server, entity);
this.name = getName(); this.name = getName();
this.entity = entity; this.entity = entity;
@ -31,8 +31,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public boolean isOnline() { public boolean isOnline() {
for (Object obj: server.getHandle().b) { for (Object obj: server.getHandle().b) {
EntityPlayerMP player = (EntityPlayerMP) obj; EntityPlayer player = (EntityPlayer) obj;
if (player.aw.equalsIgnoreCase(getName())) { if (player.name.equalsIgnoreCase(getName())) {
return true; return true;
} }
} }
@ -49,12 +49,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public EntityPlayerMP getHandle() { public EntityPlayer getHandle() {
return entity; return entity;
} }
public void setHandle(final EntityPlayerMP entity) { public void setHandle(final EntityPlayer entity) {
super.setHandle((EntityPlayer) entity); super.setHandle((EntityHuman) entity);
this.entity = entity; this.entity = entity;
} }

View File

@ -15,7 +15,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public Entity getPassenger() { public Entity getPassenger() {
return isEmpty()?null:(getHandle().j.getBukkitEntity()); return isEmpty() ? null : (getHandle().passenger.getBukkitEntity());
} }
public boolean setPassenger(Entity passenger) { public boolean setPassenger(Entity passenger) {
@ -28,15 +28,15 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public boolean isEmpty() { public boolean isEmpty() {
return getHandle().j == null; return getHandle().passenger == null;
} }
public boolean eject() { public boolean eject() {
if (getHandle().j == null) { if (getHandle().passenger == null) {
return false; return false;
} }
getHandle().j.setPassengerOf(null); getHandle().passenger.setPassengerOf(null);
return true; return true;
} }
} }

View File

@ -1,13 +1,13 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityWaterMob; import net.minecraft.server.EntityWaterAnimal;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.WaterMob; import org.bukkit.entity.WaterMob;
public class CraftWaterMob extends CraftCreature implements WaterMob { public class CraftWaterMob extends CraftCreature implements WaterMob {
public CraftWaterMob(CraftServer server, EntityWaterMob entity) { public CraftWaterMob(CraftServer server, EntityWaterAnimal entity) {
super(server, entity); super(server, entity);
} }

View File

@ -8,9 +8,9 @@ public class CraftItemStack extends ItemStack {
public CraftItemStack(net.minecraft.server.ItemStack item) { public CraftItemStack(net.minecraft.server.ItemStack item) {
super( super(
item != null ? item.c : 0, item != null ? item.id: 0,
item != null ? item.a : 0, item != null ? item.count : 0,
(byte)(item != null ? item.d : 0) (byte)(item != null ? item.damage : 0)
); );
this.item = item; this.item = item;
} }
@ -55,14 +55,14 @@ public class CraftItemStack extends ItemStack {
@Override @Override
public Material getType() { public Material getType() {
super.setTypeId(item != null ? item.c : 0); // sync, needed? super.setTypeId(item != null ? item.id : 0); // sync, needed?
return super.getType(); return super.getType();
} }
@Override @Override
public int getTypeId() { public int getTypeId() {
super.setTypeId(item != null ? item.c : 0); // sync, needed? super.setTypeId(item != null ? item.id : 0); // sync, needed?
return item != null ? item.c : 0; return item != null ? item.id : 0;
} }
@Override @Override
@ -76,16 +76,16 @@ public class CraftItemStack extends ItemStack {
item = new net.minecraft.server.ItemStack(type, 1, 0); item = new net.minecraft.server.ItemStack(type, 1, 0);
super.setAmount(1); super.setAmount(1);
} else { } else {
item.c = type; item.id = type;
super.setTypeId(item.c); super.setTypeId(item.id);
} }
} }
} }
@Override @Override
public int getAmount() { public int getAmount() {
super.setAmount(item != null ? item.a : 0); // sync, needed? super.setAmount(item != null ? item.count : 0); // sync, needed?
return (item != null ? item.a : 0); return (item != null ? item.count : 0);
} }
@Override @Override
@ -96,7 +96,7 @@ public class CraftItemStack extends ItemStack {
item = null; item = null;
} else { } else {
super.setAmount(amount); super.setAmount(amount);
item.a = amount; item.count = amount;
} }
} }
@ -105,15 +105,15 @@ public class CraftItemStack extends ItemStack {
// Ignore damage if item is null // Ignore damage if item is null
if (item != null) { if (item != null) {
super.setDamage(damage); super.setDamage(damage);
item.d = damage; item.damage = damage;
} }
} }
@Override @Override
public byte getDamage() { public byte getDamage() {
if (item != null) { if (item != null) {
super.setDamage((byte) item.d); // sync, needed? super.setDamage((byte) item.damage); // sync, needed?
return (byte) item.d; return (byte) item.damage;
} else { } else {
return 0; return 0;
} }