Update for 1.4_00_01 -- if you bypassed Bukkit, you will most likely break.

This commit is contained in:
Erik Broes 2011-04-20 19:05:14 +02:00
parent ac9f297445
commit 483a878b8b
116 changed files with 3155 additions and 3207 deletions

34
pom.xml
View file

@ -39,7 +39,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId> <artifactId>minecraft-server</artifactId>
<version>1.4</version> <version>1.4_00_01</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
@ -47,36 +47,11 @@
<groupId>net.sf.jopt-simple</groupId> <groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId> <artifactId>jopt-simple</artifactId>
<version>3.2</version> <version>3.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jline</groupId> <groupId>jline</groupId>
<artifactId>jline</artifactId> <artifactId>jline</artifactId>
<version>0.9.94</version> <version>0.9.94</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.avaje</groupId>
<artifactId>ebean</artifactId>
<version>2.7.3</version>
<type>jar</type>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<!-- This builds a completely 'ready to start' jar with all dependencies inside --> <!-- This builds a completely 'ready to start' jar with all dependencies inside -->
@ -149,13 +124,6 @@
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration>
<artifactSet>
<excludes>
<exclude>junit:junit</exclude>
</excludes>
</artifactSet>
</configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>

View file

@ -13,8 +13,8 @@ public class BlockBloodStone extends Block {
} }
// Craftbukkit start // Craftbukkit start
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].c()) { if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k); org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);

View file

@ -28,11 +28,11 @@ public class BlockButton extends Block {
return false; return false;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int 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 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)));
} }
public void d(World world, int i, int j, int k, int l) { public void postPlace(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k); int i1 = world.getData(i, j, k);
int j1 = i1 & 8; int j1 = i1 & 8;
@ -49,14 +49,14 @@ public class BlockButton extends Block {
i1 = this.g(world, i, j, k); i1 = this.g(world, i, j, k);
} }
world.c(i, j, k, i1 + j1); world.setData(i, j, k, i1 + j1);
} }
private int g(World world, int i, int j, int k) { private int g(World world, int i, int j, int k) {
return world.d(i - 1, j, k) ? 1 : (world.d(i + 1, j, k) ? 2 : (world.d(i, j, k - 1) ? 3 : (world.d(i, j, k + 1) ? 4 : 1))); return world.d(i - 1, j, k) ? 1 : (world.d(i + 1, j, k) ? 2 : (world.d(i, j, k - 1) ? 3 : (world.d(i, j, k + 1) ? 4 : 1)));
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (this.h(world, i, j, k)) { if (this.h(world, i, j, k)) {
int i1 = world.getData(i, j, k) & 7; int i1 = world.getData(i, j, k) & 7;
boolean flag = false; boolean flag = false;
@ -79,15 +79,15 @@ public class BlockButton extends Block {
if (flag) { if (flag) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
} }
} }
private boolean h(World world, int i, int j, int k) { private boolean h(World world, int i, int j, int k) {
if (!this.a(world, i, j, k)) { if (!this.canPlace(world, i, j, k)) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
return false; return false;
} else { } else {
return true; return true;
@ -119,10 +119,10 @@ public class BlockButton extends Block {
} }
public void b(World world, int i, int j, int k, EntityHuman entityhuman) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
this.a(world, i, j, k, entityhuman); this.interact(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
int i1 = l & 7; int i1 = l & 7;
int j1 = 8 - (l & 8); int j1 = 8 - (l & 8);
@ -144,20 +144,20 @@ public class BlockButton extends Block {
} }
// CraftBukkit end // CraftBukkit end
world.c(i, j, k, i1 + j1); world.setData(i, j, k, i1 + j1);
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.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
if (i1 == 1) { if (i1 == 1) {
world.h(i - 1, j, k, this.id); world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
} }
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
@ -165,27 +165,27 @@ public class BlockButton extends Block {
} }
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) > 0) { if ((l & 8) > 0) {
world.h(i, j, k, this.id); world.applyPhysics(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, this.id); world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
} }
} }
super.b(world, i, j, k); super.remove(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) {
@ -204,7 +204,7 @@ public class BlockButton extends Block {
} }
} }
public boolean c() { public boolean isPowerSource() {
return true; return true;
} }
@ -217,28 +217,30 @@ public class BlockButton extends Block {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k); CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0);
server.getPluginManager().callEvent(eventRedstone); server.getPluginManager().callEvent(eventRedstone);
if (eventRedstone.getNewCurrent() > 0) return; if (eventRedstone.getNewCurrent() > 0) return;
// CraftBukkit end // CraftBukkit end
world.c(i, j, k, l & 7); world.setData(i, j, k, l & 7);
world.h(i, j, k, this.id); world.applyPhysics(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, this.id); world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, this.id); world.applyPhysics(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.makeSound((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.b(i, j, k, i, j, k);
} }
} }

View file

@ -28,10 +28,10 @@ public class BlockCactus extends Block {
int i1 = world.getData(i, j, k); int i1 = world.getData(i, j, k);
if (i1 == 15) { if (i1 == 15) {
world.e(i, j + 1, k, this.id); world.setTypeId(i, j + 1, k, this.id);
world.c(i, j, k, 0); world.setData(i, j, k, 0);
} else { } else {
world.c(i, j, k, i1 + 1); world.setData(i, j, k, i1 + 1);
} }
} }
} }
@ -51,14 +51,14 @@ public class BlockCactus extends Block {
return false; return false;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
return !super.a(world, i, j, k) ? false : this.f(world, i, j, k); return !super.canPlace(world, i, j, k) ? false : this.f(world, i, j, k);
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (!this.f(world, i, j, k)) { if (!this.f(world, i, j, k)) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
} }
@ -91,11 +91,11 @@ public class BlockCactus extends Block {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entity.a((Entity) null, event.getDamage()); entity.damageEntity((Entity) null, event.getDamage());
} }
return; return;
} }
// CraftBukkit end // CraftBukkit end
entity.a((Entity) null, 1); entity.damageEntity((Entity) null, 1);
} }
} }

View file

@ -45,14 +45,14 @@ public class BlockDispenser extends BlockContainer {
b0 = 4; b0 = 4;
} }
world.c(i, j, k, b0); world.setData(i, j, k, b0);
} }
public int a(int i) { public int a(int i) {
return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId + 1 : this.textureId)); return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId + 1 : this.textureId));
} }
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) { if (world.isStatic) {
return true; return true;
} else { } else {
@ -64,7 +64,7 @@ public class BlockDispenser extends BlockContainer {
} }
// CraftBukkit - private->public // CraftBukkit - private->public
public void b(World world, int i, int j, int k, Random random) { public void dispense(World world, int i, int j, int k, Random random) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
float f = 0.0F; float f = 0.0F;
float f1 = 0.0F; float f1 = 0.0F;
@ -86,7 +86,7 @@ public class BlockDispenser extends BlockContainer {
double d2 = (double) k + (double) f1 * 0.5D + 0.5D; double d2 = (double) k + (double) f1 * 0.5D + 0.5D;
if (itemstack == null) { if (itemstack == null) {
world.a((double) i, (double) j, (double) k, "random.click", 1.0F, 1.2F); world.makeSound((double) i, (double) j, (double) k, "random.click", 1.0F, 1.2F);
} else { } else {
double d3; double d3;
@ -94,20 +94,20 @@ public class BlockDispenser extends BlockContainer {
EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2);
entityarrow.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); entityarrow.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F);
world.a((Entity) entityarrow); world.addEntity(entityarrow);
world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); world.makeSound((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F);
} else if (itemstack.id == Item.EGG.id) { } else if (itemstack.id == Item.EGG.id) {
EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); EntityEgg entityegg = new EntityEgg(world, d0, d1, d2);
entityegg.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); entityegg.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F);
world.a((Entity) entityegg); world.addEntity(entityegg);
world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); world.makeSound((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F);
} else if (itemstack.id == Item.SNOW_BALL.id) { } else if (itemstack.id == Item.SNOW_BALL.id) {
EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2);
entitysnowball.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F); entitysnowball.a((double) f, 0.10000000149011612D, (double) f1, 1.1F, 6.0F);
world.a((Entity) entitysnowball); world.addEntity(entitysnowball);
world.a((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F); world.makeSound((double) i, (double) j, (double) k, "random.bow", 1.0F, 1.2F);
} else { } else {
EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
@ -118,8 +118,8 @@ public class BlockDispenser extends BlockContainer {
entityitem.motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; entityitem.motX += random.nextGaussian() * 0.007499999832361937D * 6.0D;
entityitem.motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; entityitem.motY += random.nextGaussian() * 0.007499999832361937D * 6.0D;
entityitem.motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; entityitem.motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D;
world.a((Entity) entityitem); world.addEntity(entityitem);
world.a((double) i, (double) j, (double) k, "random.click", 1.0F, 1.0F); world.makeSound((double) i, (double) j, (double) k, "random.click", 1.0F, 1.0F);
} }
for (int i1 = 0; i1 < 10; ++i1) { for (int i1 = 0; i1 < 10; ++i1) {
@ -136,9 +136,9 @@ public class BlockDispenser extends BlockContainer {
} }
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (l > 0 && Block.byId[l].c()) { if (l > 0 && Block.byId[l].isPowerSource()) {
boolean flag = world.p(i, j, k) || world.p(i, j + 1, k); boolean flag = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k);
if (flag) { if (flag) {
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
@ -147,8 +147,8 @@ public class BlockDispenser extends BlockContainer {
} }
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.p(i, j, k) || world.p(i, j + 1, k)) { if (world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k)) {
this.b(world, i, j, k, random); this.dispense(world, i, j, k, random);
} }
} }
@ -156,23 +156,23 @@ public class BlockDispenser extends BlockContainer {
return new TileEntityDispenser(); return new TileEntityDispenser();
} }
public void a(World world, int i, int j, int k, EntityLiving entityliving) { public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) { if (l == 0) {
world.c(i, j, k, 2); world.setData(i, j, k, 2);
} }
if (l == 1) { if (l == 1) {
world.c(i, j, k, 5); world.setData(i, j, k, 5);
} }
if (l == 2) { if (l == 2) {
world.c(i, j, k, 3); world.setData(i, j, k, 3);
} }
if (l == 3) { if (l == 3) {
world.c(i, j, k, 4); world.setData(i, j, k, 4);
} }
} }
} }

View file

@ -51,7 +51,7 @@ 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) {
this.a((IBlockAccess) world, i, j, k); this.a(world, i, j, k);
return super.d(world, i, j, k); return super.d(world, i, j, k);
} }
@ -81,10 +81,10 @@ public class BlockDoor extends Block {
} }
public void b(World world, int i, int j, int k, EntityHuman entityhuman) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
this.a(world, i, j, k, entityhuman); this.interact(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (this.material == Material.ORE) { if (this.material == Material.ORE) {
return true; return true;
} else { } else {
@ -92,21 +92,21 @@ public class BlockDoor extends Block {
if ((l & 8) != 0) { if ((l & 8) != 0) {
if (world.getTypeId(i, j - 1, k) == this.id) { if (world.getTypeId(i, j - 1, k) == this.id) {
this.a(world, i, j - 1, k, entityhuman); this.interact(world, i, j - 1, k, entityhuman);
} }
return true; return true;
} else { } else {
if (world.getTypeId(i, j + 1, k) == this.id) { if (world.getTypeId(i, j + 1, k) == this.id) {
world.c(i, j + 1, k, (l ^ 4) + 8); world.setData(i, j + 1, k, (l ^ 4) + 8);
} }
world.c(i, j, k, l ^ 4); world.setData(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k); world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) { 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.k.nextFloat() * 0.1F + 0.9F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.random.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.k.nextFloat() * 0.1F + 0.9F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.random.nextFloat() * 0.1F + 0.9F);
} }
return true; return true;
@ -114,56 +114,56 @@ public class BlockDoor extends Block {
} }
} }
public void a(World world, int i, int j, int k, boolean flag) { public void setDoor(World world, int i, int j, int k, boolean flag) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) != 0) { if ((l & 8) != 0) {
if (world.getTypeId(i, j - 1, k) == this.id) { if (world.getTypeId(i, j - 1, k) == this.id) {
this.a(world, i, j - 1, k, flag); this.setDoor(world, i, j - 1, k, flag);
} }
} else { } else {
boolean flag1 = (world.getData(i, j, k) & 4) > 0; boolean flag1 = (world.getData(i, j, k) & 4) > 0;
if (flag1 != flag) { if (flag1 != flag) {
if (world.getTypeId(i, j + 1, k) == this.id) { if (world.getTypeId(i, j + 1, k) == this.id) {
world.c(i, j + 1, k, (l ^ 4) + 8); world.setData(i, j + 1, k, (l ^ 4) + 8);
} }
world.c(i, j, k, l ^ 4); world.setData(i, j, k, l ^ 4);
world.b(i, j - 1, k, i, j, k); world.b(i, j - 1, k, i, j, k);
if (Math.random() < 0.5D) { 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.k.nextFloat() * 0.1F + 0.9F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.random.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.k.nextFloat() * 0.1F + 0.9F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.random.nextFloat() * 0.1F + 0.9F);
} }
} }
} }
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
int i1 = world.getData(i, j, k); int i1 = world.getData(i, j, k);
if ((i1 & 8) != 0) { if ((i1 & 8) != 0) {
if (world.getTypeId(i, j - 1, k) != this.id) { if (world.getTypeId(i, j - 1, k) != this.id) {
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
if (l > 0 && Block.byId[l].c()) { if (l > 0 && Block.byId[l].isPowerSource()) {
this.a(world, i, j - 1, k, l); this.doPhysics(world, i, j - 1, k, l);
} }
} else { } else {
boolean flag = false; boolean flag = false;
if (world.getTypeId(i, j + 1, k) != this.id) { if (world.getTypeId(i, j + 1, k) != this.id) {
world.e(i, j, k, 0); world.setTypeId(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.setTypeId(i, j, k, 0);
flag = true; flag = true;
if (world.getTypeId(i, j + 1, k) == this.id) { if (world.getTypeId(i, j + 1, k) == this.id) {
world.e(i, j + 1, k, 0); world.setTypeId(i, j + 1, k, 0);
} }
} }
@ -171,8 +171,8 @@ public class BlockDoor extends Block {
if (!world.isStatic) { if (!world.isStatic) {
this.a_(world, i, j, k, i1); this.a_(world, i, j, k, i1);
} }
} else if (l > 0 && Block.byId[l].c()) { } else if (l > 0 && Block.byId[l].isPowerSource()) {
boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k); boolean flag1 = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k);
// Craftbukkit start // Craftbukkit start
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
@ -185,8 +185,11 @@ public class BlockDoor extends Block {
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, power); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15: 0, power);
server.getPluginManager().callEvent(eventRedstone); server.getPluginManager().callEvent(eventRedstone);
this.a(world, i, j, k, eventRedstone.getNewCurrent() > 0);
flag1 = eventRedstone.getNewCurrent() > 0;
// Craftbukkit end // Craftbukkit end
this.setDoor(world, i, j, k, flag1);
} }
} }
} }
@ -196,7 +199,7 @@ public class BlockDoor extends Block {
} }
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) {
this.a((IBlockAccess) world, i, j, k); this.a(world, i, j, k);
return super.a(world, i, j, k, vec3d, vec3d1); return super.a(world, i, j, k, vec3d, vec3d1);
} }
@ -204,7 +207,7 @@ public class BlockDoor extends Block {
return (i & 4) == 0 ? i - 1 & 3 : i & 3; return (i & 4) == 0 ? i - 1 & 3 : i & 3;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
return j >= 127 ? false : world.d(i, j - 1, k) && super.a(world, i, j, k) && super.a(world, i, j + 1, k); return j >= 127 ? false : world.d(i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k);
} }
} }

View file

@ -53,17 +53,16 @@ public class BlockFire extends Block {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if (l < 15) { if (l < 15) {
world.c(i, j, k, l + 1); world.setData(i, j, k, l + 1);
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
} }
if (!flag && !this.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.setTypeId(i, j, k, 0);
} }
// CraftBukkit - Cast to IBlockAccess } else if (!flag && !this.b(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
} else if (!flag && !this.b((IBlockAccess) world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { world.setTypeId(i, j, k, 0);
world.e(i, j, k, 0);
} else { } else {
if (l % 2 == 0 && l > 2) { if (l % 2 == 0 && l > 2) {
this.a(world, i + 1, j, k, 300, random); this.a(world, i + 1, j, k, 300, random);
@ -106,7 +105,7 @@ public class BlockFire extends Block {
} }
// CraftBukkit end // CraftBukkit end
world.e(i1, k1, j1, this.id); world.setTypeId(i1, k1, j1, this.id);
} }
} }
} }
@ -142,21 +141,18 @@ public class BlockFire extends Block {
// CraftBukkit end // CraftBukkit end
if (random.nextInt(2) == 0) { if (random.nextInt(2) == 0) {
world.e(i, j, k, this.id); world.setTypeId(i, j, k, this.id);
} else { } else {
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
if (flag) { if (flag) {
Block.TNT.b(world, i, j, k, 0); Block.TNT.postBreak(world, i, j, k, 0);
} }
} }
} }
// CraftBukkit start -- fix cast to IBlockAccess private boolean g(World world, int i, int j, int k) {
private boolean g(World world1, int i, int j, int k) {
IBlockAccess world = (IBlockAccess) world1;
// CraftBukkit end
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 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)))));
} }
@ -191,20 +187,20 @@ public class BlockFire extends Block {
return i1 > l ? i1 : l; return i1 > l ? i1 : l;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
return world.d(i, j - 1, k) || this.g(world, i, j, k); return world.d(i, j - 1, k) || this.g(world, i, j, k);
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.d(i, j - 1, k) && !this.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.setTypeId(i, j, k, 0);
} }
} }
public void e(World world, int i, int j, int k) { public void e(World world, int i, int j, int k) {
if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.a_(world, i, j, k)) { if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.a_(world, i, j, k)) {
if (!world.d(i, j - 1, k) && !this.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.setTypeId(i, j, k, 0);
} else { } else {
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
} }

View file

@ -23,9 +23,9 @@ public class BlockFlowing extends BlockFluids {
private void i(World world, int i, int j, int k) { private void i(World world, int i, int j, int k) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
world.setTypeIdAndData(i, j, k, this.id + 1, l); world.setRawTypeIdAndData(i, j, k, this.id + 1, l);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.g(i, j, k); world.notify(i, j, k);
} }
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) {
@ -38,7 +38,7 @@ public class BlockFlowing extends BlockFluids {
int l = this.g(world, i, j, k); int l = this.g(world, i, j, k);
byte b0 = 1; byte b0 = 1;
if (this.material == Material.LAVA && !world.m.d) { if (this.material == Material.LAVA && !world.worldProvider.d) {
b0 = 2; b0 = 2;
} }
@ -85,11 +85,11 @@ public class BlockFlowing extends BlockFluids {
if (i1 != l) { if (i1 != l) {
l = i1; l = i1;
if (i1 < 0) { if (i1 < 0) {
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} else { } else {
world.c(i, j, k, i1); world.setData(i, j, k, i1);
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
} }
} else if (flag) { } else if (flag) {
this.i(world, i, j, k); this.i(world, i, j, k);
@ -107,9 +107,9 @@ public class BlockFlowing extends BlockFluids {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (l >= 8) { if (l >= 8) {
world.b(i, j - 1, k, this.id, l); world.setTypeIdAndData(i, j - 1, k, this.id, l);
} else { } else {
world.b(i, j - 1, k, this.id, l + 8); world.setTypeIdAndData(i, j - 1, k, this.id, l + 8);
} }
} }
// CraftBukkit end // CraftBukkit end
@ -137,7 +137,7 @@ public class BlockFlowing extends BlockFluids {
} }
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.f(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1); this.flow(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1);
} }
} }
index++; index++;
@ -146,7 +146,7 @@ public class BlockFlowing extends BlockFluids {
} }
} }
private void f(World world, int i, int j, int k, int l) { private void flow(World world, int i, int j, int k, int l) {
if (this.l(world, i, j, k)) { if (this.l(world, i, j, k)) {
int i1 = world.getTypeId(i, j, k); int i1 = world.getTypeId(i, j, k);
@ -158,7 +158,7 @@ public class BlockFlowing extends BlockFluids {
} }
} }
world.b(i, j, k, this.id, l); world.setTypeIdAndData(i, j, k, this.id, l);
} }
} }

View file

@ -19,7 +19,7 @@ public class BlockLeaves extends BlockLeavesBase {
this.a(true); this.a(true);
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
byte b0 = 1; byte b0 = 1;
int l = b0 + 1; int l = b0 + 1;
@ -32,7 +32,7 @@ public class BlockLeaves extends BlockLeavesBase {
if (l1 == Block.LEAVES.id) { if (l1 == Block.LEAVES.id) {
int i2 = world.getData(i + i1, j + j1, k + k1); int i2 = world.getData(i + i1, j + j1, k + k1);
world.d(i + i1, j + j1, k + k1, i2 | 4); world.setRawData(i + i1, j + j1, k + k1, i2 | 4);
} }
} }
} }
@ -114,7 +114,7 @@ public class BlockLeaves extends BlockLeavesBase {
l1 = this.a[k1 * j1 + k1 * b1 + k1]; l1 = this.a[k1 * j1 + k1 * b1 + k1];
if (l1 >= 0) { if (l1 >= 0) {
world.c(i, j, k, l & -5); world.setData(i, j, k, l & -5);
} else { } else {
this.g(world, i, j, k); this.g(world, i, j, k);
} }
@ -133,7 +133,7 @@ public class BlockLeaves extends BlockLeavesBase {
// CraftBukkit end // CraftBukkit end
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
public int a(Random random) { public int a(Random random) {

View file

@ -21,17 +21,17 @@ public class BlockLever extends Block {
return false; return false;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int 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 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))));
} }
public void d(World world, int i, int j, int k, int l) { public void postPlace(World world, int i, int j, int k, int l) {
int i1 = world.getData(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.k.nextInt(2); i1 = 5 + world.random.nextInt(2);
} }
if (l == 2 && world.d(i, j, k + 1)) { if (l == 2 && world.d(i, j, k + 1)) {
@ -50,10 +50,10 @@ public class BlockLever extends Block {
i1 = 1; i1 = 1;
} }
world.c(i, j, k, i1 + j1); world.setData(i, j, k, i1 + j1);
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (this.g(world, i, j, k)) { if (this.g(world, i, j, k)) {
int i1 = world.getData(i, j, k) & 7; int i1 = world.getData(i, j, k) & 7;
boolean flag = false; boolean flag = false;
@ -80,15 +80,15 @@ public class BlockLever extends Block {
if (flag) { if (flag) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(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 (!this.a(world, i, j, k)) { if (!this.canPlace(world, i, j, k)) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
return false; return false;
} else { } else {
return true; return true;
@ -114,10 +114,10 @@ public class BlockLever extends Block {
} }
public void b(World world, int i, int j, int k, EntityHuman entityhuman) { public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
this.a(world, i, j, k, entityhuman); this.interact(world, i, j, k, entityhuman);
} }
public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) { public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
if (world.isStatic) { if (world.isStatic) {
return true; return true;
} else { } else {
@ -140,47 +140,47 @@ public class BlockLever extends Block {
} }
// CraftBukkit end // CraftBukkit end
world.c(i, j, k, i1 + j1); world.setData(i, j, k, i1 + j1);
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.5D, (double) k + 0.5D, "random.click", 0.3F, j1 > 0 ? 0.6F : 0.5F); world.makeSound((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); world.applyPhysics(i, j, k, this.id);
if (i1 == 1) { if (i1 == 1) {
world.h(i - 1, j, k, this.id); world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
} }
return true; return true;
} }
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) > 0) { if ((l & 8) > 0) {
world.h(i, j, k, this.id); world.applyPhysics(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, this.id); world.applyPhysics(i - 1, j, k, this.id);
} else if (i1 == 2) { } else if (i1 == 2) {
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
} else if (i1 == 3) { } else if (i1 == 3) {
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
} else if (i1 == 4) { } else if (i1 == 4) {
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} else { } else {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
} }
} }
super.b(world, i, j, k); super.remove(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) {
@ -199,7 +199,7 @@ public class BlockLever extends Block {
} }
} }
public boolean c() { public boolean isPowerSource() {
return true; return true;
} }
} }

View file

@ -40,13 +40,13 @@ public class BlockPressurePlate extends Block {
return false; return false;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
return world.d(i, j - 1, k); return world.d(i, j - 1, k);
} }
public void e(World world, int i, int j, int k) {} public void e(World world, int i, int j, int k) {}
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
boolean flag = false; boolean flag = false;
if (!world.d(i, j - 1, k)) { if (!world.d(i, j - 1, k)) {
@ -55,7 +55,7 @@ public class BlockPressurePlate extends Block {
if (flag) { if (flag) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
} }
@ -129,19 +129,19 @@ public class BlockPressurePlate extends Block {
// CraftBukkit end // CraftBukkit end
if (flag1 && !flag) { if (flag1 && !flag) {
world.c(i, j, k, 1); world.setData(i, j, k, 1);
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(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.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); world.makeSound((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.setData(i, j, k, 0);
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(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.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
} }
if (flag1) { if (flag1) {
@ -149,15 +149,15 @@ public class BlockPressurePlate extends Block {
} }
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if (l > 0) { if (l > 0) {
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
} }
super.b(world, i, j, k); super.remove(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) {
@ -179,7 +179,7 @@ public class BlockPressurePlate extends Block {
return world.getData(i, j, k) == 0 ? false : l == 1; return world.getData(i, j, k) == 0 ? false : l == 1;
} }
public boolean c() { public boolean isPowerSource() {
return true; return true;
} }
} }

View file

@ -1,10 +1,8 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
// CraftBukkit end
public class BlockPumpkin extends Block { public class BlockPumpkin extends Block {
@ -41,21 +39,21 @@ public class BlockPumpkin extends Block {
super.e(world, i, j, k); super.e(world, i, j, k);
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
int l = world.getTypeId(i, j, k); int l = world.getTypeId(i, j, k);
return (l == 0 || Block.byId[l].material.isLiquid()) && world.d(i, j - 1, k); return (l == 0 || Block.byId[l].material.isLiquid()) && world.d(i, j - 1, k);
} }
public void a(World world, int i, int j, int k, EntityLiving entityliving) { public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) {
int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
world.c(i, j, k, l); world.setData(i, j, k, l);
} }
// Craftbukkit start // Craftbukkit start
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].c()) { if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k); org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k);

View file

@ -12,7 +12,7 @@ import org.bukkit.plugin.PluginManager;
public class BlockRedstoneTorch extends BlockTorch { public class BlockRedstoneTorch extends BlockTorch {
private boolean a = false; private boolean isOn = false;
private static List b = new ArrayList(); private static List b = new ArrayList();
public int a(int i, int j) { public int a(int i, int j) {
@ -21,7 +21,7 @@ public class BlockRedstoneTorch extends BlockTorch {
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.l())); b.add(new RedstoneUpdateInfo(i, j, k, world.getTime()));
} }
int l = 0; int l = 0;
@ -42,7 +42,7 @@ 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);
this.a = flag; this.isOn = flag;
this.a(true); this.a(true);
} }
@ -55,29 +55,29 @@ public class BlockRedstoneTorch extends BlockTorch {
super.e(world, i, j, k); super.e(world, i, j, k);
} }
if (this.a) { if (this.isOn) {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
world.h(i, j + 1, k, this.id); world.applyPhysics(i, j + 1, k, this.id);
world.h(i - 1, j, k, this.id); world.applyPhysics(i - 1, j, k, this.id);
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
} }
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
if (this.a) { if (this.isOn) {
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
world.h(i, j + 1, k, this.id); world.applyPhysics(i, j + 1, k, this.id);
world.h(i - 1, j, k, this.id); world.applyPhysics(i - 1, j, k, this.id);
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
world.h(i, j, k + 1, this.id); world.applyPhysics(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 (!this.a) { if (!this.isOn) {
return false; return false;
} else { } else {
int i1 = iblockaccess.getData(i, j, k); int i1 = iblockaccess.getData(i, j, k);
@ -89,24 +89,24 @@ public class BlockRedstoneTorch extends BlockTorch {
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.getData(i, j, k); int l = world.getData(i, j, k);
return l == 5 && world.j(i, j - 1, k, 0) ? true : (l == 3 && world.j(i, j, k - 1, 2) ? true : (l == 4 && world.j(i, j, k + 1, 3) ? true : (l == 1 && world.j(i - 1, j, k, 4) ? true : l == 2 && world.j(i + 1, j, k, 5)))); return l == 5 && world.isBlockFaceIndirectlyPowered(i, j - 1, k, 0) ? true : (l == 3 && world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) ? true : (l == 4 && world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) ? true : (l == 1 && world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) ? true : l == 2 && world.isBlockFaceIndirectlyPowered(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 = this.g(world, i, j, k); boolean flag = this.g(world, i, j, k);
while (b.size() > 0 && world.l() - ((RedstoneUpdateInfo) b.get(0)).d > 100L) { while (b.size() > 0 && world.getTime() - ((RedstoneUpdateInfo) b.get(0)).d > 100L) {
b.remove(0); 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);
PluginManager man = ((WorldServer) world).getServer().getPluginManager(); PluginManager man = ((WorldServer) world).getServer().getPluginManager();
int oldCurrent = this.a ? 15 : 0; int oldCurrent = this.isOn ? 15 : 0;
BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent); BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
// CraftBukkit end // CraftBukkit end
if (this.a) { if (this.isOn) {
if (flag) { if (flag) {
// CraftBukkit start // CraftBukkit start
if (oldCurrent != 0) { if (oldCurrent != 0) {
@ -117,9 +117,9 @@ public class BlockRedstoneTorch extends BlockTorch {
} }
} }
// CraftBukkit end // CraftBukkit end
world.b(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k)); world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k));
if (this.a(world, i, j, k, true)) { if (this.a(world, i, j, k, true)) {
world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.k.nextFloat() - world.k.nextFloat()) * 0.8F); world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
for (int l = 0; l < 5; ++l) { for (int l = 0; l < 5; ++l) {
double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D; double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D;
@ -140,25 +140,24 @@ public class BlockRedstoneTorch extends BlockTorch {
} }
} }
// CraftBukkit end // CraftBukkit end
world.b(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k)); world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k));
} }
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
super.a(world, i, j, k, l); super.doPhysics(world, i, j, k, l);
world.c(i, j, k, this.id, this.b()); world.c(i, j, k, this.id, this.b());
} }
public boolean c(World world, int i, int j, int k, int l) { public boolean c(World world, int i, int j, int k, int l) {
// CraftBukkit -- cast to IBlockAccess return l == 0 ? this.b(world, i, j, k, l) : false;
return l == 0 ? this.b((IBlockAccess) world, i, j, k, l) : false;
} }
public int a(int i, Random random) { public int a(int i, Random random) {
return Block.REDSTONE_TORCH_ON.id; return Block.REDSTONE_TORCH_ON.id;
} }
public boolean c() { public boolean isPowerSource() {
return true; return true;
} }
} }

View file

@ -32,7 +32,7 @@ public class BlockRedstoneWire extends Block {
return false; return false;
} }
public boolean a(World world, int i, int j, int k) { public boolean canPlace(World world, int i, int j, int k) {
return world.d(i, j - 1, k); return world.d(i, j - 1, k);
} }
@ -45,7 +45,7 @@ public class BlockRedstoneWire extends Block {
for (int l = 0; l < arraylist.size(); ++l) { for (int l = 0; l < arraylist.size(); ++l) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l); ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);
world.h(chunkposition.a, chunkposition.b, chunkposition.c, this.id); world.applyPhysics(chunkposition.x, chunkposition.y, chunkposition.z, this.id);
} }
} }
@ -54,7 +54,7 @@ public class BlockRedstoneWire extends Block {
int l1 = 0; int l1 = 0;
this.a = false; this.a = false;
boolean flag = world.p(i, j, k); boolean flag = world.isBlockIndirectlyPowered(i, j, k);
this.a = true; this.a = true;
int i2; int i2;
@ -84,15 +84,15 @@ public class BlockRedstoneWire extends Block {
} }
if (j2 != l || j != i1 || k2 != j1) { if (j2 != l || j != i1 || k2 != j1) {
l1 = this.f(world, j2, j, k2, l1); l1 = this.getPower(world, j2, j, k2, l1);
} }
if (world.d(j2, j, k2) && !world.d(i, j + 1, k)) { if (world.d(j2, j, k2) && !world.d(i, j + 1, k)) {
if (j2 != l || j + 1 != i1 || k2 != j1) { if (j2 != l || j + 1 != i1 || k2 != j1) {
l1 = this.f(world, j2, j + 1, k2, l1); l1 = this.getPower(world, j2, j + 1, k2, l1);
} }
} else if (!world.d(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) { } else if (!world.d(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) {
l1 = this.f(world, j2, j - 1, k2, l1); l1 = this.getPower(world, j2, j - 1, k2, l1);
} }
} }
@ -114,7 +114,7 @@ public class BlockRedstoneWire extends Block {
if (k1 != l1) { if (k1 != l1) {
world.h = true; world.h = true;
world.c(i, j, k, l1); world.setData(i, j, k, l1);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.h = false; world.h = false;
@ -144,7 +144,7 @@ public class BlockRedstoneWire extends Block {
} }
boolean flag1 = false; boolean flag1 = false;
int i3 = this.f(world, j2, j, k2, -1); int i3 = this.getPower(world, j2, j, k2, -1);
l1 = world.getData(i, j, k); l1 = world.getData(i, j, k);
if (l1 > 0) { if (l1 > 0) {
@ -155,7 +155,7 @@ public class BlockRedstoneWire extends Block {
this.a(world, j2, j, k2, i, j, k); this.a(world, j2, j, k2, i, j, k);
} }
i3 = this.f(world, j2, l2, k2, -1); i3 = this.getPower(world, j2, l2, k2, -1);
l1 = world.getData(i, j, k); l1 = world.getData(i, j, k);
if (l1 > 0) { if (l1 > 0) {
--l1; --l1;
@ -180,13 +180,13 @@ public class BlockRedstoneWire extends Block {
private void h(World world, int i, int j, int k) { private void h(World world, int i, int j, int k) {
if (world.getTypeId(i, j, k) == this.id) { if (world.getTypeId(i, j, k) == this.id) {
world.h(i, j, k, this.id); world.applyPhysics(i, j, k, this.id);
world.h(i - 1, j, k, this.id); world.applyPhysics(i - 1, j, k, this.id);
world.h(i + 1, j, k, this.id); world.applyPhysics(i + 1, j, k, this.id);
world.h(i, j, k - 1, this.id); world.applyPhysics(i, j, k - 1, this.id);
world.h(i, j, k + 1, this.id); world.applyPhysics(i, j, k + 1, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
world.h(i, j + 1, k, this.id); world.applyPhysics(i, j + 1, k, this.id);
} }
} }
@ -194,8 +194,8 @@ public class BlockRedstoneWire extends Block {
super.e(world, i, j, k); super.e(world, i, j, k);
if (!world.isStatic) { if (!world.isStatic) {
this.g(world, i, j, k); this.g(world, i, j, k);
world.h(i, j + 1, k, this.id); world.applyPhysics(i, j + 1, k, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
this.h(world, i - 1, j, k); this.h(world, i - 1, j, k);
this.h(world, i + 1, j, k); this.h(world, i + 1, j, k);
this.h(world, i, j, k - 1); this.h(world, i, j, k - 1);
@ -226,11 +226,11 @@ public class BlockRedstoneWire extends Block {
} }
} }
public void b(World world, int i, int j, int k) { public void remove(World world, int i, int j, int k) {
super.b(world, i, j, k); super.remove(world, i, j, k);
if (!world.isStatic) { if (!world.isStatic) {
world.h(i, j + 1, k, this.id); world.applyPhysics(i, j + 1, k, this.id);
world.h(i, j - 1, k, this.id); world.applyPhysics(i, j - 1, k, this.id);
this.g(world, i, j, k); this.g(world, i, j, k);
this.h(world, i - 1, j, k); this.h(world, i - 1, j, k);
this.h(world, i + 1, j, k); this.h(world, i + 1, j, k);
@ -262,8 +262,8 @@ public class BlockRedstoneWire extends Block {
} }
} }
// Craftbukkit private-> public // Craftbukkit private->public
public int f(World world, int i, int j, int k, int l) { public int getPower(World world, int i, int j, int k, int l) {
if (world.getTypeId(i, j, k) != this.id) { if (world.getTypeId(i, j, k) != this.id) {
return l; return l;
} else { } else {
@ -273,21 +273,21 @@ public class BlockRedstoneWire extends Block {
} }
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
if (!world.isStatic) { if (!world.isStatic) {
int i1 = world.getData(i, j, k); int i1 = world.getData(i, j, k);
boolean flag = this.a(world, i, j, k); boolean flag = this.canPlace(world, i, j, k);
if (!flag) { if (!flag) {
this.a_(world, i, j, k, i1); this.a_(world, i, j, k, i1);
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} else } else {
// Craftbukkit // Craftbukkit
if ((Block.byId[l] != null && Block.byId[l].c()) || Block.DIODE_OFF.id == l || Block.DIODE_ON.id == l) { if ((Block.byId[l] != null && Block.byId[l].isPowerSource()) || Block.DIODE_OFF.id == l || Block.DIODE_ON.id == l)
this.g(world, i, j, k); this.g(world, i, j, k);
} }
super.a(world, i, j, k, l); super.doPhysics(world, i, j, k, l);
} }
} }
@ -296,8 +296,7 @@ public class BlockRedstoneWire extends Block {
} }
public boolean c(World world, int i, int j, int k, int l) { public boolean c(World world, int i, int j, int k, int l) {
// CraftBukkit -- cast to IBlockAccess return !this.a ? false : this.b(world, i, j, k, l);
return !this.a ? false : this.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) {
@ -335,13 +334,13 @@ public class BlockRedstoneWire extends Block {
} }
} }
public boolean c() { public boolean isPowerSource() {
return this.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.getTypeId(i, j, k); int l = iblockaccess.getTypeId(i, j, k);
return l == Block.REDSTONE_WIRE.id ? true : (l == 0 ? false : Block.byId[l].c()); return l == Block.REDSTONE_WIRE.id ? true : (l == 0 ? false : Block.byId[l].isPowerSource());
} }
} }

View file

@ -73,7 +73,7 @@ public class BlockSign extends BlockContainer {
return Item.SIGN.id; return Item.SIGN.id;
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
boolean flag = false; boolean flag = false;
if (this.b) { if (this.b) {
@ -103,17 +103,18 @@ public class BlockSign extends BlockContainer {
if (flag) { if (flag) {
this.a_(world, i, j, k, world.getData(i, j, k)); this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
} }
super.a(world, i, j, k, l); super.doPhysics(world, i, j, k, l);
// CraftBukkit start // CraftBukkit start
if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].c()) { if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) {
CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
Block block = craftWorld.getBlockAt(i, j, k); Block block = craftWorld.getBlockAt(i, j, k);
int power = block.getBlockPower(); int power = block.getBlockPower();
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, power, power);
server.getPluginManager().callEvent(eventRedstone); server.getPluginManager().callEvent(eventRedstone);
} }

View file

@ -1,10 +1,14 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.entity.EntityInteractEvent;
// CraftBukkit end
public class BlockSoil extends Block { public class BlockSoil extends Block {
@ -31,34 +35,36 @@ public class BlockSoil 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 (random.nextInt(5) == 0) { if (random.nextInt(5) == 0) {
if (this.h(world, i, j, k)) { if (this.h(world, i, j, k)) {
world.c(i, j, k, 7); world.setData(i, j, k, 7);
} else { } else {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if (l > 0) { if (l > 0) {
world.c(i, j, k, l - 1); world.setData(i, j, k, l - 1);
} else if (!this.g(world, i, j, k)) { } else if (!this.g(world, i, j, k)) {
world.e(i, j, k, Block.DIRT.id); world.setTypeId(i, j, k, Block.DIRT.id);
} }
} }
} }
} }
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) {
// CraftBukkit start - Interact Soil if (world.random.nextInt(4) == 0) {
Cancellable cancellable; // CraftBukkit start - Interact Soil
if (entity instanceof EntityHuman) { Cancellable cancellable;
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null); if (entity instanceof EntityHuman) {
} cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, Action.PHYSICAL, i, j, k, -1, null);
else { } else {
cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer)world).getWorld().getBlockAt(i, j, k)); cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k));
} Bukkit.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
if (!cancellable.isCancelled()) {
if (world.k.nextInt(4) == 0) {
world.e(i, j, k, Block.DIRT.id);
} }
if (cancellable.isCancelled()) {
return;
}
// Craftbukkit end
world.setTypeId(i, j, k, Block.DIRT.id);
} }
// Craftbukkit end
} }
private boolean g(World world, int i, int j, int k) { private boolean g(World world, int i, int j, int k) {
@ -89,12 +95,12 @@ public class BlockSoil extends Block {
return false; return false;
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
super.a(world, i, j, k, l); super.doPhysics(world, i, j, k, l);
Material material = world.getMaterial(i, j + 1, k); Material material = world.getMaterial(i, j + 1, k);
if (material.isBuildable()) { if (material.isBuildable()) {
world.e(i, j, k, Block.DIRT.id); world.setTypeId(i, j, k, Block.DIRT.id);
} }
} }

View file

@ -20,8 +20,8 @@ public class BlockStationary extends BlockFluids {
} }
} }
public void a(World world, int i, int j, int k, int l) { public void doPhysics(World world, int i, int j, int k, int l) {
super.a(world, i, j, k, l); super.doPhysics(world, i, j, k, l);
if (world.getTypeId(i, j, k) == this.id) { if (world.getTypeId(i, j, k) == this.id) {
this.i(world, i, j, k); this.i(world, i, j, k);
} }
@ -31,7 +31,7 @@ public class BlockStationary extends BlockFluids {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
world.h = true; world.h = true;
world.setTypeIdAndData(i, j, k, this.id - 1, l); world.setRawTypeIdAndData(i, j, k, this.id - 1, l);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);
world.c(i, j, k, this.id - 1, this.b()); world.c(i, j, k, this.id - 1, this.b());
world.h = false; world.h = false;
@ -69,7 +69,7 @@ public class BlockStationary extends BlockFluids {
} }
// CraftBukkit end // CraftBukkit end
world.e(i, j, k, Block.FIRE.id); world.setTypeId(i, j, k, Block.FIRE.id);
return; return;
} }
} else if (Block.byId[j1].material.isSolid()) { } else if (Block.byId[j1].material.isSolid()) {

View file

@ -17,36 +17,36 @@ public class Chunk {
public static boolean a; public static boolean a;
public byte[] b; public byte[] b;
public boolean c; public boolean c;
public World d; public World world;
public NibbleArray e; public NibbleArray e;
public NibbleArray f; public NibbleArray f;
public NibbleArray g; public NibbleArray g;
public byte[] h; public byte[] h;
public int i; public int i;
public final int j; public final int x;
public final int k; public final int z;
public Map l; public Map tileEntities;
public List[] m; public List[] entitySlices;
public boolean n; public boolean done;
public boolean o; public boolean o;
public boolean p; public boolean p;
public boolean q; public boolean q;
public long r; public long r;
public Chunk(World world, int i, int j) { public Chunk(World world, int i, int j) {
this.l = new HashMap(); this.tileEntities = new HashMap();
this.m = new List[8]; this.entitySlices = new List[8];
this.n = false; this.done = false;
this.o = false; this.o = false;
this.q = false; this.q = false;
this.r = 0L; this.r = 0L;
this.d = world; this.world = world;
this.j = i; this.x = i;
this.k = j; this.z = j;
this.h = new byte[256]; this.h = new byte[256];
for (int k = 0; k < this.m.length; ++k) { for (int k = 0; k < this.entitySlices.length; ++k) {
this.m[k] = new ArrayList(); this.entitySlices[k] = new ArrayList();
} }
// CraftBukkit start // CraftBukkit start
@ -69,7 +69,7 @@ public class Chunk {
} }
public boolean a(int i, int j) { public boolean a(int i, int j) {
return i == this.j && j == this.k; return i == this.x && j == this.z;
} }
public int b(int i, int j) { public int b(int i, int j) {
@ -99,7 +99,7 @@ public class Chunk {
i = l; i = l;
} }
if (!this.d.m.e) { if (!this.world.worldProvider.e) {
int j1 = 15; int j1 = 15;
int k1 = 127; int k1 = 127;
@ -126,12 +126,12 @@ public class Chunk {
this.o = true; this.o = true;
} }
public void c() {} public void loadNOP() {}
private void c(int i, int j) { private void c(int i, int j) {
int k = this.b(i, j); int k = this.b(i, j);
int l = this.j * 16 + i; int l = this.x * 16 + i;
int i1 = this.k * 16 + j; int i1 = this.z * 16 + j;
this.f(l - 1, i1, k); this.f(l - 1, i1, k);
this.f(l + 1, i1, k); this.f(l + 1, i1, k);
@ -140,13 +140,13 @@ public class Chunk {
} }
private void f(int i, int j, int k) { private void f(int i, int j, int k) {
int l = this.d.d(i, j); int l = this.world.getHighestBlockYAt(i, j);
if (l > k) { if (l > k) {
this.d.a(EnumSkyBlock.SKY, i, k, j, i, l, j); this.world.a(EnumSkyBlock.SKY, i, k, j, i, l, j);
this.o = true; this.o = true;
} else if (l < k) { } else if (l < k) {
this.d.a(EnumSkyBlock.SKY, i, l, j, i, k, j); this.world.a(EnumSkyBlock.SKY, i, l, j, i, k, j);
this.o = true; this.o = true;
} }
} }
@ -164,7 +164,7 @@ public class Chunk {
} }
if (i1 != l) { if (i1 != l) {
this.d.g(i, k, i1, l); this.world.g(i, k, i1, l);
this.h[k << 4 | i] = (byte) i1; this.h[k << 4 | i] = (byte) i1;
int k1; int k1;
int l1; int l1;
@ -186,14 +186,14 @@ public class Chunk {
this.i = k1; this.i = k1;
} }
k1 = this.j * 16 + i; k1 = this.x * 16 + i;
l1 = this.k * 16 + k; l1 = this.z * 16 + k;
if (i1 < l) { if (i1 < l) {
for (i2 = i1; i2 < l; ++i2) { for (i2 = i1; i2 < l; ++i2) {
this.f.a(i, i2, k, 15); this.f.a(i, i2, k, 15);
} }
} else { } else {
this.d.a(EnumSkyBlock.SKY, k1, l, l1, k1, i1, l1); this.world.a(EnumSkyBlock.SKY, k1, l, l1, k1, i1, l1);
for (i2 = l; i2 < i1; ++i2) { for (i2 = l; i2 < i1; ++i2) {
this.f.a(i, i2, k, 0); this.f.a(i, i2, k, 0);
@ -206,7 +206,7 @@ public class Chunk {
for (j2 = i1; i1 > 0 && i2 > 0; this.f.a(i, i1, k, i2)) { for (j2 = i1; i1 > 0 && i2 > 0; this.f.a(i, i1, k, i2)) {
--i1; --i1;
int k2 = Block.q[this.a(i, i1, k)]; int k2 = Block.q[this.getTypeId(i, i1, k)];
if (k2 == 0) { if (k2 == 0) {
k2 = 1; k2 = 1;
@ -218,19 +218,19 @@ public class Chunk {
} }
} }
while (i1 > 0 && Block.q[this.a(i, i1 - 1, k)] == 0) { while (i1 > 0 && Block.q[this.getTypeId(i, i1 - 1, k)] == 0) {
--i1; --i1;
} }
if (i1 != j2) { if (i1 != j2) {
this.d.a(EnumSkyBlock.SKY, k1 - 1, i1, l1 - 1, k1 + 1, j2, l1 + 1); this.world.a(EnumSkyBlock.SKY, k1 - 1, i1, l1 - 1, k1 + 1, j2, l1 + 1);
} }
this.o = true; this.o = true;
} }
} }
public int a(int i, int j, int k) { public int getTypeId(int i, int j, int k) {
return this.b[i << 11 | k << 7 | j] & 255; return this.b[i << 11 | k << 7 | j] & 255;
} }
@ -242,16 +242,16 @@ public class Chunk {
if (k1 == l && this.e.a(i, j, k) == i1) { if (k1 == l && this.e.a(i, j, k) == i1) {
return false; return false;
} else { } else {
int l1 = this.j * 16 + i; int l1 = this.x * 16 + i;
int i2 = this.k * 16 + k; int i2 = this.z * 16 + k;
this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255); this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255);
if (k1 != 0 && !this.d.isStatic) { if (k1 != 0 && !this.world.isStatic) {
Block.byId[k1].b(this.d, l1, j, i2); Block.byId[k1].remove(this.world, l1, j, i2);
} }
this.e.a(i, j, k, i1); this.e.a(i, j, k, i1);
if (!this.d.m.e) { if (!this.world.worldProvider.e) {
if (Block.q[b0 & 255] != 0) { if (Block.q[b0 & 255] != 0) {
if (j >= j1) { if (j >= j1) {
this.g(i, j + 1, k); this.g(i, j + 1, k);
@ -260,14 +260,14 @@ public class Chunk {
this.g(i, j, k); this.g(i, j, k);
} }
this.d.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2); this.world.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2);
} }
this.d.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2); this.world.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2);
this.c(i, k); this.c(i, k);
this.e.a(i, j, k, i1); this.e.a(i, j, k, i1);
if (l != 0) { if (l != 0) {
Block.byId[l].e(this.d, l1, j, i2); Block.byId[l].e(this.world, l1, j, i2);
} }
this.o = true; this.o = true;
@ -283,12 +283,12 @@ public class Chunk {
if (j1 == l) { if (j1 == l) {
return false; return false;
} else { } else {
int k1 = this.j * 16 + i; int k1 = this.x * 16 + i;
int l1 = this.k * 16 + k; int l1 = this.z * 16 + k;
this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255); this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255);
if (j1 != 0) { if (j1 != 0) {
Block.byId[j1].b(this.d, k1, j, l1); Block.byId[j1].remove(this.world, k1, j, l1);
} }
this.e.a(i, j, k, 0); this.e.a(i, j, k, 0);
@ -300,11 +300,11 @@ public class Chunk {
this.g(i, j, k); this.g(i, j, k);
} }
this.d.a(EnumSkyBlock.SKY, k1, j, l1, k1, j, l1); this.world.a(EnumSkyBlock.SKY, k1, j, l1, k1, j, l1);
this.d.a(EnumSkyBlock.BLOCK, k1, j, l1, k1, j, l1); this.world.a(EnumSkyBlock.BLOCK, k1, j, l1, k1, j, l1);
this.c(i, k); this.c(i, k);
if (l != 0 && !this.d.isStatic) { if (l != 0 && !this.world.isStatic) {
Block.byId[l].e(this.d, k1, j, l1); Block.byId[l].e(this.world, k1, j, l1);
} }
this.o = true; this.o = true;
@ -312,7 +312,7 @@ public class Chunk {
} }
} }
public int b(int i, int j, int k) { public int getData(int i, int j, int k) {
return this.e.a(i, j, k); return this.e.a(i, j, k);
} }
@ -357,31 +357,31 @@ public class Chunk {
public void a(Entity entity) { public void a(Entity entity) {
this.q = true; this.q = true;
int i = MathHelper.b(entity.locX / 16.0D); int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.b(entity.locZ / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D);
if (i != this.j || j != this.k) { if (i != this.x || j != this.z) {
System.out.println("Wrong location! " + entity); System.out.println("Wrong location! " + entity);
// CraftBukkit // CraftBukkit
System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.j + "," + this.k); System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z);
Thread.dumpStack(); Thread.dumpStack();
} }
int k = MathHelper.b(entity.locY / 16.0D); int k = MathHelper.floor(entity.locY / 16.0D);
if (k < 0) { if (k < 0) {
k = 0; k = 0;
} }
if (k >= this.m.length) { if (k >= this.entitySlices.length) {
k = this.m.length - 1; k = this.entitySlices.length - 1;
} }
entity.bA = true; entity.bA = true;
entity.chunkX = this.j; entity.chunkX = this.x;
entity.bC = k; entity.bC = k;
entity.chunkZ = this.k; entity.chunkZ = this.z;
this.m[k].add(entity); this.entitySlices[k].add(entity);
} }
public void b(Entity entity) { public void b(Entity entity) {
@ -393,11 +393,11 @@ public class Chunk {
i = 0; i = 0;
} }
if (i >= this.m.length) { if (i >= this.entitySlices.length) {
i = this.m.length - 1; i = this.entitySlices.length - 1;
} }
this.m[i].remove(entity); this.entitySlices[i].remove(entity);
} }
public boolean c(int i, int j, int k) { public boolean c(int i, int j, int k) {
@ -406,28 +406,28 @@ public class Chunk {
public TileEntity d(int i, int j, int k) { public TileEntity d(int i, int j, int k) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k); ChunkPosition chunkposition = new ChunkPosition(i, j, k);
TileEntity tileentity = (TileEntity) this.l.get(chunkposition); TileEntity tileentity = (TileEntity) this.tileEntities.get(chunkposition);
if (tileentity == null) { if (tileentity == null) {
int l = this.a(i, j, k); int l = this.getTypeId(i, j, k);
if (!Block.p[l]) { if (!Block.isTileEntity[l]) {
return null; return null;
} }
BlockContainer blockcontainer = (BlockContainer) Block.byId[l]; BlockContainer blockcontainer = (BlockContainer) Block.byId[l];
blockcontainer.e(this.d, this.j * 16 + i, j, this.k * 16 + k); blockcontainer.e(this.world, this.x * 16 + i, j, this.z * 16 + k);
tileentity = (TileEntity) this.l.get(chunkposition); tileentity = (TileEntity) this.tileEntities.get(chunkposition);
} }
return tileentity; return tileentity;
} }
public void a(TileEntity tileentity) { public void a(TileEntity tileentity) {
int i = tileentity.e - this.j * 16; int i = tileentity.e - this.x * 16;
int j = tileentity.f; int j = tileentity.f;
int k = tileentity.g - this.k * 16; int k = tileentity.g - this.z * 16;
this.a(i, j, k, tileentity); this.a(i, j, k, tileentity);
} }
@ -435,20 +435,20 @@ public class Chunk {
public void a(int i, int j, int k, TileEntity tileentity) { public void a(int i, int j, int k, TileEntity tileentity) {
ChunkPosition chunkposition = new ChunkPosition(i, j, k); ChunkPosition chunkposition = new ChunkPosition(i, j, k);
tileentity.d = this.d; tileentity.world = this.world;
tileentity.e = this.j * 16 + i; tileentity.e = this.x * 16 + i;
tileentity.f = j; tileentity.f = j;
tileentity.g = this.k * 16 + k; tileentity.g = this.z * 16 + k;
if (this.a(i, j, k) != 0 && Block.byId[this.a(i, j, k)] instanceof BlockContainer) { if (this.getTypeId(i, j, k) != 0 && Block.byId[this.getTypeId(i, j, k)] instanceof BlockContainer) {
if (this.c) { if (this.c) {
if (this.l.get(chunkposition) != null) { if (this.tileEntities.get(chunkposition) != null) {
this.d.c.remove(this.l.get(chunkposition)); this.world.c.remove(this.tileEntities.get(chunkposition));
} }
this.d.c.add(tileentity); this.world.c.add(tileentity);
} }
this.l.put(chunkposition, tileentity); this.tileEntities.put(chunkposition, tileentity);
} else { } else {
System.out.println("Attempted to place a tile entity where there was no entity tile!"); System.out.println("Attempted to place a tile entity where there was no entity tile!");
} }
@ -458,41 +458,40 @@ public class Chunk {
ChunkPosition chunkposition = new ChunkPosition(i, j, k); ChunkPosition chunkposition = new ChunkPosition(i, j, k);
if (this.c) { if (this.c) {
this.d.c.remove(this.l.remove(chunkposition)); this.world.c.remove(this.tileEntities.remove(chunkposition));
} }
} }
public void d() { public void addEntities() {
this.c = true; this.c = true;
this.d.c.addAll(this.l.values()); this.world.c.addAll(this.tileEntities.values());
for (int i = 0; i < this.m.length; ++i) { for (int i = 0; i < this.entitySlices.length; ++i) {
this.d.a(this.m[i]); this.world.a(this.entitySlices[i]);
} }
} }
public void e() { public void removeEntities() {
this.c = false; this.c = false;
this.d.c.removeAll(this.l.values()); this.world.c.removeAll(this.tileEntities.values());
for (int i = 0; i < this.m.length; ++i) {
Iterator<Object> iter = this.m[i].iterator();
for (int i = 0; i < this.entitySlices.length; ++i) {
// Craftbukkit start // Craftbukkit start
while(iter.hasNext()) { Iterator<Object> iter = this.entitySlices[i].iterator();
Entity e = (Entity)iter.next(); while (iter.hasNext()) {
int cx = Location.locToBlock(e.locX) >> 4; Entity entity = (Entity) iter.next();
int cz = Location.locToBlock(e.locZ) >> 4; int cx = Location.locToBlock(entity.locX) >> 4;
int cz = Location.locToBlock(entity.locZ) >> 4;
if ((e instanceof EntityPlayer) && ((cx != this.j) || (cz != this.k))) { if ((entity instanceof EntityPlayer) && ((cx != this.x) || (cz != this.z))) {
EntityPlayer player = (EntityPlayer)e; EntityPlayer player = (EntityPlayer) entity;
iter.remove(); // Do not pass along players, as doing so can get them stuck outside of time. iter.remove(); // Do not pass along players, as doing so can get them stuck outside of time.
// (which for example disables inventory icon updates and prevents block breaking) // (which for example disables inventory icon updates and prevents block breaking)
} }
} }
// Craftbukkit end // Craftbukkit end
this.d.b(this.m[i]); this.world.b(this.entitySlices[i]);
} }
} }
@ -501,19 +500,19 @@ public class Chunk {
} }
public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) { public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.b((axisalignedbb.b - 2.0D) / 16.0D); int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.b((axisalignedbb.e + 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
if (i < 0) { if (i < 0) {
i = 0; i = 0;
} }
if (j >= this.m.length) { if (j >= this.entitySlices.length) {
j = this.m.length - 1; j = this.entitySlices.length - 1;
} }
for (int k = i; k <= j; ++k) { for (int k = i; k <= j; ++k) {
List list1 = this.m[k]; List list1 = this.entitySlices[k];
for (int l = 0; l < list1.size(); ++l) { for (int l = 0; l < list1.size(); ++l) {
Entity entity1 = (Entity) list1.get(l); Entity entity1 = (Entity) list1.get(l);
@ -526,19 +525,19 @@ public class Chunk {
} }
public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) { public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) {
int i = MathHelper.b((axisalignedbb.b - 2.0D) / 16.0D); int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D);
int j = MathHelper.b((axisalignedbb.e + 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D);
if (i < 0) { if (i < 0) {
i = 0; i = 0;
} }
if (j >= this.m.length) { if (j >= this.entitySlices.length) {
j = this.m.length - 1; j = this.entitySlices.length - 1;
} }
for (int k = i; k <= j; ++k) { for (int k = i; k <= j; ++k) {
List list1 = this.m[k]; List list1 = this.entitySlices[k];
for (int l = 0; l < list1.size(); ++l) { for (int l = 0; l < list1.size(); ++l) {
Entity entity = (Entity) list1.get(l); Entity entity = (Entity) list1.get(l);
@ -555,10 +554,10 @@ public class Chunk {
return false; return false;
} else { } else {
if (flag) { if (flag) {
if (this.q && this.d.l() != this.r) { if (this.q && this.world.getTime() != this.r) {
return true; return true;
} }
} else if (this.q && this.d.l() >= this.r + 600L) { } else if (this.q && this.world.getTime() >= this.r + 600L) {
return true; return true;
} }
@ -612,7 +611,7 @@ public class Chunk {
} }
public Random a(long i) { public Random a(long i) {
return new Random(this.d.k() + (long) (this.j * this.j * 4987142) + (long) (this.j * 5947611) + (long) (this.k * this.k) * 4392871L + (long) (this.k * 389711) ^ i); return new Random(this.world.getSeed() + (long) (this.x * this.x * 4987142) + (long) (this.x * 5947611) + (long) (this.z * this.z) * 4392871L + (long) (this.z * 389711) ^ i);
} }
public boolean g() { public boolean g() {

View file

@ -21,62 +21,62 @@ import org.bukkit.event.world.ChunkUnloadEvent;
public class ChunkProviderServer implements IChunkProvider { public class ChunkProviderServer implements IChunkProvider {
// CraftBukkit start // CraftBukkit start
public LongHashset a = new LongHashset(); public LongHashset unloadQueue = new LongHashset();
public Chunk b; public Chunk emptyChunk;
public IChunkProvider c; public IChunkProvider chunkProvider; // CraftBukkit
private IChunkLoader d; private IChunkLoader d;
public LongHashtable<Chunk> e = new LongHashtable<Chunk>(); public LongHashtable<Chunk> chunks = new LongHashtable<Chunk>();
public List f = new ArrayList(); public List chunkList = new ArrayList();
public WorldServer g; public WorldServer world;
// CraftBukkit end // CraftBukkit end
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
this.b = new EmptyChunk(worldserver, new byte['\u8000'], 0, 0); this.emptyChunk = new EmptyChunk(worldserver, new byte['\u8000'], 0, 0);
this.g = worldserver; this.world = worldserver;
this.d = ichunkloader; this.d = ichunkloader;
this.c = ichunkprovider; this.chunkProvider = ichunkprovider;
} }
public boolean a(int i, int j) { public boolean isChunkLoaded(int i, int j) {
return this.e.containsKey(i, j); // CraftBukkit return this.chunks.containsKey(i, j); // CraftBukkit
} }
public void d(int i, int j) { public void queueUnload(int i, int j) {
ChunkCoordinates chunkcoordinates = this.g.m(); ChunkCoordinates chunkcoordinates = this.world.getSpawn();
int k = i * 16 + 8 - chunkcoordinates.a; int k = i * 16 + 8 - chunkcoordinates.x;
int l = j * 16 + 8 - chunkcoordinates.c; int l = j * 16 + 8 - chunkcoordinates.z;
short short1 = 128; short short1 = 128;
if (k < -short1 || k > short1 || l < -short1 || l > short1) { if (k < -short1 || k > short1 || l < -short1 || l > short1) {
this.a.add(i, j); // CraftBukkit this.unloadQueue.add(i, j); // CraftBukkit
} }
} }
public Chunk c(int i, int j) { public Chunk getChunkAt(int i, int j) {
// CraftBukkit start // CraftBukkit start
this.a.remove(i, j); this.unloadQueue.remove(i, j);
Chunk chunk = (Chunk) this.e.get(i, j); Chunk chunk = (Chunk) this.chunks.get(i, j);
// CraftBukkit end // CraftBukkit end
if (chunk == null) { if (chunk == null) {
chunk = this.e(i, j); chunk = this.loadChunk(i, j);
if (chunk == null) { if (chunk == null) {
if (this.c == null) { if (this.chunkProvider == null) {
chunk = this.b; chunk = this.emptyChunk;
} else { } else {
chunk = this.c.b(i, j); chunk = this.chunkProvider.getOrCreateChunk(i, j);
} }
} }
this.e.put(i, j, chunk); // CraftBukkit this.chunks.put(i, j, chunk); // CraftBukkit
this.f.add(chunk); this.chunkList.add(chunk);
if (chunk != null) { if (chunk != null) {
chunk.c(); chunk.loadNOP();
chunk.d(); chunk.addEntities();
} }
// CraftBukkit start // CraftBukkit start
CraftServer server = g.getServer(); CraftServer server = this.world.getServer();
if (server != null) { if (server != null) {
/* /*
* If it's a new world, the first few chunks are generated inside * If it's a new world, the first few chunks are generated inside
@ -87,53 +87,52 @@ public class ChunkProviderServer implements IChunkProvider {
} }
// CraftBukkit end // CraftBukkit end
if (!chunk.n && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) { if (!chunk.done && this.isChunkLoaded(i + 1, j + 1) && this.isChunkLoaded(i, j + 1) && this.isChunkLoaded(i + 1, j)) {
this.a(this, i, j); this.getChunkAt(this, i, 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)) { if (this.isChunkLoaded(i - 1, j) && !this.getOrCreateChunk(i - 1, j).done && this.isChunkLoaded(i - 1, j + 1) && this.isChunkLoaded(i, j + 1) && this.isChunkLoaded(i - 1, j)) {
this.a(this, i - 1, j); this.getChunkAt(this, i - 1, j);
} }
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)) { if (this.isChunkLoaded(i, j - 1) && !this.getOrCreateChunk(i, j - 1).done && this.isChunkLoaded(i + 1, j - 1) && this.isChunkLoaded(i, j - 1) && this.isChunkLoaded(i + 1, j)) {
this.a(this, i, j - 1); this.getChunkAt(this, i, 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)) { if (this.isChunkLoaded(i - 1, j - 1) && !this.getOrCreateChunk(i - 1, j - 1).done && this.isChunkLoaded(i - 1, j - 1) && this.isChunkLoaded(i, j - 1) && this.isChunkLoaded(i - 1, j)) {
this.a(this, i - 1, j - 1); this.getChunkAt(this, i - 1, j - 1);
} }
} }
return chunk; return chunk;
} }
public Chunk b(int i, int j) { public Chunk getOrCreateChunk(int i, int j) {
// CraftBukkit start // CraftBukkit start
Chunk chunk = (Chunk) this.e.get(i, j); Chunk chunk = (Chunk) this.chunks.get(i, j);
chunk = chunk == null ? (this.g.r ? this.c(i, j) : this.b) : chunk; chunk = chunk == null ? (this.world.isLoading ? this.getChunkAt(i, j) : this.emptyChunk) : chunk;
if (chunk == this.b) return chunk; if (chunk == this.emptyChunk) return chunk;
if (i != chunk.j || j != chunk.k) { if (i != chunk.x || j != chunk.z) {
MinecraftServer.a.info("Chunk (" + chunk.j + ", " + chunk.k +") stored at (" + i + ", " + j + ")"); MinecraftServer.log.info("Chunk (" + chunk.x + ", " + chunk.z +") stored at (" + i + ", " + j + ")");
MinecraftServer.a.info(chunk.getClass().getName()); MinecraftServer.log.info(chunk.getClass().getName());
Throwable x = new Throwable(); Throwable ex = new Throwable();
x.fillInStackTrace(); ex.fillInStackTrace();
x.printStackTrace(); ex.printStackTrace();
} }
return chunk; return chunk;
// CraftBukkit end // CraftBukkit end
} }
// CraftBukkit - private->public public Chunk loadChunk(int i, int j) {// CraftBukkit - private->public
public Chunk e(int i, int j) {
if (this.d == null) { if (this.d == null) {
return null; return null;
} else { } else {
try { try {
Chunk chunk = this.d.a(this.g, i, j); Chunk chunk = this.d.a(this.world, i, j);
if (chunk != null) { if (chunk != null) {
chunk.r = this.g.l(); chunk.r = this.world.getTime();
} }
return chunk; return chunk;
@ -144,53 +143,51 @@ public class ChunkProviderServer implements IChunkProvider {
} }
} }
// CraftBukkit - private->public public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private->public
public void a(Chunk chunk) {
if (this.d != null) { if (this.d != null) {
try { try {
this.d.b(this.g, chunk); this.d.b(this.world, chunk);
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
} }
// CraftBukkit - private->public public void saveChunk(Chunk chunk) { // CraftBukkit - private->public
public void b(Chunk chunk) {
if (this.d != null) { if (this.d != null) {
try { try {
chunk.r = this.g.l(); chunk.r = this.world.getTime();
this.d.a(this.g, chunk); this.d.a(this.world, chunk);
} catch (Exception ioexception) { // CraftBukkit - IOException -> Exception } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
ioexception.printStackTrace(); ioexception.printStackTrace();
} }
} }
} }
public void a(IChunkProvider ichunkprovider, int i, int j) { public void getChunkAt(IChunkProvider ichunkprovider, int i, int j) {
Chunk chunk = this.b(i, j); Chunk chunk = this.getOrCreateChunk(i, j);
if (!chunk.n) { if (!chunk.done) {
chunk.n = true; chunk.done = true;
if (this.c != null) { if (this.chunkProvider != null) {
this.c.a(ichunkprovider, i, j); this.chunkProvider.getChunkAt(ichunkprovider, i, j);
chunk.f(); chunk.f();
} }
} }
} }
public boolean a(boolean flag, IProgressUpdate iprogressupdate) { public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
int i = 0; int i = 0;
for (int j = 0; j < this.f.size(); ++j) { for (int j = 0; j < this.chunkList.size(); ++j) {
Chunk chunk = (Chunk) this.f.get(j); Chunk chunk = (Chunk) this.chunkList.get(j);
if (flag && !chunk.p) { if (flag && !chunk.p) {
this.a(chunk); this.saveChunkNOP(chunk);
} }
if (chunk.a(flag)) { if (chunk.a(flag)) {
this.b(chunk); this.saveChunk(chunk);
chunk.o = false; chunk.o = false;
++i; ++i;
if (i == 24 && !flag) { if (i == 24 && !flag) {
@ -210,25 +207,26 @@ public class ChunkProviderServer implements IChunkProvider {
return true; return true;
} }
public boolean a() { public boolean unloadChunks() {
if (!this.g.w) { if (!this.world.w) {
// CraftBukkit start // CraftBukkit start
Server server = g.getServer(); Server server = this.world.getServer();
for (int i = 0; i < 50 && !this.a.isEmpty(); i++) { for (int i = 0; i < 50 && !this.unloadQueue.isEmpty(); i++) {
long chunkcoordinates = this.a.popFirst(); long chunkcoordinates = this.unloadQueue.popFirst();
Chunk chunk = e.get(chunkcoordinates); Chunk chunk = this.chunks.get(chunkcoordinates);
if (chunk == null) continue; if (chunk == null) continue;
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
g.getWorld().preserveChunk( (CraftChunk) chunk.bukkitChunk ); this.world.getWorld().preserveChunk( (CraftChunk) chunk.bukkitChunk );
chunk.e(); chunk.removeEntities();
this.b(chunk); this.saveChunk(chunk);
this.a(chunk); this.saveChunkNOP(chunk);
this.e.remove(chunkcoordinates); //this.unloadQueue.remove(integer);
this.f.remove(chunk); this.chunks.remove(chunkcoordinates); // CraftBukkit
this.chunkList.remove(chunk);
} }
} }
// CraftBukkit end // CraftBukkit end
@ -238,10 +236,10 @@ public class ChunkProviderServer implements IChunkProvider {
} }
} }
return this.c.a(); return this.chunkProvider.unloadChunks();
} }
public boolean b() { public boolean b() {
return !this.g.w; return !this.world.w;
} }
} }

View file

@ -7,39 +7,36 @@ import java.util.logging.Logger;
public class ConsoleCommandHandler { public class ConsoleCommandHandler {
private static Logger a = Logger.getLogger("Minecraft"); private static Logger a = Logger.getLogger("Minecraft");
private MinecraftServer b; private MinecraftServer server;
private ICommandListener listener; // CraftBukkit
public ConsoleCommandHandler(MinecraftServer minecraftserver) { public ConsoleCommandHandler(MinecraftServer minecraftserver) {
this.b = minecraftserver; this.server = minecraftserver;
} }
// CraftBukkit - All calls to the following below: public boolean handle(ServerCommand servercommand) { // CraftBukkit - returns boolean
// this.a( String s1, String msg ); String s = servercommand.command;
// are changed to:
// this.notify( ICommandListener icommandlistener, String msg );
public boolean a(ServerCommand servercommand) { // CraftBukkit - returns boolean
String s = servercommand.a;
ICommandListener icommandlistener = servercommand.b; ICommandListener icommandlistener = servercommand.b;
String s1 = icommandlistener.c(); String s1 = icommandlistener.getName();
WorldServer worldserver = this.b.worlds.get(0); // CraftBukkit WorldServer worldserver = this.server.worlds.get(0); // CraftBukkit
ServerConfigurationManager serverconfigurationmanager = this.b.f; listener = icommandlistener; // CraftBukkit
ServerConfigurationManager serverconfigurationmanager = this.server.serverConfigurationManager;
if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) { if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) {
if (s.toLowerCase().startsWith("list")) { if (s.toLowerCase().startsWith("list")) {
icommandlistener.b("Connected players: " + serverconfigurationmanager.c()); icommandlistener.sendMessage("Connected players: " + serverconfigurationmanager.c());
} else if (s.toLowerCase().startsWith("stop")) { } else if (s.toLowerCase().startsWith("stop")) {
this.notify(icommandlistener, "Stopping the server.."); // CraftBukkit - notify command sender this.print(s1, "Stopping the server..");
this.b.a(); this.server.a();
} else if (s.toLowerCase().startsWith("save-all")) { } else if (s.toLowerCase().startsWith("save-all")) {
this.notify(icommandlistener, "Forcing save.."); // CraftBukkit - notify command sender this.print(s1, "Forcing save..");
this.b.f(); // CraftBukkit - We should save all worlds on save-all. this.server.saveChunks(); // CraftBukkit - We should save all worlds on save-all.
this.notify(icommandlistener, "Save complete."); // CraftBukkit - notify command sender this.print(s1, "Save complete.");
} else if (s.toLowerCase().startsWith("save-off")) { } else if (s.toLowerCase().startsWith("save-off")) {
this.notify(icommandlistener, "Disabling level saving.."); // CraftBukkit - notify command sender this.print(s1, "Disabling level saving..");
worldserver.w = true; worldserver.w = true;
} else if (s.toLowerCase().startsWith("save-on")) { } else if (s.toLowerCase().startsWith("save-on")) {
this.notify(icommandlistener, "Enabling level saving.."); // CraftBukkit - notify command sender this.print(s1, "Enabling level saving..");
worldserver.w = false; worldserver.w = false;
} else { } else {
String s2; String s2;
@ -47,36 +44,36 @@ public class ConsoleCommandHandler {
if (s.toLowerCase().startsWith("op ")) { if (s.toLowerCase().startsWith("op ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.e(s2); serverconfigurationmanager.e(s2);
this.notify(icommandlistener, "Opping " + s2); // CraftBukkit - notify command sender this.print(s1, "Opping " + s2);
serverconfigurationmanager.a(s2, "\u00A7eYou are now op!"); serverconfigurationmanager.a(s2, "\u00A7eYou are now op!");
} else if (s.toLowerCase().startsWith("deop ")) { } else if (s.toLowerCase().startsWith("deop ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.f(s2); serverconfigurationmanager.f(s2);
serverconfigurationmanager.a(s2, "\u00A7eYou are no longer op!"); serverconfigurationmanager.a(s2, "\u00A7eYou are no longer op!");
this.notify(icommandlistener, "De-opping " + s2); // CraftBukkit - notify command sender this.print(s1, "De-opping " + s2);
} else if (s.toLowerCase().startsWith("ban-ip ")) { } else if (s.toLowerCase().startsWith("ban-ip ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.c(s2); serverconfigurationmanager.c(s2);
this.notify(icommandlistener, "Banning ip " + s2); // CraftBukkit - notify command sender this.print(s1, "Banning ip " + s2);
} else if (s.toLowerCase().startsWith("pardon-ip ")) { } else if (s.toLowerCase().startsWith("pardon-ip ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.d(s2); serverconfigurationmanager.d(s2);
this.notify(icommandlistener, "Pardoning ip " + s2); // CraftBukkit - notify command sender this.print(s1, "Pardoning ip " + s2);
} else { } else {
EntityPlayer entityplayer; EntityPlayer entityplayer;
if (s.toLowerCase().startsWith("ban ")) { if (s.toLowerCase().startsWith("ban ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.a(s2); serverconfigurationmanager.a(s2);
this.notify(icommandlistener, "Banning " + s2); // CraftBukkit - notify command sender this.print(s1, "Banning " + s2);
entityplayer = serverconfigurationmanager.i(s2); entityplayer = serverconfigurationmanager.i(s2);
if (entityplayer != null) { if (entityplayer != null) {
entityplayer.a.a("Banned by admin"); entityplayer.netServerHandler.disconnect("Banned by admin");
} }
} else if (s.toLowerCase().startsWith("pardon ")) { } else if (s.toLowerCase().startsWith("pardon ")) {
s2 = s.substring(s.indexOf(" ")).trim(); s2 = s.substring(s.indexOf(" ")).trim();
serverconfigurationmanager.b(s2); serverconfigurationmanager.b(s2);
this.notify(icommandlistener, "Pardoning " + s2); // CraftBukkit - notify command sender this.print(s1, "Pardoning " + s2);
} else { } else {
int i; int i;
@ -87,8 +84,8 @@ public class ConsoleCommandHandler {
// CraftBukkit end // CraftBukkit end
entityplayer = null; entityplayer = null;
for (i = 0; i < serverconfigurationmanager.b.size(); ++i) { for (i = 0; i < serverconfigurationmanager.players.size(); ++i) {
EntityPlayer entityplayer1 = (EntityPlayer) serverconfigurationmanager.b.get(i); EntityPlayer entityplayer1 = (EntityPlayer) serverconfigurationmanager.players.get(i);
if (entityplayer1.name.equalsIgnoreCase(s2)) { if (entityplayer1.name.equalsIgnoreCase(s2)) {
entityplayer = entityplayer1; entityplayer = entityplayer1;
@ -96,10 +93,10 @@ public class ConsoleCommandHandler {
} }
if (entityplayer != null) { if (entityplayer != null) {
entityplayer.a.a("Kicked by admin"); entityplayer.netServerHandler.disconnect("Kicked by admin");
this.notify(icommandlistener, "Kicking " + entityplayer.name); // CraftBukkit - notify command sender this.print(s1, "Kicking " + entityplayer.name);
} else { } else {
icommandlistener.b("Can\'t find user " + s2 + ". No kick."); icommandlistener.sendMessage("Can\'t find user " + s2 + ". No kick.");
} }
} else { } else {
String[] astring; String[] astring;
@ -111,15 +108,15 @@ public class ConsoleCommandHandler {
entityplayer = serverconfigurationmanager.i(astring[1]); entityplayer = serverconfigurationmanager.i(astring[1]);
entityplayer2 = serverconfigurationmanager.i(astring[2]); entityplayer2 = serverconfigurationmanager.i(astring[2]);
if (entityplayer == null) { if (entityplayer == null) {
icommandlistener.b("Can\'t find user " + astring[1] + ". No tp."); icommandlistener.sendMessage("Can\'t find user " + astring[1] + ". No tp.");
} else if (entityplayer2 == null) { } else if (entityplayer2 == null) {
icommandlistener.b("Can\'t find user " + astring[2] + ". No tp."); icommandlistener.sendMessage("Can\'t find user " + astring[2] + ". No tp.");
} else { } else {
entityplayer.a.a(entityplayer2.locX, entityplayer2.locY, entityplayer2.locZ, entityplayer2.yaw, entityplayer2.pitch); entityplayer.netServerHandler.a(entityplayer2.locX, entityplayer2.locY, entityplayer2.locZ, entityplayer2.yaw, entityplayer2.pitch);
this.notify(icommandlistener, "Teleporting " + astring[1] + " to " + astring[2] + "."); // CraftBukkit - notify command sender this.print(s1, "Teleporting " + astring[1] + " to " + astring[2] + ".");
} }
} else { } else {
icommandlistener.b("Syntax error, please provice a source and a target."); icommandlistener.sendMessage("Syntax error, please provice a source and a target.");
} }
} else { } else {
String s3; String s3;
@ -127,7 +124,7 @@ public class ConsoleCommandHandler {
if (s.toLowerCase().startsWith("give ")) { if (s.toLowerCase().startsWith("give ")) {
astring = s.split(" "); astring = s.split(" ");
if (astring.length != 3 && astring.length != 4) { if (astring.length != 3 && astring.length != 4) {
return true; return true; // CraftBukkit
} }
s3 = astring[1]; s3 = astring[1];
@ -137,7 +134,7 @@ public class ConsoleCommandHandler {
int j = Integer.parseInt(astring[2]); int j = Integer.parseInt(astring[2]);
if (Item.byId[j] != null) { if (Item.byId[j] != null) {
this.notify(icommandlistener, "Giving " + entityplayer2.name + " some " + j); // CraftBukkit - notify command sender this.print(s1, "Giving " + entityplayer2.name + " some " + j);
int k = 1; int k = 1;
if (astring.length > 3) { if (astring.length > 3) {
@ -154,18 +151,18 @@ public class ConsoleCommandHandler {
entityplayer2.b(new ItemStack(j, k, 0)); entityplayer2.b(new ItemStack(j, k, 0));
} else { } else {
icommandlistener.b("There\'s no item with id " + j); icommandlistener.sendMessage("There\'s no item with id " + j);
} }
} catch (NumberFormatException numberformatexception) { } catch (NumberFormatException numberformatexception) {
icommandlistener.b("There\'s no item with id " + astring[2]); icommandlistener.sendMessage("There\'s no item with id " + astring[2]);
} }
} else { } else {
icommandlistener.b("Can\'t find user " + s3); icommandlistener.sendMessage("Can\'t find user " + s3);
} }
} else if (s.toLowerCase().startsWith("time ")) { } else if (s.toLowerCase().startsWith("time ")) {
astring = s.split(" "); astring = s.split(" ");
if (astring.length != 3) { if (astring.length != 3) {
return true; return true; // CraftBukkit
} }
s3 = astring[1]; s3 = astring[1];
@ -173,21 +170,21 @@ public class ConsoleCommandHandler {
try { try {
i = Integer.parseInt(astring[2]); i = Integer.parseInt(astring[2]);
if ("add".equalsIgnoreCase(s3)) { if ("add".equalsIgnoreCase(s3)) {
worldserver.a(worldserver.k() + (long) i); worldserver.setTime(worldserver.getTime() + (long) i);
this.notify(icommandlistener, "Added " + i + " to time"); // CraftBukkit - notify command sender this.print(s1, "Added " + i + " to time");
} else if ("set".equalsIgnoreCase(s3)) { } else if ("set".equalsIgnoreCase(s3)) {
worldserver.a((long) i); worldserver.setTime((long) i);
this.notify(icommandlistener, "Set time to " + i); // CraftBukkit - notify command sender this.print(s1, "Set time to " + i);
} else { } else {
icommandlistener.b("Unknown method, use either \"add\" or \"set\""); icommandlistener.sendMessage("Unknown method, use either \"add\" or \"set\"");
} }
} catch (NumberFormatException numberformatexception1) { } catch (NumberFormatException numberformatexception1) {
icommandlistener.b("Unable to convert time value, " + astring[2]); icommandlistener.sendMessage("Unable to convert time value, " + astring[2]);
} }
} else if (s.toLowerCase().startsWith("say ")) { } else if (s.toLowerCase().startsWith("say ")) {
s = s.substring(s.indexOf(" ")).trim(); s = s.substring(s.indexOf(" ")).trim();
a.info("[" + s1 + "] " + s); a.info("[" + s1 + "] " + s);
serverconfigurationmanager.a((Packet) (new Packet3Chat("\u00A7d[Server] " + s))); serverconfigurationmanager.sendAll(new Packet3Chat("\u00A7d[Server] " + s));
} else if (s.toLowerCase().startsWith("tell ")) { } else if (s.toLowerCase().startsWith("tell ")) {
astring = s.split(" "); astring = s.split(" ");
if (astring.length >= 3) { if (astring.length >= 3) {
@ -197,14 +194,14 @@ public class ConsoleCommandHandler {
s = "\u00A77" + s1 + " whispers " + s; s = "\u00A77" + s1 + " whispers " + s;
a.info(s); a.info(s);
if (!serverconfigurationmanager.a(astring[1], (Packet) (new Packet3Chat(s)))) { if (!serverconfigurationmanager.a(astring[1], (Packet) (new Packet3Chat(s)))) {
icommandlistener.b("There\'s no player by that name online."); icommandlistener.sendMessage("There\'s no player by that name online.");
} }
} }
} else if (s.toLowerCase().startsWith("whitelist ")) { } else if (s.toLowerCase().startsWith("whitelist ")) {
this.a(s1, s, icommandlistener); this.a(s1, s, icommandlistener);
} else { } else {
icommandlistener.b("Unknown console command. Type \"help\" for help."); // CraftBukkit - Send to listener not log icommandlistener.sendMessage("Unknown console command. Type \"help\" for help."); // CraftBukkit
return false; return false; // CraftBukkit
} }
} }
} }
@ -215,23 +212,24 @@ public class ConsoleCommandHandler {
this.a(icommandlistener); this.a(icommandlistener);
} }
return true; return true; // CraftBukkit
} }
private void a(String s, String s1, ICommandListener icommandlistener) { private void a(String s, String s1, ICommandListener icommandlistener) {
String[] astring = s1.split(" "); String[] astring = s1.split(" ");
listener = icommandlistener; // CraftBukkit
if (astring.length >= 2) { if (astring.length >= 2) {
String s2 = astring[1].toLowerCase(); String s2 = astring[1].toLowerCase();
if ("on".equals(s2)) { if ("on".equals(s2)) {
this.notify(icommandlistener, "Turned on white-listing"); // CraftBukkit - notify command sender this.print(s, "Turned on white-listing");
this.b.d.b("white-list", true); this.server.propertyManager.b("white-list", true);
} else if ("off".equals(s2)) { } else if ("off".equals(s2)) {
this.notify(icommandlistener, "Turned off white-listing"); // CraftBukkit - notify command sender this.print(s, "Turned off white-listing");
this.b.d.b("white-list", false); this.server.propertyManager.b("white-list", false);
} else if ("list".equals(s2)) { } else if ("list".equals(s2)) {
Set set = this.b.f.e(); Set set = this.server.serverConfigurationManager.e();
String s3 = ""; String s3 = "";
String s4; String s4;
@ -240,63 +238,55 @@ public class ConsoleCommandHandler {
s4 = (String) iterator.next(); s4 = (String) iterator.next();
} }
icommandlistener.b("White-listed players: " + s3); icommandlistener.sendMessage("White-listed players: " + s3);
} else { } else {
String s5; String s5;
if ("add".equals(s2) && astring.length == 3) { if ("add".equals(s2) && astring.length == 3) {
s5 = astring[2].toLowerCase(); s5 = astring[2].toLowerCase();
this.b.f.k(s5); this.server.serverConfigurationManager.k(s5);
this.notify(icommandlistener, "Added " + s5 + " to white-list"); // CraftBukkit - notify command sender this.print(s, "Added " + s5 + " to white-list");
} else if ("remove".equals(s2) && astring.length == 3) { } else if ("remove".equals(s2) && astring.length == 3) {
s5 = astring[2].toLowerCase(); s5 = astring[2].toLowerCase();
this.b.f.l(s5); this.server.serverConfigurationManager.l(s5);
this.notify(icommandlistener, "Removed " + s5 + " from white-list"); // CraftBukkit - notify command sender this.print(s, "Removed " + s5 + " from white-list");
} else if ("reload".equals(s2)) { } else if ("reload".equals(s2)) {
this.b.f.f(); this.server.serverConfigurationManager.f();
this.notify(icommandlistener, "Reloaded white-list from file"); // CraftBukkit - notify command sender this.print(s, "Reloaded white-list from file");
} }
} }
} }
} }
private void a(ICommandListener icommandlistener) { private void a(ICommandListener icommandlistener) {
icommandlistener.b("To run the server without a gui, start it like this:"); icommandlistener.sendMessage("To run the server without a gui, start it like this:");
icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui"); icommandlistener.sendMessage(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
icommandlistener.b("Console commands:"); icommandlistener.sendMessage("Console commands:");
icommandlistener.b(" help or ? shows this message"); icommandlistener.sendMessage(" help or ? shows this message");
icommandlistener.b(" kick <player> removes a player from the server"); icommandlistener.sendMessage(" kick <player> removes a player from the server");
icommandlistener.b(" ban <player> bans a player from the server"); icommandlistener.sendMessage(" ban <player> bans a player from the server");
icommandlistener.b(" pardon <player> pardons a banned player so that they can connect again"); icommandlistener.sendMessage(" pardon <player> pardons a banned player so that they can connect again");
icommandlistener.b(" ban-ip <ip> bans an IP address from the server"); icommandlistener.sendMessage(" ban-ip <ip> bans an IP address from the server");
icommandlistener.b(" pardon-ip <ip> pardons a banned IP address so that they can connect again"); icommandlistener.sendMessage(" pardon-ip <ip> pardons a banned IP address so that they can connect again");
icommandlistener.b(" op <player> turns a player into an op"); icommandlistener.sendMessage(" op <player> turns a player into an op");
icommandlistener.b(" deop <player> removes op status from a player"); icommandlistener.sendMessage(" deop <player> removes op status from a player");
icommandlistener.b(" tp <player1> <player2> moves one player to the same location as another player"); icommandlistener.sendMessage(" tp <player1> <player2> moves one player to the same location as another player");
icommandlistener.b(" give <player> <id> [num] gives a player a resource"); icommandlistener.sendMessage(" give <player> <id> [num] gives a player a resource");
icommandlistener.b(" tell <player> <message> sends a private message to a player"); icommandlistener.sendMessage(" tell <player> <message> sends a private message to a player");
icommandlistener.b(" stop gracefully stops the server"); icommandlistener.sendMessage(" stop gracefully stops the server");
icommandlistener.b(" save-all forces a server-wide level save"); icommandlistener.sendMessage(" save-all forces a server-wide level save");
icommandlistener.b(" save-off disables terrain saving (useful for backup scripts)"); icommandlistener.sendMessage(" save-off disables terrain saving (useful for backup scripts)");
icommandlistener.b(" save-on re-enables terrain saving"); icommandlistener.sendMessage(" save-on re-enables terrain saving");
icommandlistener.b(" list lists all currently connected players"); icommandlistener.sendMessage(" list lists all currently connected players");
icommandlistener.b(" say <message> broadcasts a message to all players"); icommandlistener.sendMessage(" say <message> broadcasts a message to all players");
icommandlistener.b(" time <add|set> <amount> adds to or sets the world time (0-24000)"); icommandlistener.sendMessage(" time <add|set> <amount> adds to or sets the world time (0-24000)");
} }
// CraftBukkit start private void print(String s, String s1) {
// Notify sender and ops / log listener.sendMessage(s1); // CraftBukkit
private void notify(ICommandListener commandListener, String msg ) {
commandListener.b( msg );
this.a( commandListener.c(), msg );
}
// CraftBukkit end
private void a(String s, String s1) {
String s2 = s + ": " + s1; String s2 = s + ": " + s1;
// CraftBukkit - This notifies ops and logs this.server.serverConfigurationManager.j("\u00A77(" + s2 + ")");
this.b.f.j("\u00A77(" + s2 + ")");
a.info(s2); a.info(s2);
} }

View file

@ -20,7 +20,7 @@ public class ConsoleLogManager {
public ConsoleLogManager() {} public ConsoleLogManager() {}
// Craftbukkit - change of method signature! // Craftbukkit - change of method signature!
public static void a(MinecraftServer server) { public static void init(MinecraftServer server) {
ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter(); ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter();
a.setUseParentHandlers(false); a.setUseParentHandlers(false);
@ -34,6 +34,7 @@ public class ConsoleLogManager {
consolehandler.setFormatter(new ShortConsoleLogFormatter(server)); consolehandler.setFormatter(new ShortConsoleLogFormatter(server));
global.addHandler(consolehandler); global.addHandler(consolehandler);
// CraftBukkit end // CraftBukkit end
a.addHandler(consolehandler); a.addHandler(consolehandler);
try { try {

View file

@ -42,10 +42,10 @@ public abstract class Entity {
public float lastPitch; public float lastPitch;
public final AxisAlignedBB boundingBox; public final AxisAlignedBB boundingBox;
public boolean onGround; public boolean onGround;
public boolean aW; public boolean positionChanged;
public boolean aX; public boolean aX;
public boolean aY; public boolean aY;
public boolean aZ; public boolean velocityChanged;
public boolean ba; public boolean ba;
public boolean dead; public boolean dead;
public float height; public float height;
@ -88,7 +88,7 @@ public abstract class Entity {
this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
this.onGround = false; this.onGround = false;
this.aY = false; this.aY = false;
this.aZ = false; this.velocityChanged = false;
this.ba = true; this.ba = true;
this.dead = false; this.dead = false;
this.height = 0.0F; this.height = 0.0F;
@ -116,7 +116,7 @@ public abstract class Entity {
this.datawatcher = new DataWatcher(); this.datawatcher = new DataWatcher();
this.bA = false; this.bA = false;
this.world = world; this.world = world;
this.a(0.0D, 0.0D, 0.0D); this.setPosition(0.0D, 0.0D, 0.0D);
this.datawatcher.a(0, Byte.valueOf((byte) 0)); this.datawatcher.a(0, Byte.valueOf((byte) 0));
this.a(); this.a();
} }
@ -135,7 +135,7 @@ public abstract class Entity {
return this.id; return this.id;
} }
public void D() { public void die() {
this.dead = true; this.dead = true;
} }
@ -148,16 +148,16 @@ public abstract class Entity {
// Craftbukkit start // Craftbukkit start
if ((f == Float.POSITIVE_INFINITY) || (f == Float.NEGATIVE_INFINITY) || (Float.isNaN(f))) { if ((f == Float.POSITIVE_INFINITY) || (f == Float.NEGATIVE_INFINITY) || (Float.isNaN(f))) {
if (this instanceof EntityPlayer) { if (this instanceof EntityPlayer) {
System.err.println(((CraftPlayer)this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw"); System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw");
((CraftPlayer)this.getBukkitEntity()).kickPlayer("Nope"); ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
} }
f = 0; f = 0;
} }
if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY) || (Float.isNaN(f1))) { if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY) || (Float.isNaN(f1))) {
if (this instanceof EntityPlayer) { if (this instanceof EntityPlayer) {
System.err.println(((CraftPlayer)this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch"); System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch");
((CraftPlayer)this.getBukkitEntity()).kickPlayer("Nope"); ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
} }
f1 = 0; f1 = 0;
} }
@ -167,7 +167,7 @@ public abstract class Entity {
// Craftbukkit end // Craftbukkit end
} }
public void a(double d0, double d1, double d2) { public void setPosition(double d0, double d1, double d2) {
this.locX = d0; this.locX = d0;
this.locY = d1; this.locY = d1;
this.locZ = d2; this.locZ = d2;
@ -201,8 +201,8 @@ public abstract class Entity {
f = 1.0F; f = 1.0F;
} }
this.world.a(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); this.world.makeSound(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
float f1 = (float) MathHelper.b(this.boundingBox.b); float f1 = (float) MathHelper.floor(this.boundingBox.b);
int i; int i;
float f2; float f2;
@ -250,10 +250,10 @@ public abstract class Entity {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.a((Entity) null, event.getDamage()); this.damageEntity((Entity) null, event.getDamage());
} }
} else { } else {
this.a((Entity) null, 1); this.damageEntity((Entity) null, 1);
} }
// CraftBukkit end // CraftBukkit end
} }
@ -293,7 +293,7 @@ public abstract class Entity {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.a((Entity) null, event.getDamage()); this.damageEntity((Entity) null, event.getDamage());
} }
if (this.fireTicks <= 0) { if (this.fireTicks <= 0) {
@ -311,23 +311,23 @@ public abstract class Entity {
} }
// CraftBukkit end // CraftBukkit end
this.a((Entity) null, 4); this.damageEntity((Entity) null, 4);
this.fireTicks = 600; this.fireTicks = 600;
} }
} }
protected void R() { protected void R() {
this.D(); this.die();
} }
public boolean b(double d0, double d1, double d2) { public boolean b(double d0, double d1, double d2) {
AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2); AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2);
List list = this.world.a(this, axisalignedbb); List list = this.world.getEntities(this, axisalignedbb);
return list.size() > 0 ? false : !this.world.b(axisalignedbb); return list.size() > 0 ? false : !this.world.b(axisalignedbb);
} }
public void c(double d0, double d1, double d2) { public void move(double d0, double d1, double d2) {
if (this.bn) { if (this.bn) {
this.boundingBox.d(d0, d1, d2); this.boundingBox.d(d0, d1, d2);
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
@ -339,13 +339,13 @@ public abstract class Entity {
double d5 = d0; double d5 = d0;
double d6 = d1; double d6 = d1;
double d7 = d2; double d7 = d2;
AxisAlignedBB axisalignedbb = this.boundingBox.b(); AxisAlignedBB axisalignedbb = this.boundingBox.clone();
boolean flag = this.onGround && this.Z(); boolean flag = this.onGround && this.isSneaking();
if (flag) { if (flag) {
double d8; double d8;
for (d8 = 0.05D; d0 != 0.0D && this.world.a(this, this.boundingBox.c(d0, -1.0D, 0.0D)).size() == 0; d5 = d0) { for (d8 = 0.05D; d0 != 0.0D && this.world.getEntities(this, this.boundingBox.c(d0, -1.0D, 0.0D)).size() == 0; d5 = d0) {
if (d0 < d8 && d0 >= -d8) { if (d0 < d8 && d0 >= -d8) {
d0 = 0.0D; d0 = 0.0D;
} else if (d0 > 0.0D) { } else if (d0 > 0.0D) {
@ -355,7 +355,7 @@ public abstract class Entity {
} }
} }
for (; d2 != 0.0D && this.world.a(this, this.boundingBox.c(0.0D, -1.0D, d2)).size() == 0; d7 = d2) { for (; d2 != 0.0D && this.world.getEntities(this, this.boundingBox.c(0.0D, -1.0D, d2)).size() == 0; d7 = d2) {
if (d2 < d8 && d2 >= -d8) { if (d2 < d8 && d2 >= -d8) {
d2 = 0.0D; d2 = 0.0D;
} else if (d2 > 0.0D) { } else if (d2 > 0.0D) {
@ -366,7 +366,7 @@ public abstract class Entity {
} }
} }
List list = this.world.a(this, this.boundingBox.a(d0, d1, d2)); List list = this.world.getEntities(this, this.boundingBox.a(d0, d1, d2));
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1); d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1);
@ -417,10 +417,10 @@ public abstract class Entity {
d0 = d5; d0 = d5;
d1 = (double) this.bm; d1 = (double) this.bm;
d2 = d7; d2 = d7;
AxisAlignedBB axisalignedbb1 = this.boundingBox.b(); AxisAlignedBB axisalignedbb1 = this.boundingBox.clone();
this.boundingBox.b(axisalignedbb); this.boundingBox.b(axisalignedbb);
list = this.world.a(this, this.boundingBox.a(d5, d1, d7)); list = this.world.getEntities(this, this.boundingBox.a(d5, d1, d7));
for (k = 0; k < list.size(); ++k) { for (k = 0; k < list.size(); ++k) {
d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1);
@ -468,10 +468,10 @@ public abstract class Entity {
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
this.locY = this.boundingBox.b + (double) this.height - (double) this.bl; this.locY = this.boundingBox.b + (double) this.height - (double) this.bl;
this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D;
this.aW = d5 != d0 || d7 != d2; this.positionChanged = d5 != d0 || d7 != d2;
this.aX = d6 != d1; this.aX = d6 != d1;
this.onGround = d6 != d1 && d6 < 0.0D; this.onGround = d6 != d1 && d6 < 0.0D;
this.aY = this.aW || this.aX; this.aY = this.positionChanged || this.aX;
this.a(d1, this.onGround); this.a(d1, this.onGround);
if (d5 != d0) { if (d5 != d0) {
this.motX = 0.0D; this.motX = 0.0D;
@ -492,10 +492,10 @@ public abstract class Entity {
int j1; int j1;
// CraftBukkit start // CraftBukkit start
if ((this.aW) && (getBukkitEntity() instanceof Vehicle)) { if ((this.positionChanged) && (getBukkitEntity() instanceof Vehicle)) {
Vehicle vehicle = (Vehicle) getBukkitEntity(); Vehicle vehicle = (Vehicle) getBukkitEntity();
org.bukkit.World wrld = ((WorldServer) world).getWorld(); org.bukkit.World wrld = ((WorldServer) world).getWorld();
org.bukkit.block.Block block = wrld.getBlockAt(MathHelper.b(locX), MathHelper.b(locY - 0.20000000298023224D - (double) this.height), MathHelper.b(locZ)); org.bukkit.block.Block block = wrld.getBlockAt(MathHelper.floor(locX), MathHelper.floor(locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(locZ));
if (d5 > d0) { if (d5 > d0) {
block = block.getFace(BlockFace.SOUTH); block = block.getFace(BlockFace.SOUTH);
@ -514,9 +514,9 @@ public abstract class Entity {
if (this.l() && !flag) { if (this.l() && !flag) {
this.bg = (float) ((double) this.bg + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); this.bg = (float) ((double) this.bg + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D);
l = MathHelper.b(this.locX); l = MathHelper.floor(this.locX);
i1 = MathHelper.b(this.locY - 0.20000000298023224D - (double) this.height); i1 = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
j1 = MathHelper.b(this.locZ); j1 = MathHelper.floor(this.locZ);
k = this.world.getTypeId(l, i1, j1); k = this.world.getTypeId(l, i1, j1);
if (this.bg > (float) this.b && k > 0) { if (this.bg > (float) this.b && k > 0) {
++this.b; ++this.b;
@ -524,21 +524,21 @@ public abstract class Entity {
if (this.world.getTypeId(l, i1 + 1, j1) == Block.SNOW.id) { if (this.world.getTypeId(l, i1 + 1, j1) == Block.SNOW.id) {
stepsound = Block.SNOW.stepSound; stepsound = Block.SNOW.stepSound;
this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2());
} else if (!Block.byId[k].material.isLiquid()) { } else if (!Block.byId[k].material.isLiquid()) {
this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b()); this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2());
} }
Block.byId[k].b(this.world, l, i1, j1, this); Block.byId[k].b(this.world, l, i1, j1, this);
} }
} }
l = MathHelper.b(this.boundingBox.a); l = MathHelper.floor(this.boundingBox.a);
i1 = MathHelper.b(this.boundingBox.b); i1 = MathHelper.floor(this.boundingBox.b);
j1 = MathHelper.b(this.boundingBox.c); j1 = MathHelper.floor(this.boundingBox.c);
k = MathHelper.b(this.boundingBox.d); k = MathHelper.floor(this.boundingBox.d);
int k1 = MathHelper.b(this.boundingBox.e); int k1 = MathHelper.floor(this.boundingBox.e);
int l1 = MathHelper.b(this.boundingBox.f); int l1 = MathHelper.floor(this.boundingBox.f);
if (this.world.a(l, i1, j1, k, k1, l1)) { if (this.world.a(l, i1, j1, k, k1, l1)) {
for (int i2 = l; i2 <= k; ++i2) { for (int i2 = l; i2 <= k; ++i2) {
@ -583,7 +583,7 @@ public abstract class Entity {
} }
if (flag2 && this.fireTicks > 0) { if (flag2 && this.fireTicks > 0) {
this.world.a(this, "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); this.world.makeSound(this, "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
this.fireTicks = -this.maxFireTicks; this.fireTicks = -this.maxFireTicks;
} }
} }
@ -620,14 +620,14 @@ public abstract class Entity {
EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone); EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled() || event.getDamage() == 0) { if (event.isCancelled()) {
return; return;
} }
i = event.getDamage(); i = event.getDamage();
} }
// CraftBukkit end // CraftBukkit end
this.a((Entity) null, i); this.damageEntity((Entity) null, i);
} }
} }
@ -639,9 +639,9 @@ public abstract class Entity {
public boolean a(Material material) { public boolean a(Material material) {
double d0 = this.locY + (double) this.q(); double d0 = this.locY + (double) this.q();
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.d((float) MathHelper.b(d0)); int j = MathHelper.d((float) MathHelper.floor(d0));
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
int l = this.world.getTypeId(i, j, k); int l = this.world.getTypeId(i, j, k);
if (l != 0 && Block.byId[l].material == material) { if (l != 0 && Block.byId[l].material == material) {
@ -673,8 +673,8 @@ public abstract class Entity {
f3 = f2 / f3; f3 = f2 / f3;
f *= f3; f *= f3;
f1 *= f3; f1 *= f3;
float f4 = MathHelper.a(this.yaw * 3.1415927F / 180.0F); float f4 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F);
float f5 = MathHelper.b(this.yaw * 3.1415927F / 180.0F); float f5 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F);
this.motX += (double) (f * f5 - f1 * f4); this.motX += (double) (f * f5 - f1 * f4);
this.motZ += (double) (f1 * f5 + f * f4); this.motZ += (double) (f1 * f5 + f * f4);
@ -682,15 +682,15 @@ public abstract class Entity {
} }
public float c(float f) { public float c(float f) {
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D;
int j = MathHelper.b(this.locY - (double) this.height + d0); int j = MathHelper.floor(this.locY - (double) this.height + d0);
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
return this.world.a(MathHelper.b(this.boundingBox.a), MathHelper.b(this.boundingBox.b), MathHelper.b(this.boundingBox.c), MathHelper.b(this.boundingBox.d), MathHelper.b(this.boundingBox.e), MathHelper.b(this.boundingBox.f)) ? this.world.l(i, j, k) : 0.0F; return this.world.a(MathHelper.floor(this.boundingBox.a), MathHelper.floor(this.boundingBox.b), MathHelper.floor(this.boundingBox.c), MathHelper.floor(this.boundingBox.d), MathHelper.floor(this.boundingBox.e), MathHelper.floor(this.boundingBox.f)) ? this.world.l(i, j, k) : 0.0F;
} }
public void b(double d0, double d1, double d2, float f, float f1) { public void setLocation(double d0, double d1, double d2, float f, float f1) {
this.lastX = this.locX = d0; this.lastX = this.locX = d0;
this.lastY = this.locY = d1; this.lastY = this.locY = d1;
this.lastZ = this.locZ = d2; this.lastZ = this.locZ = d2;
@ -707,17 +707,17 @@ public abstract class Entity {
this.lastYaw -= 360.0F; this.lastYaw -= 360.0F;
} }
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.c(f, f1); this.c(f, f1);
} }
public void c(double d0, double d1, double d2, float f, float f1) { public void setPositionRotation(double d0, double d1, double d2, float f, float f1) {
this.bi = this.lastX = this.locX = d0; this.bi = this.lastX = this.locX = d0;
this.bj = this.lastY = this.locY = d1 + (double) this.height; this.bj = this.lastY = this.locY = d1 + (double) this.height;
this.bk = this.lastZ = this.locZ = d2; this.bk = this.lastZ = this.locZ = d2;
this.yaw = f; this.yaw = f;
this.pitch = f1; this.pitch = f1;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
public float f(Entity entity) { public float f(Entity entity) {
@ -754,7 +754,7 @@ public abstract class Entity {
public void b(EntityHuman entityhuman) {} public void b(EntityHuman entityhuman) {}
public void h(Entity entity) { public void collide(Entity entity) {
if (entity.passenger != this && entity.vehicle != this) { if (entity.passenger != this && entity.vehicle != this) {
double d0 = entity.locX - this.locX; double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ; double d1 = entity.locZ - this.locZ;
@ -789,10 +789,10 @@ public abstract class Entity {
} }
protected void W() { protected void W() {
this.aZ = true; this.velocityChanged = true;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
this.W(); this.W();
return false; return false;
} }
@ -811,7 +811,7 @@ public abstract class Entity {
String s = this.X(); String s = this.X();
if (!this.dead && s != null) { if (!this.dead && s != null) {
nbttagcompound.a("id", s); nbttagcompound.setString("id", s);
this.d(nbttagcompound); this.d(nbttagcompound);
return true; return true;
} else { } else {
@ -827,7 +827,7 @@ public abstract class Entity {
nbttagcompound.a("Fire", (short) this.fireTicks); nbttagcompound.a("Fire", (short) this.fireTicks);
nbttagcompound.a("Air", (short) this.airTicks); nbttagcompound.a("Air", (short) this.airTicks);
nbttagcompound.a("OnGround", this.onGround); nbttagcompound.a("OnGround", this.onGround);
nbttagcompound.a("World", world.q.j); // CraftBukkit nbttagcompound.setString("World", world.worldData.name); // CraftBukkit
this.a(nbttagcompound); this.a(nbttagcompound);
} }
@ -836,7 +836,7 @@ public abstract class Entity {
NBTTagList nbttaglist1 = nbttagcompound.l("Motion"); NBTTagList nbttaglist1 = nbttagcompound.l("Motion");
NBTTagList nbttaglist2 = nbttagcompound.l("Rotation"); NBTTagList nbttaglist2 = nbttagcompound.l("Rotation");
this.a(0.0D, 0.0D, 0.0D); this.setPosition(0.0D, 0.0D, 0.0D);
this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a;
this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a;
this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a; this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a;
@ -868,16 +868,16 @@ public abstract class Entity {
this.onGround = nbttagcompound.m("OnGround"); this.onGround = nbttagcompound.m("OnGround");
// CraftBukkit start // CraftBukkit start
if (nbttagcompound.b("World")) { if (nbttagcompound.hasKey("World")) {
String worldName = nbttagcompound.i("World"); String worldName = nbttagcompound.getString("World");
for (WorldServer world: ((WorldServer) this.world).getServer().getServer().worlds) { for (WorldServer world: ((WorldServer) this.world).getServer().getServer().worlds) {
if ((world.q.j.equals(worldName)) && (world != this.world)) { if ((world.worldData.name.equals(worldName)) && (world != this.world)) {
this.world = world; this.world = world;
if (this instanceof EntityHuman) { if (this instanceof EntityHuman) {
EntityPlayer player = (EntityPlayer)this; EntityPlayer player = (EntityPlayer)this;
player.c = new ItemInWorldManager(world); player.itemInWorldManager = new ItemInWorldManager(world);
player.c.a = player; player.itemInWorldManager.player = player;
} }
break; break;
} }
@ -885,7 +885,7 @@ public abstract class Entity {
} }
// CraftBukkit end // CraftBukkit end
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.b(nbttagcompound); this.b(nbttagcompound);
} }
@ -936,8 +936,8 @@ public abstract class Entity {
public EntityItem a(ItemStack itemstack, float f) { public EntityItem a(ItemStack itemstack, float f) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.c = 10; entityitem.pickupDelay = 10;
this.world.a((Entity) entityitem); this.world.addEntity(entityitem);
return entityitem; return entityitem;
} }
@ -946,9 +946,9 @@ public abstract class Entity {
} }
public boolean E() { public boolean E() {
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.b(this.locY + (double) this.q()); int j = MathHelper.floor(this.locY + (double) this.q());
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
return this.world.d(i, j, k); return this.world.d(i, j, k);
} }
@ -1016,7 +1016,7 @@ public abstract class Entity {
} }
public void h_() { public void h_() {
this.passenger.a(this.locX, this.locY + this.k() + this.passenger.C(), this.locZ); this.passenger.setPosition(this.locX, this.locY + this.k() + this.passenger.C(), this.locZ);
} }
public double C() { public double C() {
@ -1027,7 +1027,7 @@ public abstract class Entity {
return (double) this.width * 0.75D; return (double) this.width * 0.75D;
} }
public void b(Entity entity) { public void mount(Entity entity) {
// CraftBukkit start // CraftBukkit start
setPassengerOf(entity); setPassengerOf(entity);
} }
@ -1060,7 +1060,7 @@ public abstract class Entity {
} }
// CraftBukkit end // CraftBukkit end
this.c(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.width, this.vehicle.locZ, this.yaw, this.pitch); this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.width, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null; this.vehicle.passenger = null;
} }
@ -1078,7 +1078,7 @@ public abstract class Entity {
this.vehicle.passenger = null; this.vehicle.passenger = null;
this.vehicle = null; this.vehicle = null;
this.c(entity.locX, entity.boundingBox.b + (double) entity.width, entity.locZ, this.yaw, this.pitch); this.setPositionRotation(entity.locX, entity.boundingBox.b + (double) entity.width, entity.locZ, this.yaw, this.pitch);
} else { } else {
if (this.vehicle != null) { if (this.vehicle != null) {
this.vehicle.passenger = null; this.vehicle.passenger = null;
@ -1099,15 +1099,15 @@ public abstract class Entity {
public void Y() {} public void Y() {}
public ItemStack[] k_() { public ItemStack[] getEquipment() {
return null; return null;
} }
public boolean Z() { public boolean isSneaking() {
return this.d(1); return this.d(1);
} }
public void e(boolean flag) { public void setSneak(boolean flag) {
this.a(1, flag); this.a(1, flag);
} }

View file

@ -17,7 +17,7 @@ public class EntityArrow extends Entity {
private int f = 0; private int f = 0;
private boolean g = false; private boolean g = false;
public int a = 0; public int a = 0;
public EntityLiving b; public EntityLiving shooter;
private int h; private int h;
private int i = 0; private int i = 0;
@ -29,23 +29,23 @@ public class EntityArrow extends Entity {
public EntityArrow(World world, double d0, double d1, double d2) { public EntityArrow(World world, double d0, double d1, double d2) {
super(world); super(world);
this.b(0.5F, 0.5F); this.b(0.5F, 0.5F);
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.height = 0.0F; this.height = 0.0F;
} }
public EntityArrow(World world, EntityLiving entityliving) { public EntityArrow(World world, EntityLiving entityliving) {
super(world); super(world);
this.b = entityliving; this.shooter = entityliving;
this.b(0.5F, 0.5F); this.b(0.5F, 0.5F);
this.c(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D; this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F)); this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F));
this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F)); this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F));
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F)); this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F));
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
@ -92,7 +92,7 @@ public class EntityArrow extends Entity {
if (i == this.f) { if (i == this.f) {
++this.h; ++this.h;
if (this.h == 1200) { if (this.h == 1200) {
this.D(); this.die();
} }
return; return;
@ -108,14 +108,14 @@ public class EntityArrow extends Entity {
++this.i; ++this.i;
} }
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ); Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ); vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); vec3d1 = Vec3D.create(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.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
Entity entity = null; Entity entity = null;
@ -127,7 +127,7 @@ public class EntityArrow extends Entity {
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.d_() && (entity1 != this.b || this.i >= 5)) { if (entity1.d_() && (entity1 != this.shooter || this.i >= 5)) {
f1 = 0.3F; f1 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f1, (double) f1, (double) f1); AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f1, (double) f1, (double) f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@ -150,7 +150,7 @@ public class EntityArrow extends Entity {
float f2; float f2;
if (movingobjectposition != null) { if (movingobjectposition != null) {
if (movingobjectposition.g != null) { if (movingobjectposition.entity != null) {
// CraftBukkit start // CraftBukkit start
boolean stick; boolean stick;
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
@ -158,8 +158,8 @@ public class EntityArrow extends Entity {
// 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 = (this.b == null) ? null : this.b.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.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;
@ -169,18 +169,18 @@ public class EntityArrow extends Entity {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.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
stick = movingobjectposition.g.a(this.b, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.shooter, 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
stick = !event.getBounce(); stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.g.a(this.b, 4); stick = movingobjectposition.entity.damageEntity(this.shooter, 4);
} }
if (stick) { if (stick) {
// CraftBukkit end // CraftBukkit end
this.world.a(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
this.D(); this.die();
} else { } else {
this.motX *= -0.10000000149011612D; this.motX *= -0.10000000149011612D;
this.motY *= -0.10000000149011612D; this.motY *= -0.10000000149011612D;
@ -201,7 +201,7 @@ public class EntityArrow extends Entity {
this.locX -= this.motX / (double) f2 * 0.05000000074505806D; this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
this.locY -= this.motY / (double) f2 * 0.05000000074505806D; this.locY -= this.motY / (double) f2 * 0.05000000074505806D;
this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D; this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D;
this.world.a(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
this.g = true; this.g = true;
this.a = 7; this.a = 7;
} }
@ -248,7 +248,7 @@ public class EntityArrow extends Entity {
this.motY *= (double) f3; this.motY *= (double) f3;
this.motZ *= (double) f3; this.motZ *= (double) f3;
this.motY -= (double) f1; this.motY -= (double) f1;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -271,10 +271,10 @@ public class EntityArrow extends Entity {
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
if (!this.world.isStatic) { if (!this.world.isStatic) {
if (this.g && this.b == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) { if (this.g && this.shooter == entityhuman && this.a <= 0 && entityhuman.inventory.canHold(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); this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.b(this, 1); entityhuman.receive(this, 1);
this.D(); this.die();
} }
} }
} }

View file

@ -18,7 +18,7 @@ import org.bukkit.event.vehicle.VehicleUpdateEvent;
public class EntityBoat extends Entity { public class EntityBoat extends Entity {
public int a; public int damage;
public int b; public int b;
public int c; public int c;
private int d; private int d;
@ -31,7 +31,8 @@ public class EntityBoat extends Entity {
// CraftBukkit start // CraftBukkit start
public double maxSpeed = 0.4D; public double maxSpeed = 0.4D;
public void h(Entity entity) { @Override
public void collide(Entity entity) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
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();
@ -43,13 +44,13 @@ public class EntityBoat extends Entity {
return; return;
} }
super.h(entity); super.collide(entity);
} }
// CraftBukkit end // CraftBukkit end
public EntityBoat(World world) { public EntityBoat(World world) {
super(world); super(world);
this.a = 0; this.damage = 0;
this.b = 0; this.b = 0;
this.c = 1; this.c = 1;
this.aD = true; this.aD = true;
@ -77,7 +78,7 @@ public class EntityBoat extends Entity {
public EntityBoat(World world, double d0, double d1, double d2) { public EntityBoat(World world, double d0, double d1, double d2) {
this(world); this(world);
this.a(d0, d1 + (double) this.height, d2); this.setPosition(d0, d1 + (double) this.height, d2);
this.motX = 0.0D; this.motX = 0.0D;
this.motY = 0.0D; this.motY = 0.0D;
this.motZ = 0.0D; this.motZ = 0.0D;
@ -97,7 +98,7 @@ public class EntityBoat extends Entity {
return (double) this.width * 0.0D - 0.30000001192092896D; return (double) this.width * 0.0D - 0.30000001192092896D;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (!this.world.isStatic && !this.dead) { if (!this.world.isStatic && !this.dead) {
// CraftBukkit start // CraftBukkit start
Vehicle vehicle = (Vehicle) this.getBukkitEntity(); Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@ -114,16 +115,16 @@ public class EntityBoat extends Entity {
this.c = -this.c; this.c = -this.c;
this.b = 10; this.b = 10;
this.a += i * 10; this.damage += i * 10;
this.W(); this.W();
if (this.a > 40) { if (this.damage > 40) {
// CraftBukkit start // CraftBukkit start
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
((WorldServer) this.world).getServer().getPluginManager().callEvent(destroyEvent); ((WorldServer) this.world).getServer().getPluginManager().callEvent(destroyEvent);
if (destroyEvent.isCancelled()) { if (destroyEvent.isCancelled()) {
this.a = 40; // Maximize damage so this doesn't get triggered again right away this.damage = 40; // Maximize damage so this doesn't get triggered again right away
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
@ -138,7 +139,7 @@ public class EntityBoat extends Entity {
this.a(Item.STICK.id, 1, 0.0F); this.a(Item.STICK.id, 1, 0.0F);
} }
this.D(); this.die();
} }
return true; return true;
@ -165,8 +166,8 @@ public class EntityBoat extends Entity {
--this.b; --this.b;
} }
if (this.a > 0) { if (this.damage > 0) {
--this.a; --this.damage;
} }
this.lastX = this.locX; this.lastX = this.locX;
@ -207,13 +208,13 @@ public class EntityBoat extends Entity {
this.yaw = (float) ((double) this.yaw + d6 / (double) this.d); this.yaw = (float) ((double) this.yaw + d6 / (double) this.d);
this.pitch = (float) ((double) this.pitch + (this.i - (double) this.pitch) / (double) this.d); this.pitch = (float) ((double) this.pitch + (this.i - (double) this.pitch) / (double) this.d);
--this.d; --this.d;
this.a(d3, d4, d5); this.setPosition(d3, d4, d5);
this.c(this.yaw, this.pitch); this.c(this.yaw, this.pitch);
} else { } else {
d3 = this.locX + this.motX; d3 = this.locX + this.motX;
d4 = this.locY + this.motY; d4 = this.locY + this.motY;
d5 = this.locZ + this.motZ; d5 = this.locZ + this.motZ;
this.a(d3, d4, d5); this.setPosition(d3, d4, d5);
if (this.onGround) { if (this.onGround) {
this.motX *= 0.5D; this.motX *= 0.5D;
this.motY *= 0.5D; this.motY *= 0.5D;
@ -256,7 +257,7 @@ public class EntityBoat extends Entity {
this.motZ *= 0.5D; this.motZ *= 0.5D;
} }
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
d5 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); d5 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
double d7; double d7;
@ -282,9 +283,9 @@ public class EntityBoat extends Entity {
} }
} }
if (this.aW && d5 > 0.15D) { if (this.positionChanged && d5 > 0.15D) {
if (!this.world.isStatic) { if (!this.world.isStatic) {
this.D(); this.die();
int k; int k;
@ -354,7 +355,7 @@ public class EntityBoat extends Entity {
Entity entity = (Entity) list.get(l); Entity entity = (Entity) list.get(l);
if (entity != this.passenger && entity.e_() && entity instanceof EntityBoat) { if (entity != this.passenger && entity.e_() && entity instanceof EntityBoat) {
entity.h(this); entity.collide(this);
} }
} }
} }
@ -370,7 +371,7 @@ public class EntityBoat extends Entity {
double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; 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; 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.C(), this.locZ + d1); this.passenger.setPosition(this.locX + d0, this.locY + this.k() + this.passenger.C(), this.locZ + d1);
} }
} }
@ -396,7 +397,7 @@ public class EntityBoat extends Entity {
} }
// CraftBukkit end // CraftBukkit end
entityhuman.b((Entity) this); entityhuman.mount(this);
} }
return true; return true;

View file

@ -44,7 +44,7 @@ public class EntityCow extends EntityAnimal {
} }
public boolean a(EntityHuman entityhuman) { public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.b(); ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.id == Item.BUCKET.id) { if (itemstack != null && itemstack.id == Item.BUCKET.id) {
// CraftBukkit start - got milk? // CraftBukkit start - got milk?
@ -59,7 +59,7 @@ public class EntityCow extends EntityAnimal {
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data );
entityhuman.inventory.a(entityhuman.inventory.c, itemstack); entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack);
// CraftBukkit end // CraftBukkit end
return true; return true;

View file

@ -9,10 +9,9 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end // CraftBukkit end
public class EntityCreature extends EntityLiving { public class EntityCreature extends EntityLiving {
// CraftBukkit start - both public
public PathEntity a; public PathEntity pathEntity; // CraftBukkit - public
public Entity d; public Entity target; // CraftBukkit - public
// CraftBukkit end
protected boolean e = false; protected boolean e = false;
public EntityCreature(World world) { public EntityCreature(World world) {
@ -27,9 +26,9 @@ public class EntityCreature extends EntityLiving {
this.e = this.u(); this.e = this.u();
float f = 16.0F; float f = 16.0F;
if (this.d == null) { if (this.target == null) {
// CraftBukkit start // CraftBukkit start
Entity target = this.m(); Entity target = this.findTarget();
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.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
@ -37,17 +36,17 @@ public class EntityCreature extends EntityLiving {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) { if (event.getTarget() == null) {
this.d = null; this.target = null;
} else { } else {
this.d = ((CraftEntity) event.getTarget()).getHandle(); this.target = ((CraftEntity) event.getTarget()).getHandle();
} }
} }
} }
// CraftBukkit end // CraftBukkit end
if (this.d != null) { if (this.target != null) {
this.a = this.world.a(this, this.d, f); this.pathEntity = this.world.findPath(this, this.target, f);
} }
} else if (!this.d.N()) { } else if (!this.target.N()) {
// 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.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
@ -55,23 +54,23 @@ public class EntityCreature extends EntityLiving {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) { if (event.getTarget() == null) {
this.d = null; this.target = null;
} else { } else {
this.d = ((CraftEntity) event.getTarget()).getHandle(); this.target = ((CraftEntity) event.getTarget()).getHandle();
} }
} }
// CraftBukkit end // CraftBukkit end
} else { } else {
float f1 = this.d.f(this); float f1 = this.target.f(this);
if (this.e(this.d)) { if (this.e(this.target)) {
this.a(this.d, f1); this.a(this.target, f1);
} }
} }
if (!this.e && this.d != null && (this.a == null || this.random.nextInt(20) == 0)) { if (!this.e && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) {
this.a = this.world.a(this, this.d, f); this.pathEntity = this.world.findPath(this, this.target, f);
} else if (!this.e && (this.a == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0)) { } else if (!this.e && (this.pathEntity == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0)) {
boolean flag = false; boolean flag = false;
int i = -1; int i = -1;
int j = -1; int j = -1;
@ -79,9 +78,9 @@ public class EntityCreature extends EntityLiving {
float f2 = -99999.0F; float f2 = -99999.0F;
for (int l = 0; l < 10; ++l) { for (int l = 0; l < 10; ++l) {
int i1 = MathHelper.b(this.locX + (double) this.random.nextInt(13) - 6.0D); int i1 = MathHelper.floor(this.locX + (double) this.random.nextInt(13) - 6.0D);
int j1 = MathHelper.b(this.locY + (double) this.random.nextInt(7) - 3.0D); int j1 = MathHelper.floor(this.locY + (double) this.random.nextInt(7) - 3.0D);
int k1 = MathHelper.b(this.locZ + (double) this.random.nextInt(13) - 6.0D); int k1 = MathHelper.floor(this.locZ + (double) this.random.nextInt(13) - 6.0D);
float f3 = this.a(i1, j1, k1); float f3 = this.a(i1, j1, k1);
if (f3 > f2) { if (f3 > f2) {
@ -94,26 +93,26 @@ public class EntityCreature extends EntityLiving {
} }
if (flag) { if (flag) {
this.a = this.world.a(this, i, j, k, 10.0F); this.pathEntity = this.world.a(this, i, j, k, 10.0F);
} }
} }
int l1 = MathHelper.b(this.boundingBox.b); int l1 = MathHelper.floor(this.boundingBox.b);
boolean flag1 = this.g_(); boolean flag1 = this.g_();
boolean flag2 = this.V(); boolean flag2 = this.V();
this.pitch = 0.0F; this.pitch = 0.0F;
if (this.a != null && this.random.nextInt(100) != 0) { if (this.pathEntity != null && this.random.nextInt(100) != 0) {
Vec3D vec3d = this.a.a(this); Vec3D vec3d = this.pathEntity.a(this);
double d0 = (double) (this.length * 2.0F); double d0 = (double) (this.length * 2.0F);
while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) { while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) {
this.a.a(); this.pathEntity.a();
if (this.a.b()) { if (this.pathEntity.b()) {
vec3d = null; vec3d = null;
this.a = null; this.pathEntity = null;
} else { } else {
vec3d = this.a.a(this); vec3d = this.pathEntity.a(this);
} }
} }
@ -143,15 +142,15 @@ public class EntityCreature extends EntityLiving {
} }
this.yaw += f5; this.yaw += f5;
if (this.e && this.d != null) { if (this.e && this.target != null) {
double d4 = this.d.locX - this.locX; double d4 = this.target.locX - this.locX;
double d5 = this.d.locZ - this.locZ; double d5 = this.target.locZ - this.locZ;
float f6 = this.yaw; float f6 = this.yaw;
this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F; this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
f5 = (f6 - this.yaw + 90.0F) * 3.1415927F / 180.0F; f5 = (f6 - this.yaw + 90.0F) * 3.1415927F / 180.0F;
this.au = -MathHelper.a(f5) * this.av * 1.0F; this.au = -MathHelper.sin(f5) * this.av * 1.0F;
this.av = MathHelper.b(f5) * this.av * 1.0F; this.av = MathHelper.cos(f5) * this.av * 1.0F;
} }
if (d3 > 0.0D) { if (d3 > 0.0D) {
@ -159,11 +158,11 @@ public class EntityCreature extends EntityLiving {
} }
} }
if (this.d != null) { if (this.target != null) {
this.a(this.d, 30.0F, 30.0F); this.a(this.target, 30.0F, 30.0F);
} }
if (this.aW) { if (this.positionChanged) {
this.ax = true; this.ax = true;
} }
@ -172,7 +171,7 @@ public class EntityCreature extends EntityLiving {
} }
} else { } else {
super.c_(); super.c_();
this.a = null; this.pathEntity = null;
} }
} }
@ -182,31 +181,31 @@ public class EntityCreature extends EntityLiving {
return 0.0F; return 0.0F;
} }
protected Entity m() { protected Entity findTarget() {
return null; return null;
} }
public boolean b() { public boolean b() {
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.b(this.boundingBox.b); int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
return super.b() && this.a(i, j, k) >= 0.0F; return super.b() && this.a(i, j, k) >= 0.0F;
} }
public boolean z() { public boolean z() {
return this.a != null; return this.pathEntity != null;
} }
public void a(PathEntity pathentity) { public void a(PathEntity pathentity) {
this.a = pathentity; this.pathEntity = pathentity;
} }
public Entity A() { public Entity A() {
return this.d; return this.target;
} }
public void c(Entity entity) { public void c(Entity entity) {
this.d = entity; this.target = entity;
} }
} }

View file

@ -8,7 +8,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
public class EntityCreeper extends EntityMonster { public class EntityCreeper extends EntityMonster {
int a; int fuseTicks;
int b; int b;
public EntityCreeper(World world) { public EntityCreeper(World world) {
@ -30,21 +30,21 @@ public class EntityCreeper extends EntityMonster {
} }
public void f_() { public void f_() {
this.b = this.a; this.b = this.fuseTicks;
if (this.world.isStatic) { if (this.world.isStatic) {
int i = this.v(); int i = this.v();
if (i > 0 && this.a == 0) { if (i > 0 && this.fuseTicks == 0) {
this.world.a(this, "random.fuse", 1.0F, 0.5F); this.world.makeSound(this, "random.fuse", 1.0F, 0.5F);
} }
this.a += i; this.fuseTicks += i;
if (this.a < 0) { if (this.fuseTicks < 0) {
this.a = 0; this.fuseTicks = 0;
} }
if (this.a >= 30) { if (this.fuseTicks >= 30) {
this.a = 30; this.fuseTicks = 30;
} }
} }
@ -71,18 +71,18 @@ public class EntityCreeper extends EntityMonster {
if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) { if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) {
this.e(-1); this.e(-1);
--this.a; --this.fuseTicks;
if (this.a < 0) { if (this.fuseTicks < 0) {
this.a = 0; this.fuseTicks = 0;
} }
} else { } else {
if (this.a == 0) { if (this.fuseTicks == 0) {
this.world.a(this, "random.fuse", 1.0F, 0.5F); this.world.makeSound(this, "random.fuse", 1.0F, 0.5F);
} }
this.e(1); this.e(1);
++this.a; ++this.fuseTicks;
if (this.a >= 30) { if (this.fuseTicks >= 30) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
@ -90,10 +90,10 @@ public class EntityCreeper extends EntityMonster {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.world.a(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
this.D(); this.die();
} else { } else {
this.a = 0; this.fuseTicks = 0;
} }
// CraftBukkit end // CraftBukkit end
} }

View file

@ -21,7 +21,7 @@ public class EntityEgg extends Entity {
private int e = 0; private int e = 0;
private boolean f = false; private boolean f = false;
public int a = 0; public int a = 0;
private EntityLiving g; private EntityLiving thrower;
private int h; private int h;
private int i = 0; private int i = 0;
@ -34,19 +34,19 @@ public class EntityEgg extends Entity {
public EntityEgg(World world, EntityLiving entityliving) { public EntityEgg(World world, EntityLiving entityliving) {
super(world); super(world);
this.g = entityliving; this.thrower = entityliving;
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.c(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D; this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
float f = 0.4F; 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.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(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.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f); this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
@ -54,7 +54,7 @@ public class EntityEgg extends Entity {
super(world); super(world);
this.h = 0; this.h = 0;
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.height = 0.0F; this.height = 0.0F;
} }
@ -95,7 +95,7 @@ public class EntityEgg extends Entity {
if (i == this.e) { if (i == this.e) {
++this.h; ++this.h;
if (this.h == 1200) { if (this.h == 1200) {
this.D(); this.die();
} }
return; return;
@ -111,14 +111,14 @@ public class EntityEgg extends Entity {
++this.i; ++this.i;
} }
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ); Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ); vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); vec3d1 = Vec3D.create(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.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
if (!this.world.isStatic) { if (!this.world.isStatic) {
@ -129,7 +129,7 @@ public class EntityEgg extends Entity {
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.d_() && (entity1 != this.g || this.i >= 5)) { if (entity1.d_() && (entity1 != this.thrower || this.i >= 5)) {
float f = 0.3F; float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@ -152,12 +152,12 @@ public class EntityEgg extends Entity {
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start // CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (this.g == null) ? null : this.g.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.thrower == null) ? null : this.thrower.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.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;
@ -168,13 +168,13 @@ public class EntityEgg extends Entity {
if (!event.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
stick = movingobjectposition.g.a(this.g, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.thrower, 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
stick = !event.getBounce(); stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.g.a(this.g, 0); stick = movingobjectposition.entity.damageEntity(this.thrower, 0);
} }
if (stick) { if (stick) {
@ -190,9 +190,9 @@ public class EntityEgg extends Entity {
CreatureType hatchingType = CreatureType.CHICKEN; CreatureType hatchingType = CreatureType.CHICKEN;
if (this.g instanceof EntityPlayer) { if (this.thrower instanceof EntityPlayer) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
Player player = (this.g == null) ? null : (Player) this.g.getBukkitEntity(); Player player = (this.thrower == null) ? null : (Player) this.thrower.getBukkitEntity();
PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
@ -258,9 +258,9 @@ public class EntityEgg extends Entity {
// The world we're spawning in accepts this creature // The world we're spawning in accepts this creature
boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal; boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal;
if ((isAnimal && this.world.E) || (!isAnimal && this.world.D)) { if ((isAnimal && this.world.allowAnimals) || (!isAnimal && this.world.allowMonsters)) {
entity.c(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entity.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
this.world.a(entity); this.world.addEntity(entity);
} }
} }
} }
@ -270,7 +270,7 @@ public class EntityEgg extends Entity {
this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
} }
this.D(); this.die();
} }
this.locX += this.motX; this.locX += this.motX;
@ -315,7 +315,7 @@ public class EntityEgg extends Entity {
this.motY *= (double) f2; this.motY *= (double) f2;
this.motZ *= (double) f2; this.motZ *= (double) f2;
this.motY -= (double) f3; this.motY -= (double) f3;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -337,10 +337,10 @@ public class EntityEgg extends Entity {
} }
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
if (this.f && this.g == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) { if (this.f && this.thrower == entityhuman && this.a <= 0 && entityhuman.inventory.canHold(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); this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.b(this, 1); entityhuman.receive(this, 1);
this.D(); this.die();
} }
} }
} }

View file

@ -19,7 +19,7 @@ public class EntityFireball extends Entity {
private int h = 0; private int h = 0;
private boolean i = false; private boolean i = false;
public int a = 0; public int a = 0;
private EntityLiving j; private EntityLiving shooter;
private int k; private int k;
private int l = 0; private int l = 0;
public double b; public double b;
@ -35,10 +35,10 @@ public class EntityFireball extends Entity {
public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(world); super(world);
this.j = entityliving; this.shooter = entityliving;
this.b(1.0F, 1.0F); this.b(1.0F, 1.0F);
this.c(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
this.motX = this.motY = this.motZ = 0.0D; this.motX = this.motY = this.motZ = 0.0D;
d0 += this.random.nextGaussian() * 0.4D; d0 += this.random.nextGaussian() * 0.4D;
@ -64,7 +64,7 @@ public class EntityFireball extends Entity {
if (i == this.h) { if (i == this.h) {
++this.k; ++this.k;
if (this.k == 1200) { if (this.k == 1200) {
this.D(); this.die();
} }
return; return;
@ -80,14 +80,14 @@ public class EntityFireball extends Entity {
++this.l; ++this.l;
} }
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ); Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ); vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); vec3d1 = Vec3D.create(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.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
Entity entity = null; Entity entity = null;
@ -97,7 +97,7 @@ public class EntityFireball extends Entity {
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.d_() && (entity1 != this.j || this.l >= 25)) { if (entity1.d_() && (entity1 != this.shooter || this.l >= 25)) {
float f = 0.3F; float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@ -119,12 +119,12 @@ public class EntityFireball extends Entity {
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start // CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (this.j == null) ? null : this.j.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.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;
@ -135,13 +135,13 @@ public class EntityFireball extends Entity {
if (!event.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
stick = movingobjectposition.g.a(this.j, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.shooter, 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
stick = !event.getBounce(); stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.g.a(this.j, 0); stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
} }
if (stick) { if (stick) {
; ;
@ -154,8 +154,8 @@ public class EntityFireball extends Entity {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage // give 'this' instead of (Entity) null so we know what causes the damage
this.world.a(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
this.D(); this.die();
} }
// CraftBukkit end // CraftBukkit end
} }
@ -204,7 +204,7 @@ public class EntityFireball extends Entity {
this.motY *= (double) f2; this.motY *= (double) f2;
this.motZ *= (double) f2; this.motZ *= (double) f2;
this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); 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); this.setPosition(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -229,7 +229,7 @@ public class EntityFireball extends Entity {
return true; return true;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
this.W(); this.W();
if (entity != null) { if (entity != null) {
Vec3D vec3d = entity.S(); Vec3D vec3d = entity.S();

View file

@ -17,7 +17,7 @@ public class EntityFish extends Entity {
private int g = 0; private int g = 0;
private boolean h = false; private boolean h = false;
public int a = 0; public int a = 0;
public EntityHuman b; public EntityHuman owner;
private int i; private int i;
private int j = 0; private int j = 0;
private int k = 0; private int k = 0;
@ -38,20 +38,20 @@ public class EntityFish extends Entity {
public EntityFish(World world, EntityHuman entityhuman) { public EntityFish(World world, EntityHuman entityhuman) {
super(world); super(world);
this.b = entityhuman; this.owner = entityhuman;
this.b.hookedFish = this; this.owner.hookedFish = this;
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.c(entityhuman.locX, entityhuman.locY + 1.62D - (double) entityhuman.height, entityhuman.locZ, entityhuman.yaw, entityhuman.pitch); this.setPositionRotation(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.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D; this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
float f = 0.4F; 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.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(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.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f); this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
@ -97,15 +97,15 @@ public class EntityFish extends Entity {
this.yaw = (float) ((double) this.yaw + d3 / (double) this.l); this.yaw = (float) ((double) this.yaw + d3 / (double) this.l);
this.pitch = (float) ((double) this.pitch + (this.q - (double) this.pitch) / (double) this.l); this.pitch = (float) ((double) this.pitch + (this.q - (double) this.pitch) / (double) this.l);
--this.l; --this.l;
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.c(this.yaw, this.pitch); this.c(this.yaw, this.pitch);
} else { } else {
if (!this.world.isStatic) { if (!this.world.isStatic) {
ItemStack itemstack = this.b.A(); ItemStack itemstack = this.owner.A();
if (this.b.dead || !this.b.N() || itemstack == null || itemstack.a() != Item.FISHING_ROD || this.g(this.b) > 1024.0D) { if (this.owner.dead || !this.owner.N() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.g(this.owner) > 1024.0D) {
this.D(); this.die();
this.b.hookedFish = null; this.owner.hookedFish = null;
return; return;
} }
@ -131,7 +131,7 @@ public class EntityFish extends Entity {
if (i == this.g) { if (i == this.g) {
++this.i; ++this.i;
if (this.i == 1200) { if (this.i == 1200) {
this.D(); this.die();
} }
return; return;
@ -147,14 +147,14 @@ public class EntityFish extends Entity {
++this.j; ++this.j;
} }
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ); Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ); vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); vec3d1 = Vec3D.create(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.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
Entity entity = null; Entity entity = null;
@ -166,7 +166,7 @@ public class EntityFish extends Entity {
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.d_() && (entity1 != this.b || this.j >= 5)) { if (entity1.d_() && (entity1 != this.owner || this.j >= 5)) {
float f = 0.3F; float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@ -186,14 +186,14 @@ public class EntityFish extends Entity {
} }
if (movingobjectposition != null) { if (movingobjectposition != null) {
if (movingobjectposition.g != null) { if (movingobjectposition.entity != null) {
// CraftBukkit start // CraftBukkit start
// TODO add EntityDamagedByProjectileEvent : fishing hook? // TODO add EntityDamagedByProjectileEvent : fishing hook?
boolean stick; boolean stick;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (this.b == null) ? null : this.b.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.owner == null) ? null : this.owner.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.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;
@ -204,17 +204,17 @@ public class EntityFish extends Entity {
if (!event.isCancelled()) { if (!event.isCancelled()) {
// this function returns if the fish should stick or not, i.e. !bounce // this function returns if the fish should stick or not, i.e. !bounce
stick = movingobjectposition.g.a(this.b, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.owner, event.getDamage());
} else { } else {
// event was cancelled, get if the fish should bounce or not // event was cancelled, get if the fish should bounce or not
stick = !event.getBounce(); stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.g.a(this.b, 0); stick = movingobjectposition.entity.damageEntity(this.owner, 0);
} }
if (!stick) { if (!stick) {
// CraftBukkit end // CraftBukkit end
this.c = movingobjectposition.g; this.c = movingobjectposition.entity;
} }
} else { } else {
this.h = true; this.h = true;
@ -222,7 +222,7 @@ public class EntityFish extends Entity {
} }
if (!this.h) { if (!this.h) {
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
float f1 = MathHelper.a(this.motX * this.motX + this.motZ * 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); this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
@ -247,7 +247,7 @@ public class EntityFish extends Entity {
this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.92F; float f2 = 0.92F;
if (this.onGround || this.aW) { if (this.onGround || this.positionChanged) {
f2 = 0.5F; f2 = 0.5F;
} }
@ -270,8 +270,8 @@ public class EntityFish extends Entity {
} else if (this.random.nextInt(500) == 0) { } else if (this.random.nextInt(500) == 0) {
this.k = this.random.nextInt(30) + 10; this.k = this.random.nextInt(30) + 10;
this.motY -= 0.20000000298023224D; this.motY -= 0.20000000298023224D;
this.world.a(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); this.world.makeSound(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
float f3 = (float) MathHelper.b(this.boundingBox.b); float f3 = (float) MathHelper.floor(this.boundingBox.b);
int l; int l;
float f4; float f4;
@ -305,7 +305,7 @@ public class EntityFish extends Entity {
this.motX *= (double) f2; this.motX *= (double) f2;
this.motY *= (double) f2; this.motY *= (double) f2;
this.motZ *= (double) f2; this.motZ *= (double) f2;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
} }
} }
@ -332,9 +332,9 @@ public class EntityFish extends Entity {
byte b0 = 0; byte b0 = 0;
if (this.c != null) { if (this.c != null) {
double d0 = this.b.locX - this.locX; double d0 = this.owner.locX - this.locX;
double d1 = this.b.locY - this.locY; double d1 = this.owner.locY - this.locY;
double d2 = this.b.locZ - this.locZ; double d2 = this.owner.locZ - this.locZ;
double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
double d4 = 0.1D; double d4 = 0.1D;
@ -344,17 +344,17 @@ public class EntityFish extends Entity {
b0 = 3; b0 = 3;
} else if (this.k > 0) { } else if (this.k > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH)); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH));
double d5 = this.b.locX - this.locX; double d5 = this.owner.locX - this.locX;
double d6 = this.b.locY - this.locY; double d6 = this.owner.locY - this.locY;
double d7 = this.b.locZ - this.locZ; double d7 = this.owner.locZ - this.locZ;
double d8 = (double) MathHelper.a(d5 * d5 + d6 * d6 + d7 * d7); double d8 = (double) MathHelper.a(d5 * d5 + d6 * d6 + d7 * d7);
double d9 = 0.1D; double d9 = 0.1D;
entityitem.motX = d5 * d9; entityitem.motX = d5 * d9;
entityitem.motY = d6 * d9 + (double) MathHelper.a(d8) * 0.08D; entityitem.motY = d6 * d9 + (double) MathHelper.a(d8) * 0.08D;
entityitem.motZ = d7 * d9; entityitem.motZ = d7 * d9;
this.world.a((Entity) entityitem); this.world.addEntity(entityitem);
this.b.a(StatisticList.x, 1); this.owner.a(StatisticList.x, 1);
b0 = 1; b0 = 1;
} }
@ -362,8 +362,8 @@ public class EntityFish extends Entity {
b0 = 2; b0 = 2;
} }
this.D(); this.die();
this.b.hookedFish = null; this.owner.hookedFish = null;
return b0; return b0;
} }
} }

View file

@ -40,9 +40,7 @@ public abstract class EntityHuman extends EntityLiving {
public boolean fauxSleeping; public boolean fauxSleeping;
// CraftBukkit end // CraftBukkit end
private ChunkCoordinates b; private ChunkCoordinates b;
// CraftBukkit start public int sleepTicks; // CraftBukkit (public)
public int sleepTicks;
// CraftBukkit end
public float z; public float z;
public float A; public float A;
private ChunkCoordinates d; private ChunkCoordinates d;
@ -54,9 +52,9 @@ public abstract class EntityHuman extends EntityLiving {
this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic); this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic);
this.activeContainer = this.defaultContainer; this.activeContainer = this.defaultContainer;
this.height = 1.62F; this.height = 1.62F;
ChunkCoordinates chunkcoordinates = world.m(); ChunkCoordinates chunkcoordinates = world.getSpawn();
this.c((double) chunkcoordinates.a + 0.5D, (double) (chunkcoordinates.b + 1), (double) chunkcoordinates.c + 0.5D, 0.0F, 0.0F); this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F);
this.health = 20; this.health = 20;
this.P = "humanoid"; this.P = "humanoid";
this.O = 180.0F; this.O = 180.0F;
@ -70,7 +68,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
public void f_() { public void f_() {
if (this.F()) { if (this.isSleeping()) {
++this.sleepTicks; ++this.sleepTicks;
if (this.sleepTicks > 100) { if (this.sleepTicks > 100) {
this.sleepTicks = 100; this.sleepTicks = 100;
@ -133,7 +131,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
protected boolean p_() { protected boolean p_() {
return this.health <= 0 || this.F(); return this.health <= 0 || this.isSleeping();
} }
protected void u() { protected void u() {
@ -161,7 +159,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
public void r() { public void r() {
if (this.world.j == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) { if (this.world.spawnMonsters == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) {
this.b(1); this.b(1);
} }
@ -208,7 +206,7 @@ public abstract class EntityHuman extends EntityLiving {
public void a(Entity entity) { public void a(Entity entity) {
super.a(entity); super.a(entity);
this.b(0.2F, 0.2F); this.b(0.2F, 0.2F);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.motY = 0.10000000149011612D; this.motY = 0.10000000149011612D;
if (this.name.equals("Notch")) { if (this.name.equals("Notch")) {
this.a(new ItemStack(Item.APPLE, 1), true); this.a(new ItemStack(Item.APPLE, 1), true);
@ -216,8 +214,8 @@ public abstract class EntityHuman extends EntityLiving {
this.inventory.h(); this.inventory.h();
if (entity != null) { if (entity != null) {
this.motX = (double) (-MathHelper.b((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); this.motX = (double) (-MathHelper.cos((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
this.motZ = (double) (-MathHelper.a((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F); this.motZ = (double) (-MathHelper.sin((this.aa + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
} else { } else {
this.motX = this.motZ = 0.0D; this.motX = this.motZ = 0.0D;
} }
@ -236,7 +234,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
public void z() { public void z() {
this.a(this.inventory.a(this.inventory.c, 1), false); this.a(this.inventory.a(this.inventory.itemInHandIndex, 1), false);
} }
public void b(ItemStack itemstack) { public void b(ItemStack itemstack) {
@ -247,7 +245,7 @@ public abstract class EntityHuman extends EntityLiving {
if (itemstack != null) { if (itemstack != null) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.q(), this.locZ, itemstack); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.q(), this.locZ, itemstack);
entityitem.c = 40; entityitem.pickupDelay = 40;
float f = 0.1F; float f = 0.1F;
float f1; float f1;
@ -255,14 +253,14 @@ public abstract class EntityHuman extends EntityLiving {
f1 = this.random.nextFloat() * 0.5F; f1 = this.random.nextFloat() * 0.5F;
float f2 = this.random.nextFloat() * 3.1415927F * 2.0F; float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;
entityitem.motX = (double) (-MathHelper.a(f2) * f1); entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
entityitem.motZ = (double) (MathHelper.b(f2) * f1); entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
entityitem.motY = 0.20000000298023224D; entityitem.motY = 0.20000000298023224D;
} else { } else {
f = 0.3F; f = 0.3F;
entityitem.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f); entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(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.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
entityitem.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f + 0.1F); entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
f = 0.02F; f = 0.02F;
f1 = this.random.nextFloat() * 3.1415927F * 2.0F; f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
f *= this.random.nextFloat(); f *= this.random.nextFloat();
@ -294,7 +292,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
protected void a(EntityItem entityitem) { protected void a(EntityItem entityitem) {
this.world.a((Entity) entityitem); this.world.addEntity(entityitem);
} }
public float a(Block block) { public float a(Block block) {
@ -324,11 +322,11 @@ public abstract class EntityHuman extends EntityLiving {
this.sleeping = nbttagcompound.m("Sleeping"); this.sleeping = nbttagcompound.m("Sleeping");
this.sleepTicks = nbttagcompound.d("SleepTimer"); this.sleepTicks = nbttagcompound.d("SleepTimer");
if (this.sleeping) { if (this.sleeping) {
this.b = new ChunkCoordinates(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)); this.b = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
this.a(true, true, false); this.a(true, true, false);
} }
if (nbttagcompound.b("SpawnX") && nbttagcompound.b("SpawnY") && nbttagcompound.b("SpawnZ")) { if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) {
this.d = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ")); this.d = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ"));
} }
} }
@ -340,9 +338,9 @@ public abstract class EntityHuman extends EntityLiving {
nbttagcompound.a("Sleeping", this.sleeping); nbttagcompound.a("Sleeping", this.sleeping);
nbttagcompound.a("SleepTimer", (short) this.sleepTicks); nbttagcompound.a("SleepTimer", (short) this.sleepTicks);
if (this.d != null) { if (this.d != null) {
nbttagcompound.a("SpawnX", this.d.a); nbttagcompound.a("SpawnX", this.d.x);
nbttagcompound.a("SpawnY", this.d.b); nbttagcompound.a("SpawnY", this.d.y);
nbttagcompound.a("SpawnZ", this.d.c); nbttagcompound.a("SpawnZ", this.d.z);
} }
} }
@ -350,7 +348,7 @@ public abstract class EntityHuman extends EntityLiving {
public void b(int i, int j, int k) {} public void b(int i, int j, int k) {}
public void b(Entity entity, int i) {} public void receive(Entity entity, int i) {}
public float q() { public float q() {
return 0.12F; return 0.12F;
@ -360,25 +358,25 @@ public abstract class EntityHuman extends EntityLiving {
this.height = 1.62F; this.height = 1.62F;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
this.at = 0; this.at = 0;
if (this.health <= 0) { if (this.health <= 0) {
return false; return false;
} else { } else {
if (this.F()) { if (this.isSleeping()) {
this.a(true, true, false); this.a(true, true, false);
} }
if (entity instanceof EntityMonster || entity instanceof EntityArrow) { if (entity instanceof EntityMonster || entity instanceof EntityArrow) {
if (this.world.j == 0) { if (this.world.spawnMonsters == 0) {
i = 0; i = 0;
} }
if (this.world.j == 1) { if (this.world.spawnMonsters == 1) {
i = i / 3 + 1; i = i / 3 + 1;
} }
if (this.world.j == 3) { if (this.world.spawnMonsters == 3) {
i = i * 3 / 2; i = i * 3 / 2;
} }
} }
@ -388,8 +386,8 @@ public abstract class EntityHuman extends EntityLiving {
} else { } else {
Object object = entity; Object object = entity;
if (entity instanceof EntityArrow && ((EntityArrow) entity).b != null) { if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) {
object = ((EntityArrow) entity).b; object = ((EntityArrow) entity).shooter;
} }
// CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters // CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters
@ -413,7 +411,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
this.a(StatisticList.t, i); this.a(StatisticList.t, i);
return super.a(entity, i); return super.damageEntity(entity, i);
} }
} }
} }
@ -474,11 +472,11 @@ public abstract class EntityHuman extends EntityLiving {
} }
public ItemStack A() { public ItemStack A() {
return this.inventory.b(); return this.inventory.getItemInHand();
} }
public void B() { public void B() {
this.inventory.a(this.inventory.c, (ItemStack) null); this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null);
} }
public double C() { public double C() {
@ -512,7 +510,7 @@ public abstract class EntityHuman extends EntityLiving {
} }
// CraftBukkit end // CraftBukkit end
entity.a(this, i); entity.damageEntity(this, i);
ItemStack itemstack = this.A(); ItemStack itemstack = this.A();
if (itemstack != null && entity instanceof EntityLiving) { if (itemstack != null && entity instanceof EntityLiving) {
@ -535,8 +533,8 @@ public abstract class EntityHuman extends EntityLiving {
public void a(ItemStack itemstack) {} public void a(ItemStack itemstack) {}
public void D() { public void die() {
super.D(); super.die();
this.defaultContainer.a(this); this.defaultContainer.a(this);
if (this.activeContainer != null) { if (this.activeContainer != null) {
this.activeContainer.a(this); this.activeContainer.a(this);
@ -548,8 +546,8 @@ public abstract class EntityHuman extends EntityLiving {
} }
public EnumBedError a(int i, int j, int k) { public EnumBedError a(int i, int j, int k) {
if (!this.F() && this.N()) { if (!this.isSleeping() && this.N()) {
if (this.world.m.c) { if (this.world.worldProvider.c) {
return EnumBedError.NOT_POSSIBLE_HERE; return EnumBedError.NOT_POSSIBLE_HERE;
} else if (this.world.d()) { } else if (this.world.d()) {
return EnumBedError.NOT_POSSIBLE_NOW; return EnumBedError.NOT_POSSIBLE_NOW;
@ -570,7 +568,7 @@ public abstract class EntityHuman extends EntityLiving {
this.b(0.2F, 0.2F); this.b(0.2F, 0.2F);
this.height = 0.2F; this.height = 0.2F;
if (this.world.f(i, j, k)) { if (this.world.isLoaded(i, j, k)) {
int l = this.world.getData(i, j, k); int l = this.world.getData(i, j, k);
int i1 = BlockBed.c(l); int i1 = BlockBed.c(l);
float f = 0.5F; float f = 0.5F;
@ -594,9 +592,9 @@ public abstract class EntityHuman extends EntityLiving {
} }
this.e(i1); this.e(i1);
this.a((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1));
} else { } else {
this.a((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F));
} }
this.sleeping = true; this.sleeping = true;
@ -604,7 +602,7 @@ public abstract class EntityHuman extends EntityLiving {
this.b = new ChunkCoordinates(i, j, k); this.b = new ChunkCoordinates(i, j, k);
this.motX = this.motZ = this.motY = 0.0D; this.motX = this.motZ = this.motY = 0.0D;
if (!this.world.isStatic) { if (!this.world.isStatic) {
this.world.q(); this.world.everyoneSleeping();
} }
return EnumBedError.OK; return EnumBedError.OK;
@ -643,19 +641,19 @@ public abstract class EntityHuman extends EntityLiving {
ChunkCoordinates chunkcoordinates = this.b; ChunkCoordinates chunkcoordinates = this.b;
ChunkCoordinates chunkcoordinates1 = this.b; ChunkCoordinates chunkcoordinates1 = this.b;
if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) == Block.BED.id) { if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) {
BlockBed.a(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, false); BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false);
chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0); chunkcoordinates1 = BlockBed.f(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0);
if (chunkcoordinates1 == null) { if (chunkcoordinates1 == null) {
chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.a, chunkcoordinates.b + 1, chunkcoordinates.c); chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z);
} }
this.a((double) ((float) chunkcoordinates1.a + 0.5F), (double) ((float) chunkcoordinates1.b + this.height + 0.1F), (double) ((float) chunkcoordinates1.c + 0.5F)); this.setPosition((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + this.height + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F));
} }
this.sleeping = false; this.sleeping = false;
if (!this.world.isStatic && flag1) { if (!this.world.isStatic && flag1) {
this.world.q(); this.world.everyoneSleeping();
} }
// CraftBukkit start // CraftBukkit start
@ -664,7 +662,7 @@ public abstract class EntityHuman extends EntityLiving {
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block bed; org.bukkit.block.Block bed;
if (chunkcoordinates != null) { if (chunkcoordinates != null) {
bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c); bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
} else { } else {
bed = ((WorldServer) world).getWorld().getBlockAt(player.getLocation()); bed = ((WorldServer) world).getWorld().getBlockAt(player.getLocation());
} }
@ -685,30 +683,30 @@ public abstract class EntityHuman extends EntityLiving {
} }
private boolean m() { private boolean m() {
return this.world.getTypeId(this.b.a, this.b.b, this.b.c) == Block.BED.id; return this.world.getTypeId(this.b.x, this.b.y, this.b.z) == Block.BED.id;
} }
public static ChunkCoordinates a(World world, ChunkCoordinates chunkcoordinates) { public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) {
IChunkProvider ichunkprovider = world.n(); IChunkProvider ichunkprovider = world.n();
ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4);
ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4);
ichunkprovider.c(chunkcoordinates.a - 3 >> 4, chunkcoordinates.c + 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4);
ichunkprovider.c(chunkcoordinates.a + 3 >> 4, chunkcoordinates.c + 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4);
if (world.getTypeId(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c) != Block.BED.id) { if (world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) != Block.BED.id) {
return null; return null;
} else { } else {
ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c, 0); ChunkCoordinates chunkcoordinates1 = BlockBed.f(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0);
return chunkcoordinates1; return chunkcoordinates1;
} }
} }
public boolean F() { public boolean isSleeping() {
return this.sleeping; return this.sleeping;
} }
public boolean G() { public boolean isDeeplySleeping() {
return this.sleeping && this.sleepTicks >= 100; return this.sleeping && this.sleepTicks >= 100;
} }

View file

@ -8,10 +8,10 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
public class EntityItem extends Entity { public class EntityItem extends Entity {
public ItemStack a; public ItemStack itemStack;
private int e; private int e;
public int b = 0; public int b = 0;
public int c; public int pickupDelay;
private int f = 5; private int f = 5;
public float d = (float) (Math.random() * 3.141592653589793D * 2.0D); public float d = (float) (Math.random() * 3.141592653589793D * 2.0D);
@ -19,8 +19,8 @@ public class EntityItem extends Entity {
super(world); super(world);
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.height = this.width / 2.0F; this.height = this.width / 2.0F;
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.a = itemstack; this.itemStack = itemstack;
this.yaw = (float) (Math.random() * 360.0D); this.yaw = (float) (Math.random() * 360.0D);
this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
this.motY = 0.20000000298023224D; this.motY = 0.20000000298023224D;
@ -41,28 +41,28 @@ public class EntityItem extends Entity {
public void f_() { public void f_() {
super.f_(); super.f_();
if (this.c > 0) { if (this.pickupDelay > 0) {
--this.c; --this.pickupDelay;
} }
this.lastX = this.locX; this.lastX = this.locX;
this.lastY = this.locY; this.lastY = this.locY;
this.lastZ = this.locZ; this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D; this.motY -= 0.03999999910593033D;
if (this.world.getMaterial(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) == Material.LAVA) { if (this.world.getMaterial(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) == Material.LAVA) {
this.motY = 0.20000000298023224D; this.motY = 0.20000000298023224D;
this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
this.motZ = (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.world.makeSound(this, "random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
} }
this.g(this.locX, this.locY, this.locZ); this.g(this.locX, this.locY, this.locZ);
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
float f = 0.98F; float f = 0.98F;
if (this.onGround) { if (this.onGround) {
f = 0.58800006F; f = 0.58800006F;
int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ)); int i = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ));
if (i > 0) { if (i > 0) {
f = Block.byId[i].frictionFactor * 0.98F; f = Block.byId[i].frictionFactor * 0.98F;
@ -79,7 +79,7 @@ public class EntityItem extends Entity {
++this.e; ++this.e;
++this.b; ++this.b;
if (this.b >= 6000) { if (this.b >= 6000) {
this.D(); this.die();
} }
} }
@ -88,9 +88,9 @@ public class EntityItem extends Entity {
} }
private boolean g(double d0, double d1, double d2) { private boolean g(double d0, double d1, double d2) {
int i = MathHelper.b(d0); int i = MathHelper.floor(d0);
int j = MathHelper.b(d1); int j = MathHelper.floor(d1);
int k = MathHelper.b(d2); int k = MathHelper.floor(d2);
double d3 = d0 - (double) i; double d3 = d0 - (double) i;
double d4 = d1 - (double) j; double d4 = d1 - (double) j;
double d5 = d2 - (double) k; double d5 = d2 - (double) k;
@ -166,14 +166,14 @@ public class EntityItem extends Entity {
} }
protected void a(int i) { protected void a(int i) {
this.a((Entity) null, i); this.damageEntity((Entity) null, i);
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
this.W(); this.W();
this.f -= i; this.f -= i;
if (this.f <= 0) { if (this.f <= 0) {
this.D(); this.die();
} }
return false; return false;
@ -182,7 +182,7 @@ public class EntityItem extends Entity {
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Health", (short) ((byte) this.f)); nbttagcompound.a("Health", (short) ((byte) this.f));
nbttagcompound.a("Age", (short) this.b); nbttagcompound.a("Age", (short) this.b);
nbttagcompound.a("Item", this.a.a(new NBTTagCompound())); nbttagcompound.a("Item", this.itemStack.a(new NBTTagCompound()));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
@ -190,26 +190,27 @@ public class EntityItem extends Entity {
this.b = nbttagcompound.d("Age"); this.b = nbttagcompound.d("Age");
NBTTagCompound nbttagcompound1 = nbttagcompound.k("Item"); NBTTagCompound nbttagcompound1 = nbttagcompound.k("Item");
this.a = new ItemStack(nbttagcompound1); this.itemStack = new ItemStack(nbttagcompound1);
} }
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
if (!this.world.isStatic) { if (!this.world.isStatic) {
int i = this.a.count; int i = this.itemStack.count;
// CraftBukkit start // CraftBukkit start
if (this.c == 0) { if (this.pickupDelay == 0) {
Player player = (Player) entityhuman.getBukkitEntity(); Player player = (Player) entityhuman.getBukkitEntity();
PlayerPickupItemEvent event = new PlayerPickupItemEvent(player, (Item) this.getBukkitEntity()); PlayerPickupItemEvent event = new PlayerPickupItemEvent(player, (Item) this.getBukkitEntity());
((WorldServer) world).getServer().getPluginManager().callEvent(event); ((WorldServer) world).getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && entityhuman.inventory.a(this.a)) { if (event.isCancelled() || !entityhuman.inventory.canHold(this.itemStack)) {
this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); return;
entityhuman.b(this, i);
this.D();
} }
// CraftBukkit end
this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.receive(this, i);
this.die();
} }
// CraftBukkit end
} }
} }
} }

View file

@ -75,7 +75,7 @@ public abstract class EntityLiving extends Entity {
super(world); super(world);
this.aD = true; this.aD = true;
this.E = (float) (Math.random() + 1.0D) * 0.01F; this.E = (float) (Math.random() + 1.0D) * 0.01F;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.D = (float) Math.random() * 12398.0F; this.D = (float) Math.random() * 12398.0F;
this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
this.bm = 0.5F; this.bm = 0.5F;
@ -84,7 +84,7 @@ public abstract class EntityLiving extends Entity {
protected void a() {} protected void a() {}
public boolean e(Entity entity) { public boolean e(Entity entity) {
return this.world.a(Vec3D.b(this.locX, this.locY + (double) this.q(), this.locZ), Vec3D.b(entity.locX, entity.locY + (double) entity.q(), entity.locZ)) == null; return this.world.a(Vec3D.create(this.locX, this.locY + (double) this.q(), this.locZ), Vec3D.create(entity.locX, entity.locY + (double) entity.q(), entity.locZ)) == null;
} }
public boolean d_() { public boolean d_() {
@ -107,7 +107,7 @@ public abstract class EntityLiving extends Entity {
String s = this.e(); String s = this.e();
if (s != null) { if (s != null) {
this.world.a(this, s, this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.world.makeSound(this, s, this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
} }
} }
@ -129,8 +129,8 @@ public abstract class EntityLiving extends Entity {
EntityDamageEvent event = new EntityDamageEvent(victim, damageType, damage); EntityDamageEvent event = new EntityDamageEvent(victim, damageType, damage);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() != 0) { if (!event.isCancelled()) {
this.a((Entity) null, event.getDamage()); this.damageEntity((Entity) null, event.getDamage());
} }
// CraftBukkit end // CraftBukkit end
} }
@ -163,8 +163,8 @@ public abstract class EntityLiving extends Entity {
EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone); EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() != 0) { if (!event.isCancelled()) {
this.a((Entity) null, event.getDamage()); this.damageEntity((Entity) null, event.getDamage());
} }
// CraftBukkit end // CraftBukkit end
} }
@ -191,7 +191,7 @@ public abstract class EntityLiving extends Entity {
++this.deathTicks; ++this.deathTicks;
if (this.deathTicks > 20) { if (this.deathTicks > 20) {
this.Q(); this.Q();
this.D(); this.die();
for (i = 0; i < 20; ++i) { for (i = 0; i < 20; ++i) {
double d0 = this.random.nextGaussian() * 0.02D; double d0 = this.random.nextGaussian() * 0.02D;
@ -338,7 +338,7 @@ public abstract class EntityLiving extends Entity {
} }
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (this.world.isStatic) { if (this.world.isStatic) {
return false; return false;
} else { } else {
@ -387,12 +387,12 @@ public abstract class EntityLiving extends Entity {
if (this.health <= 0) { if (this.health <= 0) {
if (flag) { if (flag) {
this.world.a(this, this.g(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.world.makeSound(this, this.g(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
} }
this.a(entity); this.a(entity);
} else if (flag) { } else if (flag) {
this.world.a(this, this.f(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.world.makeSound(this, this.f(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
} }
return true; return true;
@ -488,16 +488,16 @@ public abstract class EntityLiving extends Entity {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() != 0) { if (!event.isCancelled() && event.getDamage() != 0) {
this.a((Entity) null, event.getDamage()); this.damageEntity((Entity) null, event.getDamage());
} }
// CraftBukkit end // CraftBukkit end
int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.b(this.locZ)); int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.floor(this.locZ));
if (j > 0) { if (j > 0) {
StepSound stepsound = Block.byId[j].stepSound; StepSound stepsound = Block.byId[j].stepSound;
this.world.a(this, stepsound.c(), stepsound.a() * 0.5F, stepsound.b() * 0.75F); this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.5F, stepsound.getVolume2() * 0.75F);
} }
} }
} }
@ -508,23 +508,23 @@ public abstract class EntityLiving extends Entity {
if (this.g_()) { if (this.g_()) {
d0 = this.locY; d0 = this.locY;
this.a(f, f1, 0.02F); this.a(f, f1, 0.02F);
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
this.motX *= 0.800000011920929D; this.motX *= 0.800000011920929D;
this.motY *= 0.800000011920929D; this.motY *= 0.800000011920929D;
this.motZ *= 0.800000011920929D; this.motZ *= 0.800000011920929D;
this.motY -= 0.02D; this.motY -= 0.02D;
if (this.aW && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { if (this.positionChanged && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
this.motY = 0.30000001192092896D; this.motY = 0.30000001192092896D;
} }
} else if (this.V()) { } else if (this.V()) {
d0 = this.locY; d0 = this.locY;
this.a(f, f1, 0.02F); this.a(f, f1, 0.02F);
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
this.motX *= 0.5D; this.motX *= 0.5D;
this.motY *= 0.5D; this.motY *= 0.5D;
this.motZ *= 0.5D; this.motZ *= 0.5D;
this.motY -= 0.02D; this.motY -= 0.02D;
if (this.aW && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { if (this.positionChanged && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
this.motY = 0.30000001192092896D; this.motY = 0.30000001192092896D;
} }
} else { } else {
@ -532,7 +532,7 @@ public abstract class EntityLiving extends Entity {
if (this.onGround) { if (this.onGround) {
f2 = 0.54600006F; f2 = 0.54600006F;
int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ)); int i = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ));
if (i > 0) { if (i > 0) {
f2 = Block.byId[i].frictionFactor * 0.91F; f2 = Block.byId[i].frictionFactor * 0.91F;
@ -545,7 +545,7 @@ public abstract class EntityLiving extends Entity {
f2 = 0.91F; f2 = 0.91F;
if (this.onGround) { if (this.onGround) {
f2 = 0.54600006F; f2 = 0.54600006F;
int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ)); int j = this.world.getTypeId(MathHelper.floor(this.locX), MathHelper.floor(this.boundingBox.b) - 1, MathHelper.floor(this.locZ));
if (j > 0) { if (j > 0) {
f2 = Block.byId[j].frictionFactor * 0.91F; f2 = Block.byId[j].frictionFactor * 0.91F;
@ -558,13 +558,13 @@ public abstract class EntityLiving extends Entity {
this.motY = -0.15D; this.motY = -0.15D;
} }
if (this.Z() && this.motY < 0.0D) { if (this.isSneaking() && this.motY < 0.0D) {
this.motY = 0.0D; this.motY = 0.0D;
} }
} }
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
if (this.aW && this.n()) { if (this.positionChanged && this.n()) {
this.motY = 0.2D; this.motY = 0.2D;
} }
@ -588,9 +588,9 @@ public abstract class EntityLiving extends Entity {
} }
public boolean n() { public boolean n() {
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.b(this.boundingBox.b); int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
return this.world.getTypeId(i, j, k) == Block.LADDER.id || this.world.getTypeId(i, j + 1, k) == Block.LADDER.id; return this.world.getTypeId(i, j, k) == Block.LADDER.id || this.world.getTypeId(i, j + 1, k) == Block.LADDER.id;
} }
@ -604,7 +604,7 @@ public abstract class EntityLiving extends Entity {
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
this.health = nbttagcompound.d("Health"); this.health = nbttagcompound.d("Health");
if (!nbttagcompound.b("Health")) { if (!nbttagcompound.hasKey("Health")) {
this.health = 10; this.health = 10;
} }
@ -640,7 +640,7 @@ public abstract class EntityLiving extends Entity {
this.yaw = (float) ((double) this.yaw + d3 / (double) this.al); this.yaw = (float) ((double) this.yaw + d3 / (double) this.al);
this.pitch = (float) ((double) this.pitch + (this.aq - (double) this.pitch) / (double) this.al); this.pitch = (float) ((double) this.pitch + (this.aq - (double) this.pitch) / (double) this.al);
--this.al; --this.al;
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.c(this.yaw, this.pitch); this.c(this.yaw, this.pitch);
} }
@ -677,7 +677,7 @@ public abstract class EntityLiving extends Entity {
Entity entity = (Entity) list.get(i); Entity entity = (Entity) list.get(i);
if (entity.e_()) { if (entity.e_()) {
entity.h(this); entity.collide(this);
} }
} }
} }
@ -706,14 +706,14 @@ public abstract class EntityLiving extends Entity {
double d3 = d0 * d0 + d1 * d1 + d2 * d2; double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 > 16384.0D) { if (d3 > 16384.0D) {
this.D(); this.die();
} }
if (this.at > 600 && this.random.nextInt(800) == 0) { if (this.at > 600 && this.random.nextInt(800) == 0) {
if (d3 < 1024.0D) { if (d3 < 1024.0D) {
this.at = 0; this.at = 0;
} else { } else {
this.D(); this.die();
} }
} }
} }
@ -812,7 +812,7 @@ public abstract class EntityLiving extends Entity {
public void Q() {} public void Q() {}
public boolean b() { public boolean b() {
return this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox); return this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox);
} }
protected void R() { protected void R() {
@ -829,7 +829,7 @@ public abstract class EntityLiving extends Entity {
return; return;
} }
damageDone = event.getDamage(); damageDone = event.getDamage();
this.a((Entity) null, damageDone); this.damageEntity((Entity) null, damageDone);
// CraftBukkit end // CraftBukkit end
} }
@ -844,20 +844,20 @@ public abstract class EntityLiving extends Entity {
float f4; float f4;
if (f == 1.0F) { if (f == 1.0F) {
f1 = MathHelper.b(-this.yaw * 0.017453292F - 3.1415927F); f1 = MathHelper.cos(-this.yaw * 0.017453292F - 3.1415927F);
f2 = MathHelper.a(-this.yaw * 0.017453292F - 3.1415927F); f2 = MathHelper.sin(-this.yaw * 0.017453292F - 3.1415927F);
f3 = -MathHelper.b(-this.pitch * 0.017453292F); f3 = -MathHelper.cos(-this.pitch * 0.017453292F);
f4 = MathHelper.a(-this.pitch * 0.017453292F); f4 = MathHelper.sin(-this.pitch * 0.017453292F);
return Vec3D.b((double) (f2 * f3), (double) f4, (double) (f1 * f3)); return Vec3D.create((double) (f2 * f3), (double) f4, (double) (f1 * f3));
} else { } else {
f1 = this.lastPitch + (this.pitch - this.lastPitch) * f; f1 = this.lastPitch + (this.pitch - this.lastPitch) * f;
f2 = this.lastYaw + (this.yaw - this.lastYaw) * f; f2 = this.lastYaw + (this.yaw - this.lastYaw) * f;
f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.017453292F); float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F);
return Vec3D.b((double) (f4 * f5), (double) f6, (double) (f3 * f5)); return Vec3D.create((double) (f4 * f5), (double) f6, (double) (f3 * f5));
} }
} }
@ -865,7 +865,7 @@ public abstract class EntityLiving extends Entity {
return 4; return 4;
} }
public boolean F() { public boolean isSleeping() {
return false; return false;
} }
} }

View file

@ -12,16 +12,16 @@ import org.bukkit.event.vehicle.*;
public class EntityMinecart extends Entity implements IInventory { public class EntityMinecart extends Entity implements IInventory {
private ItemStack[] h; private ItemStack[] items;
public int a; public int damage;
public int b; public int b;
public int c; public int c;
private boolean i; private boolean i;
public int d; public int type;
public int e; public int e;
public double f; public double f;
public double g; public double g;
private static final int[][][] j = new int[][][] { { { 0, 0, -1}, { 0, 0, 1}}, { { -1, 0, 0}, { 1, 0, 0}}, { { -1, -1, 0}, { 1, 0, 0}}, { { -1, 0, 0}, { 1, -1, 0}}, { { 0, 0, -1}, { 0, -1, 1}}, { { 0, -1, -1}, { 0, 0, 1}}, { { 0, 0, 1}, { 1, 0, 0}}, { { 0, 0, 1}, { -1, 0, 0}}, { { 0, 0, -1}, { -1, 0, 0}}, { { 0, 0, -1}, { 1, 0, 0}}}; private static final int[][][] matrix = new int[][][] { { { 0, 0, -1}, { 0, 0, 1}}, { { -1, 0, 0}, { 1, 0, 0}}, { { -1, -1, 0}, { 1, 0, 0}}, { { -1, 0, 0}, { 1, -1, 0}}, { { 0, 0, -1}, { 0, -1, 1}}, { { 0, -1, -1}, { 0, 0, 1}}, { { 0, 0, 1}, { 1, 0, 0}}, { { 0, 0, 1}, { -1, 0, 0}}, { { 0, 0, -1}, { -1, 0, 0}}, { { 0, 0, -1}, { 1, 0, 0}}};
private int k; private int k;
private double l; private double l;
private double m; private double m;
@ -40,14 +40,14 @@ public class EntityMinecart extends Entity implements IInventory {
public double maxSpeed = 0.4D; public double maxSpeed = 0.4D;
public ItemStack[] getContents() { public ItemStack[] getContents() {
return this.h; return this.items;
} }
// CraftBukkit end // CraftBukkit end
public EntityMinecart(World world) { public EntityMinecart(World world) {
super(world); super(world);
this.h = new ItemStack[27]; // CraftBukkit this.items = new ItemStack[27]; // CraftBukkit
this.a = 0; this.damage = 0;
this.b = 0; this.b = 0;
this.c = 1; this.c = 1;
this.i = false; this.i = false;
@ -76,14 +76,14 @@ public class EntityMinecart extends Entity implements IInventory {
public EntityMinecart(World world, double d0, double d1, double d2, int i) { public EntityMinecart(World world, double d0, double d1, double d2, int i) {
this(world); this(world);
this.a(d0, d1 + (double) this.height, d2); this.setPosition(d0, d1 + (double) this.height, d2);
this.motX = 0.0D; this.motX = 0.0D;
this.motY = 0.0D; this.motY = 0.0D;
this.motZ = 0.0D; this.motZ = 0.0D;
this.lastX = d0; this.lastX = d0;
this.lastY = d1; this.lastY = d1;
this.lastZ = d2; this.lastZ = d2;
this.d = i; this.type = i;
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
@ -98,7 +98,7 @@ public class EntityMinecart extends Entity implements IInventory {
return (double) this.width * 0.0D - 0.30000001192092896D; return (double) this.width * 0.0D - 0.30000001192092896D;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (!this.world.isStatic && !this.dead) { if (!this.world.isStatic && !this.dead) {
// CraftBukkit start // CraftBukkit start
Vehicle vehicle = (Vehicle) this.getBukkitEntity(); Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@ -118,27 +118,27 @@ public class EntityMinecart extends Entity implements IInventory {
this.c = -this.c; this.c = -this.c;
this.b = 10; this.b = 10;
this.W(); this.W();
this.a += i * 10; this.damage += i * 10;
if (this.a > 40) { if (this.damage > 40) {
// CraftBukkit start // CraftBukkit start
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger); VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
((WorldServer) this.world).getServer().getPluginManager().callEvent(destroyEvent); ((WorldServer) this.world).getServer().getPluginManager().callEvent(destroyEvent);
if (destroyEvent.isCancelled()) { if (destroyEvent.isCancelled()) {
this.a = 40; // Maximize damage so this doesn't get triggered again right away this.damage = 40; // Maximize damage so this doesn't get triggered again right away
return true; return true;
} }
// CraftBukkit end // CraftBukkit end
this.a(Item.MINECART.id, 1, 0.0F); this.a(Item.MINECART.id, 1, 0.0F);
if (this.d == 1) { if (this.type == 1) {
this.a(Block.CHEST.id, 1, 0.0F); this.a(Block.CHEST.id, 1, 0.0F);
} else if (this.d == 2) { } else if (this.type == 2) {
this.a(Block.FURNACE.id, 1, 0.0F); this.a(Block.FURNACE.id, 1, 0.0F);
} }
this.D(); this.die();
} }
return true; return true;
@ -151,9 +151,9 @@ public class EntityMinecart extends Entity implements IInventory {
return !this.dead; return !this.dead;
} }
public void D() { public void die() {
for (int i = 0; i < this.q_(); ++i) { for (int i = 0; i < this.getSize(); ++i) {
ItemStack itemstack = this.c_(i); ItemStack itemstack = this.getItem(i);
if (itemstack != null) { if (itemstack != null) {
float f = this.random.nextFloat() * 0.8F + 0.1F; float f = this.random.nextFloat() * 0.8F + 0.1F;
@ -168,18 +168,18 @@ public class EntityMinecart extends Entity implements IInventory {
} }
itemstack.count -= j; itemstack.count -= j;
EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, j, itemstack.h())); EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, j, itemstack.getData()));
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motX = (double) ((float) this.random.nextGaussian() * f3); entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F); entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3); entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
this.world.a((Entity) entityitem); this.world.addEntity(entityitem);
} }
} }
} }
super.D(); super.die();
} }
public void f_() { public void f_() {
@ -195,8 +195,8 @@ public class EntityMinecart extends Entity implements IInventory {
--this.b; --this.b;
} }
if (this.a > 0) { if (this.damage > 0) {
--this.a; --this.damage;
} }
double d0; double d0;
@ -218,10 +218,10 @@ public class EntityMinecart extends Entity implements IInventory {
this.yaw = (float) ((double) this.yaw + d0 / (double) this.k); this.yaw = (float) ((double) this.yaw + d0 / (double) this.k);
this.pitch = (float) ((double) this.pitch + (this.p - (double) this.pitch) / (double) this.k); this.pitch = (float) ((double) this.pitch + (this.p - (double) this.pitch) / (double) this.k);
--this.k; --this.k;
this.a(d1, d2, d3); this.setPosition(d1, d2, d3);
this.c(this.yaw, this.pitch); this.c(this.yaw, this.pitch);
} else { } else {
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.c(this.yaw, this.pitch); this.c(this.yaw, this.pitch);
} }
} else { } else {
@ -229,9 +229,9 @@ public class EntityMinecart extends Entity implements IInventory {
this.lastY = this.locY; this.lastY = this.locY;
this.lastZ = this.locZ; this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D; this.motY -= 0.03999999910593033D;
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.b(this.locY); int j = MathHelper.floor(this.locY);
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) { if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
--j; --j;
@ -267,8 +267,7 @@ public class EntityMinecart extends Entity implements IInventory {
this.motZ -= d0; this.motZ -= d0;
} }
// CraftBukkit -- be explicit. int[][] aint = matrix[l];
int[][] aint = EntityMinecart.j[l];
double d5 = (double) (aint[1][0] - aint[0][0]); double d5 = (double) (aint[1][0] - aint[0][0]);
double d6 = (double) (aint[1][2] - aint[0][2]); double d6 = (double) (aint[1][2] - aint[0][2]);
double d7 = Math.sqrt(d5 * d5 + d6 * d6); double d7 = Math.sqrt(d5 * d5 + d6 * d6);
@ -310,7 +309,7 @@ public class EntityMinecart extends Entity implements IInventory {
this.locX = d11 + d5 * d10; this.locX = d11 + d5 * d10;
this.locZ = d12 + d6 * d10; this.locZ = d12 + d6 * d10;
this.a(this.locX, this.locY + (double) this.height, this.locZ); this.setPosition(this.locX, this.locY + (double) this.height, this.locZ);
d15 = this.motX; d15 = this.motX;
d17 = this.motZ; d17 = this.motZ;
if (this.passenger != null) { if (this.passenger != null) {
@ -334,11 +333,11 @@ public class EntityMinecart extends Entity implements IInventory {
d17 = d4; d17 = d4;
} }
this.c(d15, 0.0D, d17); this.move(d15, 0.0D, d17);
if (aint[0][1] != 0 && MathHelper.b(this.locX) - i == aint[0][0] && MathHelper.b(this.locZ) - k == aint[0][2]) { if (aint[0][1] != 0 && MathHelper.floor(this.locX) - i == aint[0][0] && MathHelper.floor(this.locZ) - k == aint[0][2]) {
this.a(this.locX, this.locY + (double) aint[0][1], this.locZ); this.setPosition(this.locX, this.locY + (double) aint[0][1], this.locZ);
} else if (aint[1][1] != 0 && MathHelper.b(this.locX) - i == aint[1][0] && MathHelper.b(this.locZ) - k == aint[1][2]) { } else if (aint[1][1] != 0 && MathHelper.floor(this.locX) - i == aint[1][0] && MathHelper.floor(this.locZ) - k == aint[1][2]) {
this.a(this.locX, this.locY + (double) aint[1][1], this.locZ); this.setPosition(this.locX, this.locY + (double) aint[1][1], this.locZ);
} }
// CraftBukkit // CraftBukkit
@ -347,7 +346,7 @@ public class EntityMinecart extends Entity implements IInventory {
this.motY *= 0.0D; this.motY *= 0.0D;
this.motZ *= 0.996999979019165D; this.motZ *= 0.996999979019165D;
} else { } else {
if (this.d == 2) { if (this.type == 2) {
d16 = (double) MathHelper.a(this.f * this.f + this.g * this.g); d16 = (double) MathHelper.a(this.f * this.f + this.g * this.g);
if (d16 > 0.01D) { if (d16 > 0.01D) {
flag = true; flag = true;
@ -383,11 +382,11 @@ public class EntityMinecart extends Entity implements IInventory {
this.motZ = this.motZ / d9 * (d9 + d19); this.motZ = this.motZ / d9 * (d9 + d19);
} }
this.a(this.locX, vec3d1.b, this.locZ); this.setPosition(this.locX, vec3d1.b, this.locZ);
} }
int i1 = MathHelper.b(this.locX); int i1 = MathHelper.floor(this.locX);
int j1 = MathHelper.b(this.locZ); int j1 = MathHelper.floor(this.locZ);
if (i1 != i || j1 != k) { if (i1 != i || j1 != k) {
d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
@ -395,7 +394,7 @@ public class EntityMinecart extends Entity implements IInventory {
this.motZ = d9 * (double) (j1 - k); this.motZ = d9 * (double) (j1 - k);
} }
if (this.d == 2) { if (this.type == 2) {
double d20 = (double) MathHelper.a(this.f * this.f + this.g * this.g); double d20 = (double) MathHelper.a(this.f * this.f + this.g * this.g);
if (d20 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) { if (d20 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) {
@ -435,7 +434,7 @@ public class EntityMinecart extends Entity implements IInventory {
// CraftBukkit start // CraftBukkit start
} }
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
if (!this.onGround) { if (!this.onGround) {
// CraftBukkit start // CraftBukkit start
this.motX *= flyingX; this.motX *= flyingX;
@ -495,7 +494,7 @@ public class EntityMinecart extends Entity implements IInventory {
Entity entity = (Entity) list.get(k1); Entity entity = (Entity) list.get(k1);
if (entity != this.passenger && entity.e_() && entity instanceof EntityMinecart) { if (entity != this.passenger && entity.e_() && entity instanceof EntityMinecart) {
entity.h(this); entity.collide(this);
} }
} }
} }
@ -516,9 +515,9 @@ public class EntityMinecart extends Entity implements IInventory {
} }
public Vec3D g(double d0, double d1, double d2) { public Vec3D g(double d0, double d1, double d2) {
int i = MathHelper.b(d0); int i = MathHelper.floor(d0);
int j = MathHelper.b(d1); int j = MathHelper.floor(d1);
int k = MathHelper.b(d2); int k = MathHelper.floor(d2);
if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) { if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
--j; --j;
@ -532,7 +531,7 @@ public class EntityMinecart extends Entity implements IInventory {
d1 = (double) (j + 1); d1 = (double) (j + 1);
} }
int[][] aint = EntityMinecart.j[l]; // CraftBukkit -- be explicit int[][] aint = matrix[l];
double d3 = 0.0D; double d3 = 0.0D;
double d4 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; double d4 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
double d5 = (double) j + 0.5D + (double) aint[0][1] * 0.5D; double d5 = (double) j + 0.5D + (double) aint[0][1] * 0.5D;
@ -569,27 +568,27 @@ public class EntityMinecart extends Entity implements IInventory {
d1 += 0.5D; d1 += 0.5D;
} }
return Vec3D.b(d0, d1, d2); return Vec3D.create(d0, d1, d2);
} else { } else {
return null; return null;
} }
} }
protected void a(NBTTagCompound nbttagcompound) { protected void a(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Type", this.d); nbttagcompound.a("Type", this.type);
if (this.d == 2) { if (this.type == 2) {
nbttagcompound.a("PushX", this.f); nbttagcompound.a("PushX", this.f);
nbttagcompound.a("PushZ", this.g); nbttagcompound.a("PushZ", this.g);
nbttagcompound.a("Fuel", (short) this.e); nbttagcompound.a("Fuel", (short) this.e);
} else if (this.d == 1) { } else if (this.type == 1) {
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.h.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.h[i] != null) { if (this.items[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i); nbttagcompound1.a("Slot", (byte) i);
this.h[i].a(nbttagcompound1); this.items[i].a(nbttagcompound1);
nbttaglist.a((NBTBase) nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
@ -599,28 +598,28 @@ public class EntityMinecart extends Entity implements IInventory {
} }
protected void b(NBTTagCompound nbttagcompound) { protected void b(NBTTagCompound nbttagcompound) {
this.d = nbttagcompound.e("Type"); this.type = nbttagcompound.e("Type");
if (this.d == 2) { if (this.type == 2) {
this.f = nbttagcompound.h("PushX"); this.f = nbttagcompound.h("PushX");
this.g = nbttagcompound.h("PushZ"); this.g = nbttagcompound.h("PushZ");
this.e = nbttagcompound.d("Fuel"); this.e = nbttagcompound.d("Fuel");
} else if (this.d == 1) { } else if (this.type == 1) {
NBTTagList nbttaglist = nbttagcompound.l("Items"); NBTTagList nbttaglist = nbttagcompound.l("Items");
this.h = new ItemStack[this.q_()]; this.items = new ItemStack[this.getSize()];
for (int i = 0; i < nbttaglist.c(); ++i) { for (int i = 0; i < nbttaglist.c(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound1.c("Slot") & 255; int j = nbttagcompound1.c("Slot") & 255;
if (j >= 0 && j < this.h.length) { if (j >= 0 && j < this.items.length) {
this.h[j] = new ItemStack(nbttagcompound1); this.items[j] = new ItemStack(nbttagcompound1);
} }
} }
} }
} }
public void h(Entity entity) { public void collide(Entity entity) {
if (!this.world.isStatic) { if (!this.world.isStatic) {
if (entity != this.passenger) { if (entity != this.passenger) {
// CraftBukkit start // CraftBukkit start
@ -635,14 +634,14 @@ public class EntityMinecart extends Entity implements IInventory {
return; return;
} }
if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.d == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) { if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.type == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
if (!collsionEvent.isPickupCancelled()) { if (!collsionEvent.isPickupCancelled()) {
VehicleEnterEvent enterEvent = new VehicleEnterEvent(vehicle, hitEntity); VehicleEnterEvent enterEvent = new VehicleEnterEvent(vehicle, hitEntity);
server.getPluginManager().callEvent(enterEvent); server.getPluginManager().callEvent(enterEvent);
if (!enterEvent.isCancelled()) { if (!enterEvent.isCancelled()) {
entity.b((Entity) this); entity.mount(this);
} }
} }
} }
@ -675,13 +674,13 @@ public class EntityMinecart extends Entity implements IInventory {
double d4 = entity.motX + this.motX; double d4 = entity.motX + this.motX;
double d5 = entity.motZ + this.motZ; double d5 = entity.motZ + this.motZ;
if (((EntityMinecart) entity).d == 2 && this.d != 2) { if (((EntityMinecart) entity).type == 2 && this.type != 2) {
this.motX *= 0.20000000298023224D; this.motX *= 0.20000000298023224D;
this.motZ *= 0.20000000298023224D; this.motZ *= 0.20000000298023224D;
this.f(entity.motX - d0, 0.0D, entity.motZ - d1); this.f(entity.motX - d0, 0.0D, entity.motZ - d1);
entity.motX *= 0.699999988079071D; entity.motX *= 0.699999988079071D;
entity.motZ *= 0.699999988079071D; entity.motZ *= 0.699999988079071D;
} else if (((EntityMinecart) entity).d != 2 && this.d == 2) { } else if (((EntityMinecart) entity).type != 2 && this.type == 2) {
entity.motX *= 0.20000000298023224D; entity.motX *= 0.20000000298023224D;
entity.motZ *= 0.20000000298023224D; entity.motZ *= 0.20000000298023224D;
entity.f(this.motX + d0, 0.0D, this.motZ + d1); entity.f(this.motX + d0, 0.0D, this.motZ + d1);
@ -706,26 +705,26 @@ public class EntityMinecart extends Entity implements IInventory {
} }
} }
public int q_() { public int getSize() {
return 27; return 27;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return this.h[i]; return this.items[i];
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.h[i] != null) { if (this.items[i] != null) {
ItemStack itemstack; ItemStack itemstack;
if (this.h[i].count <= j) { if (this.items[i].count <= j) {
itemstack = this.h[i]; itemstack = this.items[i];
this.h[i] = null; this.items[i] = null;
return itemstack; return itemstack;
} else { } else {
itemstack = this.h[i].a(j); itemstack = this.items[i].a(j);
if (this.h[i].count == 0) { if (this.items[i].count == 0) {
this.h[i] = null; this.items[i] = null;
} }
return itemstack; return itemstack;
@ -735,25 +734,25 @@ public class EntityMinecart extends Entity implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.h[i] = itemstack; this.items[i] = itemstack;
if (itemstack != null && itemstack.count > this.r_()) { if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.r_(); itemstack.count = this.getMaxStackSize();
} }
} }
public String c() { public String getName() {
return "Minecart"; return "Minecart";
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public void i() {} public void update() {}
public boolean a(EntityHuman entityhuman) { public boolean a(EntityHuman entityhuman) {
if (this.d == 0) { if (this.type == 0) {
if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) { if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true; return true;
} }
@ -772,18 +771,18 @@ public class EntityMinecart extends Entity implements IInventory {
} }
// CraftBukkit end // CraftBukkit end
entityhuman.b((Entity) this); entityhuman.mount(this);
} }
} else if (this.d == 1) { } else if (this.type == 1) {
if (!this.world.isStatic) { if (!this.world.isStatic) {
entityhuman.a((IInventory) this); entityhuman.a((IInventory) this);
} }
} else if (this.d == 2) { } else if (this.type == 2) {
ItemStack itemstack = entityhuman.inventory.b(); ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.id == Item.COAL.id) { if (itemstack != null && itemstack.id == Item.COAL.id) {
if (--itemstack.count == 0) { if (--itemstack.count == 0) {
entityhuman.inventory.a(entityhuman.inventory.c, (ItemStack) null); entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
} }
this.e += 1200; this.e += 1200;

View file

@ -13,7 +13,7 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
public class EntityMonster extends EntityCreature implements IMonster { public class EntityMonster extends EntityCreature implements IMonster {
protected int c = 2; protected int damage = 2;
public EntityMonster(World world) { public EntityMonster(World world) {
super(world); super(world);
@ -32,19 +32,19 @@ public class EntityMonster extends EntityCreature implements IMonster {
public void f_() { public void f_() {
super.f_(); super.f_();
if (this.world.j == 0) { if (this.world.spawnMonsters == 0) {
this.D(); this.die();
} }
} }
protected Entity m() { protected Entity findTarget() {
EntityHuman entityhuman = this.world.a(this, 16.0D); EntityHuman entityhuman = this.world.a(this, 16.0D);
return entityhuman != null && this.e(entityhuman) ? entityhuman : null; return entityhuman != null && this.e(entityhuman) ? entityhuman : null;
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (super.a(entity, i)) { if (super.damageEntity(entity, i)) {
if (this.passenger != entity && this.vehicle != entity) { if (this.passenger != entity && this.vehicle != entity) {
if (entity != this) { if (entity != this) {
// CraftBukkit start // CraftBukkit start
@ -59,9 +59,9 @@ public class EntityMonster extends EntityCreature implements IMonster {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) { if (event.getTarget() == null) {
this.d = null; this.target = null;
} else { } else {
this.d = ((CraftEntity) event.getTarget()).getHandle(); this.target = ((CraftEntity) event.getTarget()).getHandle();
} }
} }
// CraftBukkit end // CraftBukkit end
@ -88,17 +88,17 @@ public class EntityMonster extends EntityCreature implements IMonster {
org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK; DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, this.c); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, this.damage);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getDamage() != 0) { if (!event.isCancelled()) {
entity.a(this, event.getDamage()); entity.damageEntity(this, event.getDamage());
} }
return; return;
} }
// CraftBukkit end // CraftBukkit end
entity.a(this, this.c); entity.damageEntity(this, this.damage);
} }
} }
@ -115,14 +115,14 @@ public class EntityMonster extends EntityCreature implements IMonster {
} }
public boolean b() { public boolean b() {
int i = MathHelper.b(this.locX); int i = MathHelper.floor(this.locX);
int j = MathHelper.b(this.boundingBox.b); int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.b(this.locZ); int k = MathHelper.floor(this.locZ);
if (this.world.a(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) { if (this.world.a(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) {
return false; return false;
} else { } else {
int l = this.world.j(i, j, k); int l = this.world.getLightLevel(i, j, k);
return l <= this.random.nextInt(8) && super.b(); return l <= this.random.nextInt(8) && super.b();
} }

View file

@ -11,50 +11,50 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
public class EntityPigZombie extends EntityZombie { public class EntityPigZombie extends EntityZombie {
private int a = 0; private int angerLevel = 0;
private int b = 0; private int soundDelay = 0;
private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1); private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1);
public EntityPigZombie(World world) { public EntityPigZombie(World world) {
super(world); super(world);
this.texture = "/mob/pigzombie.png"; this.texture = "/mob/pigzombie.png";
this.az = 0.5F; this.az = 0.5F;
this.c = 5; this.damage = 5;
this.by = true; this.by = true;
} }
public void f_() { public void f_() {
this.az = this.d != null ? 0.95F : 0.5F; this.az = this.target != null ? 0.95F : 0.5F;
if (this.b > 0 && --this.b == 0) { if (this.soundDelay > 0 && --this.soundDelay == 0) {
this.world.a(this, "mob.zombiepig.zpigangry", this.i() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); this.world.makeSound(this, "mob.zombiepig.zpigangry", this.i() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
} }
super.f_(); super.f_();
} }
public boolean b() { public boolean b() {
return this.world.j > 0 && this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox); return this.world.spawnMonsters > 0 && this.world.containsEntity(this.boundingBox) && this.world.getEntities(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) this.a); nbttagcompound.a("Anger", (short) this.angerLevel);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
this.a = nbttagcompound.d("Anger"); this.angerLevel = nbttagcompound.d("Anger");
} }
protected Entity m() { protected Entity findTarget() {
return this.a == 0 ? null : super.m(); return this.angerLevel == 0 ? null : super.findTarget();
} }
public void r() { public void r() {
super.r(); super.r();
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D)); List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D));
@ -71,7 +71,7 @@ public class EntityPigZombie extends EntityZombie {
this.d(entity); this.d(entity);
} }
return super.a(entity, i); return super.damageEntity(entity, i);
} }
private void d(Entity entity) { private void d(Entity entity) {
@ -85,16 +85,20 @@ public class EntityPigZombie extends EntityZombie {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (event.isCancelled()) {
if (event.getTarget() == null) { return;
this.d = null;
} else {
this.d = ((CraftEntity) event.getTarget()).getHandle();
this.a = 400 + this.random.nextInt(400);
this.b = this.random.nextInt(40);
}
} }
if (event.getTarget() == null) {
this.target = null;
return;
}
entity = ((CraftEntity) event.getTarget()).getHandle();
// CraftBukkit end // CraftBukkit end
this.target = entity;
this.angerLevel = 400 + this.random.nextInt(400);
this.soundDelay = this.random.nextInt(40);
} }
protected String e() { protected String e() {

View file

@ -18,9 +18,9 @@ import org.bukkit.event.entity.EntityDeathEvent;
public class EntityPlayer extends EntityHuman implements ICrafting { public class EntityPlayer extends EntityHuman implements ICrafting {
public NetServerHandler a; public NetServerHandler netServerHandler;
public MinecraftServer b; public MinecraftServer b;
public ItemInWorldManager c; public ItemInWorldManager itemInWorldManager;
public double d; public double d;
public double e; public double e;
public List f = new LinkedList(); public List f = new LinkedList();
@ -33,23 +33,23 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) { public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
super(world); super(world);
ChunkCoordinates chunkcoordinates = world.m(); ChunkCoordinates chunkcoordinates = world.getSpawn();
int i = chunkcoordinates.a; int i = chunkcoordinates.x;
int j = chunkcoordinates.c; int j = chunkcoordinates.z;
int k = chunkcoordinates.b; int k = chunkcoordinates.y;
if (!world.m.e) { if (!world.worldProvider.e) {
i += this.random.nextInt(20) - 10; i += this.random.nextInt(20) - 10;
k = world.e(i, j); k = world.e(i, j);
j += this.random.nextInt(20) - 10; j += this.random.nextInt(20) - 10;
} }
this.c((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
this.b = minecraftserver; this.b = minecraftserver;
this.bm = 0.0F; this.bm = 0.0F;
iteminworldmanager.a = this; iteminworldmanager.player = this;
this.name = s; this.name = s;
this.c = iteminworldmanager; this.itemInWorldManager = iteminworldmanager;
this.height = 0.0F; this.height = 0.0F;
// CraftBukkit start // CraftBukkit start
@ -60,11 +60,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public Location compassTarget; public Location compassTarget;
// CraftBukkit end // CraftBukkit end
public void m() { public void syncInventory() {
this.activeContainer.a((ICrafting) this); this.activeContainer.a((ICrafting) this);
} }
public ItemStack[] k_() { public ItemStack[] getEquipment() {
return this.bG; return this.bG;
} }
@ -77,7 +77,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} }
public void f_() { public void f_() {
this.c.a(); this.itemInWorldManager.a();
--this.bF; --this.bF;
this.activeContainer.a(); this.activeContainer.a();
@ -85,31 +85,31 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
ItemStack itemstack = this.b_(i); ItemStack itemstack = this.b_(i);
if (itemstack != this.bG[i]) { if (itemstack != this.bG[i]) {
this.b.k.a(this, new Packet5EntityEquipment(this.id, i, itemstack)); this.b.tracker.a(this, new Packet5EntityEquipment(this.id, i, itemstack));
this.bG[i] = itemstack; this.bG[i] = itemstack;
} }
} }
} }
public ItemStack b_(int i) { public ItemStack b_(int i) {
return i == 0 ? this.inventory.b() : this.inventory.b[i - 1]; return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1];
} }
public void a(Entity entity) { public void a(Entity entity) {
// CraftBukkit start // CraftBukkit start
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>(); List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
for (int i = 0; i < inventory.a.length; ++i) { for (int i = 0; i < inventory.items.length; ++i) {
if (inventory.a[i] != null) { if (inventory.items[i] != null) {
loot.add(new CraftItemStack(inventory.a[i])); loot.add(new CraftItemStack(inventory.items[i]));
inventory.a[i] = null; inventory.items[i] = null;
} }
} }
for (int i = 0; i < inventory.b.length; ++i) { for (int i = 0; i < inventory.armor.length; ++i) {
if (inventory.b[i] != null) { if (inventory.armor[i] != null) {
loot.add(new CraftItemStack(inventory.b[i])); loot.add(new CraftItemStack(inventory.armor[i]));
inventory.b[i] = null; inventory.armor[i] = null;
} }
} }
@ -126,11 +126,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// CraftBukkit end // CraftBukkit end
} }
public boolean a(Entity entity, int i) { public boolean damageEntity(Entity entity, int i) {
if (this.bF > 0) { if (this.bF > 0) {
return false; return false;
} else { } else {
if (!this.b.n) { if (!this.b.pvpMode) {
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
return false; return false;
} }
@ -138,13 +138,13 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (entity instanceof EntityArrow) { if (entity instanceof EntityArrow) {
EntityArrow entityarrow = (EntityArrow) entity; EntityArrow entityarrow = (EntityArrow) entity;
if (entityarrow.b instanceof EntityHuman) { if (entityarrow.shooter instanceof EntityHuman) {
return false; return false;
} }
} }
} }
return super.a(entity, i); return super.damageEntity(entity, i);
} }
} }
@ -160,7 +160,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (chunkcoordintpair != null) { if (chunkcoordintpair != null) {
boolean flag1 = false; boolean flag1 = false;
if (this.a.b() < 2) { if (this.netServerHandler.b() < 2) {
flag1 = true; flag1 = true;
} }
@ -168,8 +168,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.f.remove(chunkcoordintpair); this.f.remove(chunkcoordintpair);
// CraftBukkit start // CraftBukkit start
this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.world))); this.netServerHandler.sendPacket(new Packet51MapChunk(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, 16, 128, 16, this.world));
List list = ((WorldServer) world).d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16); List list = ((WorldServer) world).getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 128, chunkcoordintpair.z * 16 + 16);
// CraftBukkit end // CraftBukkit end
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
@ -180,7 +180,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} }
if (this.health != this.bE) { if (this.health != this.bE) {
this.a.b((Packet) (new Packet8UpdateHealth(this.health))); this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.health));
this.bE = this.health; this.bE = this.health;
} }
} }
@ -190,7 +190,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
Packet packet = tileentity.e(); Packet packet = tileentity.e();
if (packet != null) { if (packet != null) {
this.a.b(packet); this.netServerHandler.sendPacket(packet);
} }
} }
} }
@ -199,18 +199,18 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
super.r(); super.r();
} }
public void b(Entity entity, int i) { public void receive(Entity entity, int i) {
if (!entity.dead) { if (!entity.dead) {
if (entity instanceof EntityItem) { if (entity instanceof EntityItem) {
this.b.k.a(entity, new Packet22Collect(entity.id, this.id)); this.b.tracker.a(entity, new Packet22Collect(entity.id, this.id));
} }
if (entity instanceof EntityArrow) { if (entity instanceof EntityArrow) {
this.b.k.a(entity, new Packet22Collect(entity.id, this.id)); this.b.tracker.a(entity, new Packet22Collect(entity.id, this.id));
} }
} }
super.b(entity, i); super.receive(entity, i);
this.activeContainer.a(); this.activeContainer.a();
} }
@ -218,7 +218,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (!this.p) { if (!this.p) {
this.q = -1; this.q = -1;
this.p = true; this.p = true;
this.b.k.a(this, new Packet18ArmAnimation(this, 1)); this.b.tracker.a(this, new Packet18ArmAnimation(this, 1));
} }
} }
@ -228,34 +228,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
EnumBedError enumbederror = super.a(i, j, k); EnumBedError enumbederror = super.a(i, j, k);
if (enumbederror == EnumBedError.OK) { if (enumbederror == EnumBedError.OK) {
this.b.k.a(this, new Packet17(this, 0, i, j, k)); this.b.tracker.a(this, new Packet17(this, 0, i, j, k));
} }
return enumbederror; return enumbederror;
} }
public void a(boolean flag, boolean flag1, boolean flag2) { public void a(boolean flag, boolean flag1, boolean flag2) {
if (this.F()) { if (this.isSleeping()) {
this.b.k.b(this, new Packet18ArmAnimation(this, 3)); this.b.tracker.b(this, new Packet18ArmAnimation(this, 3));
} }
super.a(flag, flag1, flag2); super.a(flag, flag1, flag2);
this.a.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); this.netServerHandler.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
} }
public void b(Entity entity) { public void mount(Entity entity) {
// CraftBukkit start // CraftBukkit start
setPassengerOf(entity); setPassengerOf(entity);
} }
public void setPassengerOf(Entity entity) { public void setPassengerOf(Entity entity) {
// b(null) doesn't really fly for overloaded methods, // mount(null) doesn't really fly for overloaded methods,
// so this method is needed // so this method is needed
super.setPassengerOf(entity); super.setPassengerOf(entity);
// CraftBukkit end // CraftBukkit end
this.a.b((Packet) (new Packet39AttachEntity(this, this.vehicle)));
this.a.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); this.netServerHandler.sendPacket(new Packet39AttachEntity(this, this.vehicle));
this.netServerHandler.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
} }
protected void a(double d0, boolean flag) {} protected void a(double d0, boolean flag) {}
@ -270,7 +271,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void b(int i, int j, int k) { public void b(int i, int j, int k) {
this.aa(); this.aa();
this.a.b((Packet) (new Packet100OpenWindow(this.bH, 1, "Crafting", 9))); this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bH, 1, "Crafting", 9));
this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k); this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k);
this.activeContainer.f = this.bH; this.activeContainer.f = this.bH;
this.activeContainer.a((ICrafting) this); this.activeContainer.a((ICrafting) this);
@ -278,7 +279,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(IInventory iinventory) { public void a(IInventory iinventory) {
this.aa(); this.aa();
this.a.b((Packet) (new Packet100OpenWindow(this.bH, 0, iinventory.c(), iinventory.q_()))); this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bH, 0, iinventory.getName(), iinventory.getSize()));
this.activeContainer = new ContainerChest(this.inventory, iinventory); this.activeContainer = new ContainerChest(this.inventory, iinventory);
this.activeContainer.f = this.bH; this.activeContainer.f = this.bH;
this.activeContainer.a((ICrafting) this); this.activeContainer.a((ICrafting) this);
@ -286,7 +287,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(TileEntityFurnace tileentityfurnace) { public void a(TileEntityFurnace tileentityfurnace) {
this.aa(); this.aa();
this.a.b((Packet) (new Packet100OpenWindow(this.bH, 2, tileentityfurnace.c(), tileentityfurnace.q_()))); this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bH, 2, tileentityfurnace.getName(), tileentityfurnace.getSize()));
this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace); this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace);
this.activeContainer.f = this.bH; this.activeContainer.f = this.bH;
this.activeContainer.a((ICrafting) this); this.activeContainer.a((ICrafting) this);
@ -294,7 +295,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(TileEntityDispenser tileentitydispenser) { public void a(TileEntityDispenser tileentitydispenser) {
this.aa(); this.aa();
this.a.b((Packet) (new Packet100OpenWindow(this.bH, 3, tileentitydispenser.c(), tileentitydispenser.q_()))); this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bH, 3, tileentitydispenser.getName(), tileentitydispenser.getSize()));
this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser); this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser);
this.activeContainer.f = this.bH; this.activeContainer.f = this.bH;
this.activeContainer.a((ICrafting) this); this.activeContainer.a((ICrafting) this);
@ -303,30 +304,30 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void a(Container container, int i, ItemStack itemstack) { public void a(Container container, int i, ItemStack itemstack) {
if (!(container.a(i) instanceof SlotResult)) { if (!(container.a(i) instanceof SlotResult)) {
if (!this.h) { if (!this.h) {
this.a.b((Packet) (new Packet103SetSlot(container.f, i, itemstack))); this.netServerHandler.sendPacket(new Packet103SetSlot(container.f, i, itemstack));
} }
} }
} }
public void a(Container container, List list) { public void a(Container container, List list) {
this.a.b((Packet) (new Packet104WindowItems(container.f, list))); this.netServerHandler.sendPacket(new Packet104WindowItems(container.f, list));
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.j()))); this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.j()));
} }
public void a(Container container, int i, int j) { public void a(Container container, int i, int j) {
this.a.b((Packet) (new Packet105CraftProgressBar(container.f, i, j))); this.netServerHandler.sendPacket(new Packet105CraftProgressBar(container.f, i, j));
} }
public void a(ItemStack itemstack) {} public void a(ItemStack itemstack) {}
public void u() { public void u() {
this.a.b((Packet) (new Packet101CloseWindow(this.activeContainer.f))); this.netServerHandler.sendPacket(new Packet101CloseWindow(this.activeContainer.f));
this.w(); this.w();
} }
public void v() { public void v() {
if (!this.h) { if (!this.h) {
this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.j()))); this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.j()));
} }
} }
@ -339,7 +340,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.au = f; this.au = f;
this.av = f1; this.av = f1;
this.ax = flag; this.ax = flag;
this.e(flag1); this.setSneak(flag1);
this.pitch = f2; this.pitch = f2;
this.yaw = f3; this.yaw = f3;
} }

View file

@ -36,7 +36,7 @@ public class EntitySkeleton extends EntityMonster {
if (this.world.d()) { if (this.world.d()) {
float f = this.c(1.0F); float f = this.c(1.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) { if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity entity = this.getBukkitEntity(); org.bukkit.entity.Entity entity = this.getBukkitEntity();
@ -66,8 +66,8 @@ public class EntitySkeleton extends EntityMonster {
double d2 = entity.locY - 0.20000000298023224D - entityarrow.locY; double d2 = entity.locY - 0.20000000298023224D - entityarrow.locY;
float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F; float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F;
this.world.a(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F)); this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
this.world.a((Entity) entityarrow); this.world.addEntity(entityarrow);
entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F); entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F);
this.attackTicks = 30; this.attackTicks = 30;
} }

View file

@ -17,7 +17,7 @@ public class EntitySnowball extends Entity {
private int e = 0; private int e = 0;
private boolean f = false; private boolean f = false;
public int a = 0; public int a = 0;
private EntityLiving g; private EntityLiving shooter;
private int h; private int h;
private int i = 0; private int i = 0;
@ -30,19 +30,19 @@ public class EntitySnowball extends Entity {
public EntitySnowball(World world, EntityLiving entityliving) { public EntitySnowball(World world, EntityLiving entityliving) {
super(world); super(world);
this.g = entityliving; this.shooter = entityliving;
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.c(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.q(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.locY -= 0.10000000149011612D; this.locY -= 0.10000000149011612D;
this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F);
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
this.height = 0.0F; this.height = 0.0F;
float f = 0.4F; 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.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(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.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f); this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f);
this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
} }
@ -50,7 +50,7 @@ public class EntitySnowball extends Entity {
super(world); super(world);
this.h = 0; this.h = 0;
this.b(0.25F, 0.25F); this.b(0.25F, 0.25F);
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
this.height = 0.0F; this.height = 0.0F;
} }
@ -91,7 +91,7 @@ public class EntitySnowball extends Entity {
if (i == this.e) { if (i == this.e) {
++this.h; ++this.h;
if (this.h == 1200) { if (this.h == 1200) {
this.D(); this.die();
} }
return; return;
@ -107,14 +107,14 @@ public class EntitySnowball extends Entity {
++this.i; ++this.i;
} }
Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ); Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
vec3d = Vec3D.b(this.locX, this.locY, this.locZ); vec3d = Vec3D.create(this.locX, this.locY, this.locZ);
vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); vec3d1 = Vec3D.create(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.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
} }
if (!this.world.isStatic) { if (!this.world.isStatic) {
@ -125,7 +125,7 @@ public class EntitySnowball extends Entity {
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.d_() && (entity1 != this.g || this.i >= 5)) { if (entity1.d_() && (entity1 != this.shooter || this.i >= 5)) {
float f = 0.3F; float f = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
@ -148,12 +148,12 @@ public class EntitySnowball extends Entity {
if (movingobjectposition != null) { if (movingobjectposition != null) {
// CraftBukkit start // CraftBukkit start
if (movingobjectposition.g != null) { if (movingobjectposition.entity != null) {
boolean stick; boolean stick;
if (movingobjectposition.g instanceof EntityLiving) { if (movingobjectposition.entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity shooter = (this.g == null) ? null : this.g.getBukkitEntity(); org.bukkit.entity.Entity shooter = (this.shooter == null) ? null : this.shooter.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity(); org.bukkit.entity.Entity damagee = movingobjectposition.entity.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;
@ -164,13 +164,13 @@ public class EntitySnowball extends Entity {
if (!event.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
stick = movingobjectposition.g.a(this.g, event.getDamage()); stick = movingobjectposition.entity.damageEntity(this.shooter, 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
stick = !event.getBounce(); stick = !event.getBounce();
} }
} else { } else {
stick = movingobjectposition.g.a(this.g, 0); stick = movingobjectposition.entity.damageEntity(this.shooter, 0);
} }
if (stick) { if (stick) {
; ;
@ -182,7 +182,7 @@ public class EntitySnowball extends Entity {
this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
} }
this.D(); this.die();
} }
this.locX += this.motX; this.locX += this.motX;
@ -227,7 +227,7 @@ public class EntitySnowball extends Entity {
this.motY *= (double) f2; this.motY *= (double) f2;
this.motZ *= (double) f2; this.motZ *= (double) f2;
this.motY -= (double) f3; this.motY -= (double) f3;
this.a(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
@ -249,10 +249,10 @@ public class EntitySnowball extends Entity {
} }
public void b(EntityHuman entityhuman) { public void b(EntityHuman entityhuman) {
if (this.f && this.g == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) { if (this.f && this.shooter == entityhuman && this.a <= 0 && entityhuman.inventory.canHold(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); this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.b(this, 1); entityhuman.receive(this, 1);
this.D(); this.die();
} }
} }
} }

View file

@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
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 stop
public class EntitySpider extends EntityMonster { public class EntitySpider extends EntityMonster {
@ -24,7 +24,7 @@ public class EntitySpider extends EntityMonster {
return false; return false;
} }
protected Entity m() { protected Entity findTarget() {
float f = this.c(1.0F); float f = this.c(1.0F);
if (f < 0.5F) { if (f < 0.5F) {
@ -59,9 +59,9 @@ public class EntitySpider extends EntityMonster {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (event.getTarget() == null) { if (event.getTarget() == null) {
this.d = null; this.target = null;
} else { } else {
this.d = ((CraftEntity) event.getTarget()).getHandle(); this.target = ((CraftEntity) event.getTarget()).getHandle();
} }
return; return;
} }
@ -96,6 +96,6 @@ public class EntitySpider extends EntityMonster {
} }
public boolean n() { public boolean n() {
return this.aW; return this.positionChanged;
} }
} }

View file

@ -20,12 +20,12 @@ public class EntityTNTPrimed extends Entity {
public EntityTNTPrimed(World world, double d0, double d1, double d2) { public EntityTNTPrimed(World world, double d0, double d1, double d2) {
this(world); this(world);
this.a(d0, d1, d2); this.setPosition(d0, d1, d2);
float f = (float) (Math.random() * 3.1415927410125732D * 2.0D); float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
this.motX = (double) (-MathHelper.a(f * 3.1415927F / 180.0F) * 0.02F); this.motX = (double) (-MathHelper.sin(f * 3.1415927F / 180.0F) * 0.02F);
this.motY = 0.20000000298023224D; this.motY = 0.20000000298023224D;
this.motZ = (double) (-MathHelper.b(f * 3.1415927F / 180.0F) * 0.02F); this.motZ = (double) (-MathHelper.cos(f * 3.1415927F / 180.0F) * 0.02F);
this.a = 80; this.a = 80;
this.lastX = d0; this.lastX = d0;
this.lastY = d1; this.lastY = d1;
@ -47,7 +47,7 @@ public class EntityTNTPrimed extends Entity {
this.lastY = this.locY; this.lastY = this.locY;
this.lastZ = this.locZ; this.lastZ = this.locZ;
this.motY -= 0.03999999910593033D; this.motY -= 0.03999999910593033D;
this.c(this.motX, this.motY, this.motZ); this.move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D; this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D; this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D; this.motZ *= 0.9800000190734863D;
@ -59,15 +59,15 @@ public class EntityTNTPrimed extends Entity {
if (this.a-- <= 0) { if (this.a-- <= 0) {
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event. // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event.
this.h(); this.explode();
this.D(); this.die();
// CraftBukkit end // CraftBukkit end
} else { } else {
this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 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 h() { private void explode() {
float f = 4.0F; float f = 4.0F;
// CraftBukkit start // CraftBukkit start
@ -78,7 +78,7 @@ public class EntityTNTPrimed extends Entity {
if (!event.isCancelled()) { if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage // give 'this' instead of (Entity) null so we know what causes the damage
this.world.a(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
} }
// CraftBukkit end // CraftBukkit end
} }

View file

@ -14,7 +14,7 @@ public class EntityTracker {
public EntityTracker(MinecraftServer minecraftserver) { public EntityTracker(MinecraftServer minecraftserver) {
this.c = minecraftserver; this.c = minecraftserver;
this.d = minecraftserver.f.a(); this.d = minecraftserver.serverConfigurationManager.a();
} }
// CraftBukkit -- synchronized // CraftBukkit -- synchronized
@ -27,7 +27,7 @@ public class EntityTracker {
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
if (entitytrackerentry.a != entityplayer) { if (entitytrackerentry.tracker != entityplayer) {
entitytrackerentry.b(entityplayer); entitytrackerentry.b(entityplayer);
} }
} }
@ -76,12 +76,12 @@ public class EntityTracker {
this.a.add(entitytrackerentry); this.a.add(entitytrackerentry);
this.b.a(entity.id, entitytrackerentry); this.b.a(entity.id, entitytrackerentry);
// CraftBukkit // CraftBukkit
entitytrackerentry.b(entity.world.d); // CraftBukkit entitytrackerentry.scanPlayers(entity.world.players);
} }
} }
// CraftBukkit -- synchronized // CraftBukkit -- synchronized
public synchronized void b(Entity entity) { public synchronized void untrackEntity(Entity entity) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity; EntityPlayer entityplayer = (EntityPlayer) entity;
Iterator iterator = this.a.iterator(); Iterator iterator = this.a.iterator();
@ -110,9 +110,9 @@ public class EntityTracker {
EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next(); EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
// CraftBukkit // CraftBukkit
entitytrackerentry.a(entitytrackerentry.a.world.d); entitytrackerentry.track(entitytrackerentry.tracker.world.players);
if (entitytrackerentry.m && entitytrackerentry.a instanceof EntityPlayer) { if (entitytrackerentry.m && entitytrackerentry.tracker instanceof EntityPlayer) {
arraylist.add((EntityPlayer) entitytrackerentry.a); arraylist.add((EntityPlayer) entitytrackerentry.tracker);
} }
} }
@ -123,7 +123,7 @@ public class EntityTracker {
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next(); EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next();
if (entitytrackerentry1.a != entityplayer) { if (entitytrackerentry1.tracker != entityplayer) {
entitytrackerentry1.b(entityplayer); entitytrackerentry1.b(entityplayer);
} }
} }
@ -149,7 +149,7 @@ public class EntityTracker {
} }
// CraftBukkit -- synchronized // CraftBukkit -- synchronized
public synchronized void a(EntityPlayer entityplayer) { public synchronized void trackPlayer(EntityPlayer entityplayer) {
Iterator iterator = this.a.iterator(); Iterator iterator = this.a.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {

View file

@ -7,7 +7,7 @@ import java.util.Set;
public class EntityTrackerEntry { public class EntityTrackerEntry {
public Entity a; public Entity tracker;
public int b; public int b;
public int c; public int c;
public int d; public int d;
@ -23,47 +23,47 @@ public class EntityTrackerEntry {
private double p; private double p;
private double q; private double q;
private boolean r = false; private boolean r = false;
private boolean s; private boolean isMoving;
public boolean m = false; public boolean m = false;
public Set n = new HashSet(); public Set trackedPlayers = new HashSet();
public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) { public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) {
this.a = entity; this.tracker = entity;
this.b = i; this.b = i;
this.c = j; this.c = j;
this.s = flag; this.isMoving = flag;
this.d = MathHelper.b(entity.locX * 32.0D); this.d = MathHelper.floor(entity.locX * 32.0D);
this.e = MathHelper.b(entity.locY * 32.0D); this.e = MathHelper.floor(entity.locY * 32.0D);
this.f = MathHelper.b(entity.locZ * 32.0D); this.f = MathHelper.floor(entity.locZ * 32.0D);
this.g = MathHelper.d(entity.yaw * 256.0F / 360.0F); this.g = MathHelper.d(entity.yaw * 256.0F / 360.0F);
this.h = MathHelper.d(entity.pitch * 256.0F / 360.0F); this.h = MathHelper.d(entity.pitch * 256.0F / 360.0F);
} }
public boolean equals(Object object) { public boolean equals(Object object) {
return object instanceof EntityTrackerEntry ? ((EntityTrackerEntry) object).a.id == this.a.id : false; return object instanceof EntityTrackerEntry ? ((EntityTrackerEntry) object).tracker.id == this.tracker.id : false;
} }
public int hashCode() { public int hashCode() {
return this.a.id; return this.tracker.id;
} }
public void a(List list) { public void track(List list) {
this.m = false; this.m = false;
if (!this.r || this.a.d(this.o, this.p, this.q) > 16.0D) { if (!this.r || this.tracker.d(this.o, this.p, this.q) > 16.0D) {
this.o = this.a.locX; this.o = this.tracker.locX;
this.p = this.a.locY; this.p = this.tracker.locY;
this.q = this.a.locZ; this.q = this.tracker.locZ;
this.r = true; this.r = true;
this.m = true; this.m = true;
this.b(list); this.scanPlayers(list);
} }
if (++this.l % this.c == 0) { if (++this.l % this.c == 0) {
int i = MathHelper.b(this.a.locX * 32.0D); int i = MathHelper.floor(this.tracker.locX * 32.0D);
int j = MathHelper.b(this.a.locY * 32.0D); int j = MathHelper.floor(this.tracker.locY * 32.0D);
int k = MathHelper.b(this.a.locZ * 32.0D); int k = MathHelper.floor(this.tracker.locZ * 32.0D);
int l = MathHelper.d(this.a.yaw * 256.0F / 360.0F); int l = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F);
int i1 = MathHelper.d(this.a.pitch * 256.0F / 360.0F); int i1 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F);
int j1 = i - this.d; int j1 = i - this.d;
int k1 = j - this.e; int k1 = j - this.e;
int l1 = k - this.f; int l1 = k - this.f;
@ -73,28 +73,28 @@ public class EntityTrackerEntry {
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128) { if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128) {
if (flag && flag1) { if (flag && flag1) {
object = new Packet33RelEntityMoveLook(this.a.id, (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1); object = new Packet33RelEntityMoveLook(this.tracker.id, (byte) j1, (byte) k1, (byte) l1, (byte) l, (byte) i1);
} else if (flag) { } else if (flag) {
object = new Packet31RelEntityMove(this.a.id, (byte) j1, (byte) k1, (byte) l1); object = new Packet31RelEntityMove(this.tracker.id, (byte) j1, (byte) k1, (byte) l1);
} else if (flag1) { } else if (flag1) {
object = new Packet32EntityLook(this.a.id, (byte) l, (byte) i1); object = new Packet32EntityLook(this.tracker.id, (byte) l, (byte) i1);
} }
} else { } else {
object = new Packet34EntityTeleport(this.a.id, i, j, k, (byte) l, (byte) i1); object = new Packet34EntityTeleport(this.tracker.id, i, j, k, (byte) l, (byte) i1);
} }
if (this.s) { if (this.isMoving) {
double d0 = this.a.motX - this.i; double d0 = this.tracker.motX - this.i;
double d1 = this.a.motY - this.j; double d1 = this.tracker.motY - this.j;
double d2 = this.a.motZ - this.k; double d2 = this.tracker.motZ - this.k;
double d3 = 0.02D; double d3 = 0.02D;
double d4 = d0 * d0 + d1 * d1 + d2 * d2; double d4 = d0 * d0 + d1 * d1 + d2 * d2;
if (d4 > d3 * d3 || d4 > 0.0D && this.a.motX == 0.0D && this.a.motY == 0.0D && this.a.motZ == 0.0D) { if (d4 > d3 * d3 || d4 > 0.0D && this.tracker.motX == 0.0D && this.tracker.motY == 0.0D && this.tracker.motZ == 0.0D) {
this.i = this.a.motX; this.i = this.tracker.motX;
this.j = this.a.motY; this.j = this.tracker.motY;
this.k = this.a.motZ; this.k = this.tracker.motZ;
this.a((Packet) (new Packet28EntityVelocity(this.a.id, this.i, this.j, this.k))); this.a((Packet) (new Packet28EntityVelocity(this.tracker.id, this.i, this.j, this.k)));
} }
} }
@ -102,10 +102,10 @@ public class EntityTrackerEntry {
this.a((Packet) object); this.a((Packet) object);
} }
DataWatcher datawatcher = this.a.T(); DataWatcher datawatcher = this.tracker.T();
if (datawatcher.a()) { if (datawatcher.a()) {
this.b((Packet) (new Packet40EntityMetadata(this.a.id, datawatcher))); this.b((Packet) (new Packet40EntityMetadata(this.tracker.id, datawatcher)));
} }
if (flag) { if (flag) {
@ -120,142 +120,142 @@ public class EntityTrackerEntry {
} }
} }
if (this.a.aZ) { if (this.tracker.velocityChanged) {
this.b((Packet) (new Packet28EntityVelocity(this.a))); this.b((Packet) (new Packet28EntityVelocity(this.tracker)));
this.a.aZ = false; this.tracker.velocityChanged = false;
} }
} }
public void a(Packet packet) { public void a(Packet packet) {
Iterator iterator = this.n.iterator(); Iterator iterator = this.trackedPlayers.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
entityplayer.a.b(packet); entityplayer.netServerHandler.sendPacket(packet);
} }
} }
public void b(Packet packet) { public void b(Packet packet) {
this.a(packet); this.a(packet);
if (this.a instanceof EntityPlayer) { if (this.tracker instanceof EntityPlayer) {
((EntityPlayer) this.a).a.b(packet); ((EntityPlayer) this.tracker).netServerHandler.sendPacket(packet);
} }
} }
public void a() { public void a() {
this.a((Packet) (new Packet29DestroyEntity(this.a.id))); this.a((Packet) (new Packet29DestroyEntity(this.tracker.id)));
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
if (this.n.contains(entityplayer)) { if (this.trackedPlayers.contains(entityplayer)) {
this.n.remove(entityplayer); this.trackedPlayers.remove(entityplayer);
} }
} }
public void b(EntityPlayer entityplayer) { public void b(EntityPlayer entityplayer) {
if (entityplayer != this.a) { if (entityplayer != this.tracker) {
double d0 = entityplayer.locX - (double) (this.d / 32); double d0 = entityplayer.locX - (double) (this.d / 32);
double d1 = entityplayer.locZ - (double) (this.f / 32); double d1 = entityplayer.locZ - (double) (this.f / 32);
if (d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b) { if (d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b) {
// CraftBukkit // CraftBukkit
if ((!this.n.contains(entityplayer)) && (this.a.world == entityplayer.world)) { if ((!this.trackedPlayers.contains(entityplayer)) && (this.tracker.world == entityplayer.world)) {
this.n.add(entityplayer); this.trackedPlayers.add(entityplayer);
entityplayer.a.b(this.b()); entityplayer.netServerHandler.sendPacket(this.b());
if (this.s) { if (this.isMoving) {
entityplayer.a.b((Packet) (new Packet28EntityVelocity(this.a.id, this.a.motX, this.a.motY, this.a.motZ))); entityplayer.netServerHandler.sendPacket(new Packet28EntityVelocity(this.tracker.id, this.tracker.motX, this.tracker.motY, this.tracker.motZ));
} }
ItemStack[] aitemstack = this.a.k_(); ItemStack[] aitemstack = this.tracker.getEquipment();
if (aitemstack != null) { if (aitemstack != null) {
for (int i = 0; i < aitemstack.length; ++i) { for (int i = 0; i < aitemstack.length; ++i) {
entityplayer.a.b((Packet) (new Packet5EntityEquipment(this.a.id, i, aitemstack[i]))); entityplayer.netServerHandler.sendPacket(new Packet5EntityEquipment(this.tracker.id, i, aitemstack[i]));
} }
} }
} }
} else if (this.n.contains(entityplayer)) { } else if (this.trackedPlayers.contains(entityplayer)) {
this.n.remove(entityplayer); this.trackedPlayers.remove(entityplayer);
entityplayer.a.b((Packet) (new Packet29DestroyEntity(this.a.id))); entityplayer.netServerHandler.sendPacket(new Packet29DestroyEntity(this.tracker.id));
} }
} }
} }
public void b(List list) { public void scanPlayers(List list) {
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
this.b((EntityPlayer) list.get(i)); this.b((EntityPlayer) list.get(i));
} }
} }
private Packet b() { private Packet b() {
if (this.a instanceof EntityItem) { if (this.tracker instanceof EntityItem) {
EntityItem entityitem = (EntityItem) this.a; EntityItem entityitem = (EntityItem) this.tracker;
Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem); Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem);
entityitem.locX = (double) packet21pickupspawn.b / 32.0D; entityitem.locX = (double) packet21pickupspawn.b / 32.0D;
entityitem.locY = (double) packet21pickupspawn.c / 32.0D; entityitem.locY = (double) packet21pickupspawn.c / 32.0D;
entityitem.locZ = (double) packet21pickupspawn.d / 32.0D; entityitem.locZ = (double) packet21pickupspawn.d / 32.0D;
return packet21pickupspawn; return packet21pickupspawn;
} else if (this.a instanceof EntityPlayer) { } else if (this.tracker instanceof EntityPlayer) {
return new Packet20NamedEntitySpawn((EntityHuman) this.a); return new Packet20NamedEntitySpawn((EntityHuman) this.tracker);
} else { } else {
if (this.a instanceof EntityMinecart) { if (this.tracker instanceof EntityMinecart) {
EntityMinecart entityminecart = (EntityMinecart) this.a; EntityMinecart entityminecart = (EntityMinecart) this.tracker;
if (entityminecart.d == 0) { if (entityminecart.type == 0) {
return new Packet23VehicleSpawn(this.a, 10); return new Packet23VehicleSpawn(this.tracker, 10);
} }
if (entityminecart.d == 1) { if (entityminecart.type == 1) {
return new Packet23VehicleSpawn(this.a, 11); return new Packet23VehicleSpawn(this.tracker, 11);
} }
if (entityminecart.d == 2) { if (entityminecart.type == 2) {
return new Packet23VehicleSpawn(this.a, 12); return new Packet23VehicleSpawn(this.tracker, 12);
} }
} }
if (this.a instanceof EntityBoat) { if (this.tracker instanceof EntityBoat) {
return new Packet23VehicleSpawn(this.a, 1); return new Packet23VehicleSpawn(this.tracker, 1);
} else if (this.a instanceof IAnimal) { } else if (this.tracker instanceof IAnimal) {
return new Packet24MobSpawn((EntityLiving) this.a); return new Packet24MobSpawn((EntityLiving) this.tracker);
} else if (this.a instanceof EntityFish) { } else if (this.tracker instanceof EntityFish) {
return new Packet23VehicleSpawn(this.a, 90); return new Packet23VehicleSpawn(this.tracker, 90);
} else if (this.a instanceof EntityArrow) { } else if (this.tracker instanceof EntityArrow) {
return new Packet23VehicleSpawn(this.a, 60); return new Packet23VehicleSpawn(this.tracker, 60);
} else if (this.a instanceof EntitySnowball) { } else if (this.tracker instanceof EntitySnowball) {
return new Packet23VehicleSpawn(this.a, 61); return new Packet23VehicleSpawn(this.tracker, 61);
} else if (this.a instanceof EntityEgg) { } else if (this.tracker instanceof EntityEgg) {
return new Packet23VehicleSpawn(this.a, 62); return new Packet23VehicleSpawn(this.tracker, 62);
} else if (this.a instanceof EntityTNTPrimed) { } else if (this.tracker instanceof EntityTNTPrimed) {
return new Packet23VehicleSpawn(this.a, 50); return new Packet23VehicleSpawn(this.tracker, 50);
} else { } else {
if (this.a instanceof EntityFallingSand) { if (this.tracker instanceof EntityFallingSand) {
EntityFallingSand entityfallingsand = (EntityFallingSand) this.a; EntityFallingSand entityfallingsand = (EntityFallingSand) this.tracker;
if (entityfallingsand.a == Block.SAND.id) { if (entityfallingsand.a == Block.SAND.id) {
return new Packet23VehicleSpawn(this.a, 70); return new Packet23VehicleSpawn(this.tracker, 70);
} }
if (entityfallingsand.a == Block.GRAVEL.id) { if (entityfallingsand.a == Block.GRAVEL.id) {
return new Packet23VehicleSpawn(this.a, 71); return new Packet23VehicleSpawn(this.tracker, 71);
} }
} }
if (this.a instanceof EntityPainting) { if (this.tracker instanceof EntityPainting) {
return new Packet25EntityPainting((EntityPainting) this.a); return new Packet25EntityPainting((EntityPainting) this.tracker);
} else { } else {
throw new IllegalArgumentException("Don\'t know how to add " + this.a.getClass() + "!"); throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!");
} }
} }
} }
} }
public void c(EntityPlayer entityplayer) { public void c(EntityPlayer entityplayer) {
if (this.n.contains(entityplayer)) { if (this.trackedPlayers.contains(entityplayer)) {
this.n.remove(entityplayer); this.trackedPlayers.remove(entityplayer);
entityplayer.a.b((Packet) (new Packet29DestroyEntity(this.a.id))); entityplayer.netServerHandler.sendPacket(new Packet29DestroyEntity(this.tracker.id));
} }
} }
} }

View file

@ -11,14 +11,14 @@ public class EntityZombie extends EntityMonster {
super(world); super(world);
this.texture = "/mob/zombie.png"; this.texture = "/mob/zombie.png";
this.az = 0.5F; this.az = 0.5F;
this.c = 5; this.damage = 5;
} }
public void r() { public void r() {
if (this.world.d()) { if (this.world.d()) {
float f = this.c(1.0F); float f = this.c(1.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) { if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start // CraftBukkit start
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity()); EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity());

View file

@ -22,27 +22,27 @@ public class Explosion {
public boolean a = false; public boolean a = false;
private Random h = new Random(); private Random h = new Random();
private World i; private World world;
public double b; public double posX;
public double c; public double posY;
public double d; public double posZ;
public Entity e; public Entity source;
public float f; public float size;
public Set g = new HashSet(); public Set g = new HashSet();
public boolean wasCanceled = false; // CraftBukkit public boolean wasCanceled = false; // CraftBukkit
public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) { public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) {
this.i = world; this.world = world;
this.e = entity; this.source = entity;
this.f = f; this.size = f;
this.b = d0; this.posX = d0;
this.c = d1; this.posY = d1;
this.d = d2; this.posZ = d2;
} }
public void a() { public void a() {
float f = this.f; float f = this.size;
byte b0 = 16; byte b0 = 16;
int i; int i;
@ -64,20 +64,20 @@ public class Explosion {
d3 /= d6; d3 /= d6;
d4 /= d6; d4 /= d6;
d5 /= d6; d5 /= d6;
float f1 = this.f * (0.7F + this.i.k.nextFloat() * 0.6F); float f1 = this.size * (0.7F + this.world.random.nextFloat() * 0.6F);
d0 = this.b; d0 = this.posX;
d1 = this.c; d1 = this.posY;
d2 = this.d; d2 = this.posZ;
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) { for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
int l = MathHelper.b(d0); int l = MathHelper.floor(d0);
int i1 = MathHelper.b(d1); int i1 = MathHelper.floor(d1);
int j1 = MathHelper.b(d2); int j1 = MathHelper.floor(d2);
int k1 = this.i.getTypeId(l, i1, j1); int k1 = this.world.getTypeId(l, i1, j1);
if (k1 > 0) { if (k1 > 0) {
f1 -= (Block.byId[k1].a(this.e) + 0.3F) * f2; f1 -= (Block.byId[k1].a(this.source) + 0.3F) * f2;
} }
if (f1 > 0.0F) { if (f1 > 0.0F) {
@ -93,41 +93,41 @@ public class Explosion {
} }
} }
this.f *= 2.0F; this.size *= 2.0F;
i = MathHelper.b(this.b - (double) this.f - 1.0D); i = MathHelper.floor(this.posX - (double) this.size - 1.0D);
j = MathHelper.b(this.b + (double) this.f + 1.0D); j = MathHelper.floor(this.posX + (double) this.size + 1.0D);
k = MathHelper.b(this.c - (double) this.f - 1.0D); k = MathHelper.floor(this.posY - (double) this.size - 1.0D);
int l1 = MathHelper.b(this.c + (double) this.f + 1.0D); int l1 = MathHelper.floor(this.posY + (double) this.size + 1.0D);
int i2 = MathHelper.b(this.d - (double) this.f - 1.0D); int i2 = MathHelper.floor(this.posZ - (double) this.size - 1.0D);
int j2 = MathHelper.b(this.d + (double) this.f + 1.0D); int j2 = MathHelper.floor(this.posZ + (double) this.size + 1.0D);
List list = this.i.b(this.e, AxisAlignedBB.b((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2)); List list = this.world.b(this.source, AxisAlignedBB.b((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
Vec3D vec3d = Vec3D.b(this.b, this.c, this.d); Vec3D vec3d = Vec3D.create(this.posX, this.posY, this.posZ);
for (int k2 = 0; k2 < list.size(); ++k2) { for (int k2 = 0; k2 < list.size(); ++k2) {
Entity entity = (Entity) list.get(k2); Entity entity = (Entity) list.get(k2);
double d7 = entity.e(this.b, this.c, this.d) / (double) this.f; double d7 = entity.e(this.posX, this.posY, this.posZ) / (double) this.size;
if (d7 <= 1.0D) { if (d7 <= 1.0D) {
d0 = entity.locX - this.b; d0 = entity.locX - this.posX;
d1 = entity.locY - this.c; d1 = entity.locY - this.posY;
d2 = entity.locZ - this.d; d2 = entity.locZ - this.posZ;
double d8 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); double d8 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
d0 /= d8; d0 /= d8;
d1 /= d8; d1 /= d8;
d2 /= d8; d2 /= d8;
double d9 = (double) this.i.a(vec3d, entity.boundingBox); double d9 = (double) this.world.a(vec3d, entity.boundingBox);
double d10 = (1.0D - d7) * d9; double d10 = (1.0D - d7) * d9;
// CraftBukkit start - explosion damage hook // CraftBukkit start - explosion damage hook
CraftServer server = ((WorldServer) this.i).getServer(); CraftServer server = ((WorldServer) this.world).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) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.f + 1.0D); int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.size + 1.0D);
if (damagee == null) { if (damagee == null) {
// nothing was hurt // nothing was hurt
} else if (e == null) { // Block explosion } else if (this.source == null) { // Block 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;
@ -136,20 +136,20 @@ public class Explosion {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entity.a(this.e, event.getDamage()); entity.damageEntity(this.source, event.getDamage());
entity.motX += d0 * d10; entity.motX += d0 * d10;
entity.motY += d1 * d10; entity.motY += d1 * d10;
entity.motZ += d2 * d10; entity.motZ += d2 * d10;
} }
} else { } else {
org.bukkit.entity.Entity damager = this.e.getBukkitEntity(); org.bukkit.entity.Entity damager = this.source.getBukkitEntity();
damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION; damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone); EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
entity.a(this.e, event.getDamage()); entity.damageEntity(this.source, event.getDamage());
entity.motX += d0 * d10; entity.motX += d0 * d10;
entity.motY += d1 * d10; entity.motY += d1 * d10;
@ -160,42 +160,42 @@ public class Explosion {
} }
} }
this.f = f; this.size = f;
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
arraylist.addAll(this.g); arraylist.addAll(this.g);
if (this.a) { if (this.a) {
for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) { for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2); ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
int i3 = chunkposition.a; int i3 = chunkposition.x;
int j3 = chunkposition.b; int j3 = chunkposition.y;
int k3 = chunkposition.c; int k3 = chunkposition.z;
int l3 = this.i.getTypeId(i3, j3, k3); int l3 = this.world.getTypeId(i3, j3, k3);
int i4 = this.i.getTypeId(i3, j3 - 1, k3); int i4 = this.world.getTypeId(i3, j3 - 1, k3);
if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) { if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) {
this.i.e(i3, j3, k3, Block.FIRE.id); this.world.setTypeId(i3, j3, k3, Block.FIRE.id);
} }
} }
} }
} }
public void b() { public void b() {
this.i.a(this.b, this.c, this.d, "random.explode", 4.0F, (1.0F + (this.i.k.nextFloat() - this.i.k.nextFloat()) * 0.2F) * 0.7F); this.world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F);
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
arraylist.addAll(this.g); arraylist.addAll(this.g);
// CraftBukkit start // CraftBukkit start
Server server = ((WorldServer) this.i).getServer(); Server server = ((WorldServer) this.world).getServer();
CraftWorld world = ((WorldServer) this.i).getWorld(); CraftWorld world = ((WorldServer) this.world).getWorld();
org.bukkit.entity.Entity explode = (this.e == null) ? null : this.e.getBukkitEntity(); org.bukkit.entity.Entity explode = (this.source == null) ? null : this.source.getBukkitEntity();
Location location = new Location(world, this.b, this.c, this.d); Location location = new Location(world, this.posX, this.posY, this.posZ);
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--) {
ChunkPosition cpos = (ChunkPosition) arraylist.get(j); ChunkPosition cpos = (ChunkPosition) arraylist.get(j);
org.bukkit.block.Block block = world.getBlockAt(cpos.a, cpos.b, cpos.c); org.bukkit.block.Block block = world.getBlockAt(cpos.x, cpos.y, cpos.z);
if (!block.getType().equals(org.bukkit.Material.AIR)) { if (!block.getType().equals(org.bukkit.Material.AIR)) {
blockList.add(block); blockList.add(block);
} }
@ -212,38 +212,38 @@ public class Explosion {
for (int i = arraylist.size() - 1; i >= 0; --i) { for (int i = arraylist.size() - 1; i >= 0; --i) {
ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i); ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i);
int j = chunkposition.a; int j = chunkposition.x;
int k = chunkposition.b; int k = chunkposition.y;
int l = chunkposition.c; int l = chunkposition.z;
int i1 = this.i.getTypeId(j, k, l); int i1 = this.world.getTypeId(j, k, l);
for (int j1 = 0; j1 < 1; ++j1) { for (int j1 = 0; j1 < 1; ++j1) {
double d0 = (double) ((float) j + this.i.k.nextFloat()); double d0 = (double) ((float) j + this.world.random.nextFloat());
double d1 = (double) ((float) k + this.i.k.nextFloat()); double d1 = (double) ((float) k + this.world.random.nextFloat());
double d2 = (double) ((float) l + this.i.k.nextFloat()); double d2 = (double) ((float) l + this.world.random.nextFloat());
double d3 = d0 - this.b; double d3 = d0 - this.posX;
double d4 = d1 - this.c; double d4 = d1 - this.posY;
double d5 = d2 - this.d; double d5 = d2 - this.posZ;
double d6 = (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); double d6 = (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5);
d3 /= d6; d3 /= d6;
d4 /= d6; d4 /= d6;
d5 /= d6; d5 /= d6;
double d7 = 0.5D / (d6 / (double) this.f + 0.1D); double d7 = 0.5D / (d6 / (double) this.size + 0.1D);
d7 *= (double) (this.i.k.nextFloat() * this.i.k.nextFloat() + 0.3F); d7 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F);
d3 *= d7; d3 *= d7;
d4 *= d7; d4 *= d7;
d5 *= 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.world.a("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5);
this.i.a("smoke", d0, d1, d2, d3, d4, d5); this.world.a("smoke", d0, d1, d2, d3, d4, d5);
} }
if (i1 > 0) { if (i1 > 0) {
// CraftBukkit // CraftBukkit
Block.byId[i1].a(this.i, j, k, l, this.i.getData(j, k, l), event.getYield()); Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield());
this.i.e(j, k, l, 0); this.world.setTypeId(j, k, l, 0);
Block.byId[i1].c(this.i, j, k, l); Block.byId[i1].c(this.world, j, k, l);
} }
} }
} }

View file

@ -2,19 +2,19 @@ package net.minecraft.server;
public interface IInventory { public interface IInventory {
int q_(); int getSize();
ItemStack c_(int i); ItemStack getItem(int i);
ItemStack a(int i, int j); ItemStack a(int i, int j);
void a(int i, ItemStack itemstack); void setItem(int i, ItemStack itemstack);
String c(); String getName();
int r_(); int getMaxStackSize();
void i(); void update();
boolean a_(EntityHuman entityhuman); boolean a_(EntityHuman entityhuman);

View file

@ -2,48 +2,48 @@ package net.minecraft.server;
public class InventoryCraftResult implements IInventory { public class InventoryCraftResult implements IInventory {
private ItemStack[] a = new ItemStack[1]; private ItemStack[] items = new ItemStack[1];
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return items;
} }
// CraftBukkit end // CraftBukkit end
public InventoryCraftResult() {} public InventoryCraftResult() {}
public int q_() { public int getSize() {
return 1; return 1;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return this.a[i]; return this.items[i];
} }
public String c() { public String getName() {
return "Result"; return "Result";
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.a[i] != null) { if (this.items[i] != null) {
ItemStack itemstack = this.a[i]; ItemStack itemstack = this.items[i];
this.a[i] = null; this.items[i] = null;
return itemstack; return itemstack;
} else { } else {
return null; return null;
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.a[i] = itemstack; this.items[i] = itemstack;
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public void i() {} public void update() {}
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {
return true; return true;

View file

@ -2,59 +2,59 @@ package net.minecraft.server;
public class InventoryCrafting implements IInventory { public class InventoryCrafting implements IInventory {
private ItemStack[] a; private ItemStack[] items;
private int b; private int b;
private Container c; private Container c;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return items;
} }
// CraftBukkit end // CraftBukkit end
public InventoryCrafting(Container container, int i, int j) { public InventoryCrafting(Container container, int i, int j) {
int k = i * j; int k = i * j;
this.a = new ItemStack[k]; this.items = new ItemStack[k];
this.c = container; this.c = container;
this.b = i; this.b = i;
} }
public int q_() { public int getSize() {
return this.a.length; return this.items.length;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return i >= this.q_() ? null : this.a[i]; return i >= this.getSize() ? null : this.items[i];
} }
public ItemStack b(int i, int j) { public ItemStack b(int i, int j) {
if (i >= 0 && i < this.b) { if (i >= 0 && i < this.b) {
int k = i + j * this.b; int k = i + j * this.b;
return this.c_(k); return this.getItem(k);
} else { } else {
return null; return null;
} }
} }
public String c() { public String getName() {
return "Crafting"; return "Crafting";
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.a[i] != null) { if (this.items[i] != null) {
ItemStack itemstack; ItemStack itemstack;
if (this.a[i].count <= j) { if (this.items[i].count <= j) {
itemstack = this.a[i]; itemstack = this.items[i];
this.a[i] = null; this.items[i] = null;
this.c.a((IInventory) this); this.c.a((IInventory) this);
return itemstack; return itemstack;
} else { } else {
itemstack = this.a[i].a(j); itemstack = this.items[i].a(j);
if (this.a[i].count == 0) { if (this.items[i].count == 0) {
this.a[i] = null; this.items[i] = null;
} }
this.c.a((IInventory) this); this.c.a((IInventory) this);
@ -65,16 +65,16 @@ public class InventoryCrafting implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.a[i] = itemstack; this.items[i] = itemstack;
this.c.a((IInventory) this); this.c.a((IInventory) this);
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public void i() {} public void update() {}
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {
return true; return true;

View file

@ -8,9 +8,9 @@ public class InventoryLargeChest implements IInventory {
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
ItemStack[] result = new ItemStack[q_()]; ItemStack[] result = new ItemStack[getSize()];
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
result[i] = c_(i); result[i] = getItem(i);
} }
return result; return result;
} }
@ -22,37 +22,37 @@ public class InventoryLargeChest implements IInventory {
this.c = iinventory1; this.c = iinventory1;
} }
public int q_() { public int getSize() {
return this.b.q_() + this.c.q_(); return this.b.getSize() + this.c.getSize();
} }
public String c() { public String getName() {
return this.a; return this.a;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return i >= this.b.q_() ? this.c.c_(i - this.b.q_()) : this.b.c_(i); return i >= this.b.getSize() ? this.c.getItem(i - this.b.getSize()) : this.b.getItem(i);
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
return i >= this.b.q_() ? this.c.a(i - this.b.q_(), j) : this.b.a(i, j); return i >= this.b.getSize() ? this.c.a(i - this.b.getSize(), j) : this.b.a(i, j);
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
if (i >= this.b.q_()) { if (i >= this.b.getSize()) {
this.c.a(i - this.b.q_(), itemstack); this.c.setItem(i - this.b.getSize(), itemstack);
} else { } else {
this.b.a(i, itemstack); this.b.setItem(i, itemstack);
} }
} }
public int r_() { public int getMaxStackSize() {
return this.b.r_(); return this.b.getMaxStackSize();
} }
public void i() { public void update() {
this.b.i(); this.b.update();
this.c.i(); this.c.update();
} }
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {

View file

@ -2,20 +2,20 @@ package net.minecraft.server;
public class InventoryPlayer implements IInventory { public class InventoryPlayer implements IInventory {
public ItemStack[] a = new ItemStack[36]; public ItemStack[] items = new ItemStack[36];
public ItemStack[] b = new ItemStack[4]; public ItemStack[] armor = new ItemStack[4];
public int c = 0; public int itemInHandIndex = 0;
public EntityHuman d; // CraftBukkit - private->public public EntityHuman d; // CraftBukkit - private->public
private ItemStack f; private ItemStack f;
public boolean e = false; public boolean e = false;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return items;
} }
public ItemStack[] getArmorContents() { public ItemStack[] getArmorContents() {
return b; return armor;
} }
// CraftBukkit end // CraftBukkit end
@ -23,8 +23,8 @@ public class InventoryPlayer implements IInventory {
this.d = entityhuman; this.d = entityhuman;
} }
public ItemStack b() { public ItemStack getItemInHand() {
return this.c < 9 && this.c >= 0 ? this.a[this.c] : null; return this.itemInHandIndex < 9 && this.itemInHandIndex >= 0 ? this.items[this.itemInHandIndex] : null;
} }
public static int e() { public static int e() {
@ -32,8 +32,8 @@ public class InventoryPlayer implements IInventory {
} }
private int d(int i) { private int d(int i) {
for (int j = 0; j < this.a.length; ++j) { for (int j = 0; j < this.items.length; ++j) {
if (this.a[j] != null && this.a[j].id == i) { if (this.items[j] != null && this.items[j].id == i) {
return j; return j;
} }
} }
@ -42,8 +42,8 @@ public class InventoryPlayer implements IInventory {
} }
private int c(ItemStack itemstack) { private int c(ItemStack itemstack) {
for (int i = 0; i < this.a.length; ++i) { for (int i = 0; i < this.items.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.r_() && (!this.a[i].e() || this.a[i].h() == itemstack.h())) { if (this.items[i] != null && this.items[i].id == itemstack.id && this.items[i].c() && this.items[i].count < this.items[i].b() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].e() || this.items[i].getData() == itemstack.getData())) {
return i; return i;
} }
} }
@ -52,8 +52,8 @@ public class InventoryPlayer implements IInventory {
} }
private int k() { private int k() {
for (int i = 0; i < this.a.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.a[i] == null) { if (this.items[i] == null) {
return i; return i;
} }
} }
@ -73,35 +73,35 @@ public class InventoryPlayer implements IInventory {
if (k < 0) { if (k < 0) {
return j; return j;
} else { } else {
if (this.a[k] == null) { if (this.items[k] == null) {
this.a[k] = new ItemStack(i, 0, itemstack.h()); this.items[k] = new ItemStack(i, 0, itemstack.getData());
} }
int l = j; int l = j;
if (j > this.a[k].b() - this.a[k].count) { if (j > this.items[k].b() - this.items[k].count) {
l = this.a[k].b() - this.a[k].count; l = this.items[k].b() - this.items[k].count;
} }
if (l > this.r_() - this.a[k].count) { if (l > this.getMaxStackSize() - this.items[k].count) {
l = this.r_() - this.a[k].count; l = this.getMaxStackSize() - this.items[k].count;
} }
if (l == 0) { if (l == 0) {
return j; return j;
} else { } else {
j -= l; j -= l;
this.a[k].count += l; this.items[k].count += l;
this.a[k].b = 5; this.items[k].b = 5;
return j; return j;
} }
} }
} }
public void f() { public void f() {
for (int i = 0; i < this.a.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.a[i] != null && this.a[i].b > 0) { if (this.items[i] != null && this.items[i].b > 0) {
--this.a[i].b; --this.items[i].b;
} }
} }
} }
@ -112,15 +112,15 @@ public class InventoryPlayer implements IInventory {
if (j < 0) { if (j < 0) {
return false; return false;
} else { } else {
if (--this.a[j].count <= 0) { if (--this.items[j].count <= 0) {
this.a[j] = null; this.items[j] = null;
} }
return true; return true;
} }
} }
public boolean a(ItemStack itemstack) { public boolean canHold(ItemStack itemstack) {
if (!itemstack.f()) { if (!itemstack.f()) {
itemstack.count = this.d(itemstack); itemstack.count = this.d(itemstack);
if (itemstack.count == 0) { if (itemstack.count == 0) {
@ -131,8 +131,8 @@ public class InventoryPlayer implements IInventory {
int i = this.k(); int i = this.k();
if (i >= 0) { if (i >= 0) {
this.a[i] = itemstack; this.items[i] = itemstack;
this.a[i].b = 5; this.items[i].b = 5;
return true; return true;
} else { } else {
return false; return false;
@ -140,11 +140,11 @@ public class InventoryPlayer implements IInventory {
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
ItemStack[] aitemstack = this.a; ItemStack[] aitemstack = this.items;
if (i >= this.a.length) { if (i >= this.items.length) {
aitemstack = this.b; aitemstack = this.armor;
i -= this.a.length; i -= this.items.length;
} }
if (aitemstack[i] != null) { if (aitemstack[i] != null) {
@ -167,12 +167,12 @@ public class InventoryPlayer implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
ItemStack[] aitemstack = this.a; ItemStack[] aitemstack = this.items;
if (i >= aitemstack.length) { if (i >= aitemstack.length) {
i -= aitemstack.length; i -= aitemstack.length;
aitemstack = this.b; aitemstack = this.armor;
} }
aitemstack[i] = itemstack; aitemstack[i] = itemstack;
@ -181,8 +181,8 @@ public class InventoryPlayer implements IInventory {
public float a(Block block) { public float a(Block block) {
float f = 1.0F; float f = 1.0F;
if (this.a[this.c] != null) { if (this.items[this.itemInHandIndex] != null) {
f *= this.a[this.c].a(block); f *= this.items[this.itemInHandIndex].a(block);
} }
return f; return f;
@ -192,20 +192,20 @@ public class InventoryPlayer implements IInventory {
int i; int i;
NBTTagCompound nbttagcompound; NBTTagCompound nbttagcompound;
for (i = 0; i < this.a.length; ++i) { for (i = 0; i < this.items.length; ++i) {
if (this.a[i] != null) { if (this.items[i] != null) {
nbttagcompound = new NBTTagCompound(); nbttagcompound = new NBTTagCompound();
nbttagcompound.a("Slot", (byte) i); nbttagcompound.a("Slot", (byte) i);
this.a[i].a(nbttagcompound); this.items[i].a(nbttagcompound);
nbttaglist.a((NBTBase) nbttagcompound); nbttaglist.a((NBTBase) nbttagcompound);
} }
} }
for (i = 0; i < this.b.length; ++i) { for (i = 0; i < this.armor.length; ++i) {
if (this.b[i] != null) { if (this.armor[i] != null) {
nbttagcompound = new NBTTagCompound(); nbttagcompound = new NBTTagCompound();
nbttagcompound.a("Slot", (byte) (i + 100)); nbttagcompound.a("Slot", (byte) (i + 100));
this.b[i].a(nbttagcompound); this.armor[i].a(nbttagcompound);
nbttaglist.a((NBTBase) nbttagcompound); nbttaglist.a((NBTBase) nbttagcompound);
} }
} }
@ -214,51 +214,51 @@ public class InventoryPlayer implements IInventory {
} }
public void b(NBTTagList nbttaglist) { public void b(NBTTagList nbttaglist) {
this.a = new ItemStack[36]; this.items = new ItemStack[36];
this.b = new ItemStack[4]; this.armor = new ItemStack[4];
for (int i = 0; i < nbttaglist.c(); ++i) { for (int i = 0; i < nbttaglist.c(); ++i) {
NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i); NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound.c("Slot") & 255; int j = nbttagcompound.c("Slot") & 255;
ItemStack itemstack = new ItemStack(nbttagcompound); ItemStack itemstack = new ItemStack(nbttagcompound);
if (itemstack.a() != null) { if (itemstack.getItem() != null) {
if (j >= 0 && j < this.a.length) { if (j >= 0 && j < this.items.length) {
this.a[j] = itemstack; this.items[j] = itemstack;
} }
if (j >= 100 && j < this.b.length + 100) { if (j >= 100 && j < this.armor.length + 100) {
this.b[j - 100] = itemstack; this.armor[j - 100] = itemstack;
} }
} }
} }
} }
public int q_() { public int getSize() {
return this.a.length + 4; return this.items.length + 4;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
ItemStack[] aitemstack = this.a; ItemStack[] aitemstack = this.items;
if (i >= aitemstack.length) { if (i >= aitemstack.length) {
i -= aitemstack.length; i -= aitemstack.length;
aitemstack = this.b; aitemstack = this.armor;
} }
return aitemstack[i]; return aitemstack[i];
} }
public String c() { public String getName() {
return "Inventory"; return "Inventory";
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public int a(Entity entity) { public int a(Entity entity) {
ItemStack itemstack = this.c_(this.c); ItemStack itemstack = this.getItem(this.itemInHandIndex);
return itemstack != null ? itemstack.a(entity) : 1; return itemstack != null ? itemstack.a(entity) : 1;
} }
@ -267,7 +267,7 @@ public class InventoryPlayer implements IInventory {
if (block.material != Material.STONE && block.material != Material.ORE && block.material != Material.SNOW_BLOCK && block.material != Material.SNOW_LAYER) { if (block.material != Material.STONE && block.material != Material.ORE && block.material != Material.SNOW_BLOCK && block.material != Material.SNOW_LAYER) {
return true; return true;
} else { } else {
ItemStack itemstack = this.c_(this.c); ItemStack itemstack = this.getItem(this.itemInHandIndex);
return itemstack != null ? itemstack.b(block) : false; return itemstack != null ? itemstack.b(block) : false;
} }
@ -278,15 +278,15 @@ public class InventoryPlayer implements IInventory {
int j = 0; int j = 0;
int k = 0; int k = 0;
for (int l = 0; l < this.b.length; ++l) { for (int l = 0; l < this.armor.length; ++l) {
if (this.b[l] != null && this.b[l].a() instanceof ItemArmor) { if (this.armor[l] != null && this.armor[l].getItem() instanceof ItemArmor) {
int i1 = this.b[l].i(); int i1 = this.armor[l].i();
int j1 = this.b[l].g(); int j1 = this.armor[l].g();
int k1 = i1 - j1; int k1 = i1 - j1;
j += k1; j += k1;
k += i1; k += i1;
int l1 = ((ItemArmor) this.b[l].a()).bj; int l1 = ((ItemArmor) this.armor[l].getItem()).bj;
i += l1; i += l1;
} }
@ -300,12 +300,12 @@ public class InventoryPlayer implements IInventory {
} }
public void c(int i) { public void c(int i) {
for (int j = 0; j < this.b.length; ++j) { for (int j = 0; j < this.armor.length; ++j) {
if (this.b[j] != null && this.b[j].a() instanceof ItemArmor) { if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) {
this.b[j].a(i, this.d); this.armor[j].damage(i, this.d);
if (this.b[j].count == 0) { if (this.armor[j].count == 0) {
this.b[j].a(this.d); this.armor[j].a(this.d);
this.b[j] = null; this.armor[j] = null;
} }
} }
} }
@ -314,22 +314,22 @@ public class InventoryPlayer implements IInventory {
public void h() { public void h() {
int i; int i;
for (i = 0; i < this.a.length; ++i) { for (i = 0; i < this.items.length; ++i) {
if (this.a[i] != null) { if (this.items[i] != null) {
this.d.a(this.a[i], true); this.d.a(this.items[i], true);
this.a[i] = null; this.items[i] = null;
} }
} }
for (i = 0; i < this.b.length; ++i) { for (i = 0; i < this.armor.length; ++i) {
if (this.b[i] != null) { if (this.armor[i] != null) {
this.d.a(this.b[i], true); this.d.a(this.armor[i], true);
this.b[i] = null; this.armor[i] = null;
} }
} }
} }
public void i() { public void update() {
this.e = true; this.e = true;
} }

View file

@ -21,7 +21,7 @@ public class ItemBed extends Item {
++j; ++j;
BlockBed blockbed = (BlockBed) Block.BED; BlockBed blockbed = (BlockBed) Block.BED;
int i1 = MathHelper.b((double) (entityhuman.yaw * 4.0F / 360.0F) + 0.5D) & 3; int i1 = MathHelper.floor((double) (entityhuman.yaw * 4.0F / 360.0F) + 0.5D) & 3;
byte b0 = 0; byte b0 = 0;
byte b1 = 0; byte b1 = 0;
@ -44,7 +44,7 @@ public class ItemBed extends Item {
if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.d(i, j - 1, k) && world.d(i + b0, j - 1, k + b1)) { if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.d(i, j - 1, k) && world.d(i + b0, j - 1, k + b1)) {
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
world.b(i, j, k, blockbed.id, i1); world.setTypeIdAndData(i, j, k, blockbed.id, i1);
// CraftBukkit start - bed // CraftBukkit start - bed
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed);
@ -55,7 +55,7 @@ public class ItemBed extends Item {
} }
// CraftBukkit end // CraftBukkit end
world.b(i + b0, j, k + b1, blockbed.id, i1 + 8); world.setTypeIdAndData(i + b0, j, k + b1, blockbed.id, i1 + 8);
--itemstack.count; --itemstack.count;
return true; return true;
} else { } else {

View file

@ -9,11 +9,11 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class ItemBlock extends Item { public class ItemBlock extends Item {
private int a; private int id;
public ItemBlock(int i) { public ItemBlock(int i) {
super(i); super(i);
this.a = i + 256; this.id = i + 256;
this.b(Block.byId[i + 256].a(2)); this.b(Block.byId[i + 256].a(2));
} }
@ -50,64 +50,64 @@ public class ItemBlock extends Item {
if (itemstack.count == 0) { if (itemstack.count == 0) {
return false; return false;
} else { } else if (world.a(this.id, i, j, k, false)) {
if (world.a(this.a, i, j, k, false)) { Block block = Block.byId[this.id];
Block block = Block.byId[this.a];
// CraftBukkit start - This executes the placement of the block // CraftBukkit start - This executes the placement of the block
BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k);
// Special case the silly stepstone :'( // Special case the silly stepstone :'(
if (l == 1 && world.getTypeId(i, j - 1, k) == Block.STEP.id && itemstack.id == Block.STEP.id) { if (l == 1 && world.getTypeId(i, j - 1, k) == Block.STEP.id && itemstack.id == Block.STEP.id) {
replacedBlockState = CraftBlockState.getBlockState(world, i, j - 1, k); replacedBlockState = CraftBlockState.getBlockState(world, i, j - 1, k);
} }
/** /**
* @see net.minecraft.server.World#b(int i, int j, int k, int l, int i1) * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1)
* *
* This replaces world.b(IIIII), we're doing this because we need to * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to
* hook between the 'placement' and the informing to 'world' so we can * hook between the 'placement' and the informing to 'world' so we can
* sanely undo this. * sanely undo this.
* *
* Whenever the call to 'world.b' changes we need to figure out again what to * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to
* replace this with. * replace this with.
*/ */
if (world.setTypeIdAndData(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block);
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
// CraftBukkit Undo! // CraftBukkit Undo!
if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) { if ((this.id == 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 // Half steps automatically set the block below to a double
world.setTypeId(i, j - 1, k, 44); world.setTypeId(i, j - 1, k, 44);
} else {
if (this.a == Block.ICE.id) {
// Ice will explode if we set straight to 0
world.setTypeId(i, j, k, 20);
}
world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData());
}
} else { } else {
world.f(i, j, k, a); // <-- world.b does this on success (tell the world)
Block.byId[this.a].d(world, i, j, k, l); if (this.id == Block.ICE.id) {
Block.byId[this.a].a(world, i, j, k, (EntityLiving) entityhuman); // Ice will explode if we set straight to 0
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); world.setTypeId(i, j, k, 20);
--itemstack.count; }
world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData());
} }
// CraftBukkit end
} else {
world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world)
Block.byId[this.id].postPlace(world, i, j, k, l);
Block.byId[this.id].postPlace(world, i, j, k, entityhuman);
world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
--itemstack.count;
} }
// CraftBukkit end
} }
return true; return true;
} else {
return false;
} }
} }
public String a() { public String a() {
return Block.byId[this.a].f(); return Block.byId[this.id].f();
} }
} }

View file

@ -20,35 +20,35 @@ public class ItemBoat extends Item {
double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height;
double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
Vec3D vec3d = Vec3D.b(d0, d1, d2); Vec3D vec3d = Vec3D.create(d0, d1, d2);
float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.017453292F); float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f3 * f5; float f8 = f3 * f5;
double d3 = 5.0D; double d3 = 5.0D;
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true); MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, true);
if (movingobjectposition == null) { if (movingobjectposition == null) {
return itemstack; return itemstack;
} else { } else {
if (movingobjectposition.a == EnumMovingObjectType.TILE) { if (movingobjectposition.type == 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.isStatic) { if (!world.isStatic) {
// CraftBukkit start - Boat placement // CraftBukkit start - Boat placement
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.e, itemstack); PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.face, itemstack);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
} }
// CraftBukkit end // CraftBukkit end
world.a((Entity) (new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.5F), (double) ((float) k + 0.5F)))); world.addEntity(new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.5F), (double) ((float) k + 0.5F)));
} }
--itemstack.count; --itemstack.count;

View file

@ -25,21 +25,21 @@ public class ItemBucket extends Item {
double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f;
double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height;
double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
Vec3D vec3d = Vec3D.b(d0, d1, d2); Vec3D vec3d = Vec3D.create(d0, d1, d2);
float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.017453292F); float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f3 * f5; float f8 = f3 * f5;
double d3 = 5.0D; double d3 = 5.0D;
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, this.a == 0); MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, this.a == 0);
if (movingobjectposition == null) { if (movingobjectposition == null) {
return itemstack; return itemstack;
} else { } else {
if (movingobjectposition.a == EnumMovingObjectType.TILE) { if (movingobjectposition.type == 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;
@ -61,7 +61,7 @@ public class ItemBucket extends Item {
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
// CraftBukkit end // CraftBukkit end
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit
} }
@ -77,13 +77,13 @@ public class ItemBucket extends Item {
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
// CraftBukkit end // CraftBukkit end
world.e(i, j, k, 0); world.setTypeId(i, j, k, 0);
return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); // CraftBukkit return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); // CraftBukkit
} }
} else { } else {
if (this.a < 0) { if (this.a < 0) {
// CraftBukkit start // CraftBukkit start
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.e, itemstack); PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, i, j, k, movingobjectposition.face, itemstack);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
@ -96,47 +96,47 @@ public class ItemBucket extends Item {
} }
int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
if (movingobjectposition.e == 0) { if (movingobjectposition.face == 0) {
--j; --j;
} }
if (movingobjectposition.e == 1) { if (movingobjectposition.face == 1) {
++j; ++j;
} }
if (movingobjectposition.e == 2) { if (movingobjectposition.face == 2) {
--k; --k;
} }
if (movingobjectposition.e == 3) { if (movingobjectposition.face == 3) {
++k; ++k;
} }
if (movingobjectposition.e == 4) { if (movingobjectposition.face == 4) {
--i; --i;
} }
if (movingobjectposition.e == 5) { if (movingobjectposition.face == 5) {
++i; ++i;
} }
if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) { if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) {
// CraftBukkit start // CraftBukkit start
PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.e, itemstack); PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack);
if (event.isCancelled()) { if (event.isCancelled()) {
return itemstack; return itemstack;
} }
// CraftBukkit end // CraftBukkit end
if (world.m.d && this.a == Block.WATER.id) { if (world.worldProvider.d && this.a == Block.WATER.id) {
world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.k.nextFloat() - world.k.nextFloat()) * 0.8F); world.makeSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) { 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); world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
} }
} else { } else {
world.b(i, j, k, this.a, 0); world.setTypeIdAndData(i, j, k, this.a, 0);
} }
// CraftBukkit start // CraftBukkit start
@ -146,9 +146,9 @@ public class ItemBucket extends Item {
// CraftBukkit end // CraftBukkit end
} }
} }
} else if (this.a == 0 && movingobjectposition.g instanceof EntityCow) { } else if (this.a == 0 && movingobjectposition.entity instanceof EntityCow) {
// CraftBukkit start -- This codepath seems to be *NEVER* called // CraftBukkit start -- This codepath seems to be *NEVER* called
Location loc = movingobjectposition.g.getBukkitEntity().getLocation(); Location loc = movingobjectposition.entity.getBukkitEntity().getLocation();
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET); PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);
if (event.isCancelled()) { if (event.isCancelled()) {

View file

@ -32,10 +32,10 @@ public class ItemDoor extends Item {
block = Block.IRON_DOOR_BLOCK; block = Block.IRON_DOOR_BLOCK;
} }
if (!block.a(world, i, j, k)) { if (!block.canPlace(world, i, j, k)) {
return false; return false;
} else { } else {
int i1 = MathHelper.b((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
byte b0 = 0; byte b0 = 0;
byte b1 = 0; byte b1 = 0;
@ -74,8 +74,8 @@ public class ItemDoor extends Item {
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
world.e(i, j, k, block.id); world.setTypeId(i, j, k, block.id);
world.c(i, j, k, i1); world.setData(i, j, k, i1);
// CraftBukkit start - bed // CraftBukkit start - bed
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, block); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, block);
@ -86,8 +86,8 @@ public class ItemDoor extends Item {
} }
// CraftBukkit end // CraftBukkit end
world.e(i, j + 1, k, block.id); world.setTypeId(i, j + 1, k, block.id);
world.c(i, j + 1, k, i1 + 8); world.setData(i, j + 1, k, i1 + 8);
--itemstack.count; --itemstack.count;
return true; return true;
} }

View file

@ -63,15 +63,15 @@ public class ItemFlintAndSteel extends Item {
boolean preventFire = eventIgnite.isCancelled(); boolean preventFire = eventIgnite.isCancelled();
if (preventFire) { if (preventFire) {
itemstack.a(1, entityhuman); itemstack.damage(1, entityhuman);
return false; return false;
} }
// CraftBukkit end // CraftBukkit end
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
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.makeSound((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.FIRE.id); world.setTypeId(i, j, k, Block.FIRE.id);
// CraftBukkit start // CraftBukkit start
BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id);
@ -83,7 +83,7 @@ public class ItemFlintAndSteel extends Item {
// CraftBukkit end // CraftBukkit end
} }
itemstack.a(1, entityhuman); itemstack.damage(1, entityhuman);
return true; return true;
} }
} }

View file

@ -24,13 +24,13 @@ public class ItemHoe extends Item {
} else { } else {
Block block = Block.SOIL; Block block = Block.SOIL;
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); world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
if (world.isStatic) { if (world.isStatic) {
return true; return true;
} else { } else {
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
world.e(i, j, k, block.id); world.setTypeId(i, j, k, block.id);
// CraftBukkit start - Hoes - blockface -1 for 'SELF' // CraftBukkit start - Hoes - blockface -1 for 'SELF'
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block);
@ -40,19 +40,19 @@ public class ItemHoe extends Item {
} }
// CraftBukkit end // CraftBukkit end
itemstack.a(1, entityhuman); itemstack.damage(1, entityhuman);
if (world.k.nextInt(8) == 0 && i1 == Block.GRASS.id) { if (world.random.nextInt(8) == 0 && i1 == Block.GRASS.id) {
byte b0 = 1; byte b0 = 1;
for (int j1 = 0; j1 < b0; ++j1) { for (int j1 = 0; j1 < b0; ++j1) {
float f = 0.7F; float f = 0.7F;
float f1 = world.k.nextFloat() * f + (1.0F - f) * 0.5F; float f1 = world.random.nextFloat() * f + (1.0F - f) * 0.5F;
float f2 = 1.2F; float f2 = 1.2F;
float f3 = world.k.nextFloat() * f + (1.0F - f) * 0.5F; float f3 = world.random.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 entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS));
entityitem.c = 10; entityitem.pickupDelay = 10;
world.a((Entity) entityitem); world.addEntity(entityitem);
} }
} }

View file

@ -12,14 +12,14 @@ import org.bukkit.event.player.PlayerInteractEvent;
public class ItemInWorldManager { public class ItemInWorldManager {
private World b; private World world;
public EntityHuman a; public EntityHuman player;
private float c = 0.0F; private float c = 0.0F;
private int d; private int d;
private int e; private int e;
private int f; private int f;
private int g; private int g;
private int h; private int currentTick;
private boolean i; private boolean i;
private int j; private int j;
private int k; private int k;
@ -27,18 +27,18 @@ public class ItemInWorldManager {
private int m; private int m;
public ItemInWorldManager(World world) { public ItemInWorldManager(World world) {
this.b = world; this.world = world;
} }
public void a() { public void a() {
this.h = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
if (this.i) { if (this.i) {
int i = this.h - this.m; int i = this.currentTick - this.m;
int j = this.b.getTypeId(this.j, this.k, this.l); int j = this.world.getTypeId(this.j, this.k, this.l);
if (j != 0) { if (j != 0) {
Block block = Block.byId[j]; Block block = Block.byId[j];
float f = block.a(this.a) * (float) (i + 1); float f = block.getDamage(this.player) * (float) (i + 1);
if (f >= 1.0F) { if (f >= 1.0F) {
this.i = false; this.i = false;
@ -51,9 +51,9 @@ public class ItemInWorldManager {
} }
// CraftBukkit added face // CraftBukkit added face
public void a(int i, int j, int k, int face) { public void dig(int i, int j, int k, int face) {
this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit
int l = this.b.getTypeId(i, j, k); int l = this.world.getTypeId(i, j, k);
// CraftBukkit start // CraftBukkit start
// Swings at air do *NOT* exist. // Swings at air do *NOT* exist.
@ -61,30 +61,30 @@ public class ItemInWorldManager {
return; return;
} }
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.a, Action.LEFT_CLICK_BLOCK , i, j, k, face, this.a.inventory.b()); PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK , i, j, k, face, this.player.inventory.getItemInHand());
if (event.useInteractedBlock() == Event.Result.DENY) { if (event.useInteractedBlock() == Event.Result.DENY) {
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
if (l == Block.WOODEN_DOOR.id) { if (l == Block.WOODEN_DOOR.id) {
// For some reason *BOTH* the bottom/top part have to be marked updated. // For some reason *BOTH* the bottom/top part have to be marked updated.
boolean bottom = (this.b.getData(i, j, k) & 8) == 0; boolean bottom = (this.world.getData(i, j, k) & 8) == 0;
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.b))); ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.world));
} }
} else { } else {
Block.byId[l].b(this.b, i, j, k, this.a); Block.byId[l].b(this.world, i, j, k, this.player);
} }
// Handle hitting a block // Handle hitting a block
float toolDamage = Block.byId[l].a(this.a); float toolDamage = Block.byId[l].getDamage(this.player);
if (event.useItemInHand() == Event.Result.DENY) { if (event.useItemInHand() == Event.Result.DENY) {
// If we 'insta destroyed' then the client needs to be informed. // If we 'insta destroyed' then the client needs to be informed.
if (toolDamage > 1.0f) { if (toolDamage > 1.0f) {
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
} }
return; return;
} }
BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.a, i, j, k, this.a.inventory.b(), toolDamage >= 1.0f); BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), toolDamage >= 1.0f);
if (blockEvent.isCancelled()) { if (blockEvent.isCancelled()) {
return; return;
@ -106,13 +106,13 @@ public class ItemInWorldManager {
public void b(int i, int j, int k) { public void b(int i, int j, int k) {
if (i == this.e && j == this.f && k == this.g) { if (i == this.e && j == this.f && k == this.g) {
this.h = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
int l = this.h - this.d; int l = this.currentTick - this.d;
int i1 = this.b.getTypeId(i, j, k); int i1 = this.world.getTypeId(i, j, k);
if (i1 != 0) { if (i1 != 0) {
Block block = Block.byId[i1]; Block block = Block.byId[i1];
float f = block.a(this.a) * (float) (l + 1); float f = block.getDamage(this.player) * (float) (l + 1);
if (f >= 1.0F) { if (f >= 1.0F) {
this.d(i, j, k); this.d(i, j, k);
@ -126,21 +126,20 @@ public class ItemInWorldManager {
} }
// CraftBukkit start -- force blockreset to client // CraftBukkit start -- force blockreset to client
} else { } else {
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
// CraftBukkit end // CraftBukkit end
} }
this.c = 0.0F; this.c = 0.0F;
this.e = 0;
} }
public boolean c(int i, int j, int k) { public boolean c(int i, int j, int k) {
Block block = Block.byId[this.b.getTypeId(i, j, k)]; Block block = Block.byId[this.world.getTypeId(i, j, k)];
int l = this.b.getData(i, j, k); int l = this.world.getData(i, j, k);
boolean flag = this.b.e(i, j, k, 0); boolean flag = this.world.setTypeId(i, j, k, 0);
if (block != null && flag) { if (block != null && flag) {
block.b(this.b, i, j, k, l); block.postBreak(this.world, i, j, k, l);
} }
return flag; return flag;
@ -148,10 +147,10 @@ public class ItemInWorldManager {
public boolean d(int i, int j, int k) { public boolean d(int i, int j, int k) {
// CraftBukkit start // CraftBukkit start
if (this.a instanceof EntityPlayer) { if (this.player instanceof EntityPlayer) {
CraftServer server = ((WorldServer) this.b).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.block.Block block = ((WorldServer) this.b).getWorld().getBlockAt(i, j, k); org.bukkit.block.Block block = ((WorldServer) this.world).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.a.getBukkitEntity(); org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity();
BlockBreakEvent event = new BlockBreakEvent(block,player); BlockBreakEvent event = new BlockBreakEvent(block,player);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
@ -162,44 +161,44 @@ public class ItemInWorldManager {
} }
// CraftBukkit end // CraftBukkit end
int l = this.b.getTypeId(i, j, k); int l = this.world.getTypeId(i, j, k);
int i1 = this.b.getData(i, j, k); int i1 = this.world.getData(i, j, k);
boolean flag = this.c(i, j, k); boolean flag = this.c(i, j, k);
ItemStack itemstack = this.a.A(); ItemStack itemstack = this.player.A();
if (itemstack != null) { if (itemstack != null) {
itemstack.a(l, i, j, k, this.a); itemstack.a(l, i, j, k, this.player);
if (itemstack.count == 0) { if (itemstack.count == 0) {
itemstack.a(this.a); itemstack.a(this.player);
this.a.B(); this.player.B();
} }
} }
if (flag && this.a.b(Block.byId[l])) { if (flag && this.player.b(Block.byId[l])) {
Block.byId[l].a(this.b, this.a, i, j, k, i1); Block.byId[l].a(this.world, this.player, i, j, k, i1);
((EntityPlayer) this.a).a.b((Packet) (new Packet53BlockChange(i, j, k, this.b))); ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
} }
return flag; return flag;
} }
public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack) { public boolean useItem(EntityHuman entityhuman, World world, ItemStack itemstack) {
int i = itemstack.count; int i = itemstack.count;
ItemStack itemstack1 = itemstack.a(world, entityhuman); ItemStack itemstack1 = itemstack.a(world, entityhuman);
if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i)) { if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i)) {
return false; return false;
} else { } else {
entityhuman.inventory.a[entityhuman.inventory.c] = itemstack1; entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = itemstack1;
if (itemstack1.count == 0) { if (itemstack1.count == 0) {
entityhuman.inventory.a[entityhuman.inventory.c] = null; entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null;
} }
return true; return true;
} }
} }
public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) { public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) {
int i1 = world.getTypeId(i, j, k); int i1 = world.getTypeId(i, j, k);
// CraftBukkit start - Interact // CraftBukkit start - Interact
@ -210,18 +209,18 @@ public class ItemInWorldManager {
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
if (i1 == Block.WOODEN_DOOR.id) { if (i1 == Block.WOODEN_DOOR.id) {
boolean bottom = (world.getData(i, j, k) & 8) == 0; boolean bottom = (world.getData(i, j, k) & 8) == 0;
((EntityPlayer) entityhuman).a.b((Packet) (new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, world))); ((EntityPlayer) entityhuman).netServerHandler.sendPacket(new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, world));
} }
} else { } else {
result = Block.byId[i1].a(world, i, j, k, entityhuman); result = Block.byId[i1].interact(world, i, j, k, entityhuman);
if (itemstack != null && !result) { if (itemstack != null && !result) {
result = itemstack.a(entityhuman, world, i, j, k, l); result = itemstack.placeItem(entityhuman, world, i, j, k, l);
} }
} }
// If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook // If we have 'true' and no explicit deny *or* an explicit allow -- run the item part of the hook
if (itemstack != null && ((!result && event.useItemInHand() != Event.Result.DENY) || event.useItemInHand() == Event.Result.ALLOW)) { if (itemstack != null && ((!result && event.useItemInHand() != Event.Result.DENY) || event.useItemInHand() == Event.Result.ALLOW)) {
this.a(entityhuman, world, itemstack); this.useItem(entityhuman, world, itemstack);
} }
} }
return result; return result;

View file

@ -29,7 +29,7 @@ public class ItemMinecart extends Item {
} }
// CraftBukkit end // 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))); world.addEntity(new EntityMinecart(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.a));
} }
--itemstack.count; --itemstack.count;

View file

@ -43,10 +43,10 @@ public class ItemRedstone extends Item {
if (!world.isEmpty(i, j, k)) { if (!world.isEmpty(i, j, k)) {
return false; return false;
} else { } else {
if (Block.REDSTONE_WIRE.a(world, i, j, k)) { if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) {
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
world.e(i, j, k, Block.REDSTONE_WIRE.id); world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id);
// CraftBukkit start - redstone // CraftBukkit start - redstone
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE);

View file

@ -9,11 +9,11 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class ItemReed extends Item { public class ItemReed extends Item {
private int a; private int id;
public ItemReed(int i, Block block) { public ItemReed(int i, Block block) {
super(i); super(i);
this.a = block.id; this.id = block.id;
} }
public boolean a(ItemStack itemstack, EntityHuman entityhuman, 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) {
@ -50,33 +50,33 @@ public class ItemReed extends Item {
if (itemstack.count == 0) { if (itemstack.count == 0) {
return false; return false;
} else { } else {
if (world.a(this.a, i, j, k, false)) { if (world.a(this.id, i, j, k, false)) {
Block block = Block.byId[this.a]; Block block = Block.byId[this.id];
// CraftBukkit start - This executes the placement of the block // CraftBukkit start - This executes the placement of the block
BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
/** /**
* @see net.minecraft.server.World#e(int i, int j, int k, int l) * @see net.minecraft.server.World#setTypeId(int i, int j, int k, int l)
* *
* This replaces world.e(IIII), we're doing this because we need to * This replaces world.setTypeId(IIII), we're doing this because we need to
* hook between the 'placement' and the informing to 'world' so we can * hook between the 'placement' and the informing to 'world' so we can
* sanely undo this. * sanely undo this.
* *
* Whenever the call to 'world.e' changes we need to figure out again what to * Whenever the call to 'world.setTypeId' changes we need to figure out again what to
* replace this with. * replace this with.
*/ */
if (world.setTypeId(i, j, k, this.a)) { // <-- world.e does this to place the block if (world.setRawTypeId(i, j, k, this.id)) { // <-- world.e does this to place the block
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block);
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
// CraftBukkit Undo -- this only has reed, repeater and pie blocks // CraftBukkit Undo -- this only has reed, repeater and pie blocks
world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData());
} else { } else {
world.f(i, j, k, a); // <-- world.e does this on success (tell the world) world.update(i, j, k, this.id); // <-- world.setTypeId does this on success (tell the world)
Block.byId[this.a].d(world, i, j, k, l); Block.byId[this.id].postPlace(world, i, j, k, l);
Block.byId[this.a].a(world, i, j, k, (EntityLiving) entityhuman); Block.byId[this.id].postPlace(world, i, j, k, 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); world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F);
--itemstack.count; --itemstack.count;
} }
// CraftBukkit end // CraftBukkit end

View file

@ -9,11 +9,11 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class ItemSeeds extends Item { public class ItemSeeds extends Item {
private int a; private int id;
public ItemSeeds(int i, int j) { public ItemSeeds(int i, int j) {
super(i); super(i);
this.a = j; this.id = j;
} }
public boolean a(ItemStack itemstack, EntityHuman entityhuman, 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) {
@ -23,12 +23,12 @@ public class ItemSeeds extends Item {
int i1 = world.getTypeId(i, j, k); int i1 = world.getTypeId(i, j, k);
if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) { if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) {
BlockState blockState = CraftBlockState.getBlockState( world, i, j + 1, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit
world.e(i, j + 1, k, this.a); world.setTypeId(i, j + 1, k, this.id);
// CraftBukkit start - seeds // CraftBukkit start - seeds
BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, this.a); BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, this.id);
if (event.isCancelled() || !event.canBuild()) { if (event.isCancelled() || !event.canBuild()) {
event.getBlockPlaced().setTypeId(0); event.getBlockPlaced().setTypeId(0);
return false; return false;

View file

@ -42,15 +42,15 @@ public class ItemSign extends Item {
++i; ++i;
} }
if (!Block.SIGN_POST.a(world, i, j, k)) { if (!Block.SIGN_POST.canPlace(world, i, j, k)) {
return false; return false;
} else { } else {
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit
if (l == 1) { 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); world.setTypeIdAndData(i, j, k, Block.SIGN_POST.id, MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15);
} else { } else {
world.b(i, j, k, Block.WALL_SIGN.id, l); world.setTypeIdAndData(i, j, k, Block.WALL_SIGN.id, l);
} }
// CraftBukkit start - sign // CraftBukkit start - sign

View file

@ -48,12 +48,12 @@ public final class ItemStack {
return new ItemStack(this.id, i, this.damage); return new ItemStack(this.id, i, this.damage);
} }
public Item a() { public Item getItem() {
return Item.byId[this.id]; return Item.byId[this.id];
} }
public boolean a(EntityHuman entityhuman, World world, int i, int j, int k, int l) { public boolean placeItem(EntityHuman entityhuman, World world, int i, int j, int k, int l) {
boolean flag = this.a().a(this, entityhuman, world, i, j, k, l); boolean flag = this.getItem().a(this, entityhuman, world, i, j, k, l);
if (flag) { if (flag) {
entityhuman.a(StatisticList.A[this.id], 1); entityhuman.a(StatisticList.A[this.id], 1);
@ -63,11 +63,11 @@ public final class ItemStack {
} }
public float a(Block block) { public float a(Block block) {
return this.a().a(this, block); return this.getItem().a(this, block);
} }
public ItemStack a(World world, EntityHuman entityhuman) { public ItemStack a(World world, EntityHuman entityhuman) {
return this.a().a(this, world, entityhuman); return this.getItem().a(this, world, entityhuman);
} }
public NBTTagCompound a(NBTTagCompound nbttagcompound) { public NBTTagCompound a(NBTTagCompound nbttagcompound) {
@ -84,7 +84,7 @@ public final class ItemStack {
} }
public int b() { public int b() {
return this.a().b(); return this.getItem().getMaxStackSize();
} }
public boolean c() { public boolean c() {
@ -107,7 +107,7 @@ public final class ItemStack {
return this.damage; return this.damage;
} }
public int h() { public int getData() {
return this.damage; return this.damage;
} }
@ -115,7 +115,7 @@ public final class ItemStack {
return Item.byId[this.id].d(); return Item.byId[this.id].d();
} }
public void a(int i, Entity entity) { public void damage(int i, Entity entity) {
if (this.d()) { if (this.d()) {
this.damage += i; this.damage += i;
if (this.damage > this.i()) { if (this.damage > this.i()) {
@ -167,7 +167,7 @@ public final class ItemStack {
return new ItemStack(this.id, this.count, this.damage); return new ItemStack(this.id, this.count, this.damage);
} }
public static boolean a(ItemStack itemstack, ItemStack itemstack1) { public static boolean equals(ItemStack itemstack, ItemStack itemstack1) {
return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? itemstack.c(itemstack1) : false); return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? itemstack.c(itemstack1) : false);
} }

View file

@ -24,28 +24,28 @@ import org.bukkit.craftbukkit.command.ColouredConsoleSender;
import org.bukkit.craftbukkit.scheduler.CraftScheduler; import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.craftbukkit.util.ServerShutdownThread; import org.bukkit.craftbukkit.util.ServerShutdownThread;
import org.bukkit.event.world.WorldSaveEvent; import org.bukkit.event.world.WorldSaveEvent;
// CraftBukkit
public class MinecraftServer implements Runnable, ICommandListener { public class MinecraftServer implements Runnable, ICommandListener {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger log = Logger.getLogger("Minecraft");
public static HashMap b = new HashMap(); public static HashMap b = new HashMap();
public NetworkListenThread c; public NetworkListenThread networkListenThread;
public PropertyManager d; public PropertyManager propertyManager;
// public WorldServer e; // CraftBukkit - removed // public WorldServer worldServer; // CraftBukkit - removed
public ServerConfigurationManager f; public ServerConfigurationManager serverConfigurationManager;
public ConsoleCommandHandler o; // CraftBukkit - made public public ConsoleCommandHandler consoleCommandHandler; // CraftBukkit - made public
private boolean p = true; private boolean isRunning = true;
public boolean g = false; public boolean isStopped = false;
int h = 0; int ticks = 0;
public String i; public String i;
public int j; public int j;
private List q = new ArrayList(); private List q = new ArrayList();
private List r = Collections.synchronizedList(new ArrayList()); private List r = Collections.synchronizedList(new ArrayList());
public EntityTracker k; public EntityTracker tracker;
public boolean l; public boolean onlineMode;
public boolean m; public boolean spawnAnimals;
public boolean n; public boolean pvpMode;
// CraftBukkit start // CraftBukkit start
public int spawnProtection; public int spawnProtection;
@ -70,64 +70,64 @@ public class MinecraftServer implements Runnable, ICommandListener {
// CraftBukkit end // CraftBukkit end
} }
private boolean d() throws UnknownHostException { // CraftBukkit - added throws UnknownHostException private boolean init() throws UnknownHostException { // CraftBukkit - added throws UnknownHostException
this.o = new ConsoleCommandHandler(this); this.consoleCommandHandler = new ConsoleCommandHandler(this);
ThreadCommandReader threadcommandreader = new ThreadCommandReader(this); ThreadCommandReader threadcommandreader = new ThreadCommandReader(this);
threadcommandreader.setDaemon(true); threadcommandreader.setDaemon(true);
threadcommandreader.start(); threadcommandreader.start();
ConsoleLogManager.a(this); // Craftbukkit ConsoleLogManager.init(this); // Craftbukkit
// CraftBukkit start // CraftBukkit start
System.setOut(new PrintStream(new LoggerOutputStream(a, Level.INFO), true)); System.setOut(new PrintStream(new LoggerOutputStream(log, Level.INFO), true));
System.setErr(new PrintStream(new LoggerOutputStream(a, Level.SEVERE), true)); System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true));
// CraftBukkit end // CraftBukkit end
a.info("Starting minecraft server version Beta 1.4"); log.info("Starting minecraft server version Beta 1.3");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
a.warning("**** NOT ENOUGH RAM!"); log.warning("**** NOT ENOUGH RAM!");
a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); log.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
} }
a.info("Loading properties"); log.info("Loading properties");
this.d = new PropertyManager(options); // CraftBukkit this.propertyManager = new PropertyManager(new File("server.properties"));
String s = this.d.a("server-ip", ""); String s = this.propertyManager.getString("server-ip", "");
this.l = this.d.a("online-mode", true); this.onlineMode = this.propertyManager.getBoolean("online-mode", true);
this.m = this.d.a("spawn-animals", true); this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true);
this.n = this.d.a("pvp", true); this.pvpMode = this.propertyManager.getBoolean("pvp", true);
this.spawnProtection = this.d.a("spawn-protection", 16); // CraftBukkit Configurable spawn protection start this.spawnProtection = this.propertyManager.getInt("spawn-protection", 16); // CraftBukkit Configurable spawn protection start
InetAddress inetaddress = null; InetAddress inetaddress = null;
if (s.length() > 0) { if (s.length() > 0) {
inetaddress = InetAddress.getByName(s); inetaddress = InetAddress.getByName(s);
} }
int i = this.d.a("server-port", 25565); int i = this.propertyManager.getInt("server-port", 25565);
a.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i); log.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i);
try { try {
this.c = new NetworkListenThread(this, inetaddress, i); this.networkListenThread = new NetworkListenThread(this, inetaddress, i);
} catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
a.warning("**** FAILED TO BIND TO PORT!"); log.warning("**** FAILED TO BIND TO PORT!");
a.log(Level.WARNING, "The exception was: " + ioexception.toString()); log.log(Level.WARNING, "The exception was: " + ioexception.toString());
a.warning("Perhaps a server is already running on that port?"); log.warning("Perhaps a server is already running on that port?");
return false; return false;
} }
if (!this.l) { if (!this.onlineMode) {
a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); log.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
a.warning("The server will make no attempt to authenticate usernames. Beware."); log.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."); log.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."); log.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
} }
this.f = new ServerConfigurationManager(this); this.serverConfigurationManager = new ServerConfigurationManager(this);
this.k = new EntityTracker(this); this.tracker = new EntityTracker(this);
long j = System.nanoTime(); long j = System.nanoTime();
String s1 = this.d.a("level-name", "world"); String s1 = this.propertyManager.getString("level-name", "world");
String s2 = this.d.a("level-seed", ""); String s2 = this.propertyManager.getString("level-seed", "");
long k = (new Random()).nextLong(); long k = (new Random()).nextLong();
if (s2.length() > 0) { if (s2.length() > 0) {
@ -138,41 +138,41 @@ public class MinecraftServer implements Runnable, ICommandListener {
} }
} }
a.info("Preparing level \"" + s1 + "\""); log.info("Preparing level \"" + s1 + "\"");
this.a(new WorldLoaderServer(new File(".")), s1, k); this.a(new WorldLoaderServer(new File(".")), s1, k);
// CraftBukkit start // CraftBukkit start
long elapsed = System.nanoTime() - j; long elapsed = System.nanoTime() - j;
String time = String.format( "%.3fs", elapsed / 10000000000.0D ); String time = String.format( "%.3fs", elapsed / 10000000000.0D );
a.info("Done (" + time + ")! For help, type \"help\" or \"?\""); log.info("Done (" + time + ")! For help, type \"help\" or \"?\"");
// CraftBukkit end // CraftBukkit end
return true; return true;
} }
private void a(Convertable convertable, String s, long i) { private void a(Convertable convertable, String s, long i) {
if (convertable.a(s)) { if (convertable.isConvertable(s)) {
a.info("Converting map!"); log.info("Converting map!");
convertable.a(s, new ConvertProgressUpdater(this)); convertable.convert(s, new ConvertProgressUpdater(this));
} }
a.info("Preparing start region"); log.info("Preparing start region");
// CraftBukkit start // CraftBukkit start
WorldServer world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, this.d.a("hellworld", false) ? -1 : 0, i); WorldServer world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, this.propertyManager.getBoolean("hellworld", false) ? -1 : 0, i);
world.a(new WorldManager(this, world)); world.addIWorldAccess(new WorldManager(this, world));
world.j = this.d.a("spawn-monsters", true) ? 1 : 0; world.spawnMonsters = this.propertyManager.getBoolean("spawn-monsters", true) ? 1 : 0;
world.a(this.d.a("spawn-monsters", true), this.m); world.setSpawnFlags(this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals);
this.f.a(world); this.serverConfigurationManager.setPlayerFileData(world);
worlds.add(world); worlds.add(world);
// CraftBukkit end // CraftBukkit end
short short1 = 196; short short1 = 196;
long j = System.currentTimeMillis(); long j = System.currentTimeMillis();
ChunkCoordinates chunkcoordinates = worlds.get(0).m(); // CraftBukkit ChunkCoordinates chunkcoordinates = world.getSpawn(); // CraftBukkit
for (int k = -short1; k <= short1 && this.p; k += 16) { for (int k = -short1; k <= short1 && this.isRunning; k += 16) {
for (int l = -short1; l <= short1 && this.p; l += 16) { for (int l = -short1; l <= short1 && this.isRunning; l += 16) {
long i1 = System.currentTimeMillis(); long i1 = System.currentTimeMillis();
if (i1 < j) { if (i1 < j) {
@ -189,9 +189,9 @@ public class MinecraftServer implements Runnable, ICommandListener {
// CraftBukkit start // CraftBukkit start
for (WorldServer worldserver: worlds) { for (WorldServer worldserver: worlds) {
world.u.c(chunkcoordinates.a + k >> 4, chunkcoordinates.c + l >> 4); world.chunkProviderServer.getChunkAt(chunkcoordinates.x + k >> 4, chunkcoordinates.z + l >> 4);
while (world.f() && this.p) { while (world.doLighting() && this.isRunning) {
; ;
} }
} }
@ -205,7 +205,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
private void a(String s, int i) { private void a(String s, int i) {
this.i = s; this.i = s;
this.j = i; this.j = i;
a.info(s + ": " + i + "%"); log.info(s + ": " + i + "%");
} }
private void e() { private void e() {
@ -215,66 +215,66 @@ public class MinecraftServer implements Runnable, ICommandListener {
server.loadPlugins(); // CraftBukkit server.loadPlugins(); // CraftBukkit
} }
void f() { // CraftBukkit - private -> default void saveChunks() { // CraftBukkit - private -> default
a.info("Saving chunks"); log.info("Saving chunks");
// CraftBukkit start // CraftBukkit start
for (WorldServer world: worlds) { for (WorldServer world: worlds) {
world.a(true, (IProgressUpdate) null); world.save(true, (IProgressUpdate) null);
world.t(); world.saveLevel();
WorldSaveEvent event = new WorldSaveEvent( world.getWorld() ); WorldSaveEvent event = new WorldSaveEvent( world.getWorld() );
server.getPluginManager().callEvent( event ); server.getPluginManager().callEvent( event );
} }
this.f.d(); // CraftBukkit - player data should be saved whenever a save happens. this.serverConfigurationManager.savePlayers(); // CraftBukkit - player data should be saved whenever a save happens.
// CraftBukkit end // CraftBukkit end
} }
public void g() { // Craftbukkit: private -> public public void stop() { // Craftbukkit: private -> public
a.info("Stopping server"); log.info("Stopping server");
// CraftBukkit start // CraftBukkit start
if (server != null) { if (server != null) {
server.disablePlugins(); server.disablePlugins();
} }
// CraftBukkit end // CraftBukkit end
if (this.f != null) { if (this.serverConfigurationManager != null) {
this.f.d(); this.serverConfigurationManager.savePlayers();
} }
if (this.worlds.size() > 0) { // CraftBukkit if (this.worlds.size() > 0) { // CraftBukkit
this.f(); this.saveChunks();
} }
} }
public void a() { public void a() {
this.p = false; this.isRunning = false;
} }
public void run() { public void run() {
try { try {
if (this.d()) { if (this.init()) {
long i = System.currentTimeMillis(); long i = System.currentTimeMillis();
for (long j = 0L; this.p; Thread.sleep(1L)) { for (long j = 0L; this.isRunning; Thread.sleep(1L)) {
long k = System.currentTimeMillis(); long k = System.currentTimeMillis();
long l = k - i; long l = k - i;
if (l > 2000L) { if (l > 2000L) {
a.warning("Can\'t keep up! Did the system time change, or is the server overloaded?"); log.warning("Can\'t keep up! Did the system time change, or is the server overloaded?");
l = 2000L; l = 2000L;
} }
if (l < 0L) { if (l < 0L) {
a.warning("Time ran backwards! Did the system time change?"); log.warning("Time ran backwards! Did the system time change?");
l = 0L; l = 0L;
} }
j += l; j += l;
i = k; i = k;
// CraftBukkit - TODO - Replace with loop? // CraftBukkit - TODO - Replace with loop?
if (this.worlds.size() > 0 && this.worlds.get(0).s()) { if (this.worlds.size() > 0 && this.worlds.get(0).everyoneDeeplySleeping()) {
this.h(); this.h();
j = 0L; j = 0L;
} else { } else {
@ -285,7 +285,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
} }
} }
} else { } else {
while (this.p) { while (this.isRunning) {
this.b(); this.b();
try { try {
@ -297,9 +297,9 @@ public class MinecraftServer implements Runnable, ICommandListener {
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
throwable.printStackTrace(); throwable.printStackTrace();
a.log(Level.SEVERE, "Unexpected exception", throwable); log.log(Level.SEVERE, "Unexpected exception", throwable);
while (this.p) { while (this.isRunning) {
this.b(); this.b();
try { try {
@ -310,8 +310,8 @@ public class MinecraftServer implements Runnable, ICommandListener {
} }
} finally { } finally {
try { try {
this.g(); this.stop();
this.g = true; this.isStopped = true;
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
throwable1.printStackTrace(); throwable1.printStackTrace();
} finally { } finally {
@ -343,31 +343,31 @@ public class MinecraftServer implements Runnable, ICommandListener {
AxisAlignedBB.a(); AxisAlignedBB.a();
Vec3D.a(); Vec3D.a();
++this.h; ++this.ticks;
// CraftBukkit start // CraftBukkit start
if (this.h % 20 == 0) { if (this.ticks % 20 == 0) {
for (int i = 0; i < this.f.b.size(); ++i) { for (int i = 0; i < this.serverConfigurationManager.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.f.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(i);
entityplayer.a.b((Packet) (new Packet4UpdateTime(entityplayer.world.l()))); entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.world.getTime()));
} }
} }
((CraftScheduler) server.getScheduler()).mainThreadHeartbeat(this.h); ((CraftScheduler) server.getScheduler()).mainThreadHeartbeat(this.ticks);
for (WorldServer world: worlds) { for (WorldServer world: worlds) {
world.h(); world.doTick();
while (world.f()) { while (world.doLighting()) {
; ;
} }
world.e(); world.cleanUp();
} }
// CraftBukkit end // CraftBukkit end
this.c.a(); this.networkListenThread.a();
this.f.b(); this.serverConfigurationManager.b();
this.k.a(); this.tracker.a();
for (j = 0; j < this.q.size(); ++j) { for (j = 0; j < this.q.size(); ++j) {
((IUpdatePlayerListBox) this.q.get(j)).a(); ((IUpdatePlayerListBox) this.q.get(j)).a();
@ -376,11 +376,11 @@ public class MinecraftServer implements Runnable, ICommandListener {
try { try {
this.b(); this.b();
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, "Unexpected exception while parsing console command", exception); log.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
} }
} }
public void a(String s, ICommandListener icommandlistener) { public void issueCommand(String s, ICommandListener icommandlistener) {
this.r.add(new ServerCommand(s, icommandlistener)); this.r.add(new ServerCommand(s, icommandlistener));
} }
@ -388,8 +388,8 @@ public class MinecraftServer implements Runnable, ICommandListener {
while (this.r.size() > 0) { while (this.r.size() > 0) {
ServerCommand servercommand = (ServerCommand) this.r.remove(0); ServerCommand servercommand = (ServerCommand) this.r.remove(0);
// this.consoleCommandHandler.a(servercommand); // CraftBukkit - Removed its now called in server.displatchCommand
server.dispatchCommand(console, servercommand); // CraftBukkit server.dispatchCommand(console, servercommand); // CraftBukkit
// this.o.a(servercommand); // CraftBukkit - Removed its now called in server.displatchCommand
} }
} }
@ -405,7 +405,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
(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", exception); log.log(Level.SEVERE, "Failed to start the minecraft server", exception);
} }
} }
@ -413,19 +413,19 @@ public class MinecraftServer implements Runnable, ICommandListener {
return new File(s); return new File(s);
} }
public void b(String s) { public void sendMessage(String s) {
a.info(s); log.info(s);
} }
public void c(String s) { public void c(String s) {
a.warning(s); log.warning(s);
} }
public String c() { public String getName() {
return "CONSOLE"; return "CONSOLE";
} }
public static boolean a(MinecraftServer minecraftserver) { public static boolean isRunning(MinecraftServer minecraftserver) {
return minecraftserver.p; return minecraftserver.isRunning;
} }
} }

View file

@ -8,23 +8,23 @@ public class NetLoginHandler extends NetHandler {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
private static Random d = new Random(); private static Random d = new Random();
public NetworkManager b; public NetworkManager networkManager;
public boolean c = false; public boolean c = false;
private MinecraftServer e; private MinecraftServer server;
private int f = 0; private int f = 0;
private String g = null; private String g = null;
private Packet1Login h = null; private Packet1Login h = null;
private String i = ""; private String i = "";
public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) { public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) {
this.e = minecraftserver; this.server = minecraftserver;
this.b = new NetworkManager(socket, s, this); this.networkManager = new NetworkManager(socket, s, this);
this.b.d = 0; this.networkManager.d = 0;
} }
// CraftBukkit start // CraftBukkit start
public Socket getSocket() { public Socket getSocket() {
return b.f; return networkManager.socket;
} }
// CraftBukkit end // CraftBukkit end
@ -35,17 +35,17 @@ public class NetLoginHandler extends NetHandler {
} }
if (this.f++ == 600) { if (this.f++ == 600) {
this.a("Took too long to log in"); this.disconnect("Took too long to log in");
} else { } else {
this.b.a(); this.networkManager.a();
} }
} }
public void a(String s) { public void disconnect(String s) {
try { try {
a.info("Disconnecting " + this.b() + ": " + s); a.info("Disconnecting " + this.b() + ": " + s);
this.b.a((Packet) (new Packet255KickDisconnect(s))); this.networkManager.a((Packet) (new Packet255KickDisconnect(s)));
this.b.c(); this.networkManager.c();
this.c = true; this.c = true;
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
@ -53,50 +53,47 @@ public class NetLoginHandler extends NetHandler {
} }
public void a(Packet2Handshake packet2handshake) { public void a(Packet2Handshake packet2handshake) {
if (this.e.l) { if (this.server.onlineMode) {
this.i = Long.toHexString(d.nextLong()); this.i = Long.toHexString(d.nextLong());
this.b.a((Packet) (new Packet2Handshake(this.i))); this.networkManager.a((Packet) (new Packet2Handshake(this.i)));
} else { } else {
this.b.a((Packet) (new Packet2Handshake("-"))); this.networkManager.a((Packet) (new Packet2Handshake("-")));
} }
} }
public void a(Packet1Login packet1login) { public void a(Packet1Login packet1login) {
this.g = packet1login.b; this.g = packet1login.name;
if (packet1login.a != 10) { if (packet1login.a != 10) {
if (packet1login.a > 10) { if (packet1login.a > 10) {
this.a("Outdated server!"); this.disconnect("Outdated server!");
} else { } else {
this.a("Outdated client!"); this.disconnect("Outdated client!");
} }
} else { } else {
if (!this.e.l) { if (!this.server.onlineMode) {
this.b(packet1login); this.b(packet1login);
} else { } else {
(new ThreadLoginVerifier(this, packet1login, e.server)).start(); (new ThreadLoginVerifier(this, packet1login, this.server.server)).start();
} }
} }
} }
public void b(Packet1Login packet1login) { public void b(Packet1Login packet1login) {
EntityPlayer entityplayer = this.e.f.a(this, packet1login.b, packet1login.c); EntityPlayer entityplayer = this.server.serverConfigurationManager.a(this, packet1login.name, packet1login.c);
if (entityplayer != null) { if (entityplayer != null) {
a.info(this.b() + " logged in with entity id " + entityplayer.id); a.info(this.b() + " logged in with entity id " + entityplayer.id);
NetServerHandler netserverhandler = new NetServerHandler(this.e, this.b, entityplayer); ChunkCoordinates chunkcoordinates = entityplayer.world.getSpawn(); // CraftBukkit
NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer);
// CraftBukkit start netserverhandler.sendPacket(new Packet1Login("", "", entityplayer.id, entityplayer.world.getSeed(), (byte) entityplayer.world.worldProvider.dimension)); // CraftBukkit
ChunkCoordinates chunkcoordinates = entityplayer.world.m(); netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z));
netserverhandler.b((Packet) (new Packet1Login("", "", entityplayer.id, entityplayer.world.k(), (byte) entityplayer.world.m.g))); // this.server.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - message moved to join event
netserverhandler.b((Packet) (new Packet6SpawnPosition(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c))); this.server.serverConfigurationManager.a(entityplayer);
// this.e.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game."))); // CraftBukkit - message moved to join event
this.e.f.a(entityplayer);
netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
this.e.c.a(netserverhandler); this.server.networkListenThread.a(netserverhandler);
netserverhandler.b((Packet) (new Packet4UpdateTime(entityplayer.world.l()))); netserverhandler.sendPacket(new Packet4UpdateTime(entityplayer.world.getTime())); // CraftBukkit
// CraftBukkit end entityplayer.syncInventory();
entityplayer.m();
} }
this.c = true; this.c = true;
@ -108,11 +105,11 @@ public class NetLoginHandler extends NetHandler {
} }
public void a(Packet packet) { public void a(Packet packet) {
this.a("Protocol error"); this.disconnect("Protocol error");
} }
public String b() { public String b() {
return this.g != null ? this.g + " [" + this.b.b().toString() + "]" : this.b.b().toString(); return this.g != null ? this.g + " [" + this.networkManager.getSocketAddress().toString() + "]" : this.networkManager.getSocketAddress().toString();
} }
static String a(NetLoginHandler netloginhandler) { static String a(NetLoginHandler netloginhandler) {

View file

@ -24,25 +24,25 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private static final int PLACE_DISTANCE_SQUARED = 6 * 6; // CraftBukkit here for now private static final int PLACE_DISTANCE_SQUARED = 6 * 6; // CraftBukkit here for now
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public NetworkManager b; public NetworkManager networkManager;
public boolean c = false; public boolean disconnected = false;
private MinecraftServer d; private MinecraftServer minecraftServer;
public EntityPlayer e; // CraftBukkit - private->public public EntityPlayer player; // CraftBukkit - private->public
private int f; private int f;
private int g; private int g;
private boolean h; private boolean h;
private double i; private double x;
private double j; private double y;
private double k; private double z;
private boolean l = true; private boolean l = true;
private Map m = new HashMap(); private Map m = new HashMap();
public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.d = minecraftserver; this.minecraftServer = minecraftserver;
this.b = networkmanager; this.networkManager = networkmanager;
networkmanager.a((NetHandler) this); networkmanager.a((NetHandler) this);
this.e = entityplayer; this.player = entityplayer;
entityplayer.a = this; entityplayer.netServerHandler = this;
// CraftBukkit start // CraftBukkit start
server = minecraftserver.server; server = minecraftserver.server;
@ -63,42 +63,42 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private int lastMaterial; private int lastMaterial;
public CraftPlayer getPlayer() { public CraftPlayer getPlayer() {
return (e == null) ? null : (CraftPlayer) e.getBukkitEntity(); return (this.player == null) ? null : (CraftPlayer) player.getBukkitEntity();
} }
// CraftBukkit end // CraftBukkit end
public void a() { public void a() {
this.h = false; this.h = false;
this.b.a(); this.networkManager.a();
if (this.f - this.g > 20) { if (this.f - this.g > 20) {
this.b((Packet) (new Packet0KeepAlive())); this.sendPacket(new Packet0KeepAlive());
} }
} }
public void a(String s) { public void disconnect(String s) {
// CraftBukkit start // CraftBukkit start
String leaveMessage = "\u00A7e" + this.e.name + " left the game."; String leaveMessage = "\u00A7e" + this.player.name + " left the game.";
PlayerKickEvent event = new PlayerKickEvent(server.getPlayer(this.e), s, leaveMessage); PlayerKickEvent event = new PlayerKickEvent(server.getPlayer(this.player), s, leaveMessage);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
// Do not kick the player // Do not kick the player
return; return;
} }
// Send the possibly modified leave message // Send the possibly modified leave message
this.b.a((Packet) (new Packet255KickDisconnect( event.getReason() ))); this.sendPacket(new Packet255KickDisconnect( event.getReason() ));
this.b.c(); this.networkManager.c();
leaveMessage = event.getLeaveMessage(); leaveMessage = event.getLeaveMessage();
if (leaveMessage != null) { if (leaveMessage != null) {
this.d.f.a((Packet) (new Packet3Chat(leaveMessage))); this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(leaveMessage));
} }
// CraftBukkit end // CraftBukkit end
this.d.f.c(this.e); this.minecraftServer.serverConfigurationManager.disconnect(this.player);
this.c = true; this.disconnected = true;
} }
public void a(Packet27 packet27) { public void a(Packet27 packet27) {
this.e.a(packet27.c(), packet27.e(), packet27.g(), packet27.h(), packet27.d(), packet27.f()); this.player.a(packet27.c(), packet27.e(), packet27.g(), packet27.h(), packet27.d(), packet27.f());
} }
public void a(Packet10Flying packet10flying) { public void a(Packet10Flying packet10flying) {
@ -106,8 +106,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double d0; double d0;
if (!this.l) { if (!this.l) {
d0 = packet10flying.b - this.j; d0 = packet10flying.y - this.y;
if (packet10flying.a == this.i && d0 * d0 < 0.01D && packet10flying.c == this.k) { if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) {
this.l = true; this.l = true;
} }
} }
@ -118,8 +118,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
Location to = player.getLocation(); Location to = player.getLocation();
// Prevent 40 event-calls for less than a single pixel of movement >.> // Prevent 40 event-calls for less than a single pixel of movement >.>
double delta = Math.pow( this.lastPosX - this.i, 2) + Math.pow( this.lastPosY - this.j, 2) + Math.pow( this.lastPosZ - this.k, 2); double delta = Math.pow( this.lastPosX - this.x, 2) + Math.pow( this.lastPosY - this.y, 2) + Math.pow( this.lastPosZ - this.z, 2);
float deltaAngle = Math.abs(this.lastYaw - this.e.yaw) + Math.abs(this.lastPitch - this.e.pitch); float deltaAngle = Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch);
if (delta > 1f/256 || deltaAngle > 10f) { if (delta > 1f/256 || deltaAngle > 10f) {
// Skip the first time we do this // Skip the first time we do this
@ -130,45 +130,45 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
from = event.getFrom(); from = event.getFrom();
to = event.isCancelled() ? from : event.getTo(); to = event.isCancelled() ? from : event.getTo();
this.e.locX = to.getX(); this.player.locX = to.getX();
this.e.locY = to.getY(); this.player.locY = to.getY();
this.e.locZ = to.getZ(); this.player.locZ = to.getZ();
this.e.yaw = to.getYaw(); this.player.yaw = to.getYaw();
this.e.pitch = to.getPitch(); this.player.pitch = to.getPitch();
} }
this.lastPosX = this.e.locX; this.lastPosX = this.player.locX;
this.lastPosY = this.e.locY; this.lastPosY = this.player.locY;
this.lastPosZ = this.e.locZ; this.lastPosZ = this.player.locZ;
this.lastYaw = this.e.yaw; this.lastYaw = this.player.yaw;
this.lastPitch = this.e.pitch; this.lastPitch = this.player.pitch;
} }
if (Math.abs(packet10flying.a) > 32000000 || Math.abs(packet10flying.c) > 32000000) { if (Math.abs(packet10flying.x) > 32000000 || Math.abs(packet10flying.z) > 32000000) {
System.err.println(player.getName() + " was caught trying to crash the server with an invalid position."); System.err.println(player.getName() + " was caught trying to crash the server with an invalid position.");
player.kickPlayer("Nope!"); player.kickPlayer("Nope!");
return; return;
} }
if (Double.isNaN(packet10flying.a) || packet10flying.a == Double.POSITIVE_INFINITY || packet10flying.a == Double.NEGATIVE_INFINITY) { if (Double.isNaN(packet10flying.x) || packet10flying.x == Double.POSITIVE_INFINITY || packet10flying.x == Double.NEGATIVE_INFINITY) {
System.err.println(player.getName() + " was caught trying to set an invalid position."); System.err.println(player.getName() + " was caught trying to set an invalid position.");
player.kickPlayer("Nope!"); player.kickPlayer("Nope!");
return; return;
} }
if (Double.isNaN(packet10flying.b) || packet10flying.b == Double.POSITIVE_INFINITY || packet10flying.b == Double.NEGATIVE_INFINITY) { if (Double.isNaN(packet10flying.y) || packet10flying.y == Double.POSITIVE_INFINITY || packet10flying.y == Double.NEGATIVE_INFINITY) {
System.err.println(player.getName() + " was caught trying to set an invalid position."); System.err.println(player.getName() + " was caught trying to set an invalid position.");
player.kickPlayer("Nope!"); player.kickPlayer("Nope!");
return; return;
} }
if (Double.isNaN(packet10flying.c) || packet10flying.c == Double.POSITIVE_INFINITY || packet10flying.c == Double.NEGATIVE_INFINITY) { if (Double.isNaN(packet10flying.z) || packet10flying.z == Double.POSITIVE_INFINITY || packet10flying.z == Double.NEGATIVE_INFINITY) {
System.err.println(player.getName() + " was caught trying to set an invalid position."); System.err.println(player.getName() + " was caught trying to set an invalid position.");
player.kickPlayer("Nope!"); player.kickPlayer("Nope!");
return; return;
} }
if (Double.isNaN(packet10flying.d) || packet10flying.d == Double.POSITIVE_INFINITY || packet10flying.d == Double.NEGATIVE_INFINITY) { if (Double.isNaN(packet10flying.stance) || packet10flying.stance == Double.POSITIVE_INFINITY || packet10flying.stance == Double.NEGATIVE_INFINITY) {
System.err.println(player.getName() + " was caught trying to set an invalid position."); System.err.println(player.getName() + " was caught trying to set an invalid position.");
player.kickPlayer("Nope!"); player.kickPlayer("Nope!");
return; return;
@ -181,133 +181,133 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
double d3; double d3;
double d4; double d4;
if (this.e.vehicle != null) { if (this.player.vehicle != null) {
float f = this.e.yaw; float f = this.player.yaw;
float f1 = this.e.pitch; float f1 = this.player.pitch;
this.e.vehicle.h_(); this.player.vehicle.h_();
d1 = this.e.locX; d1 = this.player.locX;
d2 = this.e.locY; d2 = this.player.locY;
d3 = this.e.locZ; d3 = this.player.locZ;
double d5 = 0.0D; double d5 = 0.0D;
d4 = 0.0D; d4 = 0.0D;
if (packet10flying.i) { if (packet10flying.hasLook) {
f = packet10flying.e; f = packet10flying.yaw;
f1 = packet10flying.f; f1 = packet10flying.pitch;
} }
if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -999.0D) { if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
d5 = packet10flying.a; d5 = packet10flying.x;
d4 = packet10flying.c; d4 = packet10flying.z;
} }
this.e.onGround = packet10flying.g; this.player.onGround = packet10flying.g;
this.e.a(true); this.player.a(true);
this.e.c(d5, 0.0D, d4); this.player.move(d5, 0.0D, d4);
this.e.b(d1, d2, d3, f, f1); this.player.setLocation(d1, d2, d3, f, f1);
this.e.motX = d5; this.player.motX = d5;
this.e.motZ = d4; this.player.motZ = d4;
if (this.e.vehicle != null) { if (this.player.vehicle != null) {
// CraftBukkit // CraftBukkit
((WorldServer) this.e.world).b(this.e.vehicle, true); ((WorldServer) this.player.world).vehicleEnteredWorld(this.player.vehicle, true);
} }
if (this.e.vehicle != null) { if (this.player.vehicle != null) {
this.e.vehicle.h_(); this.player.vehicle.h_();
} }
this.d.f.b(this.e); this.minecraftServer.serverConfigurationManager.b(this.player);
this.i = this.e.locX; this.x = this.player.locX;
this.j = this.e.locY; this.y = this.player.locY;
this.k = this.e.locZ; this.z = this.player.locZ;
// CraftBukkit // CraftBukkit
this.e.world.f(this.e); ((WorldServer) this.player.world).playerJoinedWorld(this.player);
return; return;
} }
d0 = this.e.locY; d0 = this.player.locY;
this.i = this.e.locX; this.x = this.player.locX;
this.j = this.e.locY; this.y = this.player.locY;
this.k = this.e.locZ; this.z = this.player.locZ;
d1 = this.e.locX; d1 = this.player.locX;
d2 = this.e.locY; d2 = this.player.locY;
d3 = this.e.locZ; d3 = this.player.locZ;
float f2 = this.e.yaw; float f2 = this.player.yaw;
float f3 = this.e.pitch; float f3 = this.player.pitch;
if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -999.0D) { if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
packet10flying.h = false; packet10flying.h = false;
} }
if (packet10flying.h) { if (packet10flying.h) {
d1 = packet10flying.a; d1 = packet10flying.x;
d2 = packet10flying.b; d2 = packet10flying.y;
d3 = packet10flying.c; d3 = packet10flying.z;
d4 = packet10flying.d - packet10flying.b; d4 = packet10flying.stance - packet10flying.y;
if (d4 > 1.65D || d4 < 0.1D) { if (d4 > 1.65D || d4 < 0.1D) {
this.a("Illegal stance"); this.disconnect("Illegal stance");
a.warning(this.e.name + " had an illegal stance: " + d4); a.warning(this.player.name + " had an illegal stance: " + d4);
d4 = 1.62D; // CraftBukkit - reset the stance to 'the normal' height d4 = 1.62D; // CraftBukkit - reset the stance to 'the normal' height
} }
} }
// Craftbukkit start - better fix for invalid position issues; should be fixed in 1.5 // Craftbukkit start - better fix for invalid position issues; should be fixed in 1.5
d4 = d1 - this.e.locX; d4 = d1 - this.player.locX;
double d6 = d2 - this.e.locY; double d6 = d2 - this.player.locY;
double d7 = d3 - this.e.locZ; double d7 = d3 - this.player.locZ;
float f4 = 0.0625F; float f4 = 0.0625F;
if (d6 > -0.5D || d6 < 0.5D) {
d6 = 0.0D;
}
d7 = d3 - this.e.locZ;
double d8 = d4 * d4 + d6 * d6 + d7 * d7;
boolean flag1 = false;
if (d8 > 6.25D && !this.e.F()) {
flag1 = true;
a.warning(this.e.name + " was caught moving faster than the maximum allowed speed. Possible malicious activity?");
this.a(this.i, this.j, this.k, f2, f3);
return;
}
this.e.c(d4, d6, d7);
d4 = d1 - this.e.locX;
d6 = d2 - this.e.locY;
if (d6 > -0.5D || d6 < 0.5D) { if (d6 > -0.5D || d6 < 0.5D) {
d6 = 0.0D; d6 = 0.0D;
} }
d7 = d3 - this.e.locZ; d7 = d3 - this.player.locZ;
double d8 = d4 * d4 + d6 * d6 + d7 * d7;
boolean flag1 = false;
if (packet10flying.i) { if (d8 > 6.25D && !this.player.isSleeping()) {
f2 = packet10flying.e; flag1 = true;
f3 = packet10flying.f; a.warning(this.player.name + " moved wrongly!");
System.out.println("Got position " + d1 + ", " + d2 + ", " + d3);
System.out.println("Expected " + this.player.locX + ", " + this.player.locY + ", " + this.player.locZ);
}
this.player.move(d4, d6, d7);
d4 = d1 - this.player.locX;
d6 = d2 - this.player.locY;
if (d6 > -0.5D || d6 < 0.5D) {
d6 = 0.0D;
}
d7 = d3 - this.player.locZ;
if (packet10flying.hasLook) {
f2 = packet10flying.yaw;
f3 = packet10flying.pitch;
} }
// Craftbukkit end // Craftbukkit end
this.e.a(true); this.player.a(true);
this.e.bl = 0.0F; this.player.bl = 0.0F;
this.e.b(this.i, this.j, this.k, f2, f3); this.player.setLocation(this.x, this.y, this.z, f2, f3);
// CraftBukkit // CraftBukkit
boolean flag = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0; boolean flag = ((WorldServer) this.player.world).getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0;
this.e.b(d1, d2, d3, f2, f3); this.player.setLocation(d1, d2, d3, f2, f3);
// CraftBukkit // CraftBukkit
boolean flag2 = this.e.world.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0; boolean flag2 = ((WorldServer) this.player.world).getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0;
if (flag && (flag1 || !flag2) && !this.e.F()) { if (flag && (flag1 || !flag2) && !this.player.isSleeping()) {
this.a(this.i, this.j, this.k, f2, f3); this.a(this.x, this.y, this.z, f2, f3);
return; return;
} }
this.e.onGround = packet10flying.g; this.player.onGround = packet10flying.g;
this.d.f.b(this.e); this.minecraftServer.serverConfigurationManager.b(this.player);
this.e.b(this.e.locY - d0, packet10flying.g); this.player.b(this.player.locY - d0, packet10flying.g);
} }
} }
@ -340,11 +340,11 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end // CraftBukkit end
this.l = false; this.l = false;
this.i = d0; this.x = d0;
this.j = d1; this.y = d1;
this.k = d2; this.z = d2;
this.e.b(d0, d1, d2, f, f1); this.player.setLocation(d0, d1, d2, f, f1);
this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false))); this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false));
// CraftBukkit -- Returns TRUE if the teleport was successful // CraftBukkit -- Returns TRUE if the teleport was successful
return !event.isCancelled(); return !event.isCancelled();
@ -352,10 +352,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public void a(Packet14BlockDig packet14blockdig) { public void a(Packet14BlockDig packet14blockdig) {
if (packet14blockdig.e == 4) { if (packet14blockdig.e == 4) {
this.e.z(); this.player.z();
} else { } else {
// CraftBukkit // CraftBukkit
boolean flag = ((WorldServer) this.e.world).v = this.d.f.h(this.e.name); boolean flag = ((WorldServer) this.player.world).weirdIsOpCache = this.minecraftServer.serverConfigurationManager.isOp(this.player.name);
boolean flag1 = false; boolean flag1 = false;
if (packet14blockdig.e == 0) { if (packet14blockdig.e == 0) {
@ -371,9 +371,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
int k = packet14blockdig.c; int k = packet14blockdig.c;
if (flag1) { if (flag1) {
double d0 = this.e.locX - ((double) i + 0.5D); double d0 = this.player.locX - ((double) i + 0.5D);
double d1 = this.e.locY - ((double) j + 0.5D); double d1 = this.player.locY - ((double) j + 0.5D);
double d2 = this.e.locZ - ((double) k + 0.5D); double d2 = this.player.locZ - ((double) k + 0.5D);
double d3 = d0 * d0 + d1 * d1 + d2 * d2; double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 > 36.0D) { if (d3 > 36.0D) {
@ -382,9 +382,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit // CraftBukkit
ChunkCoordinates chunkcoordinates = this.e.world.m(); ChunkCoordinates chunkcoordinates = ((WorldServer) this.player.world).getSpawn();
int l = (int) MathHelper.e((float) (i - chunkcoordinates.a)); int l = (int) MathHelper.abs((float) (i - chunkcoordinates.x));
int i1 = (int) MathHelper.e((float) (k - chunkcoordinates.c)); int i1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z));
if (l > i1) { if (l > i1) {
i1 = l; i1 = l;
@ -392,26 +392,26 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (packet14blockdig.e == 0) { if (packet14blockdig.e == 0) {
// CraftBukkit // CraftBukkit
if (i1 > this.d.spawnProtection || flag) { if (i1 > this.minecraftServer.spawnProtection || flag) {
// CraftBukkit add face argument // CraftBukkit add face argument
this.e.c.a(i, j, k, packet14blockdig.d); this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face);
} }
} else if (packet14blockdig.e == 2) { } else if (packet14blockdig.e == 2) {
this.e.c.b(i, j, k); this.player.itemInWorldManager.b(i, j, k);
} else if (packet14blockdig.e == 3) { } else if (packet14blockdig.e == 3) {
double d4 = this.e.locX - ((double) i + 0.5D); double d4 = this.player.locX - ((double) i + 0.5D);
double d5 = this.e.locY - ((double) j + 0.5D); double d5 = this.player.locY - ((double) j + 0.5D);
double d6 = this.e.locZ - ((double) k + 0.5D); double d6 = this.player.locZ - ((double) k + 0.5D);
double d7 = d4 * d4 + d5 * d5 + d6 * d6; double d7 = d4 * d4 + d5 * d5 + d6 * d6;
if (d7 < 256.0D) { if (d7 < 256.0D) {
// CraftBukkit // CraftBukkit
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world))); this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.player.world));
} }
} }
// CraftBukkit // CraftBukkit
((WorldServer) this.e.world).v = false; ((WorldServer) this.player.world).weirdIsOpCache = false;
} }
} }
@ -425,14 +425,14 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// second one. This sadly has to remain until Mojang makes their packets saner. :( // second one. This sadly has to remain until Mojang makes their packets saner. :(
// -- Grum // -- Grum
if (packet15place.d == 255) { if (packet15place.face == 255) {
if (packet15place.e != null && packet15place.e.id == lastMaterial && lastPacket != null && packet15place.j - lastPacket < 100) { if (packet15place.itemstack != null && packet15place.itemstack.id == lastMaterial && lastPacket != null && packet15place.timestamp - lastPacket < 100) {
lastPacket = null; lastPacket = null;
return; return;
} }
} else { } else {
lastMaterial = packet15place.e == null ? -1 : packet15place.e.id; lastMaterial = packet15place.itemstack == null ? -1 : packet15place.itemstack.id;
lastPacket = packet15place.j; lastPacket = packet15place.timestamp;
} }
// CraftBukkit if rightclick decremented the item, always send the update packet. // CraftBukkit if rightclick decremented the item, always send the update packet.
@ -442,20 +442,19 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end // CraftBukkit end
ItemStack itemstack = this.e.inventory.b(); ItemStack itemstack = this.player.inventory.getItemInHand();
// boolean flag = this.minecraftServer.worldServer.weirdIsOpCache = this.minecraftServer.serverConfigurationManager.isOp(this.player.name);
// boolean flag = this.d.e.v = this.d.f.h(this.e.name); // CraftBukkit if (packet15place.face == 255) {
if (packet15place.d == 255) {
if (itemstack == null) { if (itemstack == null) {
return; return;
} }
// CraftBukkit start // CraftBukkit start
int itemstackAmount = itemstack.count; int itemstackAmount = itemstack.count;
PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.e, Action.RIGHT_CLICK_AIR, itemstack); PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
if (event.useItemInHand() != Event.Result.DENY) { if (event.useItemInHand() != Event.Result.DENY) {
this.e.c.a(this.e, this.e.world, itemstack); this.player.itemInWorldManager.useItem(this.player, this.player.world, itemstack);
} }
// CraftBukkit notch decrements the counter by 1 in the above method with food, // CraftBukkit notch decrements the counter by 1 in the above method with food,
@ -467,12 +466,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
int i = packet15place.a; int i = packet15place.a;
int j = packet15place.b; int j = packet15place.b;
int k = packet15place.c; int k = packet15place.c;
int l = packet15place.d; int l = packet15place.face;
ChunkCoordinates chunkcoordinates = ((WorldServer) this.player.world).getSpawn(); // CraftBukkit
// CraftBukkit int i1 = (int) MathHelper.abs((float) (i - chunkcoordinates.x));
ChunkCoordinates chunkcoordinates = this.e.world.m(); int j1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z));
int i1 = (int) MathHelper.e((float) (i - chunkcoordinates.a));
int j1 = (int) MathHelper.e((float) (k - chunkcoordinates.c));
if (i1 > j1) { if (i1 > j1) {
j1 = i1; j1 = i1;
@ -485,8 +482,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return; return;
} }
this.e.c.a(this.e, this.e.world, itemstack, i, j, k, l); this.player.itemInWorldManager.interact(this.player, this.player.world, itemstack, i, j, k, l);
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world))); this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.player.world));
// CraftBukkit end // CraftBukkit end
if (l == 0) { if (l == 0) {
@ -514,78 +511,75 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit // CraftBukkit
this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.e.world))); this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.player.world));
} }
if (itemstack != null && itemstack.count == 0) { if (itemstack != null && itemstack.count == 0) {
this.e.inventory.a[this.e.inventory.c] = null; this.player.inventory.items[this.player.inventory.itemInHandIndex] = null;
} }
this.e.h = true; this.player.h = true;
this.e.inventory.a[this.e.inventory.c] = ItemStack.b(this.e.inventory.a[this.e.inventory.c]); this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]);
Slot slot = this.e.activeContainer.a(this.e.inventory, this.e.inventory.c); Slot slot = this.player.activeContainer.a(this.player.inventory, this.player.inventory.itemInHandIndex);
this.e.activeContainer.a(); this.player.activeContainer.a();
this.e.h = false; this.player.h = false;
if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) { // CraftBukkit
// CraftBukkit this.sendPacket(new Packet103SetSlot(this.player.activeContainer.f, slot.a, this.player.inventory.getItemInHand()));
if (!ItemStack.a(this.e.inventory.b(), packet15place.e) || always) {
this.b((Packet) (new Packet103SetSlot(this.e.activeContainer.f, slot.a, this.e.inventory.b())));
} }
// CraftBukkit // CraftBukkit
((WorldServer) this.e.world).v = false; ((WorldServer) this.player.world).weirdIsOpCache = false;
} }
public void a(String s, Object[] aobject) { public void a(String s, Object[] aobject) {
// CraftBukkit start -- rarely it would send a disconnect line twice if (this.disconnected) return; // CraftBukkit -- rarely it would send a disconnect line twice
if (!this.c) {
a.info(this.e.name + " lost connection: " + s); a.info(this.player.name + " lost connection: " + s);
String quitMessage = this.d.f.c(this.e); this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + this.player.name + " left the game."));
if (quitMessage != null) { this.minecraftServer.serverConfigurationManager.disconnect(this.player);
this.d.f.a((Packet) (new Packet3Chat(quitMessage))); this.disconnected = true;
}
}
// CraftBukkit end
this.c = true;
} }
public void a(Packet packet) { public void a(Packet packet) {
a.warning(this.getClass() + " wasn\'t prepared to deal with a " + packet.getClass()); a.warning(this.getClass() + " wasn\'t prepared to deal with a " + packet.getClass());
this.a("Protocol error, unexpected packet"); this.disconnect("Protocol error, unexpected packet");
} }
public void b(Packet packet) { public void sendPacket(Packet packet) {
// CraftBukkit // CraftBukkit
if (packet instanceof Packet6SpawnPosition) { if (packet instanceof Packet6SpawnPosition) {
Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet; Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet;
this.e.compassTarget = new Location(getPlayer().getWorld(), packet6.a, packet6.b, packet6.c); this.player.compassTarget = new Location(getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
} }
// CraftBukkit // CraftBukkit
this.b.a(packet); this.networkManager.a(packet);
this.g = this.f; this.g = this.f;
} }
public void a(Packet16BlockItemSwitch packet16blockitemswitch) { public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
// CraftBukkit start if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex <= InventoryPlayer.e()) {
PlayerItemHeldEvent event = new PlayerItemHeldEvent(getPlayer(), e.inventory.c, packet16blockitemswitch.a); // CraftBukkit start
server.getPluginManager().callEvent(event); PlayerItemHeldEvent event = new PlayerItemHeldEvent(getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex);
// CraftBukkit end server.getPluginManager().callEvent(event);
// CraftBukkit end
this.e.inventory.c = packet16blockitemswitch.a; this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex;
} else {
a.warning(this.player.name + " tried to set an invalid carried item");
}
} }
public void a(Packet3Chat packet3chat) { public void a(Packet3Chat packet3chat) {
String s = packet3chat.a; String s = packet3chat.a;
if (s.length() > 100) { if (s.length() > 100) {
this.a("Chat message too long"); this.disconnect("Chat message too long");
} else { } else {
s = s.trim(); s = s.trim();
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
if (FontAllowedCharacters.a.indexOf(s.charAt(i)) < 0) { if (FontAllowedCharacters.a.indexOf(s.charAt(i)) < 0) {
this.a("Illegal characters in chat"); this.disconnect("Illegal characters in chat");
return; return;
} }
} }
@ -597,7 +591,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public boolean chat(String msg) { public boolean chat(String msg) {
if (msg.startsWith("/")) { if (msg.startsWith("/")) {
this.c(msg); this.handleCommand(msg);
return true; return true;
} else { } else {
// CraftBukkit start // CraftBukkit start
@ -621,7 +615,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit end // CraftBukkit end
private void c(String s) { private void handleCommand(String s) {
// CraftBukkit start // CraftBukkit start
CraftPlayer player = getPlayer(); CraftPlayer player = getPlayer();
@ -648,33 +642,33 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit stop // CraftBukkit stop
if (s.toLowerCase().startsWith("/me ")) { if (s.toLowerCase().startsWith("/me ")) {
s = "* " + this.e.name + " " + s.substring(s.indexOf(" ")).trim(); s = "* " + this.player.name + " " + s.substring(s.indexOf(" ")).trim();
a.info(s); a.info(s);
this.d.f.a((Packet) (new Packet3Chat(s))); this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(s));
} else if (s.toLowerCase().startsWith("/kill")) { } else if (s.toLowerCase().startsWith("/kill")) {
this.e.a((Entity) null, 1000); this.player.damageEntity((Entity) null, 1000);
} else if (s.toLowerCase().startsWith("/tell ")) { } else if (s.toLowerCase().startsWith("/tell ")) {
String[] astring = s.split(" "); String[] astring = s.split(" ");
if (astring.length >= 3) { if (astring.length >= 3) {
s = s.substring(s.indexOf(" ")).trim(); s = s.substring(s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim(); s = s.substring(s.indexOf(" ")).trim();
s = "\u00A77" + this.e.name + " whispers " + s; s = "\u00A77" + this.player.name + " whispers " + s;
a.info(s + " to " + astring[1]); a.info(s + " to " + astring[1]);
if (!this.d.f.a(astring[1], (Packet) (new Packet3Chat(s)))) { if (!this.minecraftServer.serverConfigurationManager.a(astring[1], (Packet) (new Packet3Chat(s)))) {
this.b((Packet) (new Packet3Chat("\u00A7cThere\'s no player by that name online."))); this.sendPacket(new Packet3Chat("\u00A7cThere\'s no player by that name online."));
} }
} }
} else { } else {
String s1; String s1;
if (this.d.f.h(this.e.name)) { if (this.minecraftServer.serverConfigurationManager.isOp(this.player.name)) {
s1 = s.substring(1); s1 = s.substring(1);
a.info(this.e.name + " issued server command: " + s1); a.info(this.player.name + " issued server command: " + s1);
this.d.a(s1, this); this.minecraftServer.issueCommand(s1, this);
} else { } else {
s1 = s.substring(1); s1 = s.substring(1);
a.info(this.e.name + " tried command: " + s1); a.info(this.player.name + " tried command: " + s1);
} }
} }
} }
@ -683,25 +677,25 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (packet18armanimation.b == 1) { if (packet18armanimation.b == 1) {
// CraftBukkit -- raytrace to look for 'rogue armswings' // CraftBukkit -- raytrace to look for 'rogue armswings'
float f = 1.0F; float f = 1.0F;
float f1 = this.e.lastPitch + (this.e.pitch - this.e.lastPitch) * f; float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
float f2 = this.e.lastYaw + (this.e.yaw - this.e.lastYaw) * f; float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
double d0 = this.e.lastX + (this.e.locX - this.e.lastX) * (double) f; double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
double d1 = this.e.lastY + (this.e.locY - this.e.lastY) * (double) f + 1.62D - (double) this.e.height; double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
double d2 = this.e.lastZ + (this.e.locZ - this.e.lastZ) * (double) f; double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
Vec3D vec3d = Vec3D.b(d0, d1, d2); Vec3D vec3d = Vec3D.create(d0, d1, d2);
float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F); float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F); float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
float f5 = -MathHelper.b(-f1 * 0.017453292F); float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.a(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5; float f7 = f4 * f5;
float f8 = f3 * f5; float f8 = f3 * f5;
double d3 = 5.0D; double d3 = 5.0D;
Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
MovingObjectPosition movingobjectposition = this.e.world.a(vec3d, vec3d1, true); MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);
if (movingobjectposition == null || movingobjectposition.a != EnumMovingObjectType.TILE) { if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.TILE) {
CraftEventFactory.callPlayerInteractEvent(this.e, Action.LEFT_CLICK_AIR, this.e.inventory.b()); CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
} }
// Arm swing animation // Arm swing animation
@ -710,13 +704,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
// CraftBukkit end // CraftBukkit end
this.e.m_(); this.player.m_();
} }
} }
public void a(Packet19EntityAction packet19entityaction) { public void a(Packet19EntityAction packet19entityaction) {
// CraftBukkit: Toggle Sneak // CraftBukkit start
if (packet19entityaction.b == 1 || packet19entityaction.b == 2) { if (packet19entityaction.animation == 1 || packet19entityaction.animation == 2) {
Player player = getPlayer(); Player player = getPlayer();
PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(player); PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(player);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
@ -724,107 +718,109 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return; return;
} }
} }
// CraftBukkit: Set Sneaking // CraftBukkit end
if (packet19entityaction.b == 1) { if (packet19entityaction.animation == 1) {
this.e.e(true); this.player.setSneak(true);
} else if (packet19entityaction.b == 2) { } else if (packet19entityaction.animation == 2) {
this.e.e(false); this.player.setSneak(false);
} else if (packet19entityaction.b == 3) { } else if (packet19entityaction.animation == 3) {
this.e.a(false, true, true); this.player.a(false, true, true);
this.l = false; this.l = false;
} }
} }
public void a(Packet255KickDisconnect packet255kickdisconnect) { public void a(Packet255KickDisconnect packet255kickdisconnect) {
this.b.a("disconnect.quitting", new Object[0]); this.networkManager.a("disconnect.quitting", new Object[0]);
} }
public int b() { public int b() {
return this.b.d(); return this.networkManager.d();
} }
public void b(String s) { public void sendMessage(String s) {
this.b((Packet) (new Packet3Chat("\u00A77" + s))); this.sendPacket(new Packet3Chat("\u00A77" + s));
} }
public String c() { public String getName() {
return this.e.name; return this.player.name;
} }
public void a(Packet7UseEntity packet7useentity) { public void a(Packet7UseEntity packet7useentity) {
// CraftBukkit // CraftBukkit
Entity entity = ((WorldServer) this.e.world).a(packet7useentity.b); Entity entity = ((WorldServer) this.player.world).getEntity(packet7useentity.target);
if (entity != null && this.e.e(entity) && this.e.f(entity) < 4.0F) { if (entity != null && this.player.e(entity) && this.player.f(entity) < 4.0F) {
if (packet7useentity.c == 0) { if (packet7useentity.c == 0) {
this.e.c(entity); this.player.c(entity);
} else if (packet7useentity.c == 1) { } else if (packet7useentity.c == 1) {
this.e.d(entity); this.player.d(entity);
} }
} }
} }
public void a(Packet9Respawn packet9respawn) { public void a(Packet9Respawn packet9respawn) {
if (this.e.health <= 0) { if (this.player.health <= 0) {
this.e = this.d.f.d(this.e); this.player = this.minecraftServer.serverConfigurationManager.d(this.player);
// CraftBukkit start // CraftBukkit start
CraftPlayer player = getPlayer(); CraftPlayer player = getPlayer();
player.setHandle(this.e); player.setHandle(this.player);
// CraftBukkit end // CraftBukkit end
} }
} }
public void a(Packet101CloseWindow packet101closewindow) { public void a(Packet101CloseWindow packet101closewindow) {
this.e.w(); this.player.w();
} }
public void a(Packet102WindowClick packet102windowclick) { public void a(Packet102WindowClick packet102windowclick) {
if (this.e.activeContainer.f == packet102windowclick.a && this.e.activeContainer.c(this.e)) { if (this.player.activeContainer.f == packet102windowclick.a && this.player.activeContainer.c(this.player)) {
ItemStack itemstack = this.e.activeContainer.a(packet102windowclick.b, packet102windowclick.c, this.e); ItemStack itemstack = this.player.activeContainer.a(packet102windowclick.b, packet102windowclick.c, this.player);
if (ItemStack.a(packet102windowclick.e, itemstack)) { if (ItemStack.equals(packet102windowclick.e, itemstack)) {
this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true))); this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true));
this.e.h = true; this.player.h = true;
this.e.activeContainer.a(); this.player.activeContainer.a();
this.e.v(); this.player.v();
this.e.h = false; this.player.h = false;
} else { } else {
this.m.put(Integer.valueOf(this.e.activeContainer.f), Short.valueOf(packet102windowclick.d)); this.m.put(Integer.valueOf(this.player.activeContainer.f), Short.valueOf(packet102windowclick.d));
this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false))); this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false));
this.e.activeContainer.a(this.e, false); this.player.activeContainer.a(this.player, false);
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
for (int i = 0; i < this.e.activeContainer.e.size(); ++i) { for (int i = 0; i < this.player.activeContainer.e.size(); ++i) {
arraylist.add(((Slot) this.e.activeContainer.e.get(i)).a()); arraylist.add(((Slot) this.player.activeContainer.e.get(i)).getItem());
} }
this.e.a(this.e.activeContainer, arraylist); this.player.a(this.player.activeContainer, arraylist);
} }
} }
} }
public void a(Packet106Transaction packet106transaction) { public void a(Packet106Transaction packet106transaction) {
Short oshort = (Short) this.m.get(Integer.valueOf(this.e.activeContainer.f)); Short oshort = (Short) this.m.get(Integer.valueOf(this.player.activeContainer.f));
if (oshort != null && packet106transaction.b == oshort.shortValue() && this.e.activeContainer.f == packet106transaction.a && !this.e.activeContainer.c(this.e)) { if (oshort != null && packet106transaction.b == oshort.shortValue() && this.player.activeContainer.f == packet106transaction.a && !this.player.activeContainer.c(this.player)) {
this.e.activeContainer.a(this.e, true); this.player.activeContainer.a(this.player, true);
} }
} }
public void a(Packet130UpdateSign packet130updatesign) { public void a(Packet130UpdateSign packet130updatesign) {
// CraftBukkit start // CraftBukkit start
if (this.e.world.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) { if (((WorldServer) this.player.world).isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) {
TileEntity tileentity = this.e.world.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c); TileEntity tileentity = ((WorldServer) this.player.world).getTileEntity(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z);
// CraftBukkit end
if (tileentity instanceof TileEntitySign) { if (tileentity instanceof TileEntitySign) {
TileEntitySign tileentitysign = (TileEntitySign)tileentity; TileEntitySign tileentitysign = (TileEntitySign) tileentity;
if (!tileentitysign.a()) { if (!tileentitysign.a()) {
this.d.c("Player " + this.e.name + " just tried to change non-editable sign"); this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign");
return; return;
} }
} }
// CraftBukkit end
int i; int i;
int j; int j;
@ -832,31 +828,31 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
for (j = 0; j < 4; ++j) { for (j = 0; j < 4; ++j) {
boolean flag = true; boolean flag = true;
if (packet130updatesign.d[j].length() > 15) { if (packet130updatesign.lines[j].length() > 15) {
flag = false; flag = false;
} else { } else {
for (i = 0; i < packet130updatesign.d[j].length(); ++i) { for (i = 0; i < packet130updatesign.lines[j].length(); ++i) {
if (FontAllowedCharacters.a.indexOf(packet130updatesign.d[j].charAt(i)) < 0) { if (FontAllowedCharacters.a.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) {
flag = false; flag = false;
} }
} }
} }
if (!flag) { if (!flag) {
packet130updatesign.d[j] = "!?"; packet130updatesign.lines[j] = "!?";
} }
} }
if (tileentity instanceof TileEntitySign) { if (tileentity instanceof TileEntitySign) {
j = packet130updatesign.a; j = packet130updatesign.x;
int k = packet130updatesign.b; int k = packet130updatesign.y;
i = packet130updatesign.c; i = packet130updatesign.z;
TileEntitySign tileentitysign1 = (TileEntitySign) tileentity; TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
// CraftBukkit start - SIGN_CHANGE hook // CraftBukkit start - SIGN_CHANGE hook
Player player = server.getPlayer(this.e); Player player = server.getPlayer(this.player);
SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.e), packet130updatesign.d); SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(i, k, j), server.getPlayer(this.player), packet130updatesign.lines);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -869,13 +865,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end // CraftBukkit end
for (int l = 0; l < 4; ++l) { for (int l = 0; l < 4; ++l) {
tileentitysign1.a[l] = event.getLine(l); tileentitysign1.lines[l] = event.getLine(l);
// CraftBukkit // CraftBukkit
} }
tileentitysign1.i(); tileentitysign1.update();
// CraftBukkit // CraftBukkit
this.e.world.g(j, k, i); ((WorldServer) this.player.world).notify(i, k, j);
} }
} }
} }

View file

@ -2,15 +2,13 @@ package net.minecraft.server;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; import java.io.IOException; // CraftBukkit
public class NetworkManager { public class NetworkManager {
@ -18,10 +16,10 @@ public class NetworkManager {
public static int b; public static int b;
public static int c; public static int c;
private Object e = new Object(); private Object e = new Object();
public Socket f; // CraftBukkit private->public public Socket socket; // CraftBukkit -- private->public
private final SocketAddress g; private final SocketAddress g;
private DataInputStream h; private DataInputStream input;
private DataOutputStream i; private DataOutputStream output;
private boolean j = true; private boolean j = true;
private List k = Collections.synchronizedList(new ArrayList()); private List k = Collections.synchronizedList(new ArrayList());
private List l = Collections.synchronizedList(new ArrayList()); private List l = Collections.synchronizedList(new ArrayList());
@ -39,26 +37,19 @@ public class NetworkManager {
private int w = 50; private int w = 50;
public NetworkManager(Socket socket, String s, NetHandler nethandler) { public NetworkManager(Socket socket, String s, NetHandler nethandler) {
this.f = socket; this.socket = socket;
this.g = socket.getRemoteSocketAddress(); this.g = socket.getRemoteSocketAddress();
this.n = nethandler; this.n = nethandler;
// Craftbukkit start
try { try {
socket.setSoTimeout(30000); socket.setSoTimeout(30000); // Craftbukkit start
socket.setTrafficClass(24); socket.setTrafficClass(24);
} catch (SocketException socketexception) { this.input = new DataInputStream(socket.getInputStream());
this.output = new DataOutputStream(socket.getOutputStream());
} catch (IOException socketexception) {
System.err.println(socketexception.getMessage()); System.err.println(socketexception.getMessage());
} }
try {
this.h = new DataInputStream(socket.getInputStream());
this.i = new DataOutputStream(socket.getOutputStream());
} catch (IOException ex) {
Logger.getLogger(NetworkManager.class.getName()).log(Level.SEVERE, null, ex);
}
// Craftbukkit end
this.q = new NetworkReaderThread(this, s + " read thread"); this.q = new NetworkReaderThread(this, s + " read thread");
this.p = new NetworkWriterThread(this, s + " write thread"); this.p = new NetworkWriterThread(this, s + " write thread");
this.q.start(); this.q.start();
@ -90,7 +81,7 @@ public class NetworkManager {
Object object; Object object;
Packet packet; Packet packet;
if (!this.l.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.l.get(0)).j >= (long) this.d)) { if (!this.l.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.l.get(0)).timestamp >= (long) this.d)) {
flag = false; flag = false;
object = this.e; object = this.e;
synchronized (this.e) { synchronized (this.e) {
@ -98,10 +89,10 @@ public class NetworkManager {
this.v -= packet.a() + 1; this.v -= packet.a() + 1;
} }
Packet.a(packet, this.i); Packet.a(packet, this.output);
} }
if ((flag || this.w-- <= 0) && !this.m.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.m.get(0)).j >= (long) this.d)) { if ((flag || this.w-- <= 0) && !this.m.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.m.get(0)).timestamp >= (long) this.d)) {
flag = false; flag = false;
object = this.e; object = this.e;
synchronized (this.e) { synchronized (this.e) {
@ -109,7 +100,7 @@ public class NetworkManager {
this.v -= packet.a() + 1; this.v -= packet.a() + 1;
} }
Packet.a(packet, this.i); Packet.a(packet, this.output);
this.w = 50; this.w = 50;
} }
@ -127,7 +118,7 @@ public class NetworkManager {
private void f() { private void f() {
try { try {
Packet packet = Packet.b(this.h); Packet packet = Packet.b(this.input);
if (packet != null) { if (packet != null) {
this.k.add(packet); this.k.add(packet);
@ -155,22 +146,22 @@ public class NetworkManager {
this.j = false; this.j = false;
try { try {
this.h.close(); this.input.close();
this.h = null; this.input = null;
} catch (Throwable throwable) { } catch (Throwable throwable) {
; ;
} }
try { try {
this.i.close(); this.output.close();
this.i = null; this.output = null;
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
; ;
} }
try { try {
this.f.close(); this.socket.close();
this.f = null; this.socket = null;
} catch (Throwable throwable2) { } catch (Throwable throwable2) {
; ;
} }
@ -203,7 +194,7 @@ public class NetworkManager {
} }
} }
public SocketAddress b() { public SocketAddress getSocketAddress() {
return this.g; return this.g;
} }

View file

@ -6,6 +6,7 @@ import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
// Craftbukkit start // Craftbukkit start
import java.net.SocketException; import java.net.SocketException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
@ -15,7 +16,7 @@ public abstract class Packet {
private static Map a = new HashMap(); private static Map a = new HashMap();
private static Map b = new HashMap(); private static Map b = new HashMap();
public final long j = System.currentTimeMillis(); public final long timestamp = System.currentTimeMillis();
public boolean k = false; public boolean k = false;
private static HashMap c; private static HashMap c;
private static int d; private static int d;

View file

@ -6,11 +6,11 @@ import java.util.List;
class PlayerInstance { class PlayerInstance {
private List b; private List b;
private int c; private int chunkX;
private int d; private int chunkZ;
private ChunkCoordIntPair e; private ChunkCoordIntPair e;
private short[] f; private short[] dirtyBlocks;
private int g; private int dirtyCount;
private int h; private int h;
private int i; private int i;
private int j; private int j;
@ -18,27 +18,27 @@ class PlayerInstance {
private int l; private int l;
private int m; private int m;
final PlayerManager a; final PlayerManager playerManager;
public PlayerInstance(PlayerManager playermanager, int i, int j) { public PlayerInstance(PlayerManager playermanager, int i, int j) {
this.a = playermanager; this.playerManager = playermanager;
this.b = new ArrayList(); this.b = new ArrayList();
this.f = new short[10]; this.dirtyBlocks = new short[10];
this.g = 0; this.dirtyCount = 0;
this.c = i; this.chunkX = i;
this.d = j; this.chunkZ = j;
this.e = new ChunkCoordIntPair(i, j); this.e = new ChunkCoordIntPair(i, j);
// CraftBukkit // CraftBukkit
playermanager.world.u.c(i, j); playermanager.world.chunkProviderServer.getChunkAt(i, j);
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
if (this.b.contains(entityplayer)) { if (this.b.contains(entityplayer)) {
throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.c + ", " + this.d); throw new IllegalStateException("Failed to add player. " + entityplayer + " already is in chunk " + this.chunkX + ", " + this.chunkZ);
} else { } else {
entityplayer.g.add(this.e); entityplayer.g.add(this.e);
entityplayer.a.b((Packet) (new Packet50PreChunk(this.e.a, this.e.b, true))); entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.e.x, this.e.z, true));
this.b.add(entityplayer); this.b.add(entityplayer);
entityplayer.f.add(this.e); entityplayer.f.add(this.e);
} }
@ -46,31 +46,31 @@ class PlayerInstance {
public void b(EntityPlayer entityplayer) { public void b(EntityPlayer entityplayer) {
if (!this.b.contains(entityplayer)) { if (!this.b.contains(entityplayer)) {
(new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.c + ", " + this.d)).printStackTrace(); (new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.chunkX + ", " + this.chunkZ)).printStackTrace();
} else { } else {
this.b.remove(entityplayer); this.b.remove(entityplayer);
if (this.b.size() == 0) { if (this.b.size() == 0) {
long i = (long) this.c + 2147483647L | (long) this.d + 2147483647L << 32; long i = (long) this.chunkX + 2147483647L | (long) this.chunkZ + 2147483647L << 32;
PlayerManager.b(this.a).b(i); PlayerManager.b(this.playerManager).b(i);
if (this.g > 0) { if (this.dirtyCount > 0) {
PlayerManager.c(this.a).remove(this); PlayerManager.c(this.playerManager).remove(this);
} }
// CraftBukkit // CraftBukkit
((WorldServer) entityplayer.world).u.d(this.c, this.d); ((WorldServer) entityplayer.world).chunkProviderServer.queueUnload(this.chunkX, this.chunkZ);
} }
entityplayer.f.remove(this.e); entityplayer.f.remove(this.e);
if (entityplayer.g.contains(this.e)) { if (entityplayer.g.contains(this.e)) {
entityplayer.a.b((Packet) (new Packet50PreChunk(this.c, this.d, false))); entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false));
} }
} }
} }
public void a(int i, int j, int k) { public void a(int i, int j, int k) {
if (this.g == 0) { if (this.dirtyCount == 0) {
PlayerManager.c(this.a).add(this); PlayerManager.c(this.playerManager).add(this);
this.h = this.i = i; this.h = this.i = i;
this.j = this.k = j; this.j = this.k = j;
this.l = this.m = k; this.l = this.m = k;
@ -100,95 +100,95 @@ class PlayerInstance {
this.m = k; this.m = k;
} }
if (this.g < 10) { if (this.dirtyCount < 10) {
short short1 = (short) (i << 12 | k << 8 | j); short short1 = (short) (i << 12 | k << 8 | j);
for (int l = 0; l < this.g; ++l) { for (int l = 0; l < this.dirtyCount; ++l) {
if (this.f[l] == short1) { if (this.dirtyBlocks[l] == short1) {
return; return;
} }
} }
this.f[this.g++] = short1; this.dirtyBlocks[this.dirtyCount++] = short1;
} }
} }
public void a(Packet packet) { public void sendAll(Packet packet) {
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.b.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
if (entityplayer.g.contains(this.e)) { if (entityplayer.g.contains(this.e)) {
entityplayer.a.b(packet); entityplayer.netServerHandler.sendPacket(packet);
} }
} }
} }
public void a() { public void a() {
if (this.g != 0) { if (this.dirtyCount != 0) {
int i; int i;
int j; int j;
int k; int k;
if (this.g == 1) { if (this.dirtyCount == 1) {
i = this.c * 16 + this.h; i = this.chunkX * 16 + this.h;
j = this.j; j = this.j;
k = this.d * 16 + this.l; k = this.chunkZ * 16 + this.l;
// CraftBukkit start // CraftBukkit start
this.a((Packet) (new Packet53BlockChange(i, j, k, a.world))); this.sendAll(new Packet53BlockChange(i, j, k, this.playerManager.world));
if (Block.p[a.world.getTypeId(i, j, k)]) { if (Block.isTileEntity[this.playerManager.world.getTypeId(i, j, k)]) {
this.a(a.world.getTileEntity(i, j, k)); this.sendTileEntity(this.playerManager.world.getTileEntity(i, j, k));
} }
// CraftBukkit end // CraftBukkit end
} else { } else {
int l; int l;
if (this.g == 10) { if (this.dirtyCount == 10) {
this.j = this.j / 2 * 2; this.j = this.j / 2 * 2;
this.k = (this.k / 2 + 1) * 2; this.k = (this.k / 2 + 1) * 2;
i = this.h + this.c * 16; i = this.h + this.chunkX * 16;
j = this.j; j = this.j;
k = this.l + this.d * 16; k = this.l + this.chunkZ * 16;
l = this.i - this.h + 1; l = this.i - this.h + 1;
int i1 = this.k - this.j + 2; int i1 = this.k - this.j + 2;
int j1 = this.m - this.l + 1; int j1 = this.m - this.l + 1;
// CraftBukkit start // CraftBukkit start
this.a((Packet) (new Packet51MapChunk(i, j, k, l, i1, j1, a.world))); this.sendAll(new Packet51MapChunk(i, j, k, l, i1, j1, this.playerManager.world));
List list = a.world.d(i, j, k, i + l, j + i1, k + j1); List list = this.playerManager.world.getTileEntities(i, j, k, i + l, j + i1, k + j1);
// CraftBukkit end // CraftBukkit end
for (int k1 = 0; k1 < list.size(); ++k1) { for (int k1 = 0; k1 < list.size(); ++k1) {
this.a((TileEntity) list.get(k1)); this.sendTileEntity((TileEntity) list.get(k1));
} }
} else { } else {
// CraftBukkit // CraftBukkit
this.a((Packet) (new Packet52MultiBlockChange(this.c, this.d, this.f, this.g, a.world))); this.sendAll(new Packet52MultiBlockChange(this.chunkX, this.chunkZ, this.dirtyBlocks, this.dirtyCount, this.playerManager.world));
for (i = 0; i < this.g; ++i) { for (i = 0; i < this.dirtyCount; ++i) {
j = this.c * 16 + (this.g >> 12 & 15); j = this.chunkX * 16 + (this.dirtyCount >> 12 & 15);
k = this.g & 255; k = this.dirtyCount & 255;
l = this.d * 16 + (this.g >> 8 & 15); l = this.chunkZ * 16 + (this.dirtyCount >> 8 & 15);
// CraftBukkit start // CraftBukkit start
if (Block.p[a.world.getTypeId(j, k, l)]) { if (Block.isTileEntity[this.playerManager.world.getTypeId(j, k, l)]) {
System.out.println("Sending!"); System.out.println("Sending!");
this.a(a.world.getTileEntity(j, k, l)); this.sendTileEntity(this.playerManager.world.getTileEntity(j, k, l));
} }
// CraftBukkit end // CraftBukkit end
} }
} }
} }
this.g = 0; this.dirtyCount = 0;
} }
} }
private void a(TileEntity tileentity) { private void sendTileEntity(TileEntity tileentity) {
if (tileentity != null) { if (tileentity != null) {
Packet packet = tileentity.e(); Packet packet = tileentity.e();
if (packet != null) { if (packet != null) {
this.a(packet); this.sendAll(packet);
} }
} }
} }

View file

@ -8,7 +8,7 @@ public class PlayerManager {
private List a = new ArrayList(); private List a = new ArrayList();
private PlayerList b = new PlayerList(); private PlayerList b = new PlayerList();
private List c = new ArrayList(); private List c = new ArrayList();
private MinecraftServer d; private MinecraftServer server;
private final int[][] e = new int[][] { { 1, 0}, { 0, 1}, { -1, 0}, { 0, -1}}; private final int[][] e = new int[][] { { 1, 0}, { 0, 1}, { -1, 0}, { 0, -1}};
// CraftBukkit start // CraftBukkit start
@ -16,12 +16,12 @@ public class PlayerManager {
// CraftBukkit - change of method signature // CraftBukkit - change of method signature
public PlayerManager(MinecraftServer minecraftserver, WorldServer world) { public PlayerManager(MinecraftServer minecraftserver, WorldServer world) {
this.d = minecraftserver;
this.world = world; this.world = world;
// CraftBukkit end
this.server = minecraftserver;
} }
// CraftBukkit end
public void a() { public void flush() {
for (int i = 0; i < this.c.size(); ++i) { for (int i = 0; i < this.c.size(); ++i) {
((PlayerInstance) this.c.get(i)).a(); ((PlayerInstance) this.c.get(i)).a();
} }
@ -41,7 +41,7 @@ public class PlayerManager {
return playerinstance; return playerinstance;
} }
public void a(int i, int j, int k) { public void flagDirty(int i, int j, int k) {
int l = i >> 4; int l = i >> 4;
int i1 = k >> 4; int i1 = k >> 4;
PlayerInstance playerinstance = this.a(l, i1, false); PlayerInstance playerinstance = this.a(l, i1, false);
@ -51,7 +51,7 @@ public class PlayerManager {
} }
} }
public void a(EntityPlayer entityplayer) { public void addPlayer(EntityPlayer entityplayer) {
int i = (int) entityplayer.locX >> 4; int i = (int) entityplayer.locX >> 4;
int j = (int) entityplayer.locZ >> 4; int j = (int) entityplayer.locZ >> 4;
@ -89,7 +89,7 @@ public class PlayerManager {
this.a.add(entityplayer); this.a.add(entityplayer);
} }
public void b(EntityPlayer entityplayer) { public void removePlayer(EntityPlayer entityplayer) {
int i = (int) entityplayer.d >> 4; int i = (int) entityplayer.d >> 4;
int j = (int) entityplayer.e >> 4; int j = (int) entityplayer.e >> 4;
@ -113,7 +113,7 @@ public class PlayerManager {
return i1 >= -10 && i1 <= 10 ? j1 >= -10 && j1 <= 10 : false; return i1 >= -10 && i1 <= 10 ? j1 >= -10 && j1 <= 10 : false;
} }
public void c(EntityPlayer entityplayer) { public void movePlayer(EntityPlayer entityplayer) {
int i = (int) entityplayer.locX >> 4; int i = (int) entityplayer.locX >> 4;
int j = (int) entityplayer.locZ >> 4; int j = (int) entityplayer.locZ >> 4;
double d0 = entityplayer.d - entityplayer.locX; double d0 = entityplayer.d - entityplayer.locX;
@ -128,8 +128,8 @@ public class PlayerManager {
// Craftbukkit start // Craftbukkit start
if (i1 > 10 || i1 < -10 || j1 > 10 || j1 < -10) { if (i1 > 10 || i1 < -10 || j1 > 10 || j1 < -10) {
b(entityplayer); this.removePlayer(entityplayer);
a(entityplayer); this.addPlayer(entityplayer);
return; return;
} }
// Craftbukkit end // Craftbukkit end
@ -162,7 +162,7 @@ public class PlayerManager {
} }
static MinecraftServer a(PlayerManager playermanager) { static MinecraftServer a(PlayerManager playermanager) {
return playermanager.d; return playermanager.server;
} }
static PlayerList b(PlayerManager playermanager) { static PlayerList b(PlayerManager playermanager) {

View file

@ -12,14 +12,14 @@ 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 = new Properties(); private Properties properties = new Properties();
private File c; private File c;
public PropertyManager(File file1) { public PropertyManager(File file1) {
this.c = file1; this.c = file1;
if (file1.exists()) { if (file1.exists()) {
try { try {
this.b.load(new FileInputStream(file1)); this.properties.load(new FileInputStream(file1));
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, "Failed to load " + file1, exception); a.log(Level.WARNING, "Failed to load " + file1, exception);
this.a(); this.a();
@ -55,45 +55,46 @@ public class PropertyManager {
public void b() { public void b() {
try { try {
this.b.store(new FileOutputStream(this.c), "Minecraft server properties"); this.properties.store(new FileOutputStream(this.c), "Minecraft server properties");
} catch (Exception exception) { } catch (Exception exception) {
a.log(Level.WARNING, "Failed to save " + this.c, exception); a.log(Level.WARNING, "Failed to save " + this.c, exception);
this.a(); this.a();
} }
} }
public String a(String s, String s1) { public String getString(String s, String s1) {
if (!this.b.containsKey(s)) { if (!this.properties.containsKey(s)) {
this.b.setProperty(s, getOverride(s, s1)); // CraftBukkit s1 = getOverride(s, s1); // CraftBukkit
this.properties.setProperty(s, s1);
this.b(); this.b();
} }
return getOverride(s, this.b.getProperty(s, s1)); // CraftBukkit return getOverride(s, this.properties.getProperty(s, s1)); // CraftBukkit
} }
public int a(String s, int i) { public int getInt(String s, int i) {
try { try {
return getOverride(s, Integer.parseInt(this.a(s, "" + i))); // CraftBukkit return getOverride(s, Integer.parseInt(this.getString(s, "" + i))); // CraftBukkit
} catch (Exception exception) { } catch (Exception exception) {
i = getOverride(s, i); // CraftBukkit i = getOverride(s, i); // CraftBukkit
this.b.setProperty(s, "" + i); this.properties.setProperty(s, "" + i);
return i; return i;
} }
} }
public boolean a(String s, boolean flag) { public boolean getBoolean(String s, boolean flag) {
try { try {
return getOverride(s, Boolean.parseBoolean(this.a(s, "" + flag))); // CraftBukkit return getOverride(s, Boolean.parseBoolean(this.getString(s, "" + flag))); // CraftBukkit
} catch (Exception exception) { } catch (Exception exception) {
flag = getOverride(s, flag); // CraftBukkit flag = getOverride(s, flag); // CraftBukkit
this.b.setProperty(s, "" + flag); this.properties.setProperty(s, "" + flag);
return flag; return flag;
} }
} }
public void b(String s, boolean flag) { public void b(String s, boolean flag) {
flag = getOverride(s, flag); // CraftBukkit flag = getOverride(s, flag); // CraftBukkit
this.b.setProperty(s, "" + flag); this.properties.setProperty(s, "" + flag);
this.b(); this.b();
} }
} }

View file

@ -27,38 +27,38 @@ import org.bukkit.event.player.PlayerRespawnEvent;
public class ServerConfigurationManager { public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public List b = new ArrayList(); public List players = new ArrayList();
public MinecraftServer c; // CraftBukkit - private->public public MinecraftServer server; // CraftBukkit - private->public
// public PlayerManager d; // CraftBukkit - removed! // public PlayerManager d; // CraftBukkit - removed!
public int e; // CraftBukkit - private->public public int maxPlayers; // CraftBukkit - private->public
private Set f = new HashSet(); private Set banByName = new HashSet();
private Set g = new HashSet(); private Set banByIP = new HashSet();
private Set h = new HashSet(); private Set h = new HashSet();
private Set i = new HashSet(); private Set i = new HashSet();
private File j; private File j;
private File k; private File k;
private File l; private File l;
private File m; private File m;
public PlayerFileData n; // CraftBukkit - private->public public PlayerFileData playerFileData; // CraftBukkit private->public
private boolean o; private boolean o;
// CraftBukkit start // CraftBukkit start
private CraftServer server; private CraftServer cserver;
public ServerConfigurationManager(MinecraftServer minecraftserver) { public ServerConfigurationManager(MinecraftServer minecraftserver) {
minecraftserver.server = new CraftServer(minecraftserver, this); minecraftserver.server = new CraftServer(minecraftserver, this);
minecraftserver.console = new ColouredConsoleSender(minecraftserver.server); minecraftserver.console = new ColouredConsoleSender(minecraftserver.server);
server = minecraftserver.server; cserver = minecraftserver.server;
// CraftBukkit end // CraftBukkit end
this.c = minecraftserver; this.server = minecraftserver;
this.j = minecraftserver.a("banned-players.txt"); this.j = minecraftserver.a("banned-players.txt");
this.k = minecraftserver.a("banned-ips.txt"); this.k = minecraftserver.a("banned-ips.txt");
this.l = minecraftserver.a("ops.txt"); this.l = minecraftserver.a("ops.txt");
this.m = minecraftserver.a("white-list.txt"); this.m = minecraftserver.a("white-list.txt");
// this.d = new PlayerManager(minecraftserver); // CraftBukkit - removed! // this.d = new PlayerManager(minecraftserver); // CraftBukkit - removed!
this.e = minecraftserver.d.a("max-players", 20); this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
this.o = minecraftserver.d.a("white-list", false); this.o = minecraftserver.propertyManager.getBoolean("white-list", false);
this.g(); this.g();
this.i(); this.i();
this.k(); this.k();
@ -69,12 +69,9 @@ public class ServerConfigurationManager {
this.n(); this.n();
} }
public void a(WorldServer worldserver) { public void setPlayerFileData(WorldServer worldserver) {
// CraftBukkit start if (this.playerFileData != null) return; // CraftBukkit
if (this.n == null) { this.playerFileData = worldserver.o().d();
this.n = worldserver.o().d();
}
// CraftBukkit end
} }
public int a() { public int a() {
@ -82,46 +79,45 @@ public class ServerConfigurationManager {
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
this.b.add(entityplayer); this.players.add(entityplayer);
this.n.b(entityplayer); this.playerFileData.b(entityplayer);
// CraftBukkit start // CraftBukkit start
((WorldServer) entityplayer.world).u.c((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4); ((WorldServer) entityplayer.world).chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
while (entityplayer.world.a(entityplayer, entityplayer.boundingBox).size() != 0) { while (entityplayer.world.getEntities(entityplayer, entityplayer.boundingBox).size() != 0) {
entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ); entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
} }
entityplayer.world.a(entityplayer); entityplayer.world.addEntity(entityplayer);
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(server.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game."); PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game.");
cserver.getPluginManager().callEvent(playerJoinEvent);
server.getPluginManager().callEvent(playerJoinEvent);
String joinMessage = playerJoinEvent.getJoinMessage(); String joinMessage = playerJoinEvent.getJoinMessage();
if (joinMessage != null) { if (joinMessage != null) {
this.c.f.a((Packet) (new Packet3Chat(joinMessage))); this.server.serverConfigurationManager.sendAll(new Packet3Chat(joinMessage));
} }
((WorldServer) entityplayer.world).manager.a(entityplayer); ((WorldServer) entityplayer.world).manager.addPlayer(entityplayer);
// CraftBukkit end // CraftBukkit end
} }
public void b(EntityPlayer entityplayer) { public void b(EntityPlayer entityplayer) {
((WorldServer) entityplayer.world).manager.c(entityplayer); // CraftBukkit ((WorldServer) entityplayer.world).manager.movePlayer(entityplayer); // CraftBukkit
} }
public String c(EntityPlayer entityplayer) { // CraftBukkit - changed return type public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - changed return type
// CraftBukkit start // CraftBukkit start
// Quitting must be before we do final save of data, in case plugins need to modify it // Quitting must be before we do final save of data, in case plugins need to modify it
((WorldServer) entityplayer.world).manager.b(entityplayer); ((WorldServer) entityplayer.world).manager.removePlayer(entityplayer);
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(server.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game."); PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
server.getPluginManager().callEvent(playerQuitEvent); cserver.getPluginManager().callEvent(playerQuitEvent);
// CraftBukkit end // CraftBukkit end
this.n.a(entityplayer); this.playerFileData.a(entityplayer);
entityplayer.world.d(entityplayer); // CraftBukkit entityplayer.world.kill(entityplayer); // CraftBukkit
this.b.remove(entityplayer); this.players.remove(entityplayer);
return playerQuitEvent.getQuitMessage(); // CraftBukkit return playerQuitEvent.getQuitMessage(); // CraftBukkit
} }
@ -131,84 +127,84 @@ public class ServerConfigurationManager {
// 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. Also change any reference to this.e.c to entity.world // depending on the outcome. Also change any reference to this.e.c to entity.world
EntityPlayer entity = new EntityPlayer(c, c.worlds.get(0), s, new ItemInWorldManager(c.worlds.get(0))); EntityPlayer entity = new EntityPlayer(this.server, this.server.worlds.get(0), s, new ItemInWorldManager(this.server.worlds.get(0)));
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity(); Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(player); PlayerLoginEvent event = new PlayerLoginEvent(player);
String s2 = netloginhandler.b.b().toString(); String s2 = netloginhandler.networkManager.getSocketAddress().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(":"));
if (this.f.contains(s.trim().toLowerCase())) { if (this.banByName.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 (!this.g(s)) { } else if (!this.isWhitelisted(s)) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!"); event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
} else if (this.g.contains(s2)) { } else if (this.banByIP.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 (this.b.size() >= this.e) { } else if (this.players.size() >= this.maxPlayers) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!"); event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
} else { } else {
event.disallow(PlayerLoginEvent.Result.ALLOWED, s2); event.disallow(PlayerLoginEvent.Result.ALLOWED, s2);
} }
server.getPluginManager().callEvent(event); cserver.getPluginManager().callEvent(event);
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
netloginhandler.a(event.getKickMessage()); netloginhandler.disconnect(event.getKickMessage());
return null; return null;
} }
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
if (entityplayer.name.equalsIgnoreCase(s)) { if (entityplayer.name.equalsIgnoreCase(s)) {
entityplayer.a.a("You logged in from another location"); entityplayer.netServerHandler.disconnect("You logged in from another location");
} }
} }
return new EntityPlayer(this.c, entity.world, s, new ItemInWorldManager(entity.world)); return new EntityPlayer(this.server, entity.world, s, new ItemInWorldManager(entity.world));
// CraftBukkit end // CraftBukkit end
} }
public EntityPlayer d(EntityPlayer entityplayer) { public EntityPlayer d(EntityPlayer entityplayer) {
// CraftBukkit start - every reference to this.c.e should be entityplayer.world // CraftBukkit start - every reference to this.minecraftServer.worldServer should be entityplayer.world
this.c.k.a(entityplayer); this.server.tracker.trackPlayer(entityplayer);
this.c.k.b(entityplayer); this.server.tracker.untrackEntity(entityplayer);
((WorldServer) entityplayer.world).manager.b(entityplayer); ((WorldServer) entityplayer.world).manager.removePlayer(entityplayer);
this.b.remove(entityplayer); this.players.remove(entityplayer);
entityplayer.world.e(entityplayer); entityplayer.world.removeEntity(entityplayer);
ChunkCoordinates chunkcoordinates = entityplayer.H(); ChunkCoordinates chunkcoordinates = entityplayer.H();
EntityPlayer entityplayer1 = new EntityPlayer(this.c, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world)); EntityPlayer entityplayer1 = new EntityPlayer(this.server, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world));
entityplayer1.id = entityplayer.id; entityplayer1.id = entityplayer.id;
entityplayer1.a = entityplayer.a; entityplayer1.netServerHandler = entityplayer.netServerHandler;
entityplayer1.displayName = entityplayer.displayName; // CraftBukkit entityplayer1.displayName = entityplayer.displayName; // CraftBukkit
entityplayer1.compassTarget = entityplayer.compassTarget; // CraftBukkit entityplayer1.compassTarget = entityplayer.compassTarget; // CraftBukkit
entityplayer1.fauxSleeping = entityplayer.fauxSleeping; // CraftBukkit entityplayer1.fauxSleeping = entityplayer.fauxSleeping; // CraftBukkit
if (chunkcoordinates != null) { if (chunkcoordinates != null) {
ChunkCoordinates chunkcoordinates1 = EntityHuman.a(entityplayer.world, chunkcoordinates); ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(entityplayer.world, chunkcoordinates);
if (chunkcoordinates1 != null) { if (chunkcoordinates1 != null) {
entityplayer1.c((double) ((float) chunkcoordinates1.a + 0.5F), (double) ((float) chunkcoordinates1.b + 0.1F), (double) ((float) chunkcoordinates1.c + 0.5F), 0.0F, 0.0F); entityplayer1.setPositionRotation((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F), 0.0F, 0.0F);
entityplayer1.a(chunkcoordinates); entityplayer1.a(chunkcoordinates);
} else { } else {
entityplayer1.a.b((Packet) (new Packet70Bed(0))); entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0));
} }
} }
((WorldServer) entityplayer.world).u.c((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); ((WorldServer) entityplayer.world).chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
while (entityplayer.world.a(entityplayer1, entityplayer1.boundingBox).size() != 0) { while (entityplayer.world.getEntities(entityplayer1, entityplayer1.boundingBox).size() != 0) {
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
} }
// CraftBukkit start // CraftBukkit start
Player respawnPlayer = server.getPlayer(entityplayer); Player respawnPlayer = cserver.getPlayer(entityplayer);
Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation ); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation );
server.getPluginManager().callEvent(respawnEvent); cserver.getPluginManager().callEvent(respawnEvent);
entityplayer1.world = ((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle(); entityplayer1.world = ((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle();
entityplayer1.locX = respawnEvent.getRespawnLocation().getX(); entityplayer1.locX = respawnEvent.getRespawnLocation().getX();
@ -216,77 +212,77 @@ public class ServerConfigurationManager {
entityplayer1.locZ = respawnEvent.getRespawnLocation().getZ(); entityplayer1.locZ = respawnEvent.getRespawnLocation().getZ();
entityplayer1.yaw = respawnEvent.getRespawnLocation().getYaw(); entityplayer1.yaw = respawnEvent.getRespawnLocation().getYaw();
entityplayer1.pitch = respawnEvent.getRespawnLocation().getPitch(); entityplayer1.pitch = respawnEvent.getRespawnLocation().getPitch();
entityplayer1.c = new ItemInWorldManager(((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle()); entityplayer1.itemInWorldManager = new ItemInWorldManager(((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle());
entityplayer1.c.a = entityplayer1; entityplayer1.itemInWorldManager.player = entityplayer1;
((WorldServer) entityplayer1.world).u.c((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); ((WorldServer) entityplayer1.world).chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
// CraftBukkit end // CraftBukkit end
entityplayer1.a.b((Packet) (new Packet9Respawn())); entityplayer1.netServerHandler.sendPacket(new Packet9Respawn());
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); entityplayer1.netServerHandler.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
// CraftBukkit start // CraftBukkit start
entityplayer.world.a(entityplayer1); ((WorldServer) entityplayer1.world).manager.addPlayer(entityplayer1);
((WorldServer) entityplayer1.world).manager.a(entityplayer1); entityplayer.world.addEntity(entityplayer1);
// CraftBukkit end // CraftBukkit end
this.b.add(entityplayer1); this.players.add(entityplayer1);
entityplayer1.m(); entityplayer1.syncInventory();
entityplayer1.t(); entityplayer1.t();
return entityplayer1; return entityplayer1;
} }
public void b() { public void b() {
// CraftBukkit start // CraftBukkit start
for (WorldServer world: c.worlds) { for (WorldServer world: this.server.worlds) {
world.manager.a(); world.manager.flush();
} }
// CraftBukkit end // CraftBukkit end
} }
// CraftBukkit start - changed signature // CraftBukkit start - changed signature
public void a(int i, int j, int k, WorldServer world) { public void flagDirty(int i, int j, int k, WorldServer world) {
world.manager.a(i, j, k); world.manager.flagDirty(i, j, k);
} }
// CraftBukkit end // CraftBukkit end
public void a(Packet packet) { public void sendAll(Packet packet) {
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
entityplayer.a.b(packet); entityplayer.netServerHandler.sendPacket(packet);
} }
} }
public String c() { public String c() {
String s = ""; String s = "";
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
if (i > 0) { if (i > 0) {
s = s + ", "; s = s + ", ";
} }
s = s + ((EntityPlayer) this.b.get(i)).name; s = s + ((EntityPlayer) this.players.get(i)).name;
} }
return s; return s;
} }
public void a(String s) { public void a(String s) {
this.f.add(s.toLowerCase()); this.banByName.add(s.toLowerCase());
this.h(); this.h();
} }
public void b(String s) { public void b(String s) {
this.f.remove(s.toLowerCase()); this.banByName.remove(s.toLowerCase());
this.h(); this.h();
} }
private void g() { private void g() {
try { try {
this.f.clear(); this.banByName.clear();
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j)); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j));
String s = ""; String s = "";
while ((s = bufferedreader.readLine()) != null) { while ((s = bufferedreader.readLine()) != null) {
this.f.add(s.trim().toLowerCase()); this.banByName.add(s.trim().toLowerCase());
} }
bufferedreader.close(); bufferedreader.close();
@ -298,7 +294,7 @@ public class ServerConfigurationManager {
private void h() { private void h() {
try { try {
PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false)); PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false));
Iterator iterator = this.f.iterator(); Iterator iterator = this.banByName.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String s = (String) iterator.next(); String s = (String) iterator.next();
@ -313,23 +309,23 @@ public class ServerConfigurationManager {
} }
public void c(String s) { public void c(String s) {
this.g.add(s.toLowerCase()); this.banByIP.add(s.toLowerCase());
this.j(); this.j();
} }
public void d(String s) { public void d(String s) {
this.g.remove(s.toLowerCase()); this.banByIP.remove(s.toLowerCase());
this.j(); this.j();
} }
private void i() { private void i() {
try { try {
this.g.clear(); this.banByIP.clear();
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k)); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k));
String s = ""; String s = "";
while ((s = bufferedreader.readLine()) != null) { while ((s = bufferedreader.readLine()) != null) {
this.g.add(s.trim().toLowerCase()); this.banByIP.add(s.trim().toLowerCase());
} }
bufferedreader.close(); bufferedreader.close();
@ -341,7 +337,7 @@ public class ServerConfigurationManager {
private void j() { private void j() {
try { try {
PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false)); PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false));
Iterator iterator = this.g.iterator(); Iterator iterator = this.banByIP.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String s = (String) iterator.next(); String s = (String) iterator.next();
@ -431,18 +427,18 @@ public class ServerConfigurationManager {
} }
} }
public boolean g(String s) { public boolean isWhitelisted(String s) {
s = s.trim().toLowerCase(); s = s.trim().toLowerCase();
return !this.o || this.h.contains(s) || this.i.contains(s); return !this.o || this.h.contains(s) || this.i.contains(s);
} }
public boolean h(String s) { public boolean isOp(String s) {
return this.h.contains(s.trim().toLowerCase()); return this.h.contains(s.trim().toLowerCase());
} }
public EntityPlayer i(String s) { public EntityPlayer i(String s) {
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
if (entityplayer.name.equalsIgnoreCase(s)) { if (entityplayer.name.equalsIgnoreCase(s)) {
return entityplayer; return entityplayer;
@ -456,19 +452,19 @@ public class ServerConfigurationManager {
EntityPlayer entityplayer = this.i(s); EntityPlayer entityplayer = this.i(s);
if (entityplayer != null) { if (entityplayer != null) {
entityplayer.a.b((Packet) (new Packet3Chat(s1))); entityplayer.netServerHandler.sendPacket(new Packet3Chat(s1));
} }
} }
public void a(double d0, double d1, double d2, double d3, Packet packet) { public void a(double d0, double d1, double d2, double d3, Packet packet) {
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
double d4 = d0 - entityplayer.locX; double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY; double d5 = d1 - entityplayer.locY;
double d6 = d2 - entityplayer.locZ; double d6 = d2 - entityplayer.locZ;
if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) { if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) {
entityplayer.a.b(packet); entityplayer.netServerHandler.sendPacket(packet);
} }
} }
} }
@ -476,11 +472,11 @@ public class ServerConfigurationManager {
public void j(String s) { public void j(String s) {
Packet3Chat packet3chat = new Packet3Chat(s); Packet3Chat packet3chat = new Packet3Chat(s);
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
if (this.h(entityplayer.name)) { if (this.isOp(entityplayer.name)) {
entityplayer.a.b((Packet) packet3chat); entityplayer.netServerHandler.sendPacket(packet3chat);
} }
} }
} }
@ -489,16 +485,16 @@ public class ServerConfigurationManager {
EntityPlayer entityplayer = this.i(s); EntityPlayer entityplayer = this.i(s);
if (entityplayer != null) { if (entityplayer != null) {
entityplayer.a.b(packet); entityplayer.netServerHandler.sendPacket(packet);
return true; return true;
} else { } else {
return false; return false;
} }
} }
public void d() { public void savePlayers() {
for (int i = 0; i < this.b.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
this.n.a((EntityHuman) this.b.get(i)); this.playerFileData.a((EntityHuman) this.players.get(i));
} }
} }

View file

@ -2,15 +2,15 @@ package net.minecraft.server;
public class Slot { public class Slot {
public final int d; // CraftBukkit: private -> public public final int index; // CraftBukkit: private -> public
public final IInventory e; // CraftBukkit: private -> public public final IInventory inventory; // CraftBukkit: private -> public
public int a; public int a;
public int b; public int b;
public int c; public int c;
public Slot(IInventory iinventory, int i, int j, int k) { public Slot(IInventory iinventory, int i, int j, int k) {
this.e = iinventory; this.inventory = iinventory;
this.d = i; this.index = i;
this.b = j; this.b = j;
this.c = k; this.c = k;
} }
@ -19,33 +19,33 @@ public class Slot {
this.b(); this.b();
} }
public boolean b(ItemStack itemstack) { public boolean isAllowed(ItemStack itemstack) {
return true; return true;
} }
public ItemStack a() { public ItemStack getItem() {
return this.e.c_(this.d); return this.inventory.getItem(this.index);
} }
public void c(ItemStack itemstack) { public void c(ItemStack itemstack) {
this.e.a(this.d, itemstack); this.inventory.setItem(this.index, itemstack);
this.b(); this.b();
} }
public void b() { public void b() {
this.e.i(); this.inventory.update();
} }
public int c() { public int c() {
return this.e.r_(); return this.inventory.getMaxStackSize();
} }
public ItemStack a(int i) { public ItemStack a(int i) {
return this.e.a(this.d, i); return this.inventory.a(this.index, i);
} }
public boolean a(IInventory iinventory, int i) { public boolean a(IInventory iinventory, int i) {
return iinventory == this.e && i == this.d; return iinventory == this.inventory && i == this.index;
} }
public boolean d() { public boolean d() {

View file

@ -10,23 +10,23 @@ import jline.ConsoleReader;
public class ThreadCommandReader extends Thread { public class ThreadCommandReader extends Thread {
final MinecraftServer a; final MinecraftServer server;
public ThreadCommandReader(MinecraftServer minecraftserver) { public ThreadCommandReader(MinecraftServer minecraftserver) {
this.a = minecraftserver; this.server = minecraftserver;
} }
public void run() { public void run() {
// Craftbukkit start - whole method, nuked to oblivion! :o // Craftbukkit start - whole method, nuked to oblivion! :o
try { try {
ConsoleReader reader = a.reader; ConsoleReader reader = this.server.reader;
String line = null; String line = null;
while ((!this.a.g) && (MinecraftServer.a(this.a)) && ((line = reader.readLine(">", null)) != null)) { while ((!this.server.isStopped) && (MinecraftServer.isRunning(this.server)) && ((line = reader.readLine(">", null)) != null)) {
this.a.a(line, this.a); this.server.issueCommand(line, (ICommandListener) this.server);
} }
} catch (IOException ex) { } catch (IOException ioexception) {
Logger.getLogger(ThreadCommandReader.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(ThreadCommandReader.class.getName()).log(Level.SEVERE, null, ioexception);
} }
// Craftbukkit end // Craftbukkit end
} }

View file

@ -4,14 +4,17 @@ import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.player.PlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent;
// CraftBukkit end
class ThreadLoginVerifier extends Thread { class ThreadLoginVerifier extends Thread {
final Packet1Login a; final Packet1Login loginPacket;
final NetLoginHandler b; final NetLoginHandler netLoginHandler;
// CraftBukkit start // CraftBukkit start
CraftServer server; CraftServer server;
@ -19,30 +22,32 @@ class ThreadLoginVerifier extends Thread {
ThreadLoginVerifier(NetLoginHandler netloginhandler, Packet1Login packet1login, CraftServer server) { ThreadLoginVerifier(NetLoginHandler netloginhandler, Packet1Login packet1login, CraftServer server) {
this.server = server; this.server = server;
// CraftBukkit end // CraftBukkit end
this.b = netloginhandler; this.netLoginHandler = netloginhandler;
this.a = packet1login; this.loginPacket = packet1login;
} }
public void run() { public void run() {
try { try {
String s = NetLoginHandler.a(this.b); String s = NetLoginHandler.a(this.netLoginHandler);
URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(this.a.b, "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8")); URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(this.loginPacket.name, "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream()));
String s1 = bufferedreader.readLine(); String s1 = bufferedreader.readLine();
bufferedreader.close(); bufferedreader.close();
if (s1.equals("YES")) { if (s1.equals("YES")) {
PlayerPreLoginEvent event = new PlayerPreLoginEvent(this.a.b, b.getSocket().getInetAddress()); // CraftBukkit start
PlayerPreLoginEvent event = new PlayerPreLoginEvent(this.loginPacket.name, this.netLoginHandler.getSocket().getInetAddress());
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (event.getResult() != PlayerPreLoginEvent.Result.ALLOWED) { if (event.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
this.b.a(event.getKickMessage()); this.netLoginHandler.disconnect(event.getKickMessage());
return; return;
} }
// CraftBukkit end
NetLoginHandler.a(this.b, this.a); NetLoginHandler.a(this.netLoginHandler, this.loginPacket);
} else { } else {
this.b.a("Failed to verify username!"); this.netLoginHandler.disconnect("Failed to verify username!");
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();

View file

@ -2,40 +2,40 @@ package net.minecraft.server;
public class TileEntityChest extends TileEntity implements IInventory { public class TileEntityChest extends TileEntity implements IInventory {
private ItemStack[] a = new ItemStack[27]; // CraftBukkit private ItemStack[] items = new ItemStack[27]; // CraftBukkit
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return items;
} }
// CraftBukkit end // CraftBukkit end
public TileEntityChest() {} public TileEntityChest() {}
public int q_() { public int getSize() {
return 27; return 27;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return this.a[i]; return this.items[i];
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.a[i] != null) { if (this.items[i] != null) {
ItemStack itemstack; ItemStack itemstack;
if (this.a[i].count <= j) { if (this.items[i].count <= j) {
itemstack = this.a[i]; itemstack = this.items[i];
this.a[i] = null; this.items[i] = null;
this.i(); this.update();
return itemstack; return itemstack;
} else { } else {
itemstack = this.a[i].a(j); itemstack = this.items[i].a(j);
if (this.a[i].count == 0) { if (this.items[i].count == 0) {
this.a[i] = null; this.items[i] = null;
} }
this.i(); this.update();
return itemstack; return itemstack;
} }
} else { } else {
@ -43,16 +43,16 @@ public class TileEntityChest extends TileEntity implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.a[i] = itemstack; this.items[i] = itemstack;
if (itemstack != null && itemstack.count > this.r_()) { if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.r_(); itemstack.count = this.getMaxStackSize();
} }
this.i(); this.update();
} }
public String c() { public String getName() {
return "Chest"; return "Chest";
} }
@ -60,14 +60,14 @@ public class TileEntityChest extends TileEntity implements IInventory {
super.a(nbttagcompound); super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.l("Items"); NBTTagList nbttaglist = nbttagcompound.l("Items");
this.a = new ItemStack[this.q_()]; this.items = new ItemStack[this.getSize()];
for (int i = 0; i < nbttaglist.c(); ++i) { for (int i = 0; i < nbttaglist.c(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound1.c("Slot") & 255; int j = nbttagcompound1.c("Slot") & 255;
if (j >= 0 && j < this.a.length) { if (j >= 0 && j < this.items.length) {
this.a[j] = new ItemStack(nbttagcompound1); this.items[j] = new ItemStack(nbttagcompound1);
} }
} }
} }
@ -76,12 +76,12 @@ 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 < this.a.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.a[i] != null) { if (this.items[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i); nbttagcompound1.a("Slot", (byte) i);
this.a[i].a(nbttagcompound1); this.items[i].a(nbttagcompound1);
nbttaglist.a((NBTBase) nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
@ -89,11 +89,11 @@ public class TileEntityChest extends TileEntity implements IInventory {
nbttagcompound.a("Items", (NBTBase) nbttaglist); nbttagcompound.a("Items", (NBTBase) nbttaglist);
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {
return this.d.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D; return this.world.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D;
} }
} }

View file

@ -4,41 +4,41 @@ import java.util.Random;
public class TileEntityDispenser extends TileEntity implements IInventory { public class TileEntityDispenser extends TileEntity implements IInventory {
private ItemStack[] a = new ItemStack[9]; private ItemStack[] items = new ItemStack[9];
private Random b = new Random(); private Random b = new Random();
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return a; return items;
} }
// CraftBukkit end // CraftBukkit end
public TileEntityDispenser() {} public TileEntityDispenser() {}
public int q_() { public int getSize() {
return 9; return 9;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return this.a[i]; return this.items[i];
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.a[i] != null) { if (this.items[i] != null) {
ItemStack itemstack; ItemStack itemstack;
if (this.a[i].count <= j) { if (this.items[i].count <= j) {
itemstack = this.a[i]; itemstack = this.items[i];
this.a[i] = null; this.items[i] = null;
this.i(); this.update();
return itemstack; return itemstack;
} else { } else {
itemstack = this.a[i].a(j); itemstack = this.items[i].a(j);
if (this.a[i].count == 0) { if (this.items[i].count == 0) {
this.a[i] = null; this.items[i] = null;
} }
this.i(); this.update();
return itemstack; return itemstack;
} }
} else { } else {
@ -50,8 +50,8 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
int i = -1; int i = -1;
int j = 1; int j = 1;
for (int k = 0; k < this.a.length; ++k) { for (int k = 0; k < this.items.length; ++k) {
if (this.a[k] != null && this.b.nextInt(j) == 0) { if (this.items[k] != null && this.b.nextInt(j) == 0) {
i = k; i = k;
++j; ++j;
} }
@ -64,16 +64,16 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.a[i] = itemstack; this.items[i] = itemstack;
if (itemstack != null && itemstack.count > this.r_()) { if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.r_(); itemstack.count = this.getMaxStackSize();
} }
this.i(); this.update();
} }
public String c() { public String getName() {
return "Trap"; return "Trap";
} }
@ -81,14 +81,14 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
super.a(nbttagcompound); super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.l("Items"); NBTTagList nbttaglist = nbttagcompound.l("Items");
this.a = new ItemStack[this.q_()]; this.items = new ItemStack[this.getSize()];
for (int i = 0; i < nbttaglist.c(); ++i) { for (int i = 0; i < nbttaglist.c(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
int j = nbttagcompound1.c("Slot") & 255; int j = nbttagcompound1.c("Slot") & 255;
if (j >= 0 && j < this.a.length) { if (j >= 0 && j < this.items.length) {
this.a[j] = new ItemStack(nbttagcompound1); this.items[j] = new ItemStack(nbttagcompound1);
} }
} }
} }
@ -97,12 +97,12 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
super.b(nbttagcompound); super.b(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.a.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.a[i] != null) { if (this.items[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i); nbttagcompound1.a("Slot", (byte) i);
this.a[i].a(nbttagcompound1); this.items[i].a(nbttagcompound1);
nbttaglist.a((NBTBase) nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
@ -110,11 +110,11 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
nbttagcompound.a("Items", (NBTBase) nbttaglist); nbttagcompound.a("Items", (NBTBase) nbttaglist);
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {
return this.d.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D; return this.world.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D;
} }
} }

View file

@ -2,39 +2,39 @@ package net.minecraft.server;
public class TileEntityFurnace extends TileEntity implements IInventory { public class TileEntityFurnace extends TileEntity implements IInventory {
private ItemStack[] h = new ItemStack[3]; private ItemStack[] items = new ItemStack[3];
public int a = 0; public int burnTime = 0;
public int b = 0; public int b = 0;
public int c = 0; public int cookTime = 0;
// CraftBukkit start // CraftBukkit start
public ItemStack[] getContents() { public ItemStack[] getContents() {
return h; return items;
} }
// CraftBukkit end // CraftBukkit end
public TileEntityFurnace() {} public TileEntityFurnace() {}
public int q_() { public int getSize() {
return this.h.length; return this.items.length;
} }
public ItemStack c_(int i) { public ItemStack getItem(int i) {
return this.h[i]; return this.items[i];
} }
public ItemStack a(int i, int j) { public ItemStack a(int i, int j) {
if (this.h[i] != null) { if (this.items[i] != null) {
ItemStack itemstack; ItemStack itemstack;
if (this.h[i].count <= j) { if (this.items[i].count <= j) {
itemstack = this.h[i]; itemstack = this.items[i];
this.h[i] = null; this.items[i] = null;
return itemstack; return itemstack;
} else { } else {
itemstack = this.h[i].a(j); itemstack = this.items[i].a(j);
if (this.h[i].count == 0) { if (this.items[i].count == 0) {
this.h[i] = null; this.items[i] = null;
} }
return itemstack; return itemstack;
@ -44,14 +44,14 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
} }
} }
public void a(int i, ItemStack itemstack) { public void setItem(int i, ItemStack itemstack) {
this.h[i] = itemstack; this.items[i] = itemstack;
if (itemstack != null && itemstack.count > this.r_()) { if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.r_(); itemstack.count = this.getMaxStackSize();
} }
} }
public String c() { public String getName() {
return "Furnace"; return "Furnace";
} }
@ -59,34 +59,34 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
super.a(nbttagcompound); super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.l("Items"); NBTTagList nbttaglist = nbttagcompound.l("Items");
this.h = new ItemStack[this.q_()]; this.items = new ItemStack[this.getSize()];
for (int i = 0; i < nbttaglist.c(); ++i) { for (int i = 0; i < nbttaglist.c(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
byte b0 = nbttagcompound1.c("Slot"); byte b0 = nbttagcompound1.c("Slot");
if (b0 >= 0 && b0 < this.h.length) { if (b0 >= 0 && b0 < this.items.length) {
this.h[b0] = new ItemStack(nbttagcompound1); this.items[b0] = new ItemStack(nbttagcompound1);
} }
} }
this.a = nbttagcompound.d("BurnTime"); this.burnTime = nbttagcompound.d("BurnTime");
this.c = nbttagcompound.d("CookTime"); this.cookTime = nbttagcompound.d("CookTime");
this.b = this.a(this.h[1]); this.b = this.a(this.items[1]);
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.a("BurnTime", (short) this.a); nbttagcompound.a("BurnTime", (short) this.burnTime);
nbttagcompound.a("CookTime", (short) this.c); nbttagcompound.a("CookTime", (short) this.cookTime);
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.h.length; ++i) { for (int i = 0; i < this.items.length; ++i) {
if (this.h[i] != null) { if (this.items[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i); nbttagcompound1.a("Slot", (byte) i);
this.h[i].a(nbttagcompound1); this.items[i].a(nbttagcompound1);
nbttaglist.a((NBTBase) nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1);
} }
} }
@ -94,81 +94,81 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
nbttagcompound.a("Items", (NBTBase) nbttaglist); nbttagcompound.a("Items", (NBTBase) nbttaglist);
} }
public int r_() { public int getMaxStackSize() {
return 64; return 64;
} }
public boolean f() { public boolean f() {
return this.a > 0; return this.burnTime > 0;
} }
public void i_() { public void i_() {
boolean flag = this.a > 0; boolean flag = this.burnTime > 0;
boolean flag1 = false; boolean flag1 = false;
if (this.a > 0) { if (this.burnTime > 0) {
--this.a; --this.burnTime;
} }
if (!this.d.isStatic) { if (!this.world.isStatic) {
if (this.a == 0 && this.h()) { if (this.burnTime == 0 && this.h()) {
this.b = this.a = this.a(this.h[1]); this.b = this.burnTime = this.a(this.items[1]);
if (this.a > 0) { if (this.burnTime > 0) {
flag1 = true; flag1 = true;
if (this.h[1] != null) { if (this.items[1] != null) {
--this.h[1].count; --this.items[1].count;
if (this.h[1].count == 0) { if (this.items[1].count == 0) {
this.h[1] = null; this.items[1] = null;
} }
} }
} }
} }
if (this.f() && this.h()) { if (this.f() && this.h()) {
++this.c; ++this.cookTime;
if (this.c == 200) { if (this.cookTime == 200) {
this.c = 0; this.cookTime = 0;
this.g(); this.g();
flag1 = true; flag1 = true;
} }
} else { } else {
this.c = 0; this.cookTime = 0;
} }
if (flag != this.a > 0) { if (flag != this.burnTime > 0) {
flag1 = true; flag1 = true;
BlockFurnace.a(this.a > 0, this.d, this.e, this.f, this.g); BlockFurnace.a(this.burnTime > 0, this.world, this.e, this.f, this.g);
} }
} }
if (flag1) { if (flag1) {
this.i(); this.update();
} }
} }
private boolean h() { private boolean h() {
if (this.h[0] == null) { if (this.items[0] == null) {
return false; return false;
} else { } else {
ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id); ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id);
return itemstack == null ? false : (this.h[2] == null ? true : (!this.h[2].a(itemstack) ? false : (this.h[2].count < this.r_() && this.h[2].count < this.h[2].b() ? true : this.h[2].count < itemstack.b()))); return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].a(itemstack) ? false : (this.items[2].count < this.getMaxStackSize() && this.items[2].count < this.items[2].b() ? true : this.items[2].count < itemstack.b())));
} }
} }
public void g() { public void g() {
if (this.h()) { if (this.h()) {
ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id); ItemStack itemstack = FurnaceRecipes.a().a(this.items[0].getItem().id);
if (this.h[2] == null) { if (this.items[2] == null) {
this.h[2] = itemstack.j(); this.items[2] = itemstack.j();
} else if (this.h[2].id == itemstack.id) { } else if (this.items[2].id == itemstack.id) {
++this.h[2].count; ++this.items[2].count;
} }
--this.h[0].count; --this.items[0].count;
if (this.h[0].count <= 0) { if (this.items[0].count <= 0) {
this.h[0] = null; this.items[0] = null;
} }
} }
} }
@ -177,13 +177,13 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
if (itemstack == null) { if (itemstack == null) {
return 0; return 0;
} else { } else {
int i = itemstack.a().id; int i = itemstack.getItem().id;
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 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)));
} }
} }
public boolean a_(EntityHuman entityhuman) { public boolean a_(EntityHuman entityhuman) {
return this.d.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D; return this.world.getTileEntity(this.e, this.f, this.g) != this ? false : entityhuman.d((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D) <= 64.0D;
} }
} }

View file

@ -2,48 +2,48 @@ package net.minecraft.server;
public class TileEntityMobSpawner extends TileEntity { public class TileEntityMobSpawner extends TileEntity {
public int a = -1; public int spawnDelay = -1;
public String h = "Pig"; // CraftBukkit private -> public public String mobName = "Pig"; // CraftBukkit private -> public
public double b; public double b;
public double c = 0.0D; public double c = 0.0D;
public TileEntityMobSpawner() { public TileEntityMobSpawner() {
this.a = 20; this.spawnDelay = 20;
} }
public void a(String s) { public void a(String s) {
this.h = s; this.mobName = s;
} }
public boolean a() { public boolean a() {
return this.d.a((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D, 16.0D) != null; return this.world.a((double) this.e + 0.5D, (double) this.f + 0.5D, (double) this.g + 0.5D, 16.0D) != null;
} }
public void i_() { public void i_() {
this.c = this.b; this.c = this.b;
if (this.a()) { if (this.a()) {
double d0 = (double) ((float) this.e + this.d.k.nextFloat()); double d0 = (double) ((float) this.e + this.world.random.nextFloat());
double d1 = (double) ((float) this.f + this.d.k.nextFloat()); double d1 = (double) ((float) this.f + this.world.random.nextFloat());
double d2 = (double) ((float) this.g + this.d.k.nextFloat()); double d2 = (double) ((float) this.g + this.world.random.nextFloat());
this.d.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); this.world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
this.d.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); this.world.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
for (this.b += (double) (1000.0F / ((float) this.a + 200.0F)); this.b > 360.0D; this.c -= 360.0D) { for (this.b += (double) (1000.0F / ((float) this.spawnDelay + 200.0F)); this.b > 360.0D; this.c -= 360.0D) {
this.b -= 360.0D; this.b -= 360.0D;
} }
if (this.a == -1) { if (this.spawnDelay == -1) {
this.c(); this.c();
} }
if (this.a > 0) { if (this.spawnDelay > 0) {
--this.a; --this.spawnDelay;
} else { } else {
byte b0 = 4; byte b0 = 4;
for (int i = 0; i < b0; ++i) { for (int i = 0; i < b0; ++i) {
EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.h, this.d)); EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.mobName, this.world));
if (entityliving == null) { if (entityliving == null) {
return; return;
@ -51,12 +51,12 @@ public class TileEntityMobSpawner extends TileEntity {
// CraftBukkit start - The world we're spawning in accepts this creature // CraftBukkit start - The world we're spawning in accepts this creature
boolean isAnimal = entityliving instanceof EntityAnimal || entityliving instanceof EntityWaterAnimal; boolean isAnimal = entityliving instanceof EntityAnimal || entityliving instanceof EntityWaterAnimal;
if ((isAnimal && !this.d.E) || (!isAnimal && !this.d.D)) { if ((isAnimal && !this.world.allowAnimals) || (!isAnimal && !this.world.allowMonsters)) {
return; return;
} }
// CraftBukkit end // CraftBukkit end
int j = this.d.a(entityliving.getClass(), AxisAlignedBB.b((double) this.e, (double) this.f, (double) this.g, (double) (this.e + 1), (double) (this.f + 1), (double) (this.g + 1)).b(8.0D, 4.0D, 8.0D)).size(); int j = this.world.a(entityliving.getClass(), AxisAlignedBB.b((double) this.e, (double) this.f, (double) this.g, (double) (this.e + 1), (double) (this.f + 1), (double) (this.g + 1)).b(8.0D, 4.0D, 8.0D)).size();
if (j >= 6) { if (j >= 6) {
this.c(); this.c();
@ -64,20 +64,20 @@ public class TileEntityMobSpawner extends TileEntity {
} }
if (entityliving != null) { if (entityliving != null) {
double d3 = (double) this.e + (this.d.k.nextDouble() - this.d.k.nextDouble()) * 4.0D; double d3 = (double) this.e + (this.world.random.nextDouble() - this.world.random.nextDouble()) * 4.0D;
double d4 = (double) (this.f + this.d.k.nextInt(3) - 1); double d4 = (double) (this.f + this.world.random.nextInt(3) - 1);
double d5 = (double) this.g + (this.d.k.nextDouble() - this.d.k.nextDouble()) * 4.0D; double d5 = (double) this.g + (this.world.random.nextDouble() - this.world.random.nextDouble()) * 4.0D;
entityliving.c(d3, d4, d5, this.d.k.nextFloat() * 360.0F, 0.0F); entityliving.setPositionRotation(d3, d4, d5, this.world.random.nextFloat() * 360.0F, 0.0F);
if (entityliving.b()) { if (entityliving.b()) {
this.d.a((Entity) entityliving); this.world.addEntity(entityliving);
for (int k = 0; k < 20; ++k) { for (int k = 0; k < 20; ++k) {
d0 = (double) this.e + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D; d0 = (double) this.e + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D;
d1 = (double) this.f + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D; d1 = (double) this.f + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D;
d2 = (double) this.g + 0.5D + ((double) this.d.k.nextFloat() - 0.5D) * 2.0D; d2 = (double) this.g + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D;
this.d.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); this.world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
this.d.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); this.world.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
} }
entityliving.M(); entityliving.M();
@ -92,18 +92,18 @@ public class TileEntityMobSpawner extends TileEntity {
} }
private void c() { private void c() {
this.a = 200 + this.d.k.nextInt(600); this.spawnDelay = 200 + this.world.random.nextInt(600);
} }
public void a(NBTTagCompound nbttagcompound) { public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound); super.a(nbttagcompound);
this.h = nbttagcompound.i("EntityId"); this.mobName = nbttagcompound.getString("EntityId");
this.a = nbttagcompound.d("Delay"); this.spawnDelay = nbttagcompound.d("Delay");
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.a("EntityId", this.h); nbttagcompound.setString("EntityId", this.mobName);
nbttagcompound.a("Delay", (short) this.a); nbttagcompound.a("Delay", (short) this.spawnDelay);
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@ public class WorldData {
private long g; private long g;
private NBTTagCompound h; private NBTTagCompound h;
private int i; private int i;
public String j; // CraftBukkit private->public public String name; // CraftBukkit private->public
private int k; private int k;
public WorldData(NBTTagCompound nbttagcompound) { public WorldData(NBTTagCompound nbttagcompound) {
@ -24,9 +24,9 @@ public class WorldData {
this.e = nbttagcompound.f("Time"); this.e = nbttagcompound.f("Time");
this.f = nbttagcompound.f("LastPlayed"); this.f = nbttagcompound.f("LastPlayed");
this.g = nbttagcompound.f("SizeOnDisk"); this.g = nbttagcompound.f("SizeOnDisk");
this.j = nbttagcompound.i("LevelName"); this.name = nbttagcompound.getString("LevelName");
this.k = nbttagcompound.e("version"); this.k = nbttagcompound.e("version");
if (nbttagcompound.b("Player")) { if (nbttagcompound.hasKey("Player")) {
this.h = nbttagcompound.k("Player"); this.h = nbttagcompound.k("Player");
this.i = this.h.e("Dimension"); this.i = this.h.e("Dimension");
} }
@ -34,7 +34,7 @@ public class WorldData {
public WorldData(long i, String s) { public WorldData(long i, String s) {
this.a = i; this.a = i;
this.j = s; this.name = s;
} }
public WorldData(WorldData worlddata) { public WorldData(WorldData worlddata) {
@ -47,7 +47,7 @@ public class WorldData {
this.g = worlddata.g; this.g = worlddata.g;
this.h = worlddata.h; this.h = worlddata.h;
this.i = worlddata.i; this.i = worlddata.i;
this.j = worlddata.j; this.name = worlddata.name;
this.k = worlddata.k; this.k = worlddata.k;
} }
@ -84,7 +84,7 @@ public class WorldData {
nbttagcompound.a("Time", this.e); nbttagcompound.a("Time", this.e);
nbttagcompound.a("SizeOnDisk", this.g); nbttagcompound.a("SizeOnDisk", this.g);
nbttagcompound.a("LastPlayed", System.currentTimeMillis()); nbttagcompound.a("LastPlayed", System.currentTimeMillis());
nbttagcompound.a("LevelName", this.j); nbttagcompound.setString("LevelName", this.name);
nbttagcompound.a("version", this.k); nbttagcompound.a("version", this.k);
if (nbttagcompound1 != null) { if (nbttagcompound1 != null) {
nbttagcompound.a("Player", nbttagcompound1); nbttagcompound.a("Player", nbttagcompound1);
@ -127,14 +127,14 @@ public class WorldData {
this.g = i; this.g = i;
} }
public void a(int i, int j, int k) { public void setSpawn(int i, int j, int k) {
this.b = i; this.b = i;
this.c = j; this.c = j;
this.d = k; this.d = k;
} }
public void a(String s) { public void a(String s) {
this.j = s; this.name = s;
} }
public int i() { public int i() {

View file

@ -121,7 +121,7 @@ public class WorldGenBigTree extends WorldGenerator {
if (l1 != 0 && l1 != 18) { if (l1 != 0 && l1 != 18) {
++k1; ++k1;
} else { } else {
this.c.setTypeId(aint1[0], aint1[1], aint1[2], l); this.c.setRawTypeId(aint1[0], aint1[1], aint1[2], l);
++k1; ++k1;
} }
} }
@ -194,10 +194,10 @@ public class WorldGenBigTree extends WorldGenerator {
int j = 0; int j = 0;
for (int k = aint2[b1] + b4; j != k; j += b4) { for (int k = aint2[b1] + b4; j != k; j += b4) {
aint3[b1] = MathHelper.b((double) (aint[b1] + j) + 0.5D); aint3[b1] = MathHelper.floor((double) (aint[b1] + j) + 0.5D);
aint3[b2] = MathHelper.b((double) aint[b2] + (double) j * d0 + 0.5D); aint3[b2] = MathHelper.floor((double) aint[b2] + (double) j * d0 + 0.5D);
aint3[b3] = MathHelper.b((double) aint[b3] + (double) j * d1 + 0.5D); aint3[b3] = MathHelper.floor((double) aint[b3] + (double) j * d1 + 0.5D);
this.c.setTypeId(aint3[0], aint3[1], aint3[2], i); this.c.setRawTypeId(aint3[0], aint3[1], aint3[2], i);
} }
} }
} }

View file

@ -59,7 +59,7 @@ public class WorldGenForest extends WorldGenerator {
} else { } else {
i1 = world.getTypeId(i, j - 1, k); i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) { if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setTypeId(i, j - 1, k, Block.DIRT.id); world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
int i2; int i2;
@ -74,7 +74,7 @@ public class WorldGenForest extends WorldGenerator {
int l2 = k2 - k; int l2 = k2 - k;
if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) {
world.setTypeIdAndData(l1, i2, k2, Block.LEAVES.id, 2); world.setRawTypeIdAndData(l1, i2, k2, Block.LEAVES.id, 2);
} }
} }
} }
@ -83,7 +83,7 @@ public class WorldGenForest extends WorldGenerator {
for (i2 = 0; i2 < l; ++i2) { for (i2 = 0; i2 < l; ++i2) {
j1 = world.getTypeId(i, j + i2, k); j1 = world.getTypeId(i, j + i2, k);
if (j1 == 0 || j1 == Block.LEAVES.id) { if (j1 == 0 || j1 == Block.LEAVES.id) {
world.setTypeIdAndData(i, j + i2, k, Block.LOG.id, 2); world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 2);
} }
} }

View file

@ -61,7 +61,7 @@ public class WorldGenTaiga1 extends WorldGenerator {
} else { } else {
l1 = world.getTypeId(i, j - 1, k); l1 = world.getTypeId(i, j - 1, k);
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setTypeId(i, j - 1, k, Block.DIRT.id); world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
l2 = 0; l2 = 0;
for (i2 = j + l; i2 >= j + i1; --i2) { for (i2 = j + l; i2 >= j + i1; --i2) {
@ -72,7 +72,7 @@ public class WorldGenTaiga1 extends WorldGenerator {
int j3 = i3 - k; int j3 = i3 - k;
if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.o[world.getTypeId(j2, i2, i3)]) { if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.o[world.getTypeId(j2, i2, i3)]) {
world.setTypeIdAndData(j2, i2, i3, Block.LEAVES.id, 1); world.setRawTypeIdAndData(j2, i2, i3, Block.LEAVES.id, 1);
} }
} }
} }
@ -87,7 +87,7 @@ public class WorldGenTaiga1 extends WorldGenerator {
for (i2 = 0; i2 < l - 1; ++i2) { for (i2 = 0; i2 < l - 1; ++i2) {
j2 = world.getTypeId(i, j + i2, k); j2 = world.getTypeId(i, j + i2, k);
if (j2 == 0 || j2 == Block.LEAVES.id) { if (j2 == 0 || j2 == Block.LEAVES.id) {
world.setTypeIdAndData(i, j + i2, k, Block.LOG.id, 1); world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 1);
} }
} }

View file

@ -60,7 +60,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
} else { } else {
l1 = world.getTypeId(i, j - 1, k); l1 = world.getTypeId(i, j - 1, k);
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setTypeId(i, j - 1, k, Block.DIRT.id); world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
k2 = random.nextInt(2); k2 = random.nextInt(2);
i2 = 1; i2 = 1;
byte b0 = 0; byte b0 = 0;
@ -78,7 +78,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
int i4 = l3 - k; int i4 = l3 - k;
if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) { if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) {
world.setTypeIdAndData(i3, j3, l3, Block.LEAVES.id, 1); world.setRawTypeIdAndData(i3, j3, l3, Block.LEAVES.id, 1);
} }
} }
} }
@ -100,7 +100,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
for (j3 = 0; j3 < l - j2; ++j3) { for (j3 = 0; j3 < l - j2; ++j3) {
i3 = world.getTypeId(i, j + j3, k); i3 = world.getTypeId(i, j + j3, k);
if (i3 == 0 || i3 == Block.LEAVES.id) { if (i3 == 0 || i3 == Block.LEAVES.id) {
world.setTypeIdAndData(i, j + j3, k, Block.LOG.id, 1); world.setRawTypeIdAndData(i, j + j3, k, Block.LOG.id, 1);
} }
} }

View file

@ -59,7 +59,7 @@ public class WorldGenTrees extends WorldGenerator {
} else { } else {
i1 = world.getTypeId(i, j - 1, k); i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) { if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setTypeId(i, j - 1, k, Block.DIRT.id); world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
int i2; int i2;
@ -74,7 +74,7 @@ public class WorldGenTrees extends WorldGenerator {
int l2 = k2 - k; int l2 = k2 - k;
if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) {
world.setTypeId(l1, i2, k2, Block.LEAVES.id); world.setRawTypeId(l1, i2, k2, Block.LEAVES.id);
} }
} }
} }
@ -83,7 +83,7 @@ public class WorldGenTrees extends WorldGenerator {
for (i2 = 0; i2 < l; ++i2) { for (i2 = 0; i2 < l; ++i2) {
j1 = world.getTypeId(i, j + i2, k); j1 = world.getTypeId(i, j + i2, k);
if (j1 == 0 || j1 == Block.LEAVES.id) { if (j1 == 0 || j1 == Block.LEAVES.id) {
world.setTypeId(i, j + i2, k, Block.LOG.id); world.setRawTypeId(i, j + i2, k, Block.LOG.id);
} }
} }

View file

@ -2,23 +2,23 @@ package net.minecraft.server;
public class WorldManager implements IWorldAccess { public class WorldManager implements IWorldAccess {
private MinecraftServer a; private MinecraftServer server;
public WorldServer world; // CraftBukkit public WorldServer world; // CraftBukkit
// CraftBukkit - changed signature // CraftBukkit - changed signature
public WorldManager(MinecraftServer minecraftserver, WorldServer world) { public WorldManager(MinecraftServer minecraftserver, WorldServer world) {
this.a = minecraftserver; this.server = minecraftserver;
this.world = world; // CraftBukkit this.world = world; // CraftBukkit
} }
public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {} public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) {}
public void a(Entity entity) { public void a(Entity entity) {
this.a.k.a(entity); this.server.tracker.a(entity);
} }
public void b(Entity entity) { public void b(Entity entity) {
this.a.k.b(entity); this.server.tracker.untrackEntity(entity);
} }
public void a(String s, double d0, double d1, double d2, float f, float f1) {} public void a(String s, double d0, double d1, double d2, float f, float f1) {}
@ -28,13 +28,13 @@ public class WorldManager implements IWorldAccess {
public void a() {} public void a() {}
public void a(int i, int j, int k) { public void a(int i, int j, int k) {
// CraftBukkit // CraftBukkit -- add world argument
this.a.f.a(i, j, k, world); this.server.serverConfigurationManager.flagDirty(i, j, k, world);
} }
public void a(String s, int i, int j, int k) {} public void a(String s, int i, int j, int k) {}
public void a(int i, int j, int k, TileEntity tileentity) { public void a(int i, int j, int k, TileEntity tileentity) {
this.a.f.a(i, j, k, tileentity); this.server.serverConfigurationManager.a(i, j, k, tileentity);
} }
} }

View file

@ -12,59 +12,59 @@ import org.bukkit.craftbukkit.CraftWorld;
public class WorldServer extends World implements BlockChangeDelegate { public class WorldServer extends World implements BlockChangeDelegate {
// CraftBukkit end // CraftBukkit end
public ChunkProviderServer u; public ChunkProviderServer chunkProviderServer;
public boolean v = false; public boolean weirdIsOpCache = false;
public boolean w; public boolean w;
public final MinecraftServer x; // CraftBukkit - private -> public final public final MinecraftServer server; // CraftBukkit - private -> public final
private EntityList y = new EntityList(); private EntityList y = new EntityList();
public PlayerManager manager; // CraftBukkit public PlayerManager manager; // CraftBukkit
public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j) { public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j) {
super(idatamanager, s, j, WorldProvider.a(i)); super(idatamanager, s, j, WorldProvider.a(i));
this.x = minecraftserver; this.server = minecraftserver;
// CraftBukkit start // CraftBukkit start
this.server = minecraftserver.server; this.cserver = minecraftserver.server;
this.world = new CraftWorld(this); this.world = new CraftWorld(this);
this.manager = new PlayerManager(minecraftserver, this); this.manager = new PlayerManager(minecraftserver, this);
} }
private final CraftWorld world; private final CraftWorld world;
private final CraftServer server; private final CraftServer cserver;
public CraftWorld getWorld() { public CraftWorld getWorld() {
return world; return world;
} }
public CraftServer getServer() { public CraftServer getServer() {
return server; return cserver;
} }
// CraftBukkit end // CraftBukkit end
public void a(Entity entity, boolean flag) { public void entityJoinedWorld(Entity entity, boolean flag) {
// CraftBukkit start -- We prevent spawning in general, so this butchering is not needed // CraftBukkit start -- We prevent spawning in general, so this butchering is not needed
//if (!this.x.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { //if (!this.server.spawnAnimals && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
// entity.D(); // entity.die();
//} //}
// CraftBukkit end // CraftBukkit end
if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) { if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) {
super.a(entity, flag); super.entityJoinedWorld(entity, flag);
} }
} }
public void b(Entity entity, boolean flag) { public void vehicleEnteredWorld(Entity entity, boolean flag) {
super.a(entity, flag); super.entityJoinedWorld(entity, flag);
} }
protected IChunkProvider b() { protected IChunkProvider b() {
IChunkLoader ichunkloader = this.p.a(this.m); IChunkLoader ichunkloader = this.p.a(this.worldProvider);
this.u = new ChunkProviderServer(this, ichunkloader, this.m.c()); this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.worldProvider.c());
return this.u; return this.chunkProviderServer;
} }
public List d(int i, int j, int k, int l, int i1, int j1) { public List getTileEntities(int i, int j, int k, int l, int i1, int j1) {
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
for (int k1 = 0; k1 < this.c.size(); ++k1) { for (int k1 = 0; k1 < this.c.size(); ++k1) {
@ -79,15 +79,15 @@ public class WorldServer extends World implements BlockChangeDelegate {
} }
public boolean a(EntityHuman entityhuman, int i, int j, int k) { public boolean a(EntityHuman entityhuman, int i, int j, int k) {
int l = (int) MathHelper.e((float) (i - this.q.c())); int l = (int) MathHelper.abs((float) (i - this.worldData.c()));
int i1 = (int) MathHelper.e((float) (k - this.q.e())); int i1 = (int) MathHelper.abs((float) (k - this.worldData.e()));
if (l > i1) { if (l > i1) {
i1 = l; i1 = l;
} }
// CraftBukkit -- Configurable spawn protection // CraftBukkit -- Configurable spawn protection
return i1 > this.x.spawnProtection || this.x.f.h(entityhuman.name); return i1 > this.server.spawnProtection || this.server.serverConfigurationManager.isOp(entityhuman.name);
} }
protected void b(Entity entity) { protected void b(Entity entity) {
@ -100,18 +100,18 @@ public class WorldServer extends World implements BlockChangeDelegate {
this.y.d(entity.id); this.y.d(entity.id);
} }
public Entity a(int i) { public Entity getEntity(int i) {
return (Entity) this.y.a(i); return (Entity) this.y.a(i);
} }
public void a(Entity entity, byte b0) { public void a(Entity entity, byte b0) {
Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0); Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0);
this.x.k.b(entity, packet38entitystatus); this.server.tracker.b(entity, packet38entitystatus);
} }
public Explosion a(Entity entity, double d0, double d1, double d2, float f, boolean flag) { public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
Explosion explosion = super.a(entity, d0, d1, d2, f, flag); Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag);
// CraftBukkit start // CraftBukkit start
if (explosion.wasCanceled) { if (explosion.wasCanceled) {
@ -119,16 +119,16 @@ public class WorldServer extends World implements BlockChangeDelegate {
} }
// CraftBukkit end // CraftBukkit end
this.x.f.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g)); this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g));
return explosion; return explosion;
} }
public void d(int i, int j, int k, int l, int i1) { public void d(int i, int j, int k, int l, int i1) {
super.d(i, j, k, l, i1); super.d(i, j, k, l, i1);
this.x.f.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1)); this.server.serverConfigurationManager.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1));
} }
public void t() { public void saveLevel() {
this.p.e(); this.p.e();
} }
} }

View file

@ -23,9 +23,9 @@ public class CraftChunk implements Chunk {
public CraftChunk(net.minecraft.server.Chunk chunk) { public CraftChunk(net.minecraft.server.Chunk chunk) {
this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk); this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk);
worldServer = (WorldServer) getHandle().d; worldServer = (WorldServer) getHandle().world;
x = getHandle().j; x = getHandle().x;
z = getHandle().k; z = getHandle().z;
} }
public World getWorld() { public World getWorld() {
@ -35,7 +35,7 @@ public class CraftChunk implements Chunk {
public net.minecraft.server.Chunk getHandle() { public net.minecraft.server.Chunk getHandle() {
net.minecraft.server.Chunk c = weakChunk.get(); net.minecraft.server.Chunk c = weakChunk.get();
if (c == null) { if (c == null) {
c = worldServer.c(x,z); c = worldServer.getChunkAt(x,z);
weakChunk = new WeakReference<net.minecraft.server.Chunk>(c); weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
} }
return c; return c;
@ -77,12 +77,12 @@ public class CraftChunk implements Chunk {
int count = 0, index = 0; int count = 0, index = 0;
net.minecraft.server.Chunk chunk = getHandle(); net.minecraft.server.Chunk chunk = getHandle();
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
count += chunk.m[i].size(); count += chunk.entitySlices[i].size();
} }
Entity[] entities = new Entity[count]; Entity[] entities = new Entity[count];
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
for (Object obj: chunk.m[i].toArray()) { for (Object obj: chunk.entitySlices[i].toArray()) {
if (!(obj instanceof net.minecraft.server.Entity)) continue; if (!(obj instanceof net.minecraft.server.Entity)) continue;
entities[index++] = ((net.minecraft.server.Entity) obj).getBukkitEntity(); entities[index++] = ((net.minecraft.server.Entity) obj).getBukkitEntity();
} }
@ -93,11 +93,11 @@ public class CraftChunk implements Chunk {
public BlockState[] getTileEntities() { public BlockState[] getTileEntities() {
int index = 0; int index = 0;
net.minecraft.server.Chunk chunk = getHandle(); net.minecraft.server.Chunk chunk = getHandle();
BlockState[] entities = new BlockState[chunk.l.size()]; BlockState[] entities = new BlockState[chunk.tileEntities.size()];
for (Object obj : chunk.l.keySet().toArray()) { for (Object obj : chunk.tileEntities.keySet().toArray()) {
if (!(obj instanceof ChunkPosition)) continue; if (!(obj instanceof ChunkPosition)) continue;
ChunkPosition position = (ChunkPosition) obj; ChunkPosition position = (ChunkPosition) obj;
entities[index++] = worldServer.getWorld().getBlockAt(position.a + (chunk.j << 4), position.b, position.c + (chunk.k << 4)).getState(); entities[index++] = worldServer.getWorld().getBlockAt(position.x + (chunk.x << 4), position.y, position.z + (chunk.z << 4)).getState();
} }
return entities; return entities;
} }

View file

@ -127,11 +127,11 @@ public final class CraftServer implements Server {
} }
public Player[] getOnlinePlayers() { public Player[] getOnlinePlayers() {
List<EntityPlayer> online = server.b; List<EntityPlayer> online = server.players;
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++) {
players[i] = online.get(i).a.getPlayer(); players[i] = online.get(i).netServerHandler.getPlayer();
} }
return players; return players;
@ -167,7 +167,7 @@ public final class CraftServer implements Server {
} }
public Player getPlayer(final EntityPlayer entity) { public Player getPlayer(final EntityPlayer entity) {
return entity.a.getPlayer(); return entity.netServerHandler.getPlayer();
} }
public List<Player> matchPlayer(String partialName) { public List<Player> matchPlayer(String partialName) {
@ -192,7 +192,7 @@ public final class CraftServer implements Server {
} }
public int getMaxPlayers() { public int getMaxPlayers() {
return server.e; return server.maxPlayers;
} }
// NOTE: These are dependent on the corrisponding call in MinecraftServer // NOTE: These are dependent on the corrisponding call in MinecraftServer
@ -215,11 +215,11 @@ public final class CraftServer implements Server {
// NOTE: Temporary calls through to server.properies until its replaced // NOTE: Temporary calls through to server.properies until its replaced
private String getConfigString(String variable, String defaultValue) { private String getConfigString(String variable, String defaultValue) {
return this.console.d.a(variable, defaultValue); return this.console.propertyManager.getString(variable, defaultValue);
} }
private int getConfigInt(String variable, int defaultValue) { private int getConfigInt(String variable, int defaultValue) {
return this.console.d.a(variable, defaultValue); return this.console.propertyManager.getInt(variable, defaultValue);
} }
// End Temporary calls // End Temporary calls
@ -243,10 +243,10 @@ public final class CraftServer implements Server {
// NOTE: Should only be called from MinecraftServer.b() // NOTE: Should only be called from MinecraftServer.b()
public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) { public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) {
if ( commandMap.dispatch(sender, serverCommand.a) ) { if ( commandMap.dispatch(sender, serverCommand.command) ) {
return true; return true;
} }
return console.o.a(serverCommand); return console.consoleCommandHandler.handle(serverCommand);
} }
public boolean dispatchCommand(CommandSender sender, String commandLine) { public boolean dispatchCommand(CommandSender sender, String commandLine) {
@ -260,24 +260,24 @@ public final class CraftServer implements Server {
} }
// See if the server can process this command // See if the server can process this command
return console.o.a(new ServerCommand(commandLine, new CommandListener(sender))); return console.consoleCommandHandler.handle(new ServerCommand(commandLine, new CommandListener(sender)));
} }
public void reload() { public void reload() {
PropertyManager config = new PropertyManager(console.options); PropertyManager config = new PropertyManager(console.options);
console.d = config; console.propertyManager = config;
boolean animals = config.a("spawn-monsters", console.m); boolean animals = config.getBoolean("spawn-monsters", console.spawnAnimals);
boolean monsters = config.a("spawn-monsters", console.worlds.get(0).j > 0); boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).spawnMonsters > 0);
console.l = config.a("online-mode", console.l); console.onlineMode = config.getBoolean("online-mode", console.onlineMode);
console.m = config.a("spawn-animals", console.m); console.spawnAnimals = config.getBoolean("spawn-animals", console.spawnAnimals);
console.n = config.a("pvp", console.n); console.pvpMode = config.getBoolean("pvp", console.pvpMode);
for (WorldServer world : console.worlds) { for (WorldServer world : console.worlds) {
world.j = monsters ? 1 : 0; world.spawnMonsters = monsters ? 1 : 0;
world.a(monsters, animals); world.setSpawnFlags(monsters, animals);
} }
pluginManager.clearPlugins(); pluginManager.clearPlugins();
@ -307,17 +307,17 @@ public final class CraftServer implements Server {
} }
Convertable converter = new WorldLoaderServer(folder); Convertable converter = new WorldLoaderServer(folder);
if (converter.a(name)) { if (converter.isConvertable(name)) {
getLogger().info("Converting world '" + name + "'"); getLogger().info("Converting world '" + name + "'");
converter.a(name, new ConvertProgressUpdater(console)); converter.convert(name, new ConvertProgressUpdater(console));
} }
WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, environment == World.Environment.NETHER ? -1 : 0, seed); WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, environment == World.Environment.NETHER ? -1 : 0, seed);
internal.a(new WorldManager(console, internal)); internal.addIWorldAccess(new WorldManager(console, internal));
internal.j = 1; internal.spawnMonsters = 1;
internal.a(true, true); internal.setSpawnFlags(true, true);
console.f.a(internal); console.serverConfigurationManager.setPlayerFileData(internal);
console.worlds.add(internal); console.worlds.add(internal);
short short1 = 196; short short1 = 196;
@ -338,10 +338,10 @@ public final class CraftServer implements Server {
i = l; i = l;
} }
ChunkCoordinates chunkcoordinates = internal.m(); ChunkCoordinates chunkcoordinates = internal.getSpawn();
internal.u.c(chunkcoordinates.a + j >> 4, chunkcoordinates.c + k >> 4); internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4);
while (internal.f()) { while (internal.doLighting()) {
; ;
} }
} }
@ -363,7 +363,7 @@ public final class CraftServer implements Server {
} }
public Logger getLogger() { public Logger getLogger() {
return MinecraftServer.a; return MinecraftServer.log;
} }
public ConsoleReader getReader() { public ConsoleReader getReader() {
@ -381,7 +381,7 @@ public final class CraftServer implements Server {
} }
public void savePlayers() { public void savePlayers() {
server.d(); server.savePlayers();
} }
public void configureDbConfig(ServerConfig config) { public void configureDbConfig(ServerConfig config) {
@ -410,11 +410,11 @@ public final class CraftServer implements Server {
this.prefix = parts[parts.length-1]; this.prefix = parts[parts.length-1];
} }
public void b(String msg) { public void sendMessage(String msg) {
this.commandSender.sendMessage(msg); this.commandSender.sendMessage(msg);
} }
public String c() { public String getName() {
return this.prefix; return this.prefix;
} }
} }

View file

@ -34,9 +34,9 @@ public class CraftWorld implements World {
public CraftWorld(WorldServer world) { public CraftWorld(WorldServer world) {
this.world = world; this.world = world;
this.server = world.getServer(); this.server = world.getServer();
this.provider = world.u; this.provider = world.chunkProviderServer;
if (world.m instanceof WorldProviderHell) { if (world.worldProvider instanceof WorldProviderHell) {
environment = Environment.NETHER; environment = Environment.NETHER;
} else { } else {
environment = Environment.NORMAL; environment = Environment.NORMAL;
@ -63,18 +63,18 @@ public class CraftWorld implements World {
} }
public int getHighestBlockYAt(int x, int z) { public int getHighestBlockYAt(int x, int z) {
return world.d(x, z); return world.getHighestBlockYAt(x, z);
} }
public Location getSpawnLocation() { public Location getSpawnLocation() {
ChunkCoordinates spawn = world.m(); ChunkCoordinates spawn = world.getSpawn();
return new Location(this, spawn.a, spawn.b, spawn.c); return new Location(this, spawn.x, spawn.y, spawn.z);
} }
public boolean setSpawnLocation(int x, int y, int z) { public boolean setSpawnLocation(int x, int y, int z) {
try { try {
Location previousLocation = getSpawnLocation(); Location previousLocation = getSpawnLocation();
world.q.a(x, y, z); world.worldData.setSpawn(x, y, z);
// Notify anyone who's listening. // Notify anyone who's listening.
SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation); SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
@ -87,7 +87,7 @@ public class CraftWorld implements World {
} }
public Chunk getChunkAt(int x, int z) { public Chunk getChunkAt(int x, int z) {
return this.provider.c(x, z).bukkitChunk; return this.provider.getChunkAt(x,z).bukkitChunk;
} }
public Chunk getChunkAt(Block block) { public Chunk getChunkAt(Block block) {
@ -95,11 +95,11 @@ public class CraftWorld implements World {
} }
public boolean isChunkLoaded(int x, int z) { public boolean isChunkLoaded(int x, int z) {
return provider.a( x, z ); return provider.isChunkLoaded( x, z );
} }
public Chunk[] getLoadedChunks() { public Chunk[] getLoadedChunks() {
Object[] chunks = provider.e.values().toArray(); Object[] chunks = provider.chunks.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length]; org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
for (int i = 0; i < chunks.length; i++) { for (int i = 0; i < chunks.length; i++) {
@ -131,7 +131,7 @@ public class CraftWorld implements World {
return false; return false;
} }
provider.d(x, z); provider.queueUnload(x, z);
return true; return true;
} }
@ -141,18 +141,18 @@ public class CraftWorld implements World {
return false; return false;
} }
net.minecraft.server.Chunk chunk = provider.b(x, z); net.minecraft.server.Chunk chunk = provider.getOrCreateChunk(x, z);
if (save) { if (save) {
chunk.e(); chunk.removeEntities();
provider.b(chunk); provider.saveChunk(chunk);
provider.a(chunk); provider.saveChunkNOP(chunk);
} }
preserveChunk((CraftChunk)chunk.bukkitChunk); preserveChunk((CraftChunk) chunk.bukkitChunk);
provider.a.remove(x, z); provider.unloadQueue.remove(x, z);
provider.e.remove(x, z); provider.chunks.remove(x, z);
provider.f.remove(chunk); provider.chunkList.remove(chunk);
return true; return true;
} }
@ -160,14 +160,14 @@ public class CraftWorld implements World {
public boolean regenerateChunk(int x, int z) { public boolean regenerateChunk(int x, int z) {
unloadChunk(x, z, false, false); unloadChunk(x, z, false, false);
provider.a.remove(x, z); provider.unloadQueue.remove(x, z);
net.minecraft.server.Chunk chunk = null; net.minecraft.server.Chunk chunk = null;
if (provider.c == null) { if (provider.chunkProvider == null) {
chunk = provider.b; chunk = provider.emptyChunk;
} else { } else {
chunk = provider.c.b(x, z); chunk = provider.chunkProvider.getOrCreateChunk(x, z);
} }
chunkLoadPostProcess(chunk, x, z); chunkLoadPostProcess(chunk, x, z);
@ -191,9 +191,9 @@ public class CraftWorld implements World {
// The server will compress the chunk and send it to all clients // The server will compress the chunk and send it to all clients
for(int xx = px; xx < (px + 16); xx++) { for(int xx = px; xx < (px + 16); xx++) {
world.g(xx, 0, pz); world.notify(xx, 0, pz);
} }
world.g(px, 127, pz+15); world.notify(px, 127, pz+15);
return true; return true;
} }
@ -204,7 +204,7 @@ public class CraftWorld implements World {
for (Player player : players) { for (Player player : players) {
Location loc = player.getLocation(); Location loc = player.getLocation();
if (loc.getWorld() != provider.g.getWorld()) { if (loc.getWorld() != provider.world.getWorld()) {
continue; continue;
} }
@ -221,14 +221,14 @@ public class CraftWorld implements World {
public boolean loadChunk(int x, int z, boolean generate) { public boolean loadChunk(int x, int z, boolean generate) {
if (generate) { if (generate) {
// Use the default variant of loadChunk when generate == true. // Use the default variant of loadChunk when generate == true.
return provider.c(x, z) != null; return provider.getChunkAt(x, z) != null;
} }
provider.a.remove(x, z); provider.unloadQueue.remove(x, z);
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) provider.e.get(x, z); net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) provider.chunks.get(x, z);
if (chunk == null) { if (chunk == null) {
chunk = provider.e(x, z); chunk = provider.loadChunk(x, z);
chunkLoadPostProcess(chunk, x, z); chunkLoadPostProcess(chunk, x, z);
} }
@ -237,26 +237,26 @@ public class CraftWorld implements World {
private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) { private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int x, int z) {
if (chunk != null) { if (chunk != null) {
provider.e.put(x, z, chunk); provider.chunks.put(x, z, chunk);
provider.f.add(chunk); provider.chunkList.add(chunk);
chunk.c(); chunk.loadNOP();
chunk.d(); chunk.addEntities();
if (!chunk.n && provider.a(x + 1, z + 1) && provider.a(x, z + 1) && provider.a(x + 1, z)) { if (!chunk.done && provider.isChunkLoaded(x + 1, z + 1) && provider.isChunkLoaded(x, z + 1) && provider.isChunkLoaded(x + 1, z)) {
provider.a(provider, x, z); provider.getChunkAt(provider, x, z);
} }
if (provider.a(x - 1, z) && !provider.b(x - 1, z).n && provider.a(x - 1, z + 1) && provider.a(x, z + 1) && provider.a(x - 1, z)) { if (provider.isChunkLoaded(x - 1, z) && !provider.getOrCreateChunk(x - 1, z).done && provider.isChunkLoaded(x - 1, z + 1) && provider.isChunkLoaded(x, z + 1) && provider.isChunkLoaded(x - 1, z)) {
provider.a(provider, x - 1, z); provider.getChunkAt(provider, x - 1, z);
} }
if (provider.a(x, z - 1) && !provider.b(x, z - 1).n && provider.a(x + 1, z - 1) && provider.a(x, z - 1) && provider.a(x + 1, z)) { if (provider.isChunkLoaded(x, z - 1) && !provider.getOrCreateChunk(x, z - 1).done && provider.isChunkLoaded(x + 1, z - 1) && provider.isChunkLoaded(x, z - 1) && provider.isChunkLoaded(x + 1, z)) {
provider.a(provider, x, z - 1); provider.getChunkAt(provider, x, z - 1);
} }
if (provider.a(x - 1, z - 1) && !provider.b(x - 1, z - 1).n && provider.a(x - 1, z - 1) && provider.a(x, z - 1) && provider.a(x - 1, z)) { if (provider.isChunkLoaded(x - 1, z - 1) && !provider.getOrCreateChunk(x - 1, z - 1).done && provider.isChunkLoaded(x - 1, z - 1) && provider.isChunkLoaded(x, z - 1) && provider.isChunkLoaded(x - 1, z)) {
provider.a(provider, x - 1, z - 1); provider.getChunkAt(provider, x - 1, z - 1);
} }
} }
} }
@ -281,17 +281,17 @@ public class CraftWorld implements World {
item.getDurability() item.getDurability()
); );
EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), stack); EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), stack);
entity.c = 10; entity.pickupDelay = 10;
world.a(entity); world.addEntity(entity);
//TODO this is inconsistent with how Entity.getBukkitEntity() works. //TODO this is inconsistent with how Entity.getBukkitEntity() works.
// However, this entity is not at the moment backed by a server entity class so it may be left. // However, this entity is not at the moment backed by a server entity class so it may be left.
return new CraftItem(world.getServer(), entity); return new CraftItem(world.getServer(), entity);
} }
public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) { public org.bukkit.entity.Item dropItemNaturally(Location loc, ItemStack item) {
double xs = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; double xs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; double ys = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double zs = world.k.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D; double zs = world.random.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
loc = loc.clone(); loc = loc.clone();
loc.setX(loc.getX() + xs); loc.setX(loc.getX() + xs);
loc.setY(loc.getY() + ys); loc.setY(loc.getY() + ys);
@ -301,8 +301,8 @@ public class CraftWorld implements World {
public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread) { public Arrow spawnArrow(Location loc, Vector velocity, float speed, float spread) {
EntityArrow arrow = new EntityArrow(world); EntityArrow arrow = new EntityArrow(world);
arrow.c(loc.getX(), loc.getY(), loc.getZ(), 0, 0); arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
world.a(arrow); world.addEntity(arrow);
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread); arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
return (Arrow) arrow.getBukkitEntity(); return (Arrow) arrow.getBukkitEntity();
} }
@ -315,7 +315,7 @@ public class CraftWorld implements World {
loc.getZ(), loc.getZ(),
CraftMinecart.Type.Minecart.getId() CraftMinecart.Type.Minecart.getId()
); );
world.a(minecart); world.addEntity(minecart);
return (Minecart) minecart.getBukkitEntity(); return (Minecart) minecart.getBukkitEntity();
} }
@ -327,7 +327,7 @@ public class CraftWorld implements World {
loc.getZ(), loc.getZ(),
CraftMinecart.Type.StorageMinecart.getId() CraftMinecart.Type.StorageMinecart.getId()
); );
world.a(minecart); world.addEntity(minecart);
return (StorageMinecart) minecart.getBukkitEntity(); return (StorageMinecart) minecart.getBukkitEntity();
} }
@ -339,13 +339,13 @@ public class CraftWorld implements World {
loc.getZ(), loc.getZ(),
CraftMinecart.Type.PoweredMinecart.getId() CraftMinecart.Type.PoweredMinecart.getId()
); );
world.a(minecart); world.addEntity(minecart);
return (PoweredMinecart) minecart.getBukkitEntity(); return (PoweredMinecart) minecart.getBukkitEntity();
} }
public Boat spawnBoat(Location loc) { public Boat spawnBoat(Location loc) {
EntityBoat boat = new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ()); EntityBoat boat = new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
world.a(boat); world.addEntity(boat);
return (Boat) boat.getBukkitEntity(); return (Boat) boat.getBukkitEntity();
} }
@ -353,9 +353,9 @@ public class CraftWorld implements World {
LivingEntity creature; LivingEntity creature;
try { try {
EntityLiving entityCreature = (EntityLiving) EntityTypes.a(creatureType.getName(), world); EntityLiving entityCreature = (EntityLiving) EntityTypes.a(creatureType.getName(), world);
entityCreature.a(loc.getX(), loc.getY(), loc.getZ()); entityCreature.setPosition(loc.getX(), loc.getY(), loc.getZ());
creature = (LivingEntity) CraftEntity.getEntity(server, entityCreature); creature = (LivingEntity) CraftEntity.getEntity(server, entityCreature);
world.a(entityCreature); world.addEntity(entityCreature);
} catch (Exception e) { } catch (Exception e) {
// if we fail, for any reason, return null. // if we fail, for any reason, return null.
creature = null; creature = null;
@ -388,11 +388,11 @@ public class CraftWorld implements World {
} }
public String getName() { public String getName() {
return world.q.j; return world.worldData.name;
} }
public long getId() { public long getId() {
return world.q.b(); return world.worldData.b();
} }
@Override @Override
@ -413,16 +413,16 @@ public class CraftWorld implements World {
} }
public long getFullTime() { public long getFullTime() {
return world.l(); return world.getTime();
} }
public void setFullTime(long time) { public void setFullTime(long time) {
world.a(time); world.setTime(time);
//Forces the client to update to the new time immediately //Forces the client to update to the new time immediately
for (Player p: getPlayers()) { for (Player p: getPlayers()) {
CraftPlayer cp = (CraftPlayer) p; CraftPlayer cp = (CraftPlayer) p;
cp.getHandle().a.b(new Packet4UpdateTime(time)); cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(time));
} }
} }
@ -485,7 +485,7 @@ public class CraftWorld implements World {
public List<Entity> getEntities() { public List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>(); List<Entity> list = new ArrayList<Entity>();
for (Object o: world.b) { for (Object o: world.entityList) {
if (o instanceof net.minecraft.server.Entity) { if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o; net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity(); Entity bukkitEntity = mcEnt.getBukkitEntity();
@ -503,7 +503,7 @@ public class CraftWorld implements World {
public List<LivingEntity> getLivingEntities() { public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList<LivingEntity>(); List<LivingEntity> list = new ArrayList<LivingEntity>();
for (Object o: world.b) { for (Object o: world.entityList) {
if (o instanceof net.minecraft.server.Entity) { if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o; net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity(); Entity bukkitEntity = mcEnt.getBukkitEntity();
@ -521,7 +521,7 @@ public class CraftWorld implements World {
public List<Player> getPlayers() { public List<Player> getPlayers() {
List<Player> list = new ArrayList<Player>(); List<Player> list = new ArrayList<Player>();
for (Object o : world.b) { for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) { if (o instanceof net.minecraft.server.Entity) {
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o; net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
Entity bukkitEntity = mcEnt.getBukkitEntity(); Entity bukkitEntity = mcEnt.getBukkitEntity();
@ -537,9 +537,9 @@ public class CraftWorld implements World {
public void save() { public void save() {
// Writes level.dat // Writes level.dat
world.t(); world.saveLevel();
// Saves all chunks/regions // Saves all chunks/regions
world.o.a(true, null); world.chunkProvider.saveChunks(true, null);
} }
} }

View file

@ -88,14 +88,14 @@ public class CraftBlock implements Block {
* @param data New block specific metadata * @param data New block specific metadata
*/ */
public void setData(final byte data) { public void setData(final byte data) {
chunk.getHandle().d.c(x, y, z, data); chunk.getHandle().world.setData(x, y, z, data);
} }
public void setData(final byte data, boolean applyPhysics) { public void setData(final byte data, boolean applyPhysics) {
if (applyPhysics) { if (applyPhysics) {
chunk.getHandle().d.c(x, y, z, data); chunk.getHandle().world.setData(x, y, z, data);
} else { } else {
chunk.getHandle().d.d(x, y, z, data); chunk.getHandle().world.setRawData(x, y, z, data);
} }
} }
@ -105,7 +105,7 @@ public class CraftBlock implements Block {
* @return block specific metadata * @return block specific metadata
*/ */
public byte getData() { public byte getData() {
return (byte) chunk.getHandle().b(this.x & 0xF, this.y & 0x7F, this.z & 0xF); return (byte) chunk.getHandle().getData(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
} }
/** /**
@ -124,24 +124,24 @@ public class CraftBlock implements Block {
* @return whether the block was changed * @return whether the block was changed
*/ */
public boolean setTypeId(final int type) { public boolean setTypeId(final int type) {
return chunk.getHandle().d.e(x, y, z, type); return chunk.getHandle().world.setRawTypeId(x, y, z, type);
} }
public boolean setTypeId(final int type, final boolean applyPhysics) { public boolean setTypeId(final int type, final boolean applyPhysics) {
if (applyPhysics) { if (applyPhysics) {
return setTypeId(type); return setTypeId(type);
} else { } else {
return chunk.getHandle().d.setTypeId(x, y, z, type); return chunk.getHandle().world.setRawTypeId(x, y, z, type);
} }
} }
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) { public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
if (applyPhysics) { if (applyPhysics) {
return chunk.getHandle().d.b(x, y, z, type, data); return chunk.getHandle().world.setTypeIdAndData(x, y, z, type, data);
} else { } else {
boolean success = chunk.getHandle().d.setTypeIdAndData(x, y, z, type, data); boolean success = chunk.getHandle().world.setRawTypeIdAndData(x, y, z, type, data);
if(success) { if (success) {
chunk.getHandle().d.g(x, y, z); chunk.getHandle().world.notify(x, y, z);
} }
return success; return success;
} }
@ -162,7 +162,7 @@ public class CraftBlock implements Block {
* @return block type-id * @return block type-id
*/ */
public int getTypeId() { public int getTypeId() {
return chunk.getHandle().a(this.x & 0xF, this.y & 0x7F, this.z & 0xF); return chunk.getHandle().getTypeId(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
} }
/** /**
@ -171,7 +171,7 @@ public class CraftBlock implements Block {
* @return light level * @return light level
*/ */
public byte getLightLevel() { public byte getLightLevel() {
return (byte) chunk.getHandle().d.j(this.x, this.y, this.z); return (byte) chunk.getHandle().world.getLightLevel(this.x, this.y, this.z);
} }
/** /**
@ -331,7 +331,7 @@ public class CraftBlock implements Block {
} }
public Biome getBiome() { public Biome getBiome() {
BiomeBase base = chunk.getHandle().d.a().a(x, z); BiomeBase base = chunk.getHandle().world.getWorldChunkManager().getBiome(x, z);
if (base == BiomeBase.RAINFOREST) { if (base == BiomeBase.RAINFOREST) {
return Biome.RAINFOREST; return Biome.RAINFOREST;
@ -363,11 +363,11 @@ public class CraftBlock implements Block {
} }
public boolean isBlockPowered() { public boolean isBlockPowered() {
return chunk.getHandle().d.o(x, y, z); return chunk.getHandle().world.isBlockPowered(x, y, z);
} }
public boolean isBlockIndirectlyPowered() { public boolean isBlockIndirectlyPowered() {
return chunk.getHandle().d.p(x, y, z); return chunk.getHandle().world.isBlockIndirectlyPowered(x, y, z);
} }
@Override @Override
@ -376,23 +376,23 @@ public class CraftBlock implements Block {
} }
public boolean isBlockFacePowered(BlockFace face) { public boolean isBlockFacePowered(BlockFace face) {
return chunk.getHandle().d.i(x, y, z, blockFaceToNotch(face)); return chunk.getHandle().world.isBlockFacePowered(x, y, z, blockFaceToNotch(face));
} }
public boolean isBlockFaceIndirectlyPowered(BlockFace face) { public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
return chunk.getHandle().d.j(x, y, z, blockFaceToNotch(face)); return chunk.getHandle().world.isBlockFaceIndirectlyPowered(x, y, z, blockFaceToNotch(face));
} }
public int getBlockPower(BlockFace face) { public int getBlockPower(BlockFace face) {
int power = 0; int power = 0;
BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE; BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE;
net.minecraft.server.World world = chunk.getHandle().d; net.minecraft.server.World world = chunk.getHandle().world;
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.f(world, x, y - 1, z, power); if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(x, y - 1, z, 0)) power = wire.getPower(world, x, y - 1, z, power);
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.f(world, x, y + 1, z, power); if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(x, y + 1, z, 1)) power = wire.getPower(world, x, y + 1, z, power);
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.f(world, x, y, z - 1, power); if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z - 1, 2)) power = wire.getPower(world, x, y, z - 1, power);
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.f(world, x, y, z + 1, power); if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z + 1, 3)) power = wire.getPower(world, x, y, z + 1, power);
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.f(world, x - 1, y, z, power); if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(x - 1, y, z, 4)) power = wire.getPower(world, x - 1, y, z, power);
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.f(world, x + 1, y, z, power); if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(x + 1, y, z, 5)) power = wire.getPower(world, x + 1, y, z, power);
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0; return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
} }

View file

@ -32,7 +32,7 @@ public class CraftChest extends CraftBlockState implements Chest {
boolean result = super.update(force); boolean result = super.update(force);
if (result) { if (result) {
chest.i(); chest.update();
} }
return result; return result;

View file

@ -18,15 +18,15 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
} }
public CreatureType getCreatureType() { public CreatureType getCreatureType() {
return CreatureType.fromName(spawner.h); return CreatureType.fromName(spawner.mobName);
} }
public void setCreatureType(CreatureType creatureType) { public void setCreatureType(CreatureType creatureType) {
spawner.h = creatureType.getName(); spawner.mobName = creatureType.getName();
} }
public String getCreatureTypeId() { public String getCreatureTypeId() {
return spawner.h; return spawner.mobName;
} }
public void setCreatureTypeId(String creatureType) { public void setCreatureTypeId(String creatureType) {
@ -35,15 +35,15 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
if (type == null) { if (type == null) {
return; return;
} }
spawner.h = type.getName(); spawner.mobName = type.getName();
} }
public int getDelay() { public int getDelay() {
return spawner.a; return spawner.spawnDelay;
} }
public void setDelay(int delay) { public void setDelay(int delay) {
spawner.a = delay; spawner.spawnDelay = delay;
} }
} }

View file

@ -36,7 +36,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
synchronized (block) { synchronized (block) {
if (block.getType() == Material.DISPENSER) { if (block.getType() == Material.DISPENSER) {
BlockDispenser dispense = (BlockDispenser)net.minecraft.server.Block.DISPENSER; BlockDispenser dispense = (BlockDispenser)net.minecraft.server.Block.DISPENSER;
dispense.b(world.getHandle(), getX(), getY(), getZ(), new Random()); dispense.dispense(world.getHandle(), getX(), getY(), getZ(), new Random());
return true; return true;
} else { } else {
return false; return false;
@ -49,7 +49,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
boolean result = super.update(force); boolean result = super.update(force);
if (result) { if (result) {
dispenser.i(); dispenser.update();
} }
return result; return result;

View file

@ -32,25 +32,25 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
boolean result = super.update(force); boolean result = super.update(force);
if (result) { if (result) {
furnace.i(); furnace.update();
} }
return result; return result;
} }
public short getBurnTime() { public short getBurnTime() {
return (short)furnace.a; return (short)furnace.burnTime;
} }
public void setBurnTime(short burnTime) { public void setBurnTime(short burnTime) {
furnace.a = burnTime; furnace.burnTime = burnTime;
} }
public short getCookTime() { public short getCookTime() {
return (short)furnace.c; return (short)furnace.cookTime;
} }
public void setCookTime(short cookTime) { public void setCookTime(short cookTime) {
furnace.c = cookTime; furnace.cookTime = cookTime;
} }
} }

View file

@ -23,11 +23,11 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
} }
public byte getNote() { public byte getNote() {
return note.a; return note.note;
} }
public void setNote(byte n) { public void setNote(byte n) {
note.a = n; note.note = n;
} }
public boolean play() { public boolean play() {
@ -35,7 +35,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
synchronized (block) { synchronized (block) {
if (block.getType() == Material.NOTE_BLOCK) { if (block.getType() == Material.NOTE_BLOCK) {
note.a(world.getHandle(), getX(), getY(), getZ()); note.play(world.getHandle(), getX(), getY(), getZ());
return true; return true;
} else { } else {
return false; return false;

View file

@ -17,15 +17,15 @@ public class CraftSign extends CraftBlockState implements Sign {
} }
public String[] getLines() { public String[] getLines() {
return sign.a; return sign.lines;
} }
public String getLine(int index) throws IndexOutOfBoundsException { public String getLine(int index) throws IndexOutOfBoundsException {
return sign.a[index]; return sign.lines[index];
} }
public void setLine(int index, String line) throws IndexOutOfBoundsException { public void setLine(int index, String line) throws IndexOutOfBoundsException {
sign.a[index] = line; sign.lines[index] = line;
} }
@Override @Override
@ -33,7 +33,7 @@ public class CraftSign extends CraftBlockState implements Sign {
boolean result = super.update(force); boolean result = super.update(force);
if (result) { if (result) {
sign.i(); sign.update();
} }
return result; return result;

View file

@ -14,18 +14,18 @@ public class CraftCreature extends CraftLivingEntity implements Creature{
public void setTarget(LivingEntity target) { public void setTarget(LivingEntity target) {
EntityCreature entity = getHandle(); EntityCreature entity = getHandle();
if (target == null) { if (target == null) {
entity.d = null; entity.target = null;
} else if (target instanceof CraftLivingEntity) { } else if (target instanceof CraftLivingEntity) {
EntityLiving victim = ((CraftLivingEntity) target).getHandle(); EntityLiving victim = ((CraftLivingEntity) target).getHandle();
entity.d = victim; entity.target = victim;
entity.a = entity.world.a(entity, entity.d, 16.0F); entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F);
} }
} }
public CraftLivingEntity getTarget() { public CraftLivingEntity getTarget() {
if (getHandle().d == null) return null; if (getHandle().target == null) return null;
return (CraftLivingEntity) getHandle().d.getBukkitEntity(); return (CraftLivingEntity) getHandle().target.getBukkitEntity();
} }
@Override @Override

Some files were not shown because too many files have changed in this diff Show more