summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server
diff options
context:
space:
mode:
authorErik Broes <erikbroes@grum.nl>2011-01-29 22:50:29 +0100
committerErik Broes <erikbroes@grum.nl>2011-01-30 13:24:39 +0100
commitdf69047324abc54f5d5b8d069bb69b1061b20cce (patch)
tree76f8d13addf80730deea9285f4bd9a1ffbe45f80 /src/main/java/net/minecraft/server
parentd0cd8c6cc7d1aaf38934996e7e5d3e03272e4ff1 (diff)
downloadcraftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar
craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.gz
craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.lz
craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.xz
craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.zip
Port to new mc-dev format.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r--src/main/java/net/minecraft/server/BlockButton.java228
-rw-r--r--src/main/java/net/minecraft/server/BlockCactus.java65
-rw-r--r--src/main/java/net/minecraft/server/BlockChest.java198
-rw-r--r--src/main/java/net/minecraft/server/BlockDoor.java190
-rw-r--r--src/main/java/net/minecraft/server/BlockFire.java239
-rw-r--r--src/main/java/net/minecraft/server/BlockFlowing.java357
-rw-r--r--src/main/java/net/minecraft/server/BlockFurnace.java82
-rw-r--r--src/main/java/net/minecraft/server/BlockJukeBox.java50
-rw-r--r--src/main/java/net/minecraft/server/BlockLeaves.java161
-rw-r--r--src/main/java/net/minecraft/server/BlockLever.java193
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlate.java127
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneTorch.java141
-rw-r--r--src/main/java/net/minecraft/server/BlockRedstoneWire.java412
-rw-r--r--src/main/java/net/minecraft/server/BlockStationary.java79
-rw-r--r--src/main/java/net/minecraft/server/BlockWorkbench.java32
-rw-r--r--src/main/java/net/minecraft/server/ChunkProviderServer.java197
-rw-r--r--src/main/java/net/minecraft/server/Entity.java1280
-rw-r--r--src/main/java/net/minecraft/server/EntityAnimal.java (renamed from src/main/java/net/minecraft/server/EntityAnimals.java)21
-rw-r--r--src/main/java/net/minecraft/server/EntityArrow.java368
-rw-r--r--src/main/java/net/minecraft/server/EntityBoat.java521
-rw-r--r--src/main/java/net/minecraft/server/EntityChicken.java69
-rw-r--r--src/main/java/net/minecraft/server/EntityCow.java19
-rw-r--r--src/main/java/net/minecraft/server/EntityCreature.java219
-rw-r--r--src/main/java/net/minecraft/server/EntityCreeper.java77
-rw-r--r--src/main/java/net/minecraft/server/EntityEgg.java368
-rw-r--r--src/main/java/net/minecraft/server/EntityFallingSand.java100
-rw-r--r--src/main/java/net/minecraft/server/EntityFireball.java271
-rw-r--r--src/main/java/net/minecraft/server/EntityFish.java568
-rw-r--r--src/main/java/net/minecraft/server/EntityFlying.java71
-rw-r--r--src/main/java/net/minecraft/server/EntityGhast.java166
-rw-r--r--src/main/java/net/minecraft/server/EntityGiantZombie.java28
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java391
-rw-r--r--src/main/java/net/minecraft/server/EntityItem.java250
-rw-r--r--src/main/java/net/minecraft/server/EntityList.java100
-rw-r--r--src/main/java/net/minecraft/server/EntityLiving.java934
-rw-r--r--src/main/java/net/minecraft/server/EntityMinecart.java1153
-rw-r--r--src/main/java/net/minecraft/server/EntityMobs.java135
-rw-r--r--src/main/java/net/minecraft/server/EntityMonster.java132
-rw-r--r--src/main/java/net/minecraft/server/EntityPainting.java244
-rw-r--r--src/main/java/net/minecraft/server/EntityPig.java29
-rw-r--r--src/main/java/net/minecraft/server/EntityPigZombie.java70
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java501
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayerMP.java292
-rw-r--r--src/main/java/net/minecraft/server/EntitySheep.java96
-rw-r--r--src/main/java/net/minecraft/server/EntitySkeleton.java74
-rw-r--r--src/main/java/net/minecraft/server/EntitySlime.java138
-rw-r--r--src/main/java/net/minecraft/server/EntitySnowball.java324
-rw-r--r--src/main/java/net/minecraft/server/EntitySpider.java64
-rw-r--r--src/main/java/net/minecraft/server/EntitySquid.java165
-rw-r--r--src/main/java/net/minecraft/server/EntityTNTPrimed.java76
-rw-r--r--src/main/java/net/minecraft/server/EntityTracker.java155
-rw-r--r--src/main/java/net/minecraft/server/EntityTrackerEntry.java252
-rw-r--r--src/main/java/net/minecraft/server/EntityWaterAnimal.java (renamed from src/main/java/net/minecraft/server/EntityWaterMob.java)9
-rw-r--r--src/main/java/net/minecraft/server/EntityZombie.java24
-rw-r--r--src/main/java/net/minecraft/server/EntityZombieSimple.java27
-rw-r--r--src/main/java/net/minecraft/server/Explosion.java320
-rw-r--r--src/main/java/net/minecraft/server/IInventory.java44
-rw-r--r--src/main/java/net/minecraft/server/InventoryCraftResult.java104
-rw-r--r--src/main/java/net/minecraft/server/InventoryCrafting.java166
-rw-r--r--src/main/java/net/minecraft/server/InventoryLargeChest.java130
-rw-r--r--src/main/java/net/minecraft/server/InventoryPlayer.java686
-rw-r--r--src/main/java/net/minecraft/server/ItemBlock.java147
-rw-r--r--src/main/java/net/minecraft/server/ItemBoat.java82
-rw-r--r--src/main/java/net/minecraft/server/ItemBucket.java214
-rw-r--r--src/main/java/net/minecraft/server/ItemFlintAndSteel.java58
-rw-r--r--src/main/java/net/minecraft/server/ItemHoe.java90
-rw-r--r--src/main/java/net/minecraft/server/ItemInWorldManager.java154
-rw-r--r--src/main/java/net/minecraft/server/ItemMinecart.java54
-rw-r--r--src/main/java/net/minecraft/server/ItemRedstone.java63
-rw-r--r--src/main/java/net/minecraft/server/ItemSeeds.java55
-rw-r--r--src/main/java/net/minecraft/server/ItemSign.java113
-rw-r--r--src/main/java/net/minecraft/server/ItemStack.java143
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java567
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java832
-rw-r--r--src/main/java/net/minecraft/server/PropertyManager.java58
-rw-r--r--src/main/java/net/minecraft/server/ServerConfigurationManager.java337
-rw-r--r--src/main/java/net/minecraft/server/Slot.java24
-rw-r--r--src/main/java/net/minecraft/server/ThreadCommandReader.java26
-rw-r--r--src/main/java/net/minecraft/server/TileEntityChest.java69
-rw-r--r--src/main/java/net/minecraft/server/TileEntityFurnace.java198
-rw-r--r--src/main/java/net/minecraft/server/TileEntityMobSpawner.java136
-rw-r--r--src/main/java/net/minecraft/server/WorldServer.java227
82 files changed, 8527 insertions, 9102 deletions
diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java
index 3a82ea91..b3e3283c 100644
--- a/src/main/java/net/minecraft/server/BlockButton.java
+++ b/src/main/java/net/minecraft/server/BlockButton.java
@@ -17,8 +17,8 @@ import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockButton extends Block {
protected BlockButton(int i, int j) {
- super(i, j, Material.n);
- a(true);
+ super(i, j, Material.ORIENTABLE);
+ this.a(true);
}
public AxisAlignedBB d(World world, int i, int j, int k) {
@@ -34,35 +34,30 @@ public class BlockButton extends Block {
}
public boolean a(World world, int i, int j, int k) {
- if (world.d(i - 1, j, k)) {
- return true;
- }
- if (world.d(i + 1, j, k)) {
- return true;
- }
- if (world.d(i, j, k - 1)) {
- return true;
- }
- return world.d(i, j, k + 1);
+ 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 c(World world, int i, int j, int k, int l) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
int j1 = i1 & 8;
i1 &= 7;
if (l == 2 && world.d(i, j, k + 1)) {
i1 = 4;
}
+
if (l == 3 && world.d(i, j, k - 1)) {
i1 = 3;
}
+
if (l == 4 && world.d(i + 1, j, k)) {
i1 = 2;
}
+
if (l == 5 && world.d(i - 1, j, k)) {
i1 = 1;
}
+
world.c(i, j, k, i1 + j1);
}
@@ -76,36 +71,41 @@ public class BlockButton extends Block {
} else if (world.d(i, j, k + 1)) {
world.c(i, j, k, 4);
}
- g(world, i, j, k);
+
+ this.g(world, i, j, k);
}
public void b(World world, int i, int j, int k, int l) {
- if (g(world, i, j, k)) {
- int i1 = world.b(i, j, k) & 7;
+ if (this.g(world, i, j, k)) {
+ int i1 = world.getData(i, j, k) & 7;
boolean flag = false;
if (!world.d(i - 1, j, k) && i1 == 1) {
flag = true;
}
+
if (!world.d(i + 1, j, k) && i1 == 2) {
flag = true;
}
+
if (!world.d(i, j, k - 1) && i1 == 3) {
flag = true;
}
+
if (!world.d(i, j, k + 1) && i1 == 4) {
flag = true;
}
+
if (flag) {
- a_(world, i, j, k, world.b(i, j, k));
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
}
}
}
private boolean g(World world, int i, int j, int k) {
- if (!a(world, i, j, k)) {
- a_(world, i, j, k, world.b(i, j, k));
+ if (!this.a(world, i, j, k)) {
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
return false;
} else {
@@ -114,7 +114,7 @@ public class BlockButton extends Block {
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
- int l = iblockaccess.b(i, j, k);
+ int l = iblockaccess.getData(i, j, k);
int i1 = l & 7;
boolean flag = (l & 8) > 0;
float f = 0.375F;
@@ -125,122 +125,113 @@ public class BlockButton extends Block {
if (flag) {
f3 = 0.0625F;
}
+
if (i1 == 1) {
- a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
+ this.a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
} else if (i1 == 2) {
- a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
+ this.a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
} else if (i1 == 3) {
- a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
+ this.a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
} else if (i1 == 4) {
- a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
+ this.a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
}
}
- public void b(World world, int i, int j, int k, EntityPlayer entityplayer) {
- a(world, i, j, k, entityplayer);
+ public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
+ this.a(world, i, j, k, entityhuman);
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- // CraftBukkit start - Interact Button
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.BLOCK_INTERACT;
- CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) {
- return true;
- }
- // CraftBukkit end
-
-
- if (world.z) {
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (world.isStatic) {
return true;
- }
- int l = world.b(i, j, k);
- int i1 = l & 7;
- int j1 = 8 - (l & 8);
+ } else {
+ // CraftBukkit start - Interact Button
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
- if (j1 == 0) {
- return true;
- }
+ int l = world.getData(i, j, k);
+ int i1 = l & 7;
+ int j1 = 8 - (l & 8);
- //Allow the lever to change the current
- int old = (j1 != 8) ? 1 : 0;
- int current = (j1 == 8) ? 1 : 0;
- BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
- server.getPluginManager().callEvent(bre);
- if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
- world.c(i, j, k, i1 + j1);
- world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
- world.h(i, j, k, bi);
- if (i1 == 1) {
- world.h(i - 1, j, k, bi);
- } else if (i1 == 2) {
- world.h(i + 1, j, k, bi);
- } else if (i1 == 3) {
- world.h(i, j, k - 1, bi);
- } else if (i1 == 4) {
- world.h(i, j, k + 1, bi);
+ if (j1 == 0) {
+ return true;
} else {
- world.h(i, j - 1, k, bi);
+ //Allow the lever to change the current
+ int old = (j1 != 8) ? 1 : 0;
+ int current = (j1 == 8) ? 1 : 0;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
+ server.getPluginManager().callEvent(eventRedstone);
+ if ((eventRedstone.getNewCurrent() > 0) == (j1 == 8)) {
+ world.c(i, j, k, i1 + j1);
+ world.b(i, j, k, i, j, k);
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
+ world.h(i, j, k, this.id);
+ if (i1 == 1) {
+ world.h(i - 1, j, k, this.id);
+ } else if (i1 == 2) {
+ world.h(i + 1, j, k, this.id);
+ } else if (i1 == 3) {
+ world.h(i, j, k - 1, this.id);
+ } else if (i1 == 4) {
+ world.h(i, j, k + 1, this.id);
+ } else {
+ world.h(i, j - 1, k, this.id);
+ }
+ world.i(i, j, k, this.id);
+ }
+ return true;
}
- world.i(i, j, k, bi);
}
- return true;
}
public void b(World world, int i, int j, int k) {
- int l = world.b(i, j, k);
+ int l = world.getData(i, j, k);
if ((l & 8) > 0) {
- world.h(i, j, k, bi);
+ world.h(i, j, k, this.id);
int i1 = l & 7;
if (i1 == 1) {
- world.h(i - 1, j, k, bi);
+ world.h(i - 1, j, k, this.id);
} else if (i1 == 2) {
- world.h(i + 1, j, k, bi);
+ world.h(i + 1, j, k, this.id);
} else if (i1 == 3) {
- world.h(i, j, k - 1, bi);
+ world.h(i, j, k - 1, this.id);
} else if (i1 == 4) {
- world.h(i, j, k + 1, bi);
+ world.h(i, j, k + 1, this.id);
} else {
- world.h(i, j - 1, k, bi);
+ world.h(i, j - 1, k, this.id);
}
}
+
super.b(world, i, j, k);
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- return (iblockaccess.b(i, j, k) & 8) > 0;
+ return (iblockaccess.getData(i, j, k) & 8) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
if ((i1 & 8) == 0) {
return false;
- }
- int j1 = i1 & 7;
+ } else {
+ int j1 = i1 & 7;
- if (j1 == 5 && l == 1) {
- return true;
- }
- if (j1 == 4 && l == 2) {
- return true;
- }
- if (j1 == 3 && l == 3) {
- return true;
+ return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5)));
}
- if (j1 == 2 && l == 4) {
- return true;
- }
- return j1 == 1 && l == 5;
}
public boolean c() {
@@ -248,30 +239,29 @@ public class BlockButton extends Block {
}
public void a(World world, int i, int j, int k, Random random) {
- if (world.z) {
- return;
- }
- int l = world.b(i, j, k);
-
- if ((l & 8) == 0) {
- return;
- }
- world.c(i, j, k, l & 7);
- world.h(i, j, k, bi);
- int i1 = l & 7;
-
- if (i1 == 1) {
- world.h(i - 1, j, k, bi);
- } else if (i1 == 2) {
- world.h(i + 1, j, k, bi);
- } else if (i1 == 3) {
- world.h(i, j, k - 1, bi);
- } else if (i1 == 4) {
- world.h(i, j, k + 1, bi);
- } else {
- world.h(i, j - 1, k, bi);
+ if (!world.isStatic) {
+ int l = world.getData(i, j, k);
+
+ if ((l & 8) != 0) {
+ world.c(i, j, k, l & 7);
+ world.h(i, j, k, this.id);
+ int i1 = l & 7;
+
+ if (i1 == 1) {
+ world.h(i - 1, j, k, this.id);
+ } else if (i1 == 2) {
+ world.h(i + 1, j, k, this.id);
+ } else if (i1 == 3) {
+ world.h(i, j, k - 1, this.id);
+ } else if (i1 == 4) {
+ world.h(i, j, k + 1, this.id);
+ } else {
+ world.h(i, j - 1, k, this.id);
+ }
+
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
+ world.b(i, j, k, i, j, k);
+ }
}
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
- world.b(i, j, k, i, j, k);
}
}
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
index 64a3455a..e71e0f4e 100644
--- a/src/main/java/net/minecraft/server/BlockCactus.java
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
@@ -12,22 +12,23 @@ import java.util.Random;
public class BlockCactus extends Block {
protected BlockCactus(int i, int j) {
- super(i, j, Material.u);
- a(true);
+ super(i, j, Material.CACTUS);
+ this.a(true);
}
public void a(World world, int i, int j, int k, Random random) {
- if (world.e(i, j + 1, k)) {
+ if (world.isEmpty(i, j + 1, k)) {
int l;
- for (l = 1; world.a(i, j - l, k) == bi; l++) {
+ for (l = 1; world.getTypeId(i, j - l, k) == this.id; ++l) {
;
}
+
if (l < 3) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
if (i1 == 15) {
- world.e(i, j + 1, k, bi);
+ world.e(i, j + 1, k, this.id);
world.c(i, j, k, 0);
} else {
world.c(i, j, k, i1 + 1);
@@ -37,20 +38,13 @@ public class BlockCactus extends Block {
}
public AxisAlignedBB d(World world, int i, int j, int k) {
- float f1 = 0.0625F;
+ float f = 0.0625F;
- return AxisAlignedBB.b((float) i + f1, j, (float) k + f1, (float) (i + 1) - f1, (float) (j + 1) - f1, (float) (k + 1) - f1);
+ return AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f));
}
public int a(int i) {
- if (i == 1) {
- return bh - 1;
- }
- if (i == 0) {
- return bh + 1;
- } else {
- return bh;
- }
+ return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId + 1 : this.textureId);
}
public boolean a() {
@@ -58,42 +52,34 @@ public class BlockCactus extends Block {
}
public boolean a(World world, int i, int j, int k) {
- if (!super.a(world, i, j, k)) {
- return false;
- } else {
- return f(world, i, j, k);
- }
+ return !super.a(world, i, j, k) ? false : this.f(world, i, j, k);
}
public void b(World world, int i, int j, int k, int l) {
- if (!f(world, i, j, k)) {
- a_(world, i, j, k, world.b(i, j, k));
+ if (!this.f(world, i, j, k)) {
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
}
}
public boolean f(World world, int i, int j, int k) {
- if (world.c(i - 1, j, k).a()) {
+ if (world.getMaterial(i - 1, j, k).isBuildable()) {
return false;
- }
- if (world.c(i + 1, j, k).a()) {
+ } else if (world.getMaterial(i + 1, j, k).isBuildable()) {
return false;
- }
- if (world.c(i, j, k - 1).a()) {
+ } else if (world.getMaterial(i, j, k - 1).isBuildable()) {
return false;
- }
- if (world.c(i, j, k + 1).a()) {
+ } else if (world.getMaterial(i, j, k + 1).isBuildable()) {
return false;
} else {
- int l = world.a(i, j - 1, k);
+ int l = world.getTypeId(i, j - 1, k);
- return l == Block.aV.bi || l == Block.E.bi;
+ return l == Block.CACTUS.id || l == Block.SAND.id;
}
}
public void a(World world, int i, int j, int k, Entity entity) {
// CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event
-
if(entity instanceof EntityLiving) {
CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
@@ -101,16 +87,15 @@ public class BlockCactus extends Block {
DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT;
int damageDone = 1;
- EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(edbbe);
+ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
- if (!edbbe.isCancelled()){
- entity.a(((Entity) (null)), edbbe.getDamage());
+ if (!event.isCancelled()){
+ entity.a((Entity) null, event.getDamage());
}
return;
- } else {
- entity.a(((Entity) (null)), 1);
}
- // CraftBukkit end
+ // CraftBukkit end
+ entity.a((Entity) null, 1);
}
}
diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java
index 607990df..c74ffa0f 100644
--- a/src/main/java/net/minecraft/server/BlockChest.java
+++ b/src/main/java/net/minecraft/server/BlockChest.java
@@ -14,163 +14,129 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockChest extends BlockContainer {
- private Random a;
+ private Random a = new Random();
protected BlockChest(int i) {
- super(i, Material.c);
- a = new Random();
- bh = 26;
+ super(i, Material.WOOD);
+ this.textureId = 26;
}
public int a(int i) {
- if (i == 1) {
- return bh - 1;
- }
- if (i == 0) {
- return bh - 1;
- }
- if (i == 3) {
- return bh + 1;
- } else {
- return bh;
- }
+ return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId - 1 : (i == 3 ? this.textureId + 1 : this.textureId));
}
public boolean a(World world, int i, int j, int k) {
int l = 0;
- if (world.a(i - 1, j, k) == bi) {
- l++;
- }
- if (world.a(i + 1, j, k) == bi) {
- l++;
- }
- if (world.a(i, j, k - 1) == bi) {
- l++;
+ if (world.getTypeId(i - 1, j, k) == this.id) {
+ ++l;
}
- if (world.a(i, j, k + 1) == bi) {
- l++;
- }
- if (l > 1) {
- return false;
- }
- if (g(world, i - 1, j, k)) {
- return false;
+
+ if (world.getTypeId(i + 1, j, k) == this.id) {
+ ++l;
}
- if (g(world, i + 1, j, k)) {
- return false;
+
+ if (world.getTypeId(i, j, k - 1) == this.id) {
+ ++l;
}
- if (g(world, i, j, k - 1)) {
- return false;
+
+ if (world.getTypeId(i, j, k + 1) == this.id) {
+ ++l;
}
- return !g(world, i, j, k + 1);
+
+ return l > 1 ? false : (this.g(world, i - 1, j, k) ? false : (this.g(world, i + 1, j, k) ? false : (this.g(world, i, j, k - 1) ? false : !this.g(world, i, j, k + 1))));
}
private boolean g(World world, int i, int j, int k) {
- if (world.a(i, j, k) != bi) {
- return false;
- }
- if (world.a(i - 1, j, k) == bi) {
- return true;
- }
- if (world.a(i + 1, j, k) == bi) {
- return true;
- }
- if (world.a(i, j, k - 1) == bi) {
- return true;
- }
- return world.a(i, j, k + 1) == bi;
+ return world.getTypeId(i, j, k) != this.id ? false : (world.getTypeId(i - 1, j, k) == this.id ? true : (world.getTypeId(i + 1, j, k) == this.id ? true : (world.getTypeId(i, j, k - 1) == this.id ? true : world.getTypeId(i, j, k + 1) == this.id)));
}
public void b(World world, int i, int j, int k) {
- TileEntityChest tileentitychest = (TileEntityChest) world.m(i, j, k);
+ TileEntityChest tileentitychest = (TileEntityChest) world.getTileEntity(i, j, k);
- label0:
- for (int l = 0; l < ((IInventory) (tileentitychest)).h_(); l++) {
- ItemStack itemstack = ((IInventory) (tileentitychest)).a(l);
+ for (int l = 0; l < tileentitychest.h_(); ++l) {
+ ItemStack itemstack = tileentitychest.a(l);
- if (itemstack == null) {
- continue;
- }
- float f = a.nextFloat() * 0.8F + 0.1F;
- float f1 = a.nextFloat() * 0.8F + 0.1F;
- float f2 = a.nextFloat() * 0.8F + 0.1F;
+ if (itemstack != null) {
+ float f = this.a.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.a.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.a.nextFloat() * 0.8F + 0.1F;
- do {
- if (itemstack.a <= 0) {
- continue label0;
- }
- int i1 = a.nextInt(21) + 10;
+ while (itemstack.count > 0) {
+ int i1 = this.a.nextInt(21) + 10;
- if (i1 > itemstack.a) {
- i1 = itemstack.a;
+ if (i1 > itemstack.count) {
+ i1 = itemstack.count;
+ }
+
+ itemstack.count -= i1;
+ EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.h()));
+ float f3 = 0.05F;
+
+ entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
+ entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
+ entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
+ world.a((Entity) entityitem);
}
- itemstack.a -= i1;
- EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.c, i1, itemstack.h()));
- float f3 = 0.05F;
-
- entityitem.s = (float) a.nextGaussian() * f3;
- entityitem.t = (float) a.nextGaussian() * f3 + 0.2F;
- entityitem.u = (float) a.nextGaussian() * f3;
- world.a(((Entity) (entityitem)));
- } while (true);
+ }
}
super.b(world, i, j, k);
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- Object obj = (((TileEntityChest) world.m(i, j, k)));
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ Object object = (TileEntityChest) world.getTileEntity(i, j, k);
if (world.d(i, j + 1, k)) {
return true;
- }
- if (world.a(i - 1, j, k) == bi && world.d(i - 1, j + 1, k)) {
- return true;
- }
- if (world.a(i + 1, j, k) == bi && world.d(i + 1, j + 1, k)) {
+ } else if (world.getTypeId(i - 1, j, k) == this.id && world.d(i - 1, j + 1, k)) {
return true;
- }
- if (world.a(i, j, k - 1) == bi && world.d(i, j + 1, k - 1)) {
+ } else if (world.getTypeId(i + 1, j, k) == this.id && world.d(i + 1, j + 1, k)) {
return true;
- }
- if (world.a(i, j, k + 1) == bi && world.d(i, j + 1, k + 1)) {
+ } else if (world.getTypeId(i, j, k - 1) == this.id && world.d(i, j + 1, k - 1)) {
return true;
- }
- if (world.a(i - 1, j, k) == bi) {
- obj = ((new InventoryLargeChest("Large chest", ((IInventory) ((TileEntityChest) world.m(i - 1, j, k))), ((IInventory) (obj)))));
- }
- if (world.a(i + 1, j, k) == bi) {
- obj = ((new InventoryLargeChest("Large chest", ((IInventory) (obj)), ((IInventory) ((TileEntityChest) world.m(i + 1, j, k))))));
- }
- if (world.a(i, j, k - 1) == bi) {
- obj = ((new InventoryLargeChest("Large chest", ((IInventory) ((TileEntityChest) world.m(i, j, k - 1))), ((IInventory) (obj)))));
- }
- if (world.a(i, j, k + 1) == bi) {
- obj = ((new InventoryLargeChest("Large chest", ((IInventory) (obj)), ((IInventory) ((TileEntityChest) world.m(i, j, k + 1))))));
- }
- if (world.z) {
+ } else if (world.getTypeId(i, j, k + 1) == this.id && world.d(i, j + 1, k + 1)) {
return true;
} else {
- // CraftBukkit start - Interact Chest
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.BLOCK_INTERACT;
- CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) return true;
- // CraftBukkit end
-
- entityplayer.a(((IInventory) (obj)));
- return true;
+ if (world.getTypeId(i - 1, j, k) == this.id) {
+ object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i - 1, j, k), (IInventory) object);
+ }
+
+ if (world.getTypeId(i + 1, j, k) == this.id) {
+ object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i + 1, j, k));
+ }
+
+ if (world.getTypeId(i, j, k - 1) == this.id) {
+ object = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(i, j, k - 1), (IInventory) object);
+ }
+
+ if (world.getTypeId(i, j, k + 1) == this.id) {
+ object = new InventoryLargeChest("Large chest", (IInventory) object, (TileEntityChest) world.getTileEntity(i, j, k + 1));
+ }
+
+ if (world.isStatic) {
+ return true;
+ } else {
+ // CraftBukkit start - Interact Chest
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) return true;
+ // CraftBukkit end
+
+ entityhuman.a((IInventory) object);
+ return true;
+ }
}
}
protected TileEntity a_() {
- return ((TileEntity) (new TileEntityChest()));
+ return new TileEntityChest();
}
}
diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java
index 33c577e1..da7fb166 100644
--- a/src/main/java/net/minecraft/server/BlockDoor.java
+++ b/src/main/java/net/minecraft/server/BlockDoor.java
@@ -16,14 +16,15 @@ public class BlockDoor extends Block {
protected BlockDoor(int i, Material material) {
super(i, material);
- bh = 97;
- if (material == Material.e) {
- bh++;
+ this.textureId = 97;
+ if (material == Material.ORE) {
+ ++this.textureId;
}
+
float f = 0.5F;
float f1 = 1.0F;
- a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
+ this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
}
public boolean a() {
@@ -31,170 +32,165 @@ public class BlockDoor extends Block {
}
public AxisAlignedBB d(World world, int i, int j, int k) {
- a(((IBlockAccess) (world)), i, j, k);
+ this.a((IBlockAccess) world, i, j, k);
return super.d(world, i, j, k);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
- c(d(iblockaccess.b(i, j, k)));
+ this.c(this.d(iblockaccess.getData(i, j, k)));
}
public void c(int i) {
float f = 0.1875F;
- a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
if (i == 0) {
- a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}
+
if (i == 1) {
- a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+ this.a(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
+
if (i == 2) {
- a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
+ this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}
+
if (i == 3) {
- a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
+ this.a(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}
- public void b(World world, int i, int j, int k, EntityPlayer entityplayer) {
- a(world, i, j, k, entityplayer);
+ public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
+ this.a(world, i, j, k, entityhuman);
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- if (bt == Material.e) {
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (this.material == Material.ORE) {
return true;
- }
- int l = world.b(i, j, k);
+ } else {
+ int l = world.getData(i, j, k);
- if ((l & 8) != 0) {
- if (world.a(i, j - 1, k) == bi) {
- a(world, i, j - 1, k, entityplayer);
- }
- return true;
- }
+ if ((l & 8) != 0) {
+ if (world.getTypeId(i, j - 1, k) == this.id) {
+ this.a(world, i, j - 1, k, entityhuman);
+ }
- // CraftBukkit start - Interact Door
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.BLOCK_INTERACT;
- CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
-
- // CraftBukkit the client updates the doors before the server does it's thing.
- // Forcibly send correct data.
- if (bie.isCancelled()) {
- ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
- ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world));
- return true;
- }
- // CraftBukkit end
+ return true;
+ } else {
+ // CraftBukkit start - Interact Door
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ // CraftBukkit the client updates the doors before the server does it's thing.
+ // Forcibly send correct data.
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
+ ((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j + 1, k, (WorldServer) world));
+ return true;
+ }
+ // CraftBukkit end
- if (world.a(i, j + 1, k) == bi) {
- world.c(i, j + 1, k, (l ^ 4) + 8);
- }
- world.c(i, j, k, l ^ 4);
- world.b(i, j - 1, k, i, j, k);
- if (Math.random() < 0.5D) {
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
- } else {
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ if (world.getTypeId(i, j + 1, k) == this.id) {
+ world.c(i, j + 1, k, (l ^ 4) + 8);
+ }
+
+ world.c(i, j, k, l ^ 4);
+ world.b(i, j - 1, k, i, j, k);
+ if (Math.random() < 0.5D) {
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ } else {
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ }
+
+ return true;
+ }
}
- return true;
}
public void a(World world, int i, int j, int k, boolean flag) {
- int l = world.b(i, j, k);
+ int l = world.getData(i, j, k);
if ((l & 8) != 0) {
- if (world.a(i, j - 1, k) == bi) {
- a(world, i, j - 1, k, flag);
+ if (world.getTypeId(i, j - 1, k) == this.id) {
+ this.a(world, i, j - 1, k, flag);
}
- return;
- }
- boolean flag1 = (world.b(i, j, k) & 4) > 0;
-
- if (flag1 == flag) {
- return;
- }
- if (world.a(i, j + 1, k) == bi) {
- world.c(i, j + 1, k, (l ^ 4) + 8);
- }
- world.c(i, j, k, l ^ 4);
- world.b(i, j - 1, k, i, j, k);
- if (Math.random() < 0.5D) {
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
} else {
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ boolean flag1 = (world.getData(i, j, k) & 4) > 0;
+
+ if (flag1 != flag) {
+ if (world.getTypeId(i, j + 1, k) == this.id) {
+ world.c(i, j + 1, k, (l ^ 4) + 8);
+ }
+
+ world.c(i, j, k, l ^ 4);
+ world.b(i, j - 1, k, i, j, k);
+ if (Math.random() < 0.5D) {
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_open", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ } else {
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.door_close", 1.0F, world.l.nextFloat() * 0.1F + 0.9F);
+ }
+ }
}
}
public void b(World world, int i, int j, int k, int l) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
if ((i1 & 8) != 0) {
- if (world.a(i, j - 1, k) != bi) {
+ if (world.getTypeId(i, j - 1, k) != this.id) {
world.e(i, j, k, 0);
}
- if (l > 0 && Block.m[l].c()) {
- b(world, i, j - 1, k, l);
+
+ if (l > 0 && Block.byId[l].c()) {
+ this.b(world, i, j - 1, k, l);
}
} else {
boolean flag = false;
- if (world.a(i, j + 1, k) != bi) {
+ if (world.getTypeId(i, j + 1, k) != this.id) {
world.e(i, j, k, 0);
flag = true;
}
+
if (!world.d(i, j - 1, k)) {
world.e(i, j, k, 0);
flag = true;
- if (world.a(i, j + 1, k) == bi) {
+ if (world.getTypeId(i, j + 1, k) == this.id) {
world.e(i, j + 1, k, 0);
}
}
+
if (flag) {
- a_(world, i, j, k, i1);
- } else if (l > 0 && Block.m[l].c()) {
+ this.a_(world, i, j, k, i1);
+ } else if (l > 0 && Block.byId[l].c()) {
boolean flag1 = world.p(i, j, k) || world.p(i, j + 1, k);
- a(world, i, j, k, flag1);
+ this.a(world, i, j, k, flag1);
}
}
}
public int a(int i, Random random) {
- if ((i & 8) != 0) {
- return 0;
- }
- if (bt == Material.e) {
- return Item.az.ba;
- } else {
- return Item.at.ba;
- }
+ return (i & 8) != 0 ? 0 : (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id);
}
public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) {
- a(((IBlockAccess) (world)), i, j, k);
+ this.a((IBlockAccess) world, i, j, k);
return super.a(world, i, j, k, vec3d, vec3d1);
}
public int d(int i) {
- if ((i & 4) == 0) {
- return i - 1 & 3;
- } else {
- return i & 3;
- }
+ return (i & 4) == 0 ? i - 1 & 3 : i & 3;
}
public boolean a(World world, int i, int j, int k) {
- if (j >= 127) {
- return false;
- } else {
- return 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.a(world, i, j, k) && super.a(world, i, j + 1, k);
}
}
diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java
index 96eb7983..f7ec1ea4 100644
--- a/src/main/java/net/minecraft/server/BlockFire.java
+++ b/src/main/java/net/minecraft/server/BlockFire.java
@@ -1,36 +1,35 @@
package net.minecraft.server;
+import java.util.Random;
+
// CraftBukkit start
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.craftbukkit.CraftWorld;
-import java.util.Random;
import org.bukkit.event.block.BlockBurnEvent;
// CraftBukkit end
public class BlockFire extends Block {
- private int a[];
- private int b[];
+ private int[] a = new int[256];
+ private int[] b = new int[256];
protected BlockFire(int i, int j) {
- super(i, j, Material.l);
- a = new int[256];
- b = new int[256];
- a(Block.x.bi, 5, 20);
- a(Block.J.bi, 5, 5);
- a(Block.K.bi, 30, 60);
- a(Block.an.bi, 30, 20);
- a(Block.am.bi, 15, 100);
- a(Block.ab.bi, 30, 60);
- a(true);
+ super(i, j, Material.FIRE);
+ this.a(Block.WOOD.id, 5, 20);
+ this.a(Block.LOG.id, 5, 5);
+ this.a(Block.LEAVES.id, 30, 60);
+ this.a(Block.BOOKSHELF.id, 30, 20);
+ this.a(Block.TNT.id, 15, 100);
+ this.a(Block.WOOL.id, 30, 60);
+ this.a(true);
}
private void a(int i, int j, int k) {
- a[i] = j;
- b[i] = k;
+ this.a[i] = j;
+ this.b[i] = k;
}
public AxisAlignedBB d(World world, int i, int j, int k) {
@@ -50,62 +49,66 @@ public class BlockFire extends Block {
}
public void a(World world, int i, int j, int k, Random random) {
- boolean flag = world.a(i, j - 1, k) == Block.bb.bi;
- int l = world.b(i, j, k);
+ boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id;
+ int l = world.getData(i, j, k);
if (l < 15) {
world.c(i, j, k, l + 1);
- world.i(i, j, k, bi);
+ world.i(i, j, k, this.id);
}
- if (!flag && !g(world, i, j, k)) {
+
+ if (!flag && !this.g(world, i, j, k)) {
if (!world.d(i, j - 1, k) || l > 3) {
world.e(i, j, k, 0);
}
- return;
- }
- if (!flag && !b(((IBlockAccess) (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) { // CraftBukkit - Cast to IBlockAccess
world.e(i, j, k, 0);
- return;
- }
- if (l % 2 == 0 && l > 2) {
- a(world, i + 1, j, k, 300, random);
- a(world, i - 1, j, k, 300, random);
- a(world, i, j - 1, k, 250, random);
- a(world, i, j + 1, k, 250, random);
- a(world, i, j, k - 1, 300, random);
- a(world, i, j, k + 1, 300, random);
- for (int i1 = i - 1; i1 <= i + 1; i1++) {
- for (int j1 = k - 1; j1 <= k + 1; j1++) {
- for (int k1 = j - 1; k1 <= j + 4; k1++) {
- if (i1 == i && k1 == j && j1 == k) {
- continue;
- }
- int l1 = 100;
-
- if (k1 > j + 1) {
- l1 += (k1 - (j + 1)) * 100;
- }
- int i2 = h(world, i1, k1, j1);
-
- // CraftBukkit start: Call to stop spread of fire.
- Server server = ((WorldServer)world).getServer();
- CraftWorld cworld = ((WorldServer)world).getWorld();
-
- org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, k1, j1));
- IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
- Player thePlayer = null;
-
- if (theBlock.getTypeId() != Block.ar.bi){
- BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
- server.getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- continue;
+ } else {
+ if (l % 2 == 0 && l > 2) {
+ this.a(world, i + 1, j, k, 300, random);
+ this.a(world, i - 1, j, k, 300, random);
+ this.a(world, i, j - 1, k, 250, random);
+ this.a(world, i, j + 1, k, 250, random);
+ this.a(world, i, j, k - 1, 300, random);
+ this.a(world, i, j, k + 1, 300, random);
+
+ // CraftBukkit start - Call to stop spread of fire.
+ Server server = ((WorldServer)world).getServer();
+ CraftWorld cworld = ((WorldServer)world).getWorld();
+
+ IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD;
+ Player thePlayer = null;
+ // CraftBukkit
+
+ for (int i1 = i - 1; i1 <= i + 1; ++i1) {
+ for (int j1 = k - 1; j1 <= k + 1; ++j1) {
+ for (int k1 = j - 1; k1 <= j + 4; ++k1) {
+ if (i1 != i || k1 != j || j1 != k) {
+ int l1 = 100;
+
+ if (k1 > j + 1) {
+ l1 += (k1 - (j + 1)) * 100;
+ }
+
+ int i2 = this.h(world, i1, k1, j1);
+
+ if (i2 > 0 && random.nextInt(l1) <= i2) {
+ // CraftBukkit start - Call to stop spread of fire.
+ org.bukkit.block.Block theBlock = (cworld.getBlockAt(i1, k1, j1));
+
+ if (theBlock.getTypeId() != Block.FIRE.id){
+ BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ }
+ // CraftBukkit end
+
+ world.e(i1, k1, j1, this.id);
+ }
}
}
- // CraftBukkit end
- if (i2 > 0 && random.nextInt(l1) <= i2) {
- world.e(i1, k1, j1, bi);
- }
}
}
}
@@ -113,74 +116,43 @@ public class BlockFire extends Block {
}
private void a(World world, int i, int j, int k, int l, Random random) {
- int i1 = b[world.a(i, j, k)];
+ int i1 = this.b[world.getTypeId(i, j, k)];
if (random.nextInt(l) < i1) {
- boolean flag = world.a(i, j, k) == Block.am.bi;
- // CraftBukkit start: BlockBurnEvent
- Server server = ((WorldServer)world).getServer();
- CraftWorld cworld = ((WorldServer)world).getWorld();
- org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
- BlockBurnEvent burnEvent = new BlockBurnEvent(theBlock);
- server.getPluginManager().callEvent(burnEvent);
- if(!burnEvent.isCancelled()) {
- if (random.nextInt(2) == 0) {
- // CraftBukkit start: Call to stop very slow spread of fire.
-
- IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SLOW_SPREAD;
- Player thePlayer = null;
-
- if (theBlock.getTypeId() != Block.ar.bi){
- BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
- server.getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return;
- }
- }
- // CraftBukkit end
- world.e(i, j, k, bi);
- } else {
- world.e(i, j, k, 0);
- }
- if (flag) {
- Block.am.a(world, i, j, k, 0);
- }
+ boolean flag = world.getTypeId(i, j, k) == Block.TNT.id;
+
+ if (random.nextInt(2) == 0) {
+ world.e(i, j, k, this.id);
+ } else {
+ world.e(i, j, k, 0);
+ }
+
+ if (flag) {
+ Block.TNT.a(world, i, j, k, 0);
}
- // CraftBukkit end: BlockBurnEvent
}
}
- private boolean g(World world, int i, int j, int k) {
- if (b(((IBlockAccess) (world)), i + 1, j, k)) {
- return true;
- }
- if (b(((IBlockAccess) (world)), i - 1, j, k)) {
- return true;
- }
- if (b(((IBlockAccess) (world)), i, j - 1, k)) {
- return true;
- }
- if (b(((IBlockAccess) (world)), i, j + 1, k)) {
- return true;
- }
- if (b(((IBlockAccess) (world)), i, j, k - 1)) {
- return true;
- }
- return b(((IBlockAccess) (world)), i, j, k + 1);
+ // CraftBukkit start -- fix cast to IBlockAccess
+ 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)))));
}
private int h(World world, int i, int j, int k) {
- int l = 0;
+ byte b0 = 0;
- if (!world.e(i, j, k)) {
+ if (!world.isEmpty(i, j, k)) {
return 0;
} else {
- l = f(world, i + 1, j, k, l);
- l = f(world, i - 1, j, k, l);
- l = f(world, i, j - 1, k, l);
- l = f(world, i, j + 1, k, l);
- l = f(world, i, j, k - 1, l);
- l = f(world, i, j, k + 1, l);
+ int l = this.f(world, i + 1, j, k, b0);
+
+ l = this.f(world, i - 1, j, k, l);
+ l = this.f(world, i, j - 1, k, l);
+ l = this.f(world, i, j + 1, k, l);
+ l = this.f(world, i, j, k - 1, l);
+ l = this.f(world, i, j, k + 1, l);
return l;
}
}
@@ -190,43 +162,32 @@ public class BlockFire extends Block {
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
- return a[iblockaccess.a(i, j, k)] > 0;
+ return this.a[iblockaccess.getTypeId(i, j, k)] > 0;
}
public int f(World world, int i, int j, int k, int l) {
- int i1 = a[world.a(i, j, k)];
+ int i1 = this.a[world.getTypeId(i, j, k)];
- if (i1 > l) {
- return i1;
- } else {
- return l;
- }
+ return i1 > l ? i1 : l;
}
public boolean a(World world, int i, int j, int k) {
- return world.d(i, j - 1, k) || g(world, i, j, k);
+ return world.d(i, j - 1, k) || this.g(world, i, j, k);
}
public void b(World world, int i, int j, int k, int l) {
- if (!world.d(i, j - 1, k) && !g(world, i, j, k)) {
+ if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
world.e(i, j, k, 0);
- return;
- } else {
- return;
}
}
public void e(World world, int i, int j, int k) {
- //TODO this section deals with lighting a block on fire too
- if (world.a(i, j - 1, k) == Block.ap.bi && Block.be.b_(world, i, j, k)) {
- return;
- }
- if (!world.d(i, j - 1, k) && !g(world, i, j, k)) {
- world.e(i, j, k, 0);
- return;
- } else {
- world.i(i, j, k, bi);
- return;
+ if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.b_(world, i, j, k)) {
+ if (!world.d(i, j - 1, k) && !this.g(world, i, j, k)) {
+ world.e(i, j, k, 0);
+ } else {
+ world.i(i, j, k, this.id);
+ }
}
}
}
diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java
index 81a4c792..5d89484a 100644
--- a/src/main/java/net/minecraft/server/BlockFlowing.java
+++ b/src/main/java/net/minecraft/server/BlockFlowing.java
@@ -11,121 +11,125 @@ import org.bukkit.event.block.BlockFromToEvent;
public class BlockFlowing extends BlockFluids {
- int a;
- boolean b[];
- int c[];
-
- protected BlockFlowing(int i1, Material material) {
- super(i1, material);
- a = 0;
- b = new boolean[4];
- c = new int[4];
+ int a = 0;
+ boolean[] b = new boolean[4];
+ int[] c = new int[4];
+
+ protected BlockFlowing(int i, Material material) {
+ super(i, material);
}
- private void i(World world, int i1, int j1, int k1) {
- int l1 = world.b(i1, j1, k1);
+ private void i(World world, int i, int j, int k) {
+ int l = world.getData(i, j, k);
- world.a(i1, j1, k1, bi + 1, l1);
- world.b(i1, j1, k1, i1, j1, k1);
- world.g(i1, j1, k1);
+ world.setTypeIdAndData(i, j, k, this.id + 1, l);
+ world.b(i, j, k, i, j, k);
+ world.g(i, j, k);
}
- public void a(World world, int i1, int j1, int k1, Random random) {
+ public void a(World world, int i, int j, int k, Random random) {
// CraftBukkit start
- // skedit: Moved up to make sure that it is accurate
- CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i1, j1, k1);
+ CraftBlock source = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
// CraftBukkit end
-
- int l1 = g(world, i1, j1, k1);
- byte byte0 = 1;
- if (bt == Material.g && !world.q.d) {
- byte0 = 2;
+ int l = this.g(world, i, j, k);
+ byte b0 = 1;
+
+ if (this.material == Material.LAVA && !world.q.d) {
+ b0 = 2;
}
+
boolean flag = true;
+ int i1;
- if (l1 > 0) {
- int i2 = -100;
+ if (l > 0) {
+ byte b1 = -100;
- a = 0;
- i2 = e(world, i1 - 1, j1, k1, i2);
- i2 = e(world, i1 + 1, j1, k1, i2);
- i2 = e(world, i1, j1, k1 - 1, i2);
- i2 = e(world, i1, j1, k1 + 1, i2);
- int j2 = i2 + byte0;
+ this.a = 0;
+ int j1 = this.e(world, i - 1, j, k, b1);
- if (j2 >= 8 || i2 < 0) {
- j2 = -1;
+ j1 = this.e(world, i + 1, j, k, j1);
+ j1 = this.e(world, i, j, k - 1, j1);
+ j1 = this.e(world, i, j, k + 1, j1);
+ i1 = j1 + b0;
+ if (i1 >= 8 || j1 < 0) {
+ i1 = -1;
}
- if (g(world, i1, j1 + 1, k1) >= 0) {
- int l2 = g(world, i1, j1 + 1, k1);
- if (l2 >= 8) {
- j2 = l2;
+ if (this.g(world, i, j + 1, k) >= 0) {
+ int k1 = this.g(world, i, j + 1, k);
+
+ if (k1 >= 8) {
+ i1 = k1;
} else {
- j2 = l2 + 8;
+ i1 = k1 + 8;
}
}
- if (a >= 2 && bt == Material.f) {
- if (world.d(i1, j1 - 1, k1)) {
- j2 = 0;
- } else if (world.c(i1, j1 - 1, k1) == bt && world.b(i1, j1, k1) == 0) {
- j2 = 0;
+
+ if (this.a >= 2 && this.material == Material.WATER) {
+ if (world.d(i, j - 1, k)) {
+ i1 = 0;
+ } else if (world.getMaterial(i, j - 1, k) == this.material && world.getData(i, j, k) == 0) {
+ i1 = 0;
}
}
- if (bt == Material.g && l1 < 8 && j2 < 8 && j2 > l1 && random.nextInt(4) != 0) {
- j2 = l1;
+
+ if (this.material == Material.LAVA && l < 8 && i1 < 8 && i1 > l && random.nextInt(4) != 0) {
+ i1 = l;
flag = false;
}
- if (j2 != l1) {
- l1 = j2;
- if (l1 < 0) {
- world.e(i1, j1, k1, 0);
+
+ if (i1 != l) {
+ l = i1;
+ if (i1 < 0) {
+ world.e(i, j, k, 0);
} else {
- world.c(i1, j1, k1, l1);
- world.i(i1, j1, k1, bi);
- world.h(i1, j1, k1, bi);
+ world.c(i, j, k, i1);
+ world.i(i, j, k, this.id);
+ world.h(i, j, k, this.id);
}
} else if (flag) {
- i(world, i1, j1, k1);
+ this.i(world, i, j, k);
}
} else {
- i(world, i1, j1, k1);
+ this.i(world, i, j, k);
}
-
- if (l(world, i1, j1 - 1, k1)) {
+
+ if (this.l(world, i, j - 1, k)) {
// CraftBukkit start
// Craftbucket send "down" to the server
- BlockFromToEvent blockFlow = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.DOWN);
- ((WorldServer) world).getServer().getPluginManager().callEvent(blockFlow);
+ BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, BlockFace.DOWN);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(event);
- if (!blockFlow.isCancelled()) {
- if (l1 >= 8) {
- world.b(i1, j1 - 1, k1, bi, l1);
+ if (!event.isCancelled()) {
+ if (l >= 8) {
+ world.b(i, j - 1, k, this.id, l);
} else {
- world.b(i1, j1 - 1, k1, bi, l1 + 8);
+ world.b(i, j - 1, k, this.id, l + 8);
}
}
- // CraftBukkit end
- } else if (l1 >= 0 && (l1 == 0 || k(world, i1, j1 - 1, k1))) {
- boolean aflag[] = j(world, i1, j1, k1);
- int k2 = l1 + byte0;
+ // CraftBukkit end
+ } else if (l >= 0 && (l == 0 || this.k(world, i, j - 1, k))) {
+ boolean[] aboolean = this.j(world, i, j, k);
- if (l1 >= 8) {
- k2 = 1;
+ i1 = l + b0;
+ if (l >= 8) {
+ i1 = 1;
}
- if (k2 >= 8) {
+
+ if (i1 >= 8) {
return;
}
+
// CraftBukkit start - all four cardinal directions. Do not change the order!
BlockFace[] faces = new BlockFace[]{ BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
int index = 0;
for (BlockFace currentFace: faces) {
- if (aflag[index]) {
+ if (aboolean[index]) {
BlockFromToEvent event = new BlockFromToEvent(Type.BLOCK_FLOW, source, currentFace);
((WorldServer) world).getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- f(world, i1 + currentFace.getModX(), j1, k1 + currentFace.getModZ(), k2);
+ f(world, i + currentFace.getModX(), j, k + currentFace.getModZ(), i1);
}
}
index++;
@@ -134,153 +138,158 @@ public class BlockFlowing extends BlockFluids {
}
}
- private void f(World world, int i1, int j1, int k1, int l1) {
- if (l(world, i1, j1, k1)) {
- int i2 = world.a(i1, j1, k1);
+ private void f(World world, int i, int j, int k, int l) {
+ if (this.l(world, i, j, k)) {
+ int i1 = world.getTypeId(i, j, k);
- if (i2 > 0) {
- if (bt == Material.g) {
- h(world, i1, j1, k1);
+ if (i1 > 0) {
+ if (this.material == Material.LAVA) {
+ this.h(world, i, j, k);
} else {
- Block.m[i2].a_(world, i1, j1, k1, world.b(i1, j1, k1));
+ Block.byId[i1].a_(world, i, j, k, world.getData(i, j, k));
}
}
- world.b(i1, j1, k1, bi, l1);
+
+ world.b(i, j, k, this.id, l);
}
}
- private int b(World world, int i1, int j1, int k1, int l1, int i2) {
- int j2 = 1000;
+ private int b(World world, int i, int j, int k, int l, int i1) {
+ int j1 = 1000;
- for (int k2 = 0; k2 < 4; k2++) {
- if (k2 == 0 && i2 == 1 || k2 == 1 && i2 == 0 || k2 == 2 && i2 == 3 || k2 == 3 && i2 == 2) {
- continue;
- }
- int l2 = i1;
- int i3 = j1;
- int j3 = k1;
+ for (int k1 = 0; k1 < 4; ++k1) {
+ if ((k1 != 0 || i1 != 1) && (k1 != 1 || i1 != 0) && (k1 != 2 || i1 != 3) && (k1 != 3 || i1 != 2)) {
+ int l1 = i;
+ int i2 = k;
- if (k2 == 0) {
- l2--;
- }
- if (k2 == 1) {
- l2++;
- }
- if (k2 == 2) {
- j3--;
- }
- if (k2 == 3) {
- j3++;
- }
- if (k(world, l2, i3, j3) || world.c(l2, i3, j3) == bt && world.b(l2, i3, j3) == 0) {
- continue;
- }
- if (!k(world, l2, i3 - 1, j3)) {
- return l1;
- }
- if (l1 >= 4) {
- continue;
- }
- int k3 = b(world, l2, i3, j3, l1 + 1, k2);
+ if (k1 == 0) {
+ l1 = i - 1;
+ }
+
+ if (k1 == 1) {
+ ++l1;
+ }
+
+ if (k1 == 2) {
+ i2 = k - 1;
+ }
+
+ if (k1 == 3) {
+ ++i2;
+ }
+
+ if (!this.k(world, l1, j, i2) && (world.getMaterial(l1, j, i2) != this.material || world.getData(l1, j, i2) != 0)) {
+ if (!this.k(world, l1, j - 1, i2)) {
+ return l;
+ }
+
+ if (l < 4) {
+ int j2 = this.b(world, l1, j, i2, l + 1, k1);
- if (k3 < j2) {
- j2 = k3;
+ if (j2 < j1) {
+ j1 = j2;
+ }
+ }
+ }
}
}
- return j2;
+ return j1;
}
- private boolean[] j(World world, int i1, int j1, int k1) {
- for (int l1 = 0; l1 < 4; l1++) {
- c[l1] = 1000;
- int j2 = i1;
- int i3 = j1;
- int j3 = k1;
+ private boolean[] j(World world, int i, int j, int k) {
+ int l;
+ int i1;
- if (l1 == 0) {
- j2--;
- }
- if (l1 == 1) {
- j2++;
+ for (l = 0; l < 4; ++l) {
+ this.c[l] = 1000;
+ i1 = i;
+ int j1 = k;
+
+ if (l == 0) {
+ i1 = i - 1;
}
- if (l1 == 2) {
- j3--;
+
+ if (l == 1) {
+ ++i1;
}
- if (l1 == 3) {
- j3++;
+
+ if (l == 2) {
+ j1 = k - 1;
}
- if (k(world, j2, i3, j3) || world.c(j2, i3, j3) == bt && world.b(j2, i3, j3) == 0) {
- continue;
+
+ if (l == 3) {
+ ++j1;
}
- if (!k(world, j2, i3 - 1, j3)) {
- c[l1] = 0;
- } else {
- c[l1] = b(world, j2, i3, j3, 1, l1);
+
+ if (!this.k(world, i1, j, j1) && (world.getMaterial(i1, j, j1) != this.material || world.getData(i1, j, j1) != 0)) {
+ if (!this.k(world, i1, j - 1, j1)) {
+ this.c[l] = 0;
+ } else {
+ this.c[l] = this.b(world, i1, j, j1, 1, l);
+ }
}
}
- int i2 = c[0];
+ l = this.c[0];
- for (int k2 = 1; k2 < 4; k2++) {
- if (c[k2] < i2) {
- i2 = c[k2];
+ for (i1 = 1; i1 < 4; ++i1) {
+ if (this.c[i1] < l) {
+ l = this.c[i1];
}
}
- for (int l2 = 0; l2 < 4; l2++) {
- b[l2] = c[l2] == i2;
+ for (i1 = 0; i1 < 4; ++i1) {
+ this.b[i1] = this.c[i1] == l;
}
- return b;
+ return this.b;
}
- private boolean k(World world, int i1, int j1, int k1) {
- int l1 = world.a(i1, j1, k1);
+ private boolean k(World world, int i, int j, int k) {
+ int l = world.getTypeId(i, j, k);
+
+ if (l != Block.WOODEN_DOOR.id && l != Block.IRON_DOOR_BLOCK.id && l != Block.SIGN_POST.id && l != Block.LADDER.id && l != Block.SUGAR_CANE_BLOCK.id) {
+ if (l == 0) {
+ return false;
+ } else {
+ Material material = Block.byId[l].material;
- if (l1 == Block.aE.bi || l1 == Block.aL.bi || l1 == Block.aD.bi || l1 == Block.aF.bi || l1 == Block.aX.bi) {
+ return material.isBuildable();
+ }
+ } else {
return true;
}
- if (l1 == 0) {
- return false;
- }
- Material material = Block.m[l1].bt;
-
- return material.a();
}
- protected int e(World world, int i1, int j1, int k1, int l1) {
- int i2 = g(world, i1, j1, k1);
+ protected int e(World world, int i, int j, int k, int l) {
+ int i1 = this.g(world, i, j, k);
- if (i2 < 0) {
- return l1;
- }
- if (i2 == 0) {
- a++;
- }
- if (i2 >= 8) {
- i2 = 0;
+ if (i1 < 0) {
+ return l;
+ } else {
+ if (i1 == 0) {
+ ++this.a;
+ }
+
+ if (i1 >= 8) {
+ i1 = 0;
+ }
+
+ return l >= 0 && i1 >= l ? l : i1;
}
- return l1 >= 0 && i2 >= l1 ? l1 : i2;
}
- private boolean l(World world, int i1, int j1, int k1) {
- Material material = world.c(i1, j1, k1);
+ private boolean l(World world, int i, int j, int k) {
+ Material material = world.getMaterial(i, j, k);
- if (material == bt) {
- return false;
- }
- if (material == Material.g) {
- return false;
- } else {
- return !k(world, i1, j1, k1);
- }
+ return material == this.material ? false : (material == Material.LAVA ? false : !this.k(world, i, j, k));
}
- public void e(World world, int i1, int j1, int k1) {
- super.e(world, i1, j1, k1);
- if (world.a(i1, j1, k1) == bi) {
- world.i(i1, j1, k1, bi);
+ public void e(World world, int i, int j, int k) {
+ super.e(world, i, j, k);
+ if (world.getTypeId(i, j, k) == this.id) {
+ world.i(i, j, k, this.id);
}
}
}
diff --git a/src/main/java/net/minecraft/server/BlockFurnace.java b/src/main/java/net/minecraft/server/BlockFurnace.java
index 34a13f81..728548ad 100644
--- a/src/main/java/net/minecraft/server/BlockFurnace.java
+++ b/src/main/java/net/minecraft/server/BlockFurnace.java
@@ -17,58 +17,52 @@ public class BlockFurnace extends BlockContainer {
private final boolean a;
protected BlockFurnace(int i, boolean flag) {
- super(i, Material.d);
- a = flag;
- bh = 45;
+ super(i, Material.STONE);
+ this.a = flag;
+ this.textureId = 45;
}
public int a(int i, Random random) {
- return Block.aB.bi;
+ return Block.FURNACE.id;
}
public void e(World world, int i, int j, int k) {
super.e(world, i, j, k);
- g(world, i, j, k);
+ this.g(world, i, j, k);
}
private void g(World world, int i, int j, int k) {
- int l = world.a(i, j, k - 1);
- int i1 = world.a(i, j, k + 1);
- int j1 = world.a(i - 1, j, k);
- int k1 = world.a(i + 1, j, k);
- byte byte0 = 3;
+ int l = world.getTypeId(i, j, k - 1);
+ int i1 = world.getTypeId(i, j, k + 1);
+ int j1 = world.getTypeId(i - 1, j, k);
+ int k1 = world.getTypeId(i + 1, j, k);
+ byte b0 = 3;
if (Block.o[l] && !Block.o[i1]) {
- byte0 = 3;
+ b0 = 3;
}
+
if (Block.o[i1] && !Block.o[l]) {
- byte0 = 2;
+ b0 = 2;
}
+
if (Block.o[j1] && !Block.o[k1]) {
- byte0 = 5;
+ b0 = 5;
}
+
if (Block.o[k1] && !Block.o[j1]) {
- byte0 = 4;
+ b0 = 4;
}
- world.c(i, j, k, ((int) (byte0)));
+
+ world.c(i, j, k, b0);
}
public int a(int i) {
- if (i == 1) {
- return bh + 17;
- }
- if (i == 0) {
- return bh + 17;
- }
- if (i == 3) {
- return bh - 1;
- } else {
- return bh;
- }
+ 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, EntityPlayer entityplayer) {
- if (world.z) {
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (world.isStatic) {
return true;
} else {
// CraftBukkit start - Interact Furnace
@@ -76,52 +70,56 @@ public class BlockFurnace extends BlockContainer {
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
- if (bie.isCancelled()) {
+ if (event.isCancelled()) {
return true;
}
// CraftBukkit end
- TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);
+ TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k);
- entityplayer.a(tileentityfurnace);
+ entityhuman.a(tileentityfurnace);
return true;
}
}
public static void a(boolean flag, World world, int i, int j, int k) {
- int l = world.b(i, j, k);
- TileEntity tileentity = world.m(i, j, k);
+ int l = world.getData(i, j, k);
+ TileEntity tileentity = world.getTileEntity(i, j, k);
if (flag) {
- world.e(i, j, k, Block.aC.bi);
+ world.e(i, j, k, Block.BURNING_FURNACE.id);
} else {
- world.e(i, j, k, Block.aB.bi);
+ world.e(i, j, k, Block.FURNACE.id);
}
+
world.c(i, j, k, l);
- world.a(i, j, k, tileentity);
+ world.setTileEntity(i, j, k, tileentity);
}
protected TileEntity a_() {
- return ((TileEntity) (new TileEntityFurnace()));
+ return new TileEntityFurnace();
}
public void a(World world, int i, int j, int k, EntityLiving entityliving) {
- int l = MathHelper.b((double) ((entityliving.v * 4F) / 360F) + 0.5D) & 3;
+ int l = MathHelper.b((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) {
world.c(i, j, k, 2);
}
+
if (l == 1) {
world.c(i, j, k, 5);
}
+
if (l == 2) {
world.c(i, j, k, 3);
}
+
if (l == 3) {
world.c(i, j, k, 4);
}
diff --git a/src/main/java/net/minecraft/server/BlockJukeBox.java b/src/main/java/net/minecraft/server/BlockJukeBox.java
index 2ed220e6..1413f431 100644
--- a/src/main/java/net/minecraft/server/BlockJukeBox.java
+++ b/src/main/java/net/minecraft/server/BlockJukeBox.java
@@ -13,15 +13,15 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockJukeBox extends Block {
protected BlockJukeBox(int i, int j) {
- super(i, j, Material.c);
+ super(i, j, Material.WOOD);
}
public int a(int i) {
- return bh + (i != 1 ? 0 : 1);
+ return this.textureId + (i == 1 ? 1 : 0);
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- int l = world.b(i, j, k);
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ int l = world.getData(i, j, k);
if (l > 0) {
// CraftBukkit start - Interact Jukebox
@@ -29,17 +29,17 @@ public class BlockJukeBox extends Block {
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
- if (bie.isCancelled()) {
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
return true;
}
// CraftBukkit end
- f(world, i, j, k, l);
+ this.f(world, i, j, k, l);
return true;
} else {
return false;
@@ -47,26 +47,26 @@ public class BlockJukeBox extends Block {
}
public void f(World world, int i, int j, int k, int l) {
- world.a(((String) (null)), i, j, k);
+ world.a((String) null, i, j, k);
world.c(i, j, k, 0);
- int i1 = (Item.aY.ba + l) - 1;
- float f1 = 0.7F;
- double d = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D;
- double d1 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.20000000000000001D + 0.59999999999999998D;
- double d2 = (double) (world.l.nextFloat() * f1) + (double) (1.0F - f1) * 0.5D;
- EntityItem entityitem = new EntityItem(world, (double) i + d, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
+ int i1 = Item.GOLD_RECORD.id + l - 1;
+ float f = 0.7F;
+ double d0 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
+ double d1 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
+ double d2 = (double) (world.l.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
+ EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
entityitem.c = 10;
- world.a(((Entity) (entityitem)));
+ world.a((Entity) entityitem);
}
- public void a(World world, int i, int j, int k, int l, float f1) {
- if (world.z) {
- return;
- }
- if (l > 0) {
- f(world, i, j, k, l);
+ public void a(World world, int i, int j, int k, int l, float f) {
+ if (!world.isStatic) {
+ if (l > 0) {
+ this.f(world, i, j, k, l);
+ }
+
+ super.a(world, i, j, k, l, f);
}
- super.a(world, i, j, k, l, f1);
}
}
diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java
index 1bf3eb1b..692989ec 100644
--- a/src/main/java/net/minecraft/server/BlockLeaves.java
+++ b/src/main/java/net/minecraft/server/BlockLeaves.java
@@ -12,28 +12,28 @@ import org.bukkit.event.block.LeavesDecayEvent;
public class BlockLeaves extends BlockLeavesBase {
private int c;
- int b[];
+ int[] b;
protected BlockLeaves(int i, int j) {
- super(i, j, Material.h, false);
- c = j;
- a(true);
+ super(i, j, Material.LEAVES, false);
+ this.c = j;
+ this.a(true);
}
public void b(World world, int i, int j, int k) {
- int l = 1;
- int i1 = l + 1;
+ byte b0 = 1;
+ int l = b0 + 1;
- if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
- for (int j1 = -l; j1 <= l; j1++) {
- for (int k1 = -l; k1 <= l; k1++) {
- for (int l1 = -l; l1 <= l; l1++) {
- int i2 = world.a(i + j1, j + k1, k + l1);
+ if (world.a(i - l, j - l, k - l, i + l, j + l, k + l)) {
+ for (int i1 = -b0; i1 <= b0; ++i1) {
+ for (int j1 = -b0; j1 <= b0; ++j1) {
+ for (int k1 = -b0; k1 <= b0; ++k1) {
+ int l1 = world.getTypeId(i + i1, j + j1, k + k1);
- if (i2 == Block.K.bi) {
- int j2 = world.b(i + j1, j + k1, k + l1);
+ if (l1 == Block.LEAVES.id) {
+ int i2 = world.getData(i + i1, j + j1, k + k1);
- world.d(i + j1, j + k1, k + l1, j2 | 4);
+ world.d(i + i1, j + j1, k + k1, i2 | 4);
}
}
}
@@ -42,76 +42,83 @@ public class BlockLeaves extends BlockLeavesBase {
}
public void a(World world, int i, int j, int k, Random random) {
- if (world.z) {
- return;
- }
- int l = world.b(i, j, k);
-
- if ((l & 4) != 0) {
- byte byte0 = 4;
- int i1 = byte0 + 1;
- byte byte1 = 32;
- int j1 = byte1 * byte1;
- int k1 = byte1 / 2;
+ if (!world.isStatic) {
+ int l = world.getData(i, j, k);
+
+ if ((l & 4) != 0) {
+ byte b0 = 4;
+ int i1 = b0 + 1;
+ byte b1 = 32;
+ int j1 = b1 * b1;
+ int k1 = b1 / 2;
+
+ if (this.b == null) {
+ this.b = new int[b1 * b1 * b1];
+ }
- if (b == null) {
- b = new int[byte1 * byte1 * byte1];
- }
- if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
- for (int l1 = -byte0; l1 <= byte0; l1++) {
- for (int k2 = -byte0; k2 <= byte0; k2++) {
- for (int i3 = -byte0; i3 <= byte0; i3++) {
- int k3 = world.a(i + l1, j + k2, k + i3);
-
- if (k3 == Block.J.bi) {
- b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
- continue;
- }
- if (k3 == Block.K.bi) {
- b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
- } else {
- b[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
+ int l1;
+
+ if (world.a(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) {
+ int i2;
+ int j2;
+ int k2;
+
+ for (l1 = -b0; l1 <= b0; ++l1) {
+ for (i2 = -b0; i2 <= b0; ++i2) {
+ for (j2 = -b0; j2 <= b0; ++j2) {
+ k2 = world.getTypeId(i + l1, j + i2, k + j2);
+ if (k2 == Block.LOG.id) {
+ this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0;
+ } else if (k2 == Block.LEAVES.id) {
+ this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2;
+ } else {
+ this.b[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1;
+ }
}
}
}
- }
- for (int i2 = 1; i2 <= 4; i2++) {
- for (int l2 = -byte0; l2 <= byte0; l2++) {
- for (int j3 = -byte0; j3 <= byte0; j3++) {
- for (int l3 = -byte0; l3 <= byte0; l3++) {
- if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) {
- continue;
- }
- if (b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
- b[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
- }
- if (b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) {
- b[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
- }
- if (b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) {
- b[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
- }
- if (b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) {
- b[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
- }
- if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) {
- b[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
- }
- if (b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) {
- b[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
+ for (l1 = 1; l1 <= 4; ++l1) {
+ for (i2 = -b0; i2 <= b0; ++i2) {
+ for (j2 = -b0; j2 <= b0; ++j2) {
+ for (k2 = -b0; k2 <= b0; ++k2) {
+ if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) {
+ if (this.b[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
+ this.b[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
+ }
+
+ if (this.b[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) {
+ this.b[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1;
+ }
+
+ if (this.b[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) {
+ this.b[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1;
+ }
+
+ if (this.b[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) {
+ this.b[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1;
+ }
+
+ if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) {
+ this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1;
+ }
+
+ if (this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) {
+ this.b[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1;
+ }
+ }
}
}
}
}
}
- }
- int j2 = b[k1 * j1 + k1 * byte1 + k1];
- if (j2 >= 0) {
- world.c(i, j, k, l & -5);
- } else {
- g(world, i, j, k);
+ l1 = this.b[k1 * j1 + k1 * b1 + k1];
+ if (l1 >= 0) {
+ world.c(i, j, k, l & -5);
+ } else {
+ this.g(world, i, j, k);
+ }
}
}
}
@@ -126,20 +133,20 @@ public class BlockLeaves extends BlockLeavesBase {
if (event.isCancelled()) return;
// CraftBukkit end
- a_(world, i, j, k, world.b(i, j, k));
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
}
public int a(Random random) {
- return random.nextInt(16) != 0 ? 0 : 1;
+ return random.nextInt(16) == 0 ? 1 : 0;
}
public int a(int i, Random random) {
- return Block.y.bi;
+ return Block.SAPLING.id;
}
public boolean a() {
- return !a;
+ return !this.a;
}
public void b(World world, int i, int j, int k, Entity entity) {
diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java
index bcd2846d..5c2cdae5 100644
--- a/src/main/java/net/minecraft/server/BlockLever.java
+++ b/src/main/java/net/minecraft/server/BlockLever.java
@@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockRedstoneEvent;
public class BlockLever extends Block {
protected BlockLever(int i, int j) {
- super(i, j, Material.n);
+ super(i, j, Material.ORIENTABLE);
}
public AxisAlignedBB d(World world, int i, int j, int k) {
@@ -27,41 +27,34 @@ public class BlockLever extends Block {
}
public boolean a(World world, int i, int j, int k) {
- if (world.d(i - 1, j, k)) {
- return true;
- }
- if (world.d(i + 1, j, k)) {
- return true;
- }
- if (world.d(i, j, k - 1)) {
- return true;
- }
- if (world.d(i, j, k + 1)) {
- return true;
- }
- return world.d(i, j - 1, k);
+ 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 c(World world, int i, int j, int k, int l) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
int j1 = i1 & 8;
i1 &= 7;
if (l == 1 && world.d(i, j - 1, k)) {
i1 = 5 + world.l.nextInt(2);
}
+
if (l == 2 && world.d(i, j, k + 1)) {
i1 = 4;
}
+
if (l == 3 && world.d(i, j, k - 1)) {
i1 = 3;
}
+
if (l == 4 && world.d(i + 1, j, k)) {
i1 = 2;
}
+
if (l == 5 && world.d(i - 1, j, k)) {
i1 = 1;
}
+
world.c(i, j, k, i1 + j1);
}
@@ -77,39 +70,45 @@ public class BlockLever extends Block {
} else if (world.d(i, j - 1, k)) {
world.c(i, j, k, 5 + world.l.nextInt(2));
}
- g(world, i, j, k);
+
+ this.g(world, i, j, k);
}
public void b(World world, int i, int j, int k, int l) {
- if (g(world, i, j, k)) {
- int i1 = world.b(i, j, k) & 7;
+ if (this.g(world, i, j, k)) {
+ int i1 = world.getData(i, j, k) & 7;
boolean flag = false;
if (!world.d(i - 1, j, k) && i1 == 1) {
flag = true;
}
+
if (!world.d(i + 1, j, k) && i1 == 2) {
flag = true;
}
+
if (!world.d(i, j, k - 1) && i1 == 3) {
flag = true;
}
+
if (!world.d(i, j, k + 1) && i1 == 4) {
flag = true;
}
+
if (!world.d(i, j - 1, k) && i1 == 5) {
flag = true;
}
+
if (flag) {
- a_(world, i, j, k, world.b(i, j, k));
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
}
}
}
private boolean g(World world, int i, int j, int k) {
- if (!a(world, i, j, k)) {
- a_(world, i, j, k, world.b(i, j, k));
+ if (!this.a(world, i, j, k)) {
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
return false;
} else {
@@ -118,129 +117,119 @@ public class BlockLever extends Block {
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
- int l = iblockaccess.b(i, j, k) & 7;
+ int l = iblockaccess.getData(i, j, k) & 7;
float f = 0.1875F;
if (l == 1) {
- a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
+ this.a(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
} else if (l == 2) {
- a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
+ this.a(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
} else if (l == 3) {
- a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
+ this.a(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
} else if (l == 4) {
- a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
+ this.a(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
} else {
- float f1 = 0.25F;
-
- a(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
+ f = 0.25F;
+ this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
}
}
- public void b(World world, int i, int j, int k, EntityPlayer entityplayer) {
- a(world, i, j, k, entityplayer);
+ public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
+ this.a(world, i, j, k, entityhuman);
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- if (world.z) {
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (world.isStatic) {
return true;
- }
+ } else {
+ // CraftBukkit start - Interact Lever
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ // CraftBukkit the client updates the doors before the server does it's thing.
+ // Forcibly send correct data.
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
+ return true;
+ }
+ // CraftBukkit end
- // CraftBukkit start - Interact Lever
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.BLOCK_INTERACT;
- CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
-
- // CraftBukkit the client updates the doors before the server does it's thing.
- // Forcibly send correct data.
- if (bie.isCancelled()) {
- ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
+ int l = world.getData(i, j, k);
+ int i1 = l & 7;
+ int j1 = 8 - (l & 8);
+
+ // CraftBukkit start
+ int old = (j1 != 8) ? 1 : 0;
+ int current = (j1 == 8) ? 1 : 0;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
+ server.getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) == (j1 == 8)) {
+ // CraftBukkit end
+
+ world.c(i, j, k, i1 + j1);
+ world.b(i, j, k, i, j, k);
+ world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 > 0 ? 0.6F : 0.5F);
+ world.h(i, j, k, this.id);
+ if (i1 == 1) {
+ world.h(i - 1, j, k, this.id);
+ } else if (i1 == 2) {
+ world.h(i + 1, j, k, this.id);
+ } else if (i1 == 3) {
+ world.h(i, j, k - 1, this.id);
+ } else if (i1 == 4) {
+ world.h(i, j, k + 1, this.id);
+ } else {
+ world.h(i, j - 1, k, this.id);
+ }
+ } // CraftBukkit
return true;
}
- // CraftBukkit end
-
- int l = world.b(i, j, k);
- int i1 = l & 7;
- int j1 = 8 - (l & 8);
-
- // CraftBukkit start
- int old = (j1 != 8) ? 1 : 0;
- int current = (j1 == 8) ? 1 : 0;
- BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
- server.getPluginManager().callEvent(bre);
- // CraftBukkit end
-
- if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
- world.c(i, j, k, i1 + j1);
- world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, j1 <= 0 ? 0.5F : 0.6F);
- world.h(i, j, k, bi);
- if (i1 == 1) {
- world.h(i - 1, j, k, bi);
- } else if (i1 == 2) {
- world.h(i + 1, j, k, bi);
- } else if (i1 == 3) {
- world.h(i, j, k - 1, bi);
- } else if (i1 == 4) {
- world.h(i, j, k + 1, bi);
- } else {
- world.h(i, j - 1, k, bi);
- }
- }
- return true;
}
public void b(World world, int i, int j, int k) {
- int l = world.b(i, j, k);
+ int l = world.getData(i, j, k);
if ((l & 8) > 0) {
- world.h(i, j, k, bi);
+ world.h(i, j, k, this.id);
int i1 = l & 7;
if (i1 == 1) {
- world.h(i - 1, j, k, bi);
+ world.h(i - 1, j, k, this.id);
} else if (i1 == 2) {
- world.h(i + 1, j, k, bi);
+ world.h(i + 1, j, k, this.id);
} else if (i1 == 3) {
- world.h(i, j, k - 1, bi);
+ world.h(i, j, k - 1, this.id);
} else if (i1 == 4) {
- world.h(i, j, k + 1, bi);
+ world.h(i, j, k + 1, this.id);
} else {
- world.h(i, j - 1, k, bi);
+ world.h(i, j - 1, k, this.id);
}
}
+
super.b(world, i, j, k);
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- return (iblockaccess.b(i, j, k) & 8) > 0;
+ return (iblockaccess.getData(i, j, k) & 8) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
- int i1 = world.b(i, j, k);
+ int i1 = world.getData(i, j, k);
if ((i1 & 8) == 0) {
return false;
- }
- int j1 = i1 & 7;
+ } else {
+ int j1 = i1 & 7;
- if (j1 == 5 && l == 1) {
- return true;
- }
- if (j1 == 4 && l == 2) {
- return true;
- }
- if (j1 == 3 && l == 3) {
- return true;
- }
- if (j1 == 2 && l == 4) {
- return true;
+ return j1 == 5 && l == 1 ? true : (j1 == 4 && l == 2 ? true : (j1 == 3 && l == 3 ? true : (j1 == 2 && l == 4 ? true : j1 == 1 && l == 5)));
}
- return j1 == 1 && l == 5;
}
public boolean c() {
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java
index fcb48af8..90f0a749 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlate.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java
@@ -20,12 +20,12 @@ public class BlockPressurePlate extends Block {
private EnumMobType a;
protected BlockPressurePlate(int i, int j, EnumMobType enummobtype) {
- super(i, j, Material.d);
- a = enummobtype;
- a(true);
+ super(i, j, Material.STONE);
+ this.a = enummobtype;
+ this.a(true);
float f = 0.0625F;
- a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
+ this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
}
public int b() {
@@ -52,129 +52,118 @@ public class BlockPressurePlate extends Block {
if (!world.d(i, j - 1, k)) {
flag = true;
}
+
if (flag) {
- a_(world, i, j, k, world.b(i, j, k));
+ this.a_(world, i, j, k, world.getData(i, j, k));
world.e(i, j, k, 0);
}
}
public void a(World world, int i, int j, int k, Random random) {
- if (world.z) {
- return;
- }
- if (world.b(i, j, k) == 0) {
- return;
- } else {
- g(world, i, j, k);
- return;
+ if (!world.isStatic) {
+ if (world.getData(i, j, k) != 0) {
+ this.g(world, i, j, k);
+ }
}
}
public void a(World world, int i, int j, int k, Entity entity) {
- if (world.z) {
- return;
- }
- if (world.b(i, j, k) == 1) {
- return;
- } else {
- // CraftBukkit start - Interact Pressure Plate
- if (entity instanceof EntityLiving) {
- CraftServer server = ((WorldServer) world).getServer();
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- Type eventType = Type.BLOCK_INTERACT;
- CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- org.bukkit.entity.LivingEntity who = (entity == null)?null:(LivingEntity) entity.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) {
- return;
+ if (!world.isStatic) {
+ if (world.getData(i, j, k) != 1) {
+
+ // CraftBukkit start - Interact Pressure Plate
+ if (entity instanceof EntityLiving) {
+ CraftServer server = ((WorldServer) world).getServer();
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ org.bukkit.entity.LivingEntity who = (entity == null) ? null : (LivingEntity) entity.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
}
- }
- // CraftBukkit end
+ // CraftBukkit end
- g(world, i, j, k);
- return;
+ this.g(world, i, j, k);
+ }
}
}
private void g(World world, int i, int j, int k) {
- boolean flag = world.b(i, j, k) == 1;
+ boolean flag = world.getData(i, j, k) == 1;
boolean flag1 = false;
float f = 0.125F;
List list = null;
- if (a == EnumMobType.a) {
- list = world.b(((Entity) (null)), AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f));
+ if (this.a == EnumMobType.EVERYTHING) {
+ list = world.b((Entity) null, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
}
- if (a == EnumMobType.b) {
- list = world.a(net.minecraft.server.EntityLiving.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f));
+
+ if (this.a == EnumMobType.MOBS) {
+ list = world.a(EntityLiving.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
}
- if (a == EnumMobType.c) {
- list = world.a(net.minecraft.server.EntityPlayer.class, AxisAlignedBB.b((float) i + f, j, (float) k + f, (float) (i + 1) - f, (double) j + 0.25D, (float) (k + 1) - f));
+
+ if (this.a == EnumMobType.PLAYERS) {
+ list = world.a(EntityHuman.class, AxisAlignedBB.b((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) j + 0.25D, (double) ((float) (k + 1) - f)));
}
+
if (list.size() > 0) {
flag1 = true;
}
- // Craftbukkit start
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag1 ? 15 : 0);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
- flag1 = bre.getNewCurrent() > 0;
- // Craftbukkit end
-
if (flag1 && !flag) {
world.c(i, j, k, 1);
- world.h(i, j, k, bi);
- world.h(i, j - 1, k, bi);
+ world.h(i, j, k, this.id);
+ world.h(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
+ world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F);
}
+
if (!flag1 && flag) {
world.c(i, j, k, 0);
- world.h(i, j, k, bi);
- world.h(i, j - 1, k, bi);
+ world.h(i, j, k, this.id);
+ world.h(i, j - 1, k, this.id);
world.b(i, j, k, i, j, k);
- world.a((double) i + 0.5D, (double) j + 0.10000000000000001D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
+ world.a((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F);
}
+
if (flag1) {
- world.i(i, j, k, bi);
+ world.i(i, j, k, this.id);
}
}
public void b(World world, int i, int j, int k) {
- int l = world.b(i, j, k);
+ int l = world.getData(i, j, k);
if (l > 0) {
- world.h(i, j, k, bi);
- world.h(i, j - 1, k, bi);
+ world.h(i, j, k, this.id);
+ world.h(i, j - 1, k, this.id);
}
+
super.b(world, i, j, k);
}
public void a(IBlockAccess iblockaccess, int i, int j, int k) {
- boolean flag = iblockaccess.b(i, j, k) == 1;
+ boolean flag = iblockaccess.getData(i, j, k) == 1;
float f = 0.0625F;
if (flag) {
- a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
+ this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f);
} else {
- a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
+ this.a(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f);
}
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- return iblockaccess.b(i, j, k) > 0;
+ return iblockaccess.getData(i, j, k) > 0;
}
public boolean d(World world, int i, int j, int k, int l) {
- if (world.b(i, j, k) == 0) {
- return false;
- } else {
- return l == 1;
- }
+ return world.getData(i, j, k) == 0 ? false : l == 1;
}
public boolean c() {
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
index ef89f091..efc9ee2b 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
@@ -1,26 +1,35 @@
package net.minecraft.server;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent;
+// CraftBukkit end
public class BlockRedstoneTorch extends BlockTorch {
- private boolean a;
+ private boolean a = false;
private static List b = new ArrayList();
private boolean a(World world, int i, int j, int k, boolean flag) {
if (flag) {
- b.add(((new RedstoneUpdateInfo(i, j, k, world.e))));
+ b.add(new RedstoneUpdateInfo(i, j, k, world.e));
}
+
int l = 0;
- for (int i1 = 0; i1 < b.size(); i1++) {
+ for (int i1 = 0; i1 < b.size(); ++i1) {
RedstoneUpdateInfo redstoneupdateinfo = (RedstoneUpdateInfo) b.get(i1);
- if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k && ++l >= 8) {
- return true;
+ if (redstoneupdateinfo.a == i && redstoneupdateinfo.b == j && redstoneupdateinfo.c == k) {
+ ++l;
+ if (l >= 8) {
+ return true;
+ }
}
}
@@ -29,9 +38,8 @@ public class BlockRedstoneTorch extends BlockTorch {
protected BlockRedstoneTorch(int i, int j, boolean flag) {
super(i, j);
- a = false;
- a = flag;
- a(true);
+ this.a = flag;
+ this.a(true);
}
public int b() {
@@ -39,119 +47,94 @@ public class BlockRedstoneTorch extends BlockTorch {
}
public void e(World world, int i, int j, int k) {
- if (world.b(i, j, k) == 0) {
+ if (world.getData(i, j, k) == 0) {
super.e(world, i, j, k);
}
- if (a) {
- world.h(i, j - 1, k, bi);
- world.h(i, j + 1, k, bi);
- world.h(i - 1, j, k, bi);
- world.h(i + 1, j, k, bi);
- world.h(i, j, k - 1, bi);
- world.h(i, j, k + 1, bi);
+
+ if (this.a) {
+ world.h(i, j - 1, k, this.id);
+ world.h(i, j + 1, k, this.id);
+ world.h(i - 1, j, k, this.id);
+ world.h(i + 1, j, k, this.id);
+ world.h(i, j, k - 1, this.id);
+ world.h(i, j, k + 1, this.id);
}
}
public void b(World world, int i, int j, int k) {
- if (a) {
- world.h(i, j - 1, k, bi);
- world.h(i, j + 1, k, bi);
- world.h(i - 1, j, k, bi);
- world.h(i + 1, j, k, bi);
- world.h(i, j, k - 1, bi);
- world.h(i, j, k + 1, bi);
+ if (this.a) {
+ world.h(i, j - 1, k, this.id);
+ world.h(i, j + 1, k, this.id);
+ world.h(i - 1, j, k, this.id);
+ world.h(i + 1, j, k, this.id);
+ world.h(i, j, k - 1, this.id);
+ world.h(i, j, k + 1, this.id);
}
}
public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- if (!a) {
+ if (!this.a) {
return false;
- }
- int i1 = iblockaccess.b(i, j, k);
+ } else {
+ int i1 = iblockaccess.getData(i, j, k);
- if (i1 == 5 && l == 1) {
- return false;
- }
- if (i1 == 3 && l == 3) {
- return false;
+ return i1 == 5 && l == 1 ? false : (i1 == 3 && l == 3 ? false : (i1 == 4 && l == 2 ? false : (i1 == 1 && l == 5 ? false : i1 != 2 || l != 4)));
}
- if (i1 == 4 && l == 2) {
- return false;
- }
- if (i1 == 1 && l == 5) {
- return false;
- }
- return i1 != 2 || l != 4;
}
private boolean g(World world, int i, int j, int k) {
- int l = world.b(i, j, k);
+ int l = world.getData(i, j, k);
- if (l == 5 && world.k(i, j - 1, k, 0)) {
- return true;
- }
- if (l == 3 && world.k(i, j, k - 1, 2)) {
- return true;
- }
- if (l == 4 && world.k(i, j, k + 1, 3)) {
- return true;
- }
- if (l == 1 && world.k(i - 1, j, k, 4)) {
- return true;
- }
- return l == 2 && world.k(i + 1, j, k, 5);
+ return l == 5 && world.k(i, j - 1, k, 0) ? true : (l == 3 && world.k(i, j, k - 1, 2) ? true : (l == 4 && world.k(i, j, k + 1, 3) ? true : (l == 1 && world.k(i - 1, j, k, 4) ? true : l == 2 && world.k(i + 1, j, k, 5))));
}
public void a(World world, int i, int j, int k, Random random) {
- boolean flag = g(world, i, j, k);
+ boolean flag = this.g(world, i, j, k);
- for (; b.size() > 0 && world.e - ((RedstoneUpdateInfo) b.get(0)).d > 100L; b.remove(0)) {
- ;
+ while (b.size() > 0 && world.e - ((RedstoneUpdateInfo) b.get(0)).d > 100L) {
+ b.remove(0);
}
-
+
// Craftbukkit start
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag ? 0 : 15);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
- if ((bre.getNewCurrent() != 0) == flag) {
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, BlockFace.SELF, flag ? 15 : 0, flag ? 0 : 15);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(event);
+ if ((event.getNewCurrent() != 0) == flag) {
return;
}
// Craftbukkit end
- if (a) {
+ if (this.a) {
if (flag) {
- world.b(i, j, k, Block.aP.bi, world.b(i, j, k));
- if (a(world, i, j, k, true)) {
- world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
- for (int l = 0; l < 5; l++) {
- double d1 = (double) i + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
- double d2 = (double) j + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
- double d3 = (double) k + random.nextDouble() * 0.59999999999999998D + 0.20000000000000001D;
-
- world.a("smoke", d1, d2, d3, 0.0D, 0.0D, 0.0D);
+ world.b(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k));
+ 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.l.nextFloat() - world.l.nextFloat()) * 0.8F);
+
+ for (int l = 0; l < 5; ++l) {
+ double d0 = (double) i + random.nextDouble() * 0.6D + 0.2D;
+ double d1 = (double) j + random.nextDouble() * 0.6D + 0.2D;
+ double d2 = (double) k + random.nextDouble() * 0.6D + 0.2D;
+
+ world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
}
- } else if (!flag && !a(world, i, j, k, false)) {
- world.b(i, j, k, Block.aQ.bi, world.b(i, j, k));
+ } else if (!flag && !this.a(world, i, j, k, false)) {
+ world.b(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k));
}
}
public void b(World world, int i, int j, int k, int l) {
super.b(world, i, j, k, l);
- world.i(i, j, k, bi);
+ world.i(i, j, k, this.id);
}
public boolean d(World world, int i, int j, int k, int l) {
- if (l == 0) {
- return b(((IBlockAccess) (world)), i, j, k, l);
- } else {
- return false;
- }
+ return l == 0 ? this.b((IBlockAccess) world, i, j, k, l) : false;
}
public int a(int i, Random random) {
- return Block.aQ.bi;
+ return Block.REDSTONE_TORCH_ON.id;
}
public boolean c() {
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
index 11812a56..81d85c6c 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -2,24 +2,23 @@ package net.minecraft.server;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Random;
import java.util.Set;
+
+// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.block.BlockRedstoneEvent;
-import org.bukkit.plugin.PluginLoader;
+// CraftBukkit end
public class BlockRedstoneWire extends Block {
- private boolean a;
- private Set b;
+ private boolean a = true;
+ private Set b = new HashSet();
public BlockRedstoneWire(int i, int j) {
- super(i, j, Material.n);
- a = true;
- b = ((Set) (new HashSet()));
- a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
+ super(i, j, Material.ORIENTABLE);
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
}
public AxisAlignedBB d(World world, int i, int j, int k) {
@@ -35,60 +34,67 @@ public class BlockRedstoneWire extends Block {
}
private void g(World world, int i, int j, int k) {
- a(world, i, j, k, i, j, k);
- ArrayList arraylist = new ArrayList(((java.util.Collection) (b)));
+ this.a(world, i, j, k, i, j, k);
+ ArrayList arraylist = new ArrayList(this.b);
+
+ this.b.clear();
- b.clear();
- for (int l = 0; l < ((List) (arraylist)).size(); l++) {
- ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(l);
+ for (int l = 0; l < arraylist.size(); ++l) {
+ ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);
- world.h(chunkposition.a, chunkposition.b, chunkposition.c, bi);
+ world.h(chunkposition.a, chunkposition.b, chunkposition.c, this.id);
}
}
private void a(World world, int i, int j, int k, int l, int i1, int j1) {
- int k1 = world.b(i, j, k);
+ int k1 = world.getData(i, j, k);
int l1 = 0;
- a = false;
+ this.a = false;
boolean flag = world.p(i, j, k);
- a = true;
+ this.a = true;
+ int i2;
+ int j2;
+ int k2;
+
if (flag) {
l1 = 15;
} else {
- for (int i2 = 0; i2 < 4; i2++) {
- int k2 = i;
- int i3 = k;
-
+ for (i2 = 0; i2 < 4; ++i2) {
+ j2 = i;
+ k2 = k;
if (i2 == 0) {
- k2--;
+ j2 = i - 1;
}
+
if (i2 == 1) {
- k2++;
+ ++j2;
}
+
if (i2 == 2) {
- i3--;
+ k2 = k - 1;
}
+
if (i2 == 3) {
- i3++;
+ ++k2;
}
- if (k2 != l || j != i1 || i3 != j1) {
- l1 = f(world, k2, j, i3, l1);
+
+ if (j2 != l || j != i1 || k2 != j1) {
+ l1 = this.f(world, j2, j, k2, l1);
}
- if (world.d(k2, j, i3) && !world.d(i, j + 1, k)) {
- if (k2 != l || j + 1 != i1 || i3 != j1) {
- l1 = f(world, k2, j + 1, i3, l1);
+
+ if (world.d(j2, j, k2) && !world.d(i, j + 1, k)) {
+ if (j2 != l || j + 1 != i1 || k2 != j1) {
+ l1 = this.f(world, j2, j + 1, k2, l1);
}
- continue;
- }
- if (!world.d(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) {
- l1 = f(world, k2, j - 1, i3, l1);
+ } else if (!world.d(j2, j, k2) && (j2 != l || j - 1 != i1 || k2 != j1)) {
+ l1 = this.f(world, j2, j - 1, k2, l1);
}
}
if (l1 > 0) {
- l1--;
+ --l1;
} else {
l1 = 0;
}
@@ -97,250 +103,238 @@ public class BlockRedstoneWire extends Block {
// Craftbukkit start
if (k1 != l1) {
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
- l1 = bre.getNewCurrent();
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, BlockFace.SELF, k1, l1);
+ ((WorldServer) world).getServer().getPluginManager().callEvent(event);
+ l1 = event.getNewCurrent();
}
// Craftbukkit end
-
+
if (k1 != l1) {
world.i = true;
world.c(i, j, k, l1);
world.b(i, j, k, i, j, k);
world.i = false;
- for (int j2 = 0; j2 < 4; j2++) {
- int l2 = i;
- int j3 = k;
- int k3 = j - 1;
- if (j2 == 0) {
- l2--;
+ for (i2 = 0; i2 < 4; ++i2) {
+ j2 = i;
+ k2 = k;
+ int l2 = j - 1;
+
+ if (i2 == 0) {
+ j2 = i - 1;
}
- if (j2 == 1) {
- l2++;
+
+ if (i2 == 1) {
+ ++j2;
}
- if (j2 == 2) {
- j3--;
+
+ if (i2 == 2) {
+ k2 = k - 1;
}
- if (j2 == 3) {
- j3++;
+
+ if (i2 == 3) {
+ ++k2;
}
- if (world.d(l2, j, j3)) {
- k3 += 2;
+
+ if (world.d(j2, j, k2)) {
+ l2 += 2;
}
- int l3 = 0;
- l3 = f(world, l2, j, j3, -1);
- l1 = world.b(i, j, k);
+ boolean flag1 = false;
+ int i3 = this.f(world, j2, j, k2, -1);
+
+ l1 = world.getData(i, j, k);
if (l1 > 0) {
- l1--;
+ --l1;
}
- if (l3 >= 0 && l3 != l1) {
- a(world, l2, j, j3, i, j, k);
+
+ if (i3 >= 0 && i3 != l1) {
+ this.a(world, j2, j, k2, i, j, k);
}
- l3 = f(world, l2, k3, j3, -1);
- l1 = world.b(i, j, k);
+
+ i3 = this.f(world, j2, l2, k2, -1);
+ l1 = world.getData(i, j, k);
if (l1 > 0) {
- l1--;
+ --l1;
}
- if (l3 >= 0 && l3 != l1) {
- a(world, l2, k3, j3, i, j, k);
+
+ if (i3 >= 0 && i3 != l1) {
+ this.a(world, j2, l2, k2, i, j, k);
}
}
if (k1 == 0 || l1 == 0) {
- b.add(((new ChunkPosition(i, j, k))));
- b.add(((new ChunkPosition(i - 1, j, k))));
- b.add(((new ChunkPosition(i + 1, j, k))));
- b.add(((new ChunkPosition(i, j - 1, k))));
- b.add(((new ChunkPosition(i, j + 1, k))));
- b.add(((new ChunkPosition(i, j, k - 1))));
- b.add(((new ChunkPosition(i, j, k + 1))));
+ this.b.add(new ChunkPosition(i, j, k));
+ this.b.add(new ChunkPosition(i - 1, j, k));
+ this.b.add(new ChunkPosition(i + 1, j, k));
+ this.b.add(new ChunkPosition(i, j - 1, k));
+ this.b.add(new ChunkPosition(i, j + 1, k));
+ this.b.add(new ChunkPosition(i, j, k - 1));
+ this.b.add(new ChunkPosition(i, j, k + 1));
}
}
}
private void h(World world, int i, int j, int k) {
- if (world.a(i, j, k) != bi) {
- return;
- } else {
- world.h(i, j, k, bi);
- world.h(i - 1, j, k, bi);
- world.h(i + 1, j, k, bi);
- world.h(i, j, k - 1, bi);
- world.h(i, j, k + 1, bi);
- world.h(i, j - 1, k, bi);
- world.h(i, j + 1, k, bi);
- return;
+ if (world.getTypeId(i, j, k) == this.id) {
+ world.h(i, j, k, this.id);
+ world.h(i - 1, j, k, this.id);
+ world.h(i + 1, j, k, this.id);
+ world.h(i, j, k - 1, this.id);
+ world.h(i, j, k + 1, this.id);
+ world.h(i, j - 1, k, this.id);
+ world.h(i, j + 1, k, this.id);
}
}
public void e(World world, int i, int j, int k) {
super.e(world, i, j, k);
- if (world.z) {
- return;
- }
- g(world, i, j, k);
- world.h(i, j + 1, k, bi);
- world.h(i, j - 1, k, bi);
- h(world, i - 1, j, k);
- h(world, i + 1, j, k);
- h(world, i, j, k - 1);
- h(world, i, j, k + 1);
- if (world.d(i - 1, j, k)) {
- h(world, i - 1, j + 1, k);
- } else {
- h(world, i - 1, j - 1, k);
- }
- if (world.d(i + 1, j, k)) {
- h(world, i + 1, j + 1, k);
- } else {
- h(world, i + 1, j - 1, k);
- }
- if (world.d(i, j, k - 1)) {
- h(world, i, j + 1, k - 1);
- } else {
- h(world, i, j - 1, k - 1);
- }
- if (world.d(i, j, k + 1)) {
- h(world, i, j + 1, k + 1);
- } else {
- h(world, i, j - 1, k + 1);
+ if (!world.isStatic) {
+ this.g(world, i, j, k);
+ world.h(i, j + 1, k, this.id);
+ world.h(i, j - 1, k, this.id);
+ 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);
+ if (world.d(i - 1, j, k)) {
+ this.h(world, i - 1, j + 1, k);
+ } else {
+ this.h(world, i - 1, j - 1, k);
+ }
+
+ if (world.d(i + 1, j, k)) {
+ this.h(world, i + 1, j + 1, k);
+ } else {
+ this.h(world, i + 1, j - 1, k);
+ }
+
+ if (world.d(i, j, k - 1)) {
+ this.h(world, i, j + 1, k - 1);
+ } else {
+ this.h(world, i, j - 1, k - 1);
+ }
+
+ if (world.d(i, j, k + 1)) {
+ this.h(world, i, j + 1, k + 1);
+ } else {
+ this.h(world, i, j - 1, k + 1);
+ }
}
}
public void b(World world, int i, int j, int k) {
super.b(world, i, j, k);
- if (world.z) {
- return;
- }
- world.h(i, j + 1, k, bi);
- world.h(i, j - 1, k, bi);
- g(world, i, j, k);
- h(world, i - 1, j, k);
- h(world, i + 1, j, k);
- h(world, i, j, k - 1);
- h(world, i, j, k + 1);
- if (world.d(i - 1, j, k)) {
- h(world, i - 1, j + 1, k);
- } else {
- h(world, i - 1, j - 1, k);
- }
- if (world.d(i + 1, j, k)) {
- h(world, i + 1, j + 1, k);
- } else {
- h(world, i + 1, j - 1, k);
- }
- if (world.d(i, j, k - 1)) {
- h(world, i, j + 1, k - 1);
- } else {
- h(world, i, j - 1, k - 1);
- }
- if (world.d(i, j, k + 1)) {
- h(world, i, j + 1, k + 1);
- } else {
- h(world, i, j - 1, k + 1);
+ if (!world.isStatic) {
+ world.h(i, j + 1, k, this.id);
+ world.h(i, j - 1, k, this.id);
+ this.g(world, i, 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);
+ if (world.d(i - 1, j, k)) {
+ this.h(world, i - 1, j + 1, k);
+ } else {
+ this.h(world, i - 1, j - 1, k);
+ }
+
+ if (world.d(i + 1, j, k)) {
+ this.h(world, i + 1, j + 1, k);
+ } else {
+ this.h(world, i + 1, j - 1, k);
+ }
+
+ if (world.d(i, j, k - 1)) {
+ this.h(world, i, j + 1, k - 1);
+ } else {
+ this.h(world, i, j - 1, k - 1);
+ }
+
+ if (world.d(i, j, k + 1)) {
+ this.h(world, i, j + 1, k + 1);
+ } else {
+ this.h(world, i, j - 1, k + 1);
+ }
}
}
private int f(World world, int i, int j, int k, int l) {
- if (world.a(i, j, k) != bi) {
+ if (world.getTypeId(i, j, k) != this.id) {
return l;
- }
- int i1 = world.b(i, j, k);
-
- if (i1 > l) {
- return i1;
} else {
- return l;
+ int i1 = world.getData(i, j, k);
+
+ return i1 > l ? i1 : l;
}
}
public void b(World world, int i, int j, int k, int l) {
- if (world.z) {
- return;
- }
- int i1 = world.b(i, j, k);
- boolean flag = a(world, i, j, k);
+ if (!world.isStatic) {
+ int i1 = world.getData(i, j, k);
+ boolean flag = this.a(world, i, j, k);
- if (!flag) {
- a_(world, i, j, k, i1);
- world.e(i, j, k, 0);
- } else {
- g(world, i, j, k);
+ if (!flag) {
+ this.a_(world, i, j, k, i1);
+ world.e(i, j, k, 0);
+ } else {
+ this.g(world, i, j, k);
+ }
+
+ super.b(world, i, j, k, l);
}
- super.b(world, i, j, k, l);
}
public int a(int i, Random random) {
- return Item.aA.ba;
+ return Item.REDSTONE.id;
}
public boolean d(World world, int i, int j, int k, int l) {
- if (!a) {
- return false;
- } else {
- return b(((IBlockAccess) (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) {
- if (!a) {
+ if (!this.a) {
return false;
- }
- if (iblockaccess.b(i, j, k) == 0) {
+ } else if (iblockaccess.getData(i, j, k) == 0) {
return false;
- }
- if (l == 1) {
+ } else if (l == 1) {
return true;
- }
- boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k);
- boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k);
- boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1);
- boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1);
-
- if (!iblockaccess.d(i, j + 1, k)) {
- if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) {
- flag = true;
- }
- if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) {
- flag1 = true;
- }
- if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) {
- flag2 = true;
- }
- if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) {
- flag3 = true;
+ } else {
+ boolean flag = b(iblockaccess, i - 1, j, k) || !iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j - 1, k);
+ boolean flag1 = b(iblockaccess, i + 1, j, k) || !iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j - 1, k);
+ boolean flag2 = b(iblockaccess, i, j, k - 1) || !iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j - 1, k - 1);
+ boolean flag3 = b(iblockaccess, i, j, k + 1) || !iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j - 1, k + 1);
+
+ if (!iblockaccess.d(i, j + 1, k)) {
+ if (iblockaccess.d(i - 1, j, k) && b(iblockaccess, i - 1, j + 1, k)) {
+ flag = true;
+ }
+
+ if (iblockaccess.d(i + 1, j, k) && b(iblockaccess, i + 1, j + 1, k)) {
+ flag1 = true;
+ }
+
+ if (iblockaccess.d(i, j, k - 1) && b(iblockaccess, i, j + 1, k - 1)) {
+ flag2 = true;
+ }
+
+ if (iblockaccess.d(i, j, k + 1) && b(iblockaccess, i, j + 1, k + 1)) {
+ flag3 = true;
+ }
}
+
+ return !flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5 ? true : (l == 2 && flag2 && !flag && !flag1 ? true : (l == 3 && flag3 && !flag && !flag1 ? true : (l == 4 && flag && !flag2 && !flag3 ? true : l == 5 && flag1 && !flag2 && !flag3)));
}
- if (!flag2 && !flag1 && !flag && !flag3 && l >= 2 && l <= 5) {
- return true;
- }
- if (l == 2 && flag2 && !flag && !flag1) {
- return true;
- }
- if (l == 3 && flag3 && !flag && !flag1) {
- return true;
- }
- if (l == 4 && flag && !flag2 && !flag3) {
- return true;
- }
- return l == 5 && flag1 && !flag2 && !flag3;
}
public boolean c() {
- return a;
+ return this.a;
}
public static boolean b(IBlockAccess iblockaccess, int i, int j, int k) {
- int l = iblockaccess.a(i, j, k);
+ int l = iblockaccess.getTypeId(i, j, k);
- if (l == Block.av.bi) {
- return true;
- }
- if (l == 0) {
- return false;
- }
- return Block.m[l].c();
+ return l == Block.REDSTONE_WIRE.id ? true : (l == 0 ? false : Block.byId[l].c());
}
}
diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java
index 3d4fe19d..ad86284e 100644
--- a/src/main/java/net/minecraft/server/BlockStationary.java
+++ b/src/main/java/net/minecraft/server/BlockStationary.java
@@ -1,64 +1,66 @@
package net.minecraft.server;
+import java.util.Random;
+
// CraftBukkit start
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.craftbukkit.CraftWorld;
-import java.util.Random;
// CraftBukkit end
public class BlockStationary extends BlockFluids {
- protected BlockStationary(int k, Material material) {
- super(k, material);
- a(false);
- if (material == Material.g) {
- a(true);
+ protected BlockStationary(int i, Material material) {
+ super(i, material);
+ this.a(false);
+ if (material == Material.LAVA) {
+ this.a(true);
}
}
- public void b(World world, int k, int l, int i1, int j1) {
- super.b(world, k, l, i1, j1);
- if (world.a(k, l, i1) == bi) {
- i(world, k, l, i1);
+ public void b(World world, int i, int j, int k, int l) {
+ super.b(world, i, j, k, l);
+ if (world.getTypeId(i, j, k) == this.id) {
+ this.i(world, i, j, k);
}
}
- private void i(World world, int k, int l, int i1) {
- int j1 = world.b(k, l, i1);
+ private void i(World world, int i, int j, int k) {
+ int l = world.getData(i, j, k);
world.i = true;
- world.a(k, l, i1, bi - 1, j1);
- world.b(k, l, i1, k, l, i1);
- world.i(k, l, i1, bi - 1);
+ world.setTypeIdAndData(i, j, k, this.id - 1, l);
+ world.b(i, j, k, i, j, k);
+ world.i(i, j, k, this.id - 1);
world.i = false;
}
- public void a(World world, int k, int l, int i1, Random random) {
- if (bt == Material.g) {
- int j1 = random.nextInt(3);
+ public void a(World world, int i, int j, int k, Random random) {
+ if (this.material == Material.LAVA) {
+ int l = random.nextInt(3);
+
+ // CraftBukkit start: prevent lava putting something on fire.
+ Server server = ((WorldServer)world).getServer();
+ CraftWorld cworld = ((WorldServer)world).getWorld();
- for (int k1 = 0; k1 < j1; k1++) {
+ IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
+ Player thePlayer = null;
+ // CraftBukkit end
+
+ for (int i1 = 0; i1 < l; ++i1) {
+ i += random.nextInt(3) - 1;
+ ++j;
k += random.nextInt(3) - 1;
- l++;
- i1 += random.nextInt(3) - 1;
- int l1 = world.a(k, l, i1);
+ int j1 = world.getTypeId(i, j, k);
- if (l1 == 0) {
- // this checks if an adjacent block is flammable before lighting this block.
- // perhaps we can reduce spam by checking this earlier.
- if (j(world, k - 1, l, i1) || j(world, k + 1, l, i1) || j(world, k, l, i1 - 1) || j(world, k, l, i1 + 1) || j(world, k, l - 1, i1) || j(world, k, l + 1, i1)) {
+ if (j1 == 0) {
+ if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) {
// CraftBukkit start: prevent lava putting something on fire.
- Server server = ((WorldServer)world).getServer();
- CraftWorld cworld = ((WorldServer)world).getWorld();
-
org.bukkit.block.Block theBlock = cworld.getBlockAt(k, l, i1);
- IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.LAVA;
- Player thePlayer = null;
-
- if (theBlock.getTypeId() != Block.ar.bi){
+
+ if (theBlock.getTypeId() != Block.FIRE.id){
BlockIgniteEvent event = new BlockIgniteEvent(theBlock, igniteCause, thePlayer);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -66,19 +68,18 @@ public class BlockStationary extends BlockFluids {
}
}
// CraftBukkit end
- world.e(k, l, i1, Block.ar.bi);
+
+ world.e(i, j, k, Block.FIRE.id);
return;
}
- continue;
- }
- if (Block.m[l1].bt.c()) {
+ } else if (Block.byId[j1].material.isSolid()) {
return;
}
}
}
}
- private boolean j(World world, int k, int l, int i1) {
- return world.c(k, l, i1).e();
+ private boolean j(World world, int i, int j, int k) {
+ return world.getMaterial(i, j, k).isBurnable();
}
}
diff --git a/src/main/java/net/minecraft/server/BlockWorkbench.java b/src/main/java/net/minecraft/server/BlockWorkbench.java
index 33bcf7b3..213b7750 100644
--- a/src/main/java/net/minecraft/server/BlockWorkbench.java
+++ b/src/main/java/net/minecraft/server/BlockWorkbench.java
@@ -12,26 +12,16 @@ import org.bukkit.event.block.BlockInteractEvent;
public class BlockWorkbench extends Block {
protected BlockWorkbench(int i) {
- super(i, Material.c);
- bh = 59;
+ super(i, Material.WOOD);
+ this.textureId = 59;
}
public int a(int i) {
- if (i == 1) {
- return bh - 16;
- }
- if (i == 0) {
- return Block.x.a(0);
- }
- if (i == 2 || i == 4) {
- return bh + 1;
- } else {
- return bh;
- }
+ return i == 1 ? this.textureId - 16 : (i == 0 ? Block.WOOD.a(0) : (i != 2 && i != 4 ? this.textureId : this.textureId + 1));
}
- public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
- if (world.z) {
+ public boolean a(World world, int i, int j, int k, EntityHuman entityhuman) {
+ if (world.isStatic) {
return true;
} else {
// CraftBukkit start - Interact Workbench
@@ -39,17 +29,17 @@ public class BlockWorkbench extends Block {
CraftServer server = ((WorldServer) world).getServer();
Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
- LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
-
- BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
- server.getPluginManager().callEvent(bie);
+ LivingEntity who = (entityhuman == null) ? null : (LivingEntity) entityhuman.getBukkitEntity();
+
+ BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(event);
- if (bie.isCancelled()) {
+ if (event.isCancelled()) {
return true;
}
// CraftBukkit end
- entityplayer.a(i, j, k);
+ entityhuman.a(i, j, k);
return true;
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 99727862..f5d524ea 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -1,7 +1,12 @@
package net.minecraft.server;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftChunk;
@@ -13,57 +18,55 @@ import org.bukkit.event.world.ChunkLoadEvent;
public class ChunkProviderServer implements IChunkProvider {
- private Set a;
+ private Set a = new HashSet();
private Chunk b;
private IChunkProvider c;
private IChunkLoader d;
- private Map e;
- private List f;
+ private Map e = new HashMap();
+ private List f = new ArrayList();
private WorldServer g;
public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
- a = ((Set) (new HashSet()));
- e = ((Map) (new HashMap()));
- f = ((List) (new ArrayList()));
- b = ((Chunk) (new EmptyChunk(((World) (worldserver)), new byte[32768], 0, 0)));
- g = worldserver;
- d = ichunkloader;
- c = ichunkprovider;
+ this.b = new EmptyChunk(worldserver, new byte['\u8000'], 0, 0);
+ this.g = worldserver;
+ this.d = ichunkloader;
+ this.c = ichunkprovider;
}
public boolean a(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
- return e.containsKey(((chunkcoordinates)));
+ return this.e.containsKey(chunkcoordinates);
}
public void c(int i, int j) {
- int k = (i * 16 + 8) - g.m;
- int l = (j * 16 + 8) - g.o;
- char c1 = '\200';
+ int k = i * 16 + 8 - this.g.spawnX;
+ int l = j * 16 + 8 - this.g.spawnZ;
+ short short1 = 128;
- if (k < -c1 || k > c1 || l < -c1 || l > c1) {
- a.add(((new ChunkCoordinates(i, j))));
+ if (k < -short1 || k > short1 || l < -short1 || l > short1) {
+ this.a.add(new ChunkCoordinates(i, j));
}
}
public Chunk d(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
- a.remove(((new ChunkCoordinates(i, j))));
- Chunk chunk = (Chunk) e.get(((chunkcoordinates)));
+ this.a.remove(new ChunkCoordinates(i, j));
+ Chunk chunk = (Chunk) this.e.get(chunkcoordinates);
if (chunk == null) {
- chunk = e(i, j);
+ chunk = this.e(i, j);
if (chunk == null) {
- if (c == null) {
- chunk = b;
+ if (this.c == null) {
+ chunk = this.b;
} else {
- chunk = c.b(i, j);
+ chunk = this.c.b(i, j);
}
}
- e.put(((chunkcoordinates)), ((chunk)));
- f.add(((chunk)));
+
+ this.e.put(chunkcoordinates, chunk);
+ this.f.add(chunk);
if (chunk != null) {
chunk.c();
chunk.d();
@@ -83,84 +86,80 @@ public class ChunkProviderServer implements IChunkProvider {
}
// CraftBukkit end
- if (!chunk.n && a(i + 1, j + 1) && a(i, j + 1) && a(i + 1, j)) {
- a(((IChunkProvider) (this)), i, j);
+ if (!chunk.n && this.a(i + 1, j + 1) && this.a(i, j + 1) && this.a(i + 1, j)) {
+ this.a(this, i, j);
}
- if (a(i - 1, j) && !b(i - 1, j).n && a(i - 1, j + 1) && a(i, j + 1) && a(i - 1, j)) {
- a(((IChunkProvider) (this)), i - 1, j);
+
+ if (this.a(i - 1, j) && !this.b(i - 1, j).n && this.a(i - 1, j + 1) && this.a(i, j + 1) && this.a(i - 1, j)) {
+ this.a(this, i - 1, j);
}
- if (a(i, j - 1) && !b(i, j - 1).n && a(i + 1, j - 1) && a(i, j - 1) && a(i + 1, j)) {
- a(((IChunkProvider) (this)), i, j - 1);
+
+ if (this.a(i, j - 1) && !this.b(i, j - 1).n && this.a(i + 1, j - 1) && this.a(i, j - 1) && this.a(i + 1, j)) {
+ this.a(this, i, j - 1);
}
- if (a(i - 1, j - 1) && !b(i - 1, j - 1).n && a(i - 1, j - 1) && a(i, j - 1) && a(i - 1, j)) {
- a(((IChunkProvider) (this)), i - 1, j - 1);
+
+ if (this.a(i - 1, j - 1) && !this.b(i - 1, j - 1).n && this.a(i - 1, j - 1) && this.a(i, j - 1) && this.a(i - 1, j)) {
+ this.a(this, i - 1, j - 1);
}
}
+
return chunk;
}
public Chunk b(int i, int j) {
ChunkCoordinates chunkcoordinates = new ChunkCoordinates(i, j);
- Chunk chunk = (Chunk) e.get(((chunkcoordinates)));
+ Chunk chunk = (Chunk) this.e.get(chunkcoordinates);
- if (chunk == null) {
- if (g.x) {
- return d(i, j);
- } else {
- return b;
- }
- } else {
- return chunk;
- }
+ return chunk == null ? (this.g.x ? this.d(i, j) : this.b) : chunk;
}
private Chunk e(int i, int j) {
- if (d == null) {
+ if (this.d == null) {
return null;
- }
- try {
- Chunk chunk = d.a(((World) (g)), i, j);
+ } else {
+ try {
+ Chunk chunk = this.d.a(this.g, i, j);
- if (chunk != null) {
- chunk.r = g.e;
+ if (chunk != null) {
+ chunk.r = this.g.e;
+ }
+
+ return chunk;
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ return null;
}
- return chunk;
- } catch (Exception exception) {
- exception.printStackTrace();
}
- return null;
}
private void a(Chunk chunk) {
- if (d == null) {
- return;
- }
- try {
- d.b(((World) (g)), chunk);
- } catch (Exception exception) {
- exception.printStackTrace();
+ if (this.d != null) {
+ try {
+ this.d.b(this.g, chunk);
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
}
}
private void b(Chunk chunk) {
- if (d == null) {
- return;
- }
- try {
- chunk.r = g.e;
- d.a(((World) (g)), chunk);
- } catch (Throwable ioexception) { // CraftBukkit -- downcast to work
- ioexception.printStackTrace();
+ if (this.d != null) {
+ try {
+ chunk.r = this.g.e;
+ this.d.a(this.g, chunk);
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
+ ioexception.printStackTrace();
+ }
}
}
public void a(IChunkProvider ichunkprovider, int i, int j) {
- Chunk chunk = b(i, j);
+ Chunk chunk = this.b(i, j);
if (!chunk.n) {
chunk.n = true;
- if (c != null) {
- c.a(ichunkprovider, i, j);
+ if (this.c != null) {
+ this.c.a(ichunkprovider, i, j);
chunk.f();
}
}
@@ -169,55 +168,59 @@ public class ChunkProviderServer implements IChunkProvider {
public boolean a(boolean flag, IProgressUpdate iprogressupdate) {
int i = 0;
- for (int j = 0; j < f.size(); j++) {
- Chunk chunk = (Chunk) f.get(j);
+ for (int j = 0; j < this.f.size(); ++j) {
+ Chunk chunk = (Chunk) this.f.get(j);
if (flag && !chunk.p) {
- a(chunk);
+ this.a(chunk);
}
- if (!chunk.a(flag)) {
- continue;
- }
- b(chunk);
- chunk.o = false;
- if (++i == 24 && !flag) {
- return false;
+
+ if (chunk.a(flag)) {
+ this.b(chunk);
+ chunk.o = false;
+ ++i;
+ if (i == 24 && !flag) {
+ return false;
+ }
}
}
if (flag) {
- if (d == null) {
+ if (this.d == null) {
return true;
}
- d.b();
+
+ this.d.b();
}
+
return true;
}
public boolean a() {
- if (!g.C) {
- for (int i = 0; i < 100; i++) {
- if (!a.isEmpty()) {
- ChunkCoordinates chunkcoordinates = (ChunkCoordinates) a.iterator().next();
- Chunk chunk = b(chunkcoordinates.a, chunkcoordinates.b);
+ if (!this.g.C) {
+ for (int i = 0; i < 100; ++i) {
+ if (!this.a.isEmpty()) {
+ ChunkCoordinates chunkcoordinates = (ChunkCoordinates) this.a.iterator().next();
+ Chunk chunk = this.b(chunkcoordinates.a, chunkcoordinates.b);
chunk.e();
- b(chunk);
- a(chunk);
- a.remove(((chunkcoordinates)));
- e.remove(((chunkcoordinates)));
- f.remove(((chunk)));
+ this.b(chunk);
+ this.a(chunk);
+ this.a.remove(chunkcoordinates);
+ this.e.remove(chunkcoordinates);
+ this.f.remove(chunk);
}
}
- if (d != null) {
- d.a();
+ if (this.d != null) {
+ this.d.a();
}
}
- return c.a();
+
+ return this.c.a();
}
public boolean b() {
- return !g.C;
+ return !this.g.C;
}
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 8fd6672a..74a2ac9c 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -14,41 +14,41 @@ import java.util.Random;
public abstract class Entity {
- private static int a = 0;
- public int g;
+ private static int entityCount = 0;
+ public int id;
public double h;
public boolean i;
- public Entity j;
- public Entity k;
- public World l;
- public double m;
- public double n;
- public double o;
- public double p;
- public double q;
- public double r;
- public double s;
- public double t;
- public double u;
- public float v;
- public float w;
- public float x;
- public float y;
- public final AxisAlignedBB z = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
- public boolean A;
+ public Entity passenger;
+ public Entity vehicle;
+ public World world;
+ public double lastX;
+ public double lastY;
+ public double lastZ;
+ public double locX;
+ public double locY;
+ public double locZ;
+ public double motX;
+ public double motY;
+ public double motZ;
+ public float yaw;
+ public float pitch;
+ public float lastYaw;
+ public float lastPitch;
+ public final AxisAlignedBB boundingBox;
+ public boolean onGround;
public boolean B;
public boolean C;
public boolean D;
public boolean E;
public boolean F;
- public boolean G;
- public float H;
- public float I;
- public float J;
+ public boolean dead;
+ public float height;
+ public float length;
+ public float width;
public float K;
public float L;
protected boolean M;
- protected float N;
+ protected float fallDistance;
private int b;
public double O;
public double P;
@@ -58,473 +58,509 @@ public abstract class Entity {
public boolean T;
public float U;
public boolean V;
- protected Random W;
- public int X;
- public int Y;
- public int Z;
- protected int aa;
+ protected Random random;
+ public int ticksLived;
+ public int maxFireTicks;
+ public int fireTicks;
+ protected int maxAirTicks;
protected boolean ab;
- public int ac;
- public int ad;
- private boolean c;
+ public int noDamageTicks;
+ public int airTicks;
+ private boolean justCreated;
protected boolean ae;
- protected DataWatcher af;
+ protected DataWatcher datawatcher;
private double d;
private double e;
public boolean ag;
- public int ah;
+ public int chunkX;
public int ai;
- public int aj;
-
- protected org.bukkit.entity.Entity bukkitEntity; // CraftBukkit
+ public int chunkZ;
public Entity(World world) {
- g = a++;
- h = 1.0D;
- i = false;
- A = false;
- D = false;
- E = false;
- F = true;
- G = false;
- H = 0.0F;
- I = 0.6F;
- J = 1.8F;
- K = 0.0F;
- L = 0.0F;
- M = true;
- N = 0.0F;
- b = 1;
- R = 0.0F;
- S = 0.0F;
- T = false;
- U = 0.0F;
- V = false;
- W = new Random();
- X = 0;
- Y = 1;
- Z = 0;
- aa = 300;
- ab = false;
- ac = 0;
- ad = 300;
- c = true;
- ae = false;
- af = new DataWatcher();
- ag = false;
- l = world;
- a(0.0D, 0.0D, 0.0D);
- af.a(0, ((Byte.valueOf((byte) 0))));
- a();
-
- bukkitEntity = null; // CraftBukkit
+ this.id = entityCount++;
+ this.h = 1.0D;
+ this.i = false;
+ this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
+ this.onGround = false;
+ this.D = false;
+ this.E = false;
+ this.F = true;
+ this.dead = false;
+ this.height = 0.0F;
+ this.length = 0.6F;
+ this.width = 1.8F;
+ this.K = 0.0F;
+ this.L = 0.0F;
+ this.M = true;
+ this.fallDistance = 0.0F;
+ this.b = 1;
+ this.R = 0.0F;
+ this.S = 0.0F;
+ this.T = false;
+ this.U = 0.0F;
+ this.V = false;
+ this.random = new Random();
+ this.ticksLived = 0;
+ this.maxFireTicks = 1;
+ this.fireTicks = 0;
+ this.maxAirTicks = 300;
+ this.ab = false;
+ this.noDamageTicks = 0;
+ this.airTicks = 300;
+ this.justCreated = true;
+ this.ae = false;
+ this.datawatcher = new DataWatcher();
+ this.ag = false;
+ this.world = world;
+ this.a(0.0D, 0.0D, 0.0D);
+ this.datawatcher.a(0, Byte.valueOf((byte) 0));
+ this.a();
+
+ // CraftBukkit start
+ bukkitEntity = null;
}
+ protected org.bukkit.entity.Entity bukkitEntity;
+ // CraftBukkit end
protected abstract void a();
public DataWatcher p() {
- return af;
+ return this.datawatcher;
}
- public boolean equals(Object obj) {
- if (obj instanceof Entity) {
- return ((Entity) obj).g == g;
- } else {
- return false;
- }
+ public boolean equals(Object object) {
+ return object instanceof Entity ? ((Entity) object).id == this.id : false;
}
public int hashCode() {
- return g;
+ return this.id;
}
public void q() {
- G = true;
+ this.dead = true;
}
- protected void a(float f1, float f2) {
- I = f1;
- J = f2;
+ protected void a(float f, float f1) {
+ this.length = f;
+ this.width = f1;
}
- protected void b(float f1, float f2) {
- v = f1;
- w = f2;
+ protected void b(float f, float f1) {
+ this.yaw = f;
+ this.pitch = f1;
}
- public void a(double d1, double d2, double d3) {
- p = d1;
- q = d2;
- r = d3;
- float f1 = I / 2.0F;
- float f2 = J;
+ public void a(double d0, double d1, double d2) {
+ this.locX = d0;
+ this.locY = d1;
+ this.locZ = d2;
+ float f = this.length / 2.0F;
+ float f1 = this.width;
- z.c(d1 - (double) f1, (d2 - (double) H) + (double) R, d3 - (double) f1, d1 + (double) f1, (d2 - (double) H) + (double) R + (double) f2, d3 + (double) f1);
+ this.boundingBox.c(d0 - (double) f, d1 - (double) this.height + (double) this.R, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.R + (double) f1, d2 + (double) f);
}
public void b_() {
- r();
+ this.r();
}
public void r() {
- if (k != null && k.G) {
- k = null;
+ if (this.vehicle != null && this.vehicle.dead) {
+ this.vehicle = null;
}
- X++;
- K = L;
- m = p;
- n = q;
- o = r;
- y = w;
- x = v;
- if (v()) {
- if (!ab && !c) {
- float f1 = MathHelper.a(s * s * 0.20000000298023224D + t * t + u * u * 0.20000000298023224D) * 0.2F;
-
- if (f1 > 1.0F) {
- f1 = 1.0F;
+
+ ++this.ticksLived;
+ this.K = this.L;
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ this.lastPitch = this.pitch;
+ this.lastYaw = this.yaw;
+ if (this.v()) {
+ if (!this.ab && !this.justCreated) {
+ float f = MathHelper.a(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.2F;
+
+ if (f > 1.0F) {
+ f = 1.0F;
}
- l.a(this, "random.splash", f1, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F);
- float f2 = MathHelper.b(z.b);
- for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) {
- float f3 = (W.nextFloat() * 2.0F - 1.0F) * I;
- float f5 = (W.nextFloat() * 2.0F - 1.0F) * I;
+ this.world.a(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
+ float f1 = (float) MathHelper.b(this.boundingBox.b);
- l.a("bubble", p + (double) f3, f2 + 1.0F, r + (double) f5, s, t - (double) (W.nextFloat() * 0.2F), u);
- }
+ int i;
+ float f2;
+ float f3;
- for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) {
- float f4 = (W.nextFloat() * 2.0F - 1.0F) * I;
- float f6 = (W.nextFloat() * 2.0F - 1.0F) * I;
+ for (i = 0; (float) i < 1.0F + this.length * 20.0F; ++i) {
+ f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ this.world.a("bubble", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ);
+ }
- l.a("splash", p + (double) f4, f2 + 1.0F, r + (double) f6, s, t, u);
+ for (i = 0; (float) i < 1.0F + this.length * 20.0F; ++i) {
+ f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ this.world.a("splash", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY, this.motZ);
}
}
- N = 0.0F;
- ab = true;
- Z = 0;
+
+ this.fallDistance = 0.0F;
+ this.ab = true;
+ this.fireTicks = 0;
} else {
- ab = false;
+ this.ab = false;
}
- if (l.z) {
- Z = 0;
- } else if (Z > 0) {
- if (ae) {
- Z -= 4;
- if (Z < 0) {
- Z = 0;
+
+ if (this.world.isStatic) {
+ this.fireTicks = 0;
+ } else if (this.fireTicks > 0) {
+ if (this.ae) {
+ this.fireTicks -= 4;
+ if (this.fireTicks < 0) {
+ this.fireTicks = 0;
}
} else {
- if (Z % 20 == 0) {
+ if (this.fireTicks % 20 == 0) {
// CraftBukkit start
// TODO: this event spams!
if(this instanceof EntityLiving) {
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING;
int damageDone = 1;
- EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone);
- server.getPluginManager().callEvent(ede);
+ EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
- if (!ede.isCancelled()){
- a(((Entity) (null)), ede.getDamage());
+ if (!event.isCancelled()){
+ this.a((Entity) null, event.getDamage());
}
} else {
- a(((Entity) (null)), 1);
+ this.a((Entity) null, 1);
}
// CraftBukkit end
}
- Z--;
+
+ --this.fireTicks;
}
}
- if (x()) {
- s();
+
+ if (this.x()) {
+ this.s();
}
- if (q < -64D) {
- t();
+
+ if (this.locY < -64.0D) {
+ this.t();
}
- if (!l.z) {
- a(0, Z > 0);
- a(2, k != null);
+
+ if (!this.world.isStatic) {
+ this.a(0, this.fireTicks > 0);
+ this.a(2, this.vehicle != null);
}
- c = false;
+
+ this.justCreated = false;
}
protected void s() {
- if (!ae) {
+ if (!this.ae) {
// CraftBukkit start
// TODO: this event spams!
if(this instanceof EntityLiving) {
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
// TODO: shouldn't be sending null for the block.
- org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k);
+ org.bukkit.block.Block damager = null; //((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.LAVA;
int damageDone = 4;
- EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(ede);
- if (!ede.isCancelled()){
- a(((Entity) (null)), ede.getDamage());
+ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()){
+ this.a((Entity) null, event.getDamage());
}
- if(Z <= 0){
+ if(this.fireTicks <= 0){
// not on fire yet
Type eventType = Type.ENTITY_COMBUST;
- EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee);
- server.getPluginManager().callEvent(ece);
- if (!ece.isCancelled()){
- Z = 600;
+ EntityCombustEvent combustEvent = new EntityCombustEvent(eventType, damagee);
+ server.getPluginManager().callEvent(combustEvent);
+ if (!combustEvent.isCancelled()){
+ this.fireTicks = 600;
}
} else {
// reset fire level back to max
- Z = 600;
+ this.fireTicks = 600;
}
-
- } else {
- a(((Entity) (null)), 4);
- Z = 600;
+ return;
}
// CraftBukkit end
+
+ this.a((Entity) null, 4);
+ this.fireTicks = 600;
}
}
protected void t() {
- q();
+ this.q();
}
- public boolean b(double d1, double d2, double d3) {
- AxisAlignedBB axisalignedbb = z.c(d1, d2, d3);
- List list = l.a(this, axisalignedbb);
+ public boolean b(double d0, double d1, double d2) {
+ AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2);
+ List list = this.world.a(this, axisalignedbb);
- if (list.size() > 0) {
- return false;
- }
- return !l.b(axisalignedbb);
+ return list.size() > 0 ? false : !this.world.b(axisalignedbb);
}
- public void c(double d1, double d2, double d3) {
- if (T) {
- z.d(d1, d2, d3);
- p = (z.a + z.d) / 2D;
- q = (z.b + (double) H) - (double) R;
- r = (z.c + z.f) / 2D;
- return;
- }
- double d4 = p;
- double d5 = r;
- double d6 = d1;
- double d7 = d2;
- double d8 = d3;
- AxisAlignedBB axisalignedbb = z.b();
- boolean flag = A && J();
-
- if (flag) {
- double d9 = 0.050000000000000003D;
-
- for (; d1 != 0.0D && l.a(this, z.c(d1, -1D, 0.0D)).size() == 0; d6 = d1) {
- if (d1 < d9 && d1 >= -d9) {
- d1 = 0.0D;
- continue;
- }
- if (d1 > 0.0D) {
- d1 -= d9;
- } else {
- d1 += d9;
+ public void c(double d0, double d1, double d2) {
+ if (this.T) {
+ this.boundingBox.d(d0, d1, d2);
+ this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
+ this.locY = this.boundingBox.b + (double) this.height - (double) this.R;
+ this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D;
+ } else {
+ double d3 = this.locX;
+ double d4 = this.locZ;
+ double d5 = d0;
+ double d6 = d1;
+ double d7 = d2;
+ AxisAlignedBB axisalignedbb = this.boundingBox.b();
+ boolean flag = this.onGround && this.J();
+
+ if (flag) {
+ 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) {
+ if (d0 < d8 && d0 >= -d8) {
+ d0 = 0.0D;
+ } else if (d0 > 0.0D) {
+ d0 -= d8;
+ } else {
+ d0 += d8;
+ }
}
- }
- for (; d3 != 0.0D && l.a(this, z.c(0.0D, -1D, d3)).size() == 0; d8 = d3) {
- if (d3 < d9 && d3 >= -d9) {
- d3 = 0.0D;
- continue;
- }
- if (d3 > 0.0D) {
- d3 -= d9;
- } else {
- d3 += d9;
+ for (; d2 != 0.0D && this.world.a(this, this.boundingBox.c(0.0D, -1.0D, d2)).size() == 0; d7 = d2) {
+ if (d2 < d8 && d2 >= -d8) {
+ d2 = 0.0D;
+ } else if (d2 > 0.0D) {
+ d2 -= d8;
+ } else {
+ d2 += d8;
+ }
}
}
- }
- List list = l.a(this, z.a(d1, d2, d3));
- for (int i1 = 0; i1 < list.size(); i1++) {
- d2 = ((AxisAlignedBB) list.get(i1)).b(z, d2);
- }
-
- z.d(0.0D, d2, 0.0D);
- if (!F && d7 != d2) {
- d1 = d2 = d3 = 0.0D;
- }
- boolean flag1 = A || d7 != d2 && d7 < 0.0D;
+ List list = this.world.a(this, this.boundingBox.a(d0, d1, d2));
- for (int j1 = 0; j1 < list.size(); j1++) {
- d1 = ((AxisAlignedBB) list.get(j1)).a(z, d1);
- }
+ for (int i = 0; i < list.size(); ++i) {
+ d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1);
+ }
- z.d(d1, 0.0D, 0.0D);
- if (!F && d6 != d1) {
- d1 = d2 = d3 = 0.0D;
- }
- for (int k1 = 0; k1 < list.size(); k1++) {
- d3 = ((AxisAlignedBB) list.get(k1)).c(z, d3);
- }
+ this.boundingBox.d(0.0D, d1, 0.0D);
+ if (!this.F && d6 != d1) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
+ }
- z.d(0.0D, 0.0D, d3);
- if (!F && d8 != d3) {
- d1 = d2 = d3 = 0.0D;
- }
- if (S > 0.0F && flag1 && R < 0.05F && (d6 != d1 || d8 != d3)) {
- double d10 = d1;
- double d12 = d2;
- double d14 = d3;
+ boolean flag1 = this.onGround || d6 != d1 && d6 < 0.0D;
- d1 = d6;
- d2 = S;
- d3 = d8;
- AxisAlignedBB axisalignedbb1 = z.b();
+ int j;
- z.b(axisalignedbb);
- List list1 = l.a(this, z.a(d1, d2, d3));
+ for (j = 0; j < list.size(); ++j) {
+ d0 = ((AxisAlignedBB) list.get(j)).a(this.boundingBox, d0);
+ }
- for (int j2 = 0; j2 < list1.size(); j2++) {
- d2 = ((AxisAlignedBB) list1.get(j2)).b(z, d2);
+ this.boundingBox.d(d0, 0.0D, 0.0D);
+ if (!this.F && d5 != d0) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
}
- z.d(0.0D, d2, 0.0D);
- if (!F && d7 != d2) {
- d1 = d2 = d3 = 0.0D;
+ for (j = 0; j < list.size(); ++j) {
+ d2 = ((AxisAlignedBB) list.get(j)).c(this.boundingBox, d2);
}
- for (int k2 = 0; k2 < list1.size(); k2++) {
- d1 = ((AxisAlignedBB) list1.get(k2)).a(z, d1);
+
+ this.boundingBox.d(0.0D, 0.0D, d2);
+ if (!this.F && d7 != d2) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
}
- z.d(d1, 0.0D, 0.0D);
- if (!F && d6 != d1) {
- d1 = d2 = d3 = 0.0D;
+ double d9;
+ double d10;
+ int k;
+
+ if (this.S > 0.0F && flag1 && this.R < 0.05F && (d5 != d0 || d7 != d2)) {
+ d9 = d0;
+ d10 = d1;
+ double d11 = d2;
+
+ d0 = d5;
+ d1 = (double) this.S;
+ d2 = d7;
+ AxisAlignedBB axisalignedbb1 = this.boundingBox.b();
+
+ this.boundingBox.b(axisalignedbb);
+ list = this.world.a(this, this.boundingBox.a(d5, d1, d7));
+
+ for (k = 0; k < list.size(); ++k) {
+ d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1);
+ }
+
+ this.boundingBox.d(0.0D, d1, 0.0D);
+ if (!this.F && d6 != d1) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
+ }
+
+ for (k = 0; k < list.size(); ++k) {
+ d0 = ((AxisAlignedBB) list.get(k)).a(this.boundingBox, d0);
+ }
+
+ this.boundingBox.d(d0, 0.0D, 0.0D);
+ if (!this.F && d5 != d0) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
+ }
+
+ for (k = 0; k < list.size(); ++k) {
+ d2 = ((AxisAlignedBB) list.get(k)).c(this.boundingBox, d2);
+ }
+
+ this.boundingBox.d(0.0D, 0.0D, d2);
+ if (!this.F && d7 != d2) {
+ d2 = 0.0D;
+ d1 = 0.0D;
+ d0 = 0.0D;
+ }
+
+ if (d9 * d9 + d11 * d11 >= d0 * d0 + d2 * d2) {
+ d0 = d9;
+ d1 = d10;
+ d2 = d11;
+ this.boundingBox.b(axisalignedbb1);
+ } else {
+ this.R = (float) ((double) this.R + 0.5D);
+ }
}
- for (int l2 = 0; l2 < list1.size(); l2++) {
- d3 = ((AxisAlignedBB) list1.get(l2)).c(z, d3);
+
+ this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
+ this.locY = this.boundingBox.b + (double) this.height - (double) this.R;
+ this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D;
+ this.B = d5 != d0 || d7 != d2;
+ this.C = d6 != d1;
+ this.onGround = d6 != d1 && d6 < 0.0D;
+ this.D = this.B || this.C;
+ this.a(d1, this.onGround);
+ if (d5 != d0) {
+ this.motX = 0.0D;
}
- z.d(0.0D, 0.0D, d3);
- if (!F && d8 != d3) {
- d1 = d2 = d3 = 0.0D;
+ if (d6 != d1) {
+ this.motY = 0.0D;
}
- if (d10 * d10 + d14 * d14 >= d1 * d1 + d3 * d3) {
- d1 = d10;
- d2 = d12;
- d3 = d14;
- z.b(axisalignedbb1);
- } else {
- R += 0.5D;
+
+ if (d7 != d2) {
+ this.motZ = 0.0D;
}
- }
- p = (z.a + z.d) / 2D;
- q = (z.b + (double) H) - (double) R;
- r = (z.c + z.f) / 2D;
- B = d6 != d1 || d8 != d3;
- C = d7 != d2;
- A = d7 != d2 && d7 < 0.0D;
- D = B || C;
- a(d2, A);
- if (d6 != d1) {
- s = 0.0D;
- }
- if (d7 != d2) {
- t = 0.0D;
- }
- if (d8 != d3) {
- u = 0.0D;
- }
- double d11 = p - d4;
- double d13 = r - d5;
-
- if (M && !flag) {
- L += ((float) ((double) MathHelper.a(d11 * d11 + d13 * d13) * 0.59999999999999998D));
- int k3 = MathHelper.b(p);
- int i4 = MathHelper.b(q - 0.20000000298023224D - (double) H);
- int l1 = MathHelper.b(r);
- int i3 = l.a(k3, i4, l1);
-
- if (L > (float) b && i3 > 0) {
- b++;
- StepSound stepsound = Block.m[i3].br;
-
- if (l.a(k3, i4 + 1, l1) == Block.aS.bi) {
- stepsound = Block.aS.br;
- l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
- } else if (!Block.m[i3].bt.d()) {
- l.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
+
+ d9 = this.locX - d3;
+ d10 = this.locZ - d4;
+ int l;
+ int i1;
+ int j1;
+
+ if (this.M && !flag) {
+ this.L = (float) ((double) this.L + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D);
+ l = MathHelper.b(this.locX);
+ i1 = MathHelper.b(this.locY - 0.20000000298023224D - (double) this.height);
+ j1 = MathHelper.b(this.locZ);
+ k = this.world.getTypeId(l, i1, j1);
+ if (this.L > (float) this.b && k > 0) {
+ ++this.b;
+ StepSound stepsound = Block.byId[k].stepSound;
+
+ if (this.world.getTypeId(l, i1 + 1, j1) == Block.SNOW.id) {
+ stepsound = Block.SNOW.stepSound;
+ this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
+ } else if (!Block.byId[k].material.isLiquid()) {
+ this.world.a(this, stepsound.c(), stepsound.a() * 0.15F, stepsound.b());
+ }
+
+ Block.byId[k].b(this.world, l, i1, j1, this);
}
- Block.m[i3].b(l, k3, i4, l1, this);
}
- }
- int l3 = MathHelper.b(z.a);
- int j4 = MathHelper.b(z.b);
- int i2 = MathHelper.b(z.c);
- int j3 = MathHelper.b(z.d);
- int k4 = MathHelper.b(z.e);
- int l4 = MathHelper.b(z.f);
-
- if (l.a(l3, j4, i2, j3, k4, l4)) {
- for (int i5 = l3; i5 <= j3; i5++) {
- for (int j5 = j4; j5 <= k4; j5++) {
- for (int k5 = i2; k5 <= l4; k5++) {
- int l5 = l.a(i5, j5, k5);
-
- if (l5 > 0) {
- Block.m[l5].a(l, i5, j5, k5, this);
+
+ l = MathHelper.b(this.boundingBox.a);
+ i1 = MathHelper.b(this.boundingBox.b);
+ j1 = MathHelper.b(this.boundingBox.c);
+ k = MathHelper.b(this.boundingBox.d);
+ int k1 = MathHelper.b(this.boundingBox.e);
+ int l1 = MathHelper.b(this.boundingBox.f);
+
+ if (this.world.a(l, i1, j1, k, k1, l1)) {
+ for (int i2 = l; i2 <= k; ++i2) {
+ for (int j2 = i1; j2 <= k1; ++j2) {
+ for (int k2 = j1; k2 <= l1; ++k2) {
+ int l2 = this.world.getTypeId(i2, j2, k2);
+
+ if (l2 > 0) {
+ Block.byId[l2].a(this.world, i2, j2, k2, this);
+ }
}
}
}
}
- }
- R *= 0.4F;
- boolean flag2 = v();
-
- if (l.c(z)) {
- b(1);
- if (!flag2) {
- Z++;
- // CraftBukkit start
- if(Z <= 0){
- // not on fire yet
- CraftServer server = ((WorldServer) l).getServer();
- org.bukkit.entity.Entity damagee = this.getBukkitEntity();
- Type eventType = Type.ENTITY_COMBUST;
-
- EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee);
- server.getPluginManager().callEvent(ece);
-
- if (!ece.isCancelled()){
- Z = 300;
+
+ this.R *= 0.4F;
+ boolean flag2 = this.v();
+
+ if (this.world.c(this.boundingBox)) {
+ this.b(1);
+ if (!flag2) {
+ ++this.fireTicks;
+ // CraftBukkit start
+ if (this.fireTicks <= 0){
+ // not on fire yet
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
+ Type eventType = Type.ENTITY_COMBUST;
+
+ EntityCombustEvent event = new EntityCombustEvent(eventType, damagee);
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()){
+ this.fireTicks = 300;
+ }
+ } else {
+ // CraftBukkit end - reset fire level back to max
+ this.fireTicks = 300;
}
- } else {
- // reset fire level back to max
- Z = 300;
}
- // CraftBukkit end
+ } else if (this.fireTicks <= 0) {
+ this.fireTicks = -this.maxFireTicks;
+ }
+
+ if (flag2 && this.fireTicks > 0) {
+ this.world.a(this, "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
+ this.fireTicks = -this.maxFireTicks;
}
- } else if (Z <= 0) {
- Z = -Y;
- }
- if (flag2 && Z > 0) {
- l.a(this, "random.fizz", 0.7F, 1.6F + (W.nextFloat() - W.nextFloat()) * 0.4F);
- Z = -Y;
}
}
- protected void a(double d1, boolean flag) {
+ protected void a(double d0, boolean flag) {
if (flag) {
- if (N > 0.0F) {
- a(N);
- N = 0.0F;
+ if (this.fallDistance > 0.0F) {
+ this.a(this.fallDistance);
+ this.fallDistance = 0.0F;
}
- } else if (d1 < 0.0D) {
- N -= ((float) (d1));
+ } else if (d0 < 0.0D) {
+ this.fallDistance = (float) ((double) this.fallDistance - d0);
}
}
@@ -532,46 +568,46 @@ public abstract class Entity {
return null;
}
- protected void b(int i1) {
- if (!ae) {
+ protected void b(int i) {
+ if (!this.ae) {
// CraftBukkit start
if(this instanceof EntityLiving) {
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.FIRE;
- int damageDone = i1;
+ int damageDone = i;
- EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone);
- server.getPluginManager().callEvent(ede);
+ EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
- if (!ede.isCancelled()){
- a(((Entity) (null)), ede.getDamage());
+ if (!event.isCancelled()){
+ this.a((Entity) null, event.getDamage());
}
return;
}
// CraftBukkit end
- a(((Entity) (null)), i1);
+ this.a((Entity) null, i);
}
}
- protected void a(float f1) {}
+ protected void a(float f) {}
public boolean v() {
- return l.a(z.b(0.0D, -0.40000000596046448D, 0.0D), Material.f, this);
+ return this.world.a(this.boundingBox.b(0.0D, -0.4000000059604645D, 0.0D), Material.WATER, this);
}
public boolean a(Material material) {
- double d1 = q + (double) w();
- int i1 = MathHelper.b(p);
- int j1 = MathHelper.d(MathHelper.b(d1));
- int k1 = MathHelper.b(r);
- int l1 = l.a(i1, j1, k1);
+ double d0 = this.locY + (double) this.w();
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.d((float) MathHelper.b(d0));
+ int k = MathHelper.b(this.locZ);
+ int l = this.world.getTypeId(i, j, k);
- if (l1 != 0 && Block.m[l1].bt == material) {
- float f1 = BlockFluids.c(l.b(i1, j1, k1)) - 0.1111111F;
- float f2 = (float) (j1 + 1) - f1;
+ if (l != 0 && Block.byId[l].material == material) {
+ float f = BlockFluids.c(this.world.getData(i, j, k)) - 0.11111111F;
+ float f1 = (float) (j + 1) - f;
- return d1 < (double) f2;
+ return d0 < (double) f1;
} else {
return false;
}
@@ -582,143 +618,141 @@ public abstract class Entity {
}
public boolean x() {
- return l.a(z.b(-0.10000000149011612D, -0.40000000596046448D, -0.10000000149011612D), Material.g);
+ return this.world.a(this.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA);
}
- public void a(float f1, float f2, float f3) {
- float f4 = MathHelper.c(f1 * f1 + f2 * f2);
-
- if (f4 < 0.01F) {
- return;
- }
- if (f4 < 1.0F) {
- f4 = 1.0F;
- }
- f4 = f3 / f4;
- f1 *= f4;
- f2 *= f4;
- float f5 = MathHelper.a((v * 3.141593F) / 180F);
- float f6 = MathHelper.b((v * 3.141593F) / 180F);
+ public void a(float f, float f1, float f2) {
+ float f3 = MathHelper.c(f * f + f1 * f1);
- s += f1 * f6 - f2 * f5;
- u += f2 * f6 + f1 * f5;
- }
+ if (f3 >= 0.01F) {
+ if (f3 < 1.0F) {
+ f3 = 1.0F;
+ }
- public float b(float f1) {
- int i1 = MathHelper.b(p);
- double d1 = (z.e - z.b) * 0.66000000000000003D;
- int j1 = MathHelper.b((q - (double) H) + d1);
- int k1 = MathHelper.b(r);
+ f3 = f2 / f3;
+ f *= f3;
+ f1 *= f3;
+ float f4 = MathHelper.a(this.yaw * 3.1415927F / 180.0F);
+ float f5 = MathHelper.b(this.yaw * 3.1415927F / 180.0F);
- if (l.a(MathHelper.b(z.a), MathHelper.b(z.b), MathHelper.b(z.c), MathHelper.b(z.d), MathHelper.b(z.e), MathHelper.b(z.f))) {
- return l.l(i1, j1, k1);
- } else {
- return 0.0F;
+ this.motX += (double) (f * f5 - f1 * f4);
+ this.motZ += (double) (f1 * f5 + f * f4);
}
}
- public void b(double d1, double d2, double d3, float f1, float f2) {
- m = p = d1;
- n = q = d2;
- o = r = d3;
- x = v = f1;
- y = w = f2;
- R = 0.0F;
- double d4 = x - f1;
+ public float b(float f) {
+ int i = MathHelper.b(this.locX);
+ double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D;
+ int j = MathHelper.b(this.locY - (double) this.height + d0);
+ int k = MathHelper.b(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;
+ }
- if (d4 < -180D) {
- x += 360F;
+ public void b(double d0, double d1, double d2, float f, float f1) {
+ this.lastX = this.locX = d0;
+ this.lastY = this.locY = d1;
+ this.lastZ = this.locZ = d2;
+ this.lastYaw = this.yaw = f;
+ this.lastPitch = this.pitch = f1;
+ this.R = 0.0F;
+ double d3 = (double) (this.lastYaw - f);
+
+ if (d3 < -180.0D) {
+ this.lastYaw += 360.0F;
}
- if (d4 >= 180D) {
- x -= 360F;
+
+ if (d3 >= 180.0D) {
+ this.lastYaw -= 360.0F;
}
- a(p, q, r);
- b(f1, f2);
+
+ this.a(this.locX, this.locY, this.locZ);
+ this.b(f, f1);
}
- public void c(double d1, double d2, double d3, float f1, float f2) {
- O = m = p = d1;
- P = n = q = d2 + (double) H;
- Q = o = r = d3;
- v = f1;
- w = f2;
- a(p, q, r);
+ public void c(double d0, double d1, double d2, float f, float f1) {
+ this.O = this.lastX = this.locX = d0;
+ this.P = this.lastY = this.locY = d1 + (double) this.height;
+ this.Q = this.lastZ = this.locZ = d2;
+ this.yaw = f;
+ this.pitch = f1;
+ this.a(this.locX, this.locY, this.locZ);
}
public float a(Entity entity) {
- float f1 = (float) (p - entity.p);
- float f2 = (float) (q - entity.q);
- float f3 = (float) (r - entity.r);
+ float f = (float) (this.locX - entity.locX);
+ float f1 = (float) (this.locY - entity.locY);
+ float f2 = (float) (this.locZ - entity.locZ);
- return MathHelper.c(f1 * f1 + f2 * f2 + f3 * f3);
+ return MathHelper.c(f * f + f1 * f1 + f2 * f2);
}
- public double d(double d1, double d2, double d3) {
- double d4 = p - d1;
- double d5 = q - d2;
- double d6 = r - d3;
+ public double d(double d0, double d1, double d2) {
+ double d3 = this.locX - d0;
+ double d4 = this.locY - d1;
+ double d5 = this.locZ - d2;
- return d4 * d4 + d5 * d5 + d6 * d6;
+ return d3 * d3 + d4 * d4 + d5 * d5;
}
- public double e(double d1, double d2, double d3) {
- double d4 = p - d1;
- double d5 = q - d2;
- double d6 = r - d3;
+ public double e(double d0, double d1, double d2) {
+ double d3 = this.locX - d0;
+ double d4 = this.locY - d1;
+ double d5 = this.locZ - d2;
- return (double) MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
+ return (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5);
}
public double b(Entity entity) {
- double d1 = p - entity.p;
- double d2 = q - entity.q;
- double d3 = r - entity.r;
+ double d0 = this.locX - entity.locX;
+ double d1 = this.locY - entity.locY;
+ double d2 = this.locZ - entity.locZ;
- return d1 * d1 + d2 * d2 + d3 * d3;
+ return d0 * d0 + d1 * d1 + d2 * d2;
}
- public void b(EntityPlayer entityplayer) {}
+ public void b(EntityHuman entityhuman) {}
public void c(Entity entity) {
- if (entity.j == this || entity.k == this) {
- return;
- }
- double d1 = entity.p - p;
- double d2 = entity.r - r;
- double d3 = MathHelper.a(d1, d2);
-
- if (d3 >= 0.0099999997764825821D) {
- d3 = MathHelper.a(d3);
- d1 /= d3;
- d2 /= d3;
- double d4 = 1.0D / d3;
-
- if (d4 > 1.0D) {
- d4 = 1.0D;
- }
- d1 *= d4;
- d2 *= d4;
- d1 *= 0.05000000074505806D;
- d2 *= 0.05000000074505806D;
- d1 *= 1.0F - U;
- d2 *= 1.0F - U;
- f(-d1, 0.0D, -d2);
- entity.f(d1, 0.0D, d2);
+ if (entity.passenger != this && entity.vehicle != this) {
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
+ double d2 = MathHelper.a(d0, d1);
+
+ if (d2 >= 0.009999999776482582D) {
+ d2 = (double) MathHelper.a(d2);
+ d0 /= d2;
+ d1 /= d2;
+ double d3 = 1.0D / d2;
+
+ if (d3 > 1.0D) {
+ d3 = 1.0D;
+ }
+
+ d0 *= d3;
+ d1 *= d3;
+ d0 *= 0.05000000074505806D;
+ d1 *= 0.05000000074505806D;
+ d0 *= (double) (1.0F - this.U);
+ d1 *= (double) (1.0F - this.U);
+ this.f(-d0, 0.0D, -d1);
+ entity.f(d0, 0.0D, d1);
+ }
}
}
- public void f(double d1, double d2, double d3) {
- s += d1;
- t += d2;
- u += d3;
+ public void f(double d0, double d1, double d2) {
+ this.motX += d0;
+ this.motY += d1;
+ this.motZ += d2;
}
protected void y() {
- E = true;
+ this.E = true;
}
- public boolean a(Entity entity, int i1) {
- y();
+ public boolean a(Entity entity, int i) {
+ this.y();
return false;
}
@@ -730,35 +764,29 @@ public abstract class Entity {
return false;
}
- public void b(Entity entity, int i1) {}
+ public void b(Entity entity, int i) {}
public boolean c(NBTTagCompound nbttagcompound) {
- String s1 = A();
+ String s = this.A();
- if (G || s1 == null) {
- return false;
- } else {
- nbttagcompound.a("id", s1);
- d(nbttagcompound);
+ if (!this.dead && s != null) {
+ nbttagcompound.a("id", s);
+ this.d(nbttagcompound);
return true;
+ } else {
+ return false;
}
}
public void d(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Pos", ((NBTBase) (a(new double[] {
- p, q, r
- }))));
- nbttagcompound.a("Motion", ((NBTBase) (a(new double[] {
- s, t, u
- }))));
- nbttagcompound.a("Rotation", ((NBTBase) (a(new float[] {
- v, w
- }))));
- nbttagcompound.a("FallDistance", N);
- nbttagcompound.a("Fire", (short) Z);
- nbttagcompound.a("Air", (short) ad);
- nbttagcompound.a("OnGround", A);
- a(nbttagcompound);
+ nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY, this.locZ}));
+ nbttagcompound.a("Motion", (NBTBase) this.a(new double[] { this.motX, this.motY, this.motZ}));
+ nbttagcompound.a("Rotation", (NBTBase) this.a(new float[] { this.yaw, this.pitch}));
+ nbttagcompound.a("FallDistance", this.fallDistance);
+ nbttagcompound.a("Fire", (short) this.fireTicks);
+ nbttagcompound.a("Air", (short) this.airTicks);
+ nbttagcompound.a("OnGround", this.onGround);
+ this.a(nbttagcompound);
}
public void e(NBTTagCompound nbttagcompound) {
@@ -766,88 +794,88 @@ public abstract class Entity {
NBTTagList nbttaglist1 = nbttagcompound.k("Motion");
NBTTagList nbttaglist2 = nbttagcompound.k("Rotation");
- a(0.0D, 0.0D, 0.0D);
- s = ((NBTTagDouble) nbttaglist1.a(0)).a;
- t = ((NBTTagDouble) nbttaglist1.a(1)).a;
- u = ((NBTTagDouble) nbttaglist1.a(2)).a;
- m = O = p = ((NBTTagDouble) nbttaglist.a(0)).a;
- n = P = q = ((NBTTagDouble) nbttaglist.a(1)).a;
- o = Q = r = ((NBTTagDouble) nbttaglist.a(2)).a;
- x = v = ((NBTTagFloat) nbttaglist2.a(0)).a;
- y = w = ((NBTTagFloat) nbttaglist2.a(1)).a;
- N = nbttagcompound.f("FallDistance");
- Z = ((int) (nbttagcompound.c("Fire")));
- ad = ((int) (nbttagcompound.c("Air")));
- A = nbttagcompound.l("OnGround");
- a(p, q, r);
- b(nbttagcompound);
+ this.a(0.0D, 0.0D, 0.0D);
+ this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a;
+ this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a;
+ this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a;
+ this.lastX = this.O = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a;
+ this.lastY = this.P = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a;
+ this.lastZ = this.Q = this.locZ = ((NBTTagDouble) nbttaglist.a(2)).a;
+ this.lastYaw = this.yaw = ((NBTTagFloat) nbttaglist2.a(0)).a;
+ this.lastPitch = this.pitch = ((NBTTagFloat) nbttaglist2.a(1)).a;
+ this.fallDistance = nbttagcompound.f("FallDistance");
+ this.fireTicks = nbttagcompound.c("Fire");
+ this.airTicks = nbttagcompound.c("Air");
+ this.onGround = nbttagcompound.l("OnGround");
+ this.a(this.locX, this.locY, this.locZ);
+ this.b(nbttagcompound);
}
protected final String A() {
- return EntityList.b(this);
+ return EntityTypes.b(this);
}
protected abstract void b(NBTTagCompound nbttagcompound);
protected abstract void a(NBTTagCompound nbttagcompound);
- protected NBTTagList a(double ad1[]) {
+ protected NBTTagList a(double... adouble) {
NBTTagList nbttaglist = new NBTTagList();
- double ad2[] = ad1;
- int i1 = ad2.length;
+ double[] adouble1 = adouble;
+ int i = adouble.length;
- for (int j1 = 0; j1 < i1; j1++) {
- double d1 = ad2[j1];
+ for (int j = 0; j < i; ++j) {
+ double d0 = adouble1[j];
- nbttaglist.a(((NBTBase) (new NBTTagDouble(d1))));
+ nbttaglist.a((NBTBase) (new NBTTagDouble(d0)));
}
return nbttaglist;
}
- protected NBTTagList a(float af1[]) {
+ protected NBTTagList a(float... afloat) {
NBTTagList nbttaglist = new NBTTagList();
- float af2[] = af1;
- int i1 = af2.length;
+ float[] afloat1 = afloat;
+ int i = afloat.length;
- for (int j1 = 0; j1 < i1; j1++) {
- float f1 = af2[j1];
+ for (int j = 0; j < i; ++j) {
+ float f = afloat1[j];
- nbttaglist.a(((NBTBase) (new NBTTagFloat(f1))));
+ nbttaglist.a((NBTBase) (new NBTTagFloat(f)));
}
return nbttaglist;
}
- public EntityItem a(int i1, int j1) {
- return a(i1, j1, 0.0F);
+ public EntityItem a(int i, int j) {
+ return this.a(i, j, 0.0F);
}
- public EntityItem a(int i1, int j1, float f1) {
- return a(new ItemStack(i1, j1, 0), f1);
+ public EntityItem a(int i, int j, float f) {
+ return this.a(new ItemStack(i, j, 0), f);
}
- public EntityItem a(ItemStack itemstack, float f1) {
- EntityItem entityitem = new EntityItem(l, p, q + (double) f1, r, itemstack);
+ public EntityItem a(ItemStack itemstack, float f) {
+ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.c = 10;
- l.a(((Entity) (entityitem)));
+ this.world.a((Entity) entityitem);
return entityitem;
}
public boolean B() {
- return !G;
+ return !this.dead;
}
public boolean C() {
- int i1 = MathHelper.b(p);
- int j1 = MathHelper.b(q + (double) w());
- int k1 = MathHelper.b(r);
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.locY + (double) this.w());
+ int k = MathHelper.b(this.locZ);
- return l.d(i1, j1, k1);
+ return this.world.d(i, j, k);
}
- public boolean a(EntityPlayer entityplayer) {
+ public boolean a(EntityHuman entityhuman) {
return false;
}
@@ -856,61 +884,69 @@ public abstract class Entity {
}
public void D() {
- if (k.G) {
- k = null;
- return;
- }
- s = 0.0D;
- t = 0.0D;
- u = 0.0D;
- b_();
- k.E();
- e += k.v - k.x;
- d += k.w - k.y;
- for (; e >= 180D; e -= 360D) {
- ;
- }
- for (; e < -180D; e += 360D) {
- ;
- }
- for (; d >= 180D; d -= 360D) {
- ;
- }
- for (; d < -180D; d += 360D) {
- ;
- }
- double d1 = e * 0.5D;
- double d2 = d * 0.5D;
- float f1 = 10F;
+ if (this.vehicle.dead) {
+ this.vehicle = null;
+ } else {
+ this.motX = 0.0D;
+ this.motY = 0.0D;
+ this.motZ = 0.0D;
+ this.b_();
+ this.vehicle.E();
+ this.e += (double) (this.vehicle.yaw - this.vehicle.lastYaw);
+
+ for (this.d += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.e >= 180.0D; this.e -= 360.0D) {
+ ;
+ }
- if (d1 > (double) f1) {
- d1 = f1;
- }
- if (d1 < (double) (-f1)) {
- d1 = -f1;
- }
- if (d2 > (double) f1) {
- d2 = f1;
- }
- if (d2 < (double) (-f1)) {
- d2 = -f1;
+ while (this.e < -180.0D) {
+ this.e += 360.0D;
+ }
+
+ while (this.d >= 180.0D) {
+ this.d -= 360.0D;
+ }
+
+ while (this.d < -180.0D) {
+ this.d += 360.0D;
+ }
+
+ double d0 = this.e * 0.5D;
+ double d1 = this.d * 0.5D;
+ float f = 10.0F;
+
+ if (d0 > (double) f) {
+ d0 = (double) f;
+ }
+
+ if (d0 < (double) (-f)) {
+ d0 = (double) (-f);
+ }
+
+ if (d1 > (double) f) {
+ d1 = (double) f;
+ }
+
+ if (d1 < (double) (-f)) {
+ d1 = (double) (-f);
+ }
+
+ this.e -= d0;
+ this.d -= d1;
+ this.yaw = (float) ((double) this.yaw + d0);
+ this.pitch = (float) ((double) this.pitch + d1);
}
- e -= d1;
- d -= d2;
- v += ((float) (d1));
- w += ((float) (d2));
}
public void E() {
- j.a(p, q + k() + j.F(), r);
+ this.passenger.a(this.locX, this.locY + this.k() + this.passenger.F(), this.locZ);
}
public double F() {
- return (double) H;
+ return (double) this.height;
}
public double k() {
- return (double) J * 0.75D;
+ return (double) this.width * 0.75D;
}
public void e(Entity entity) {
@@ -918,36 +954,40 @@ public abstract class Entity {
setPassengerOf(entity);
}
+ public org.bukkit.entity.Entity getBukkitEntity(){
+ return this.bukkitEntity;
+ }
+
public void setPassengerOf(Entity entity) {
// e(null) doesn't really fly for overloaded methods,
// so this method is needed
// CraftBukkit end
-
- d = 0.0D;
- e = 0.0D;
+ this.d = 0.0D;
+ this.e = 0.0D;
if (entity == null) {
- if (k != null) {
- c(k.p, k.z.b + (double) k.J, k.r, v, w);
- k.j = null;
+ if (this.vehicle != null) {
+ this.c(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.width, this.vehicle.locZ, this.yaw, this.pitch);
+ this.vehicle.passenger = null;
}
- k = null;
- return;
- }
- if (k == entity) {
- k.j = null;
- k = null;
- c(entity.p, entity.z.b + (double) entity.J, entity.r, v, w);
- return;
- }
- if (k != null) {
- k.j = null;
- }
- if (entity.j != null) {
- entity.j.k = null;
+
+ this.vehicle = null;
+ } else if (this.vehicle == entity) {
+ this.vehicle.passenger = null;
+ this.vehicle = null;
+ this.c(entity.locX, entity.boundingBox.b + (double) entity.width, entity.locZ, this.yaw, this.pitch);
+ } else {
+ if (this.vehicle != null) {
+ this.vehicle.passenger = null;
+ }
+
+ if (entity.passenger != null) {
+ entity.passenger.vehicle = null;
+ }
+
+ this.vehicle = entity;
+ entity.passenger = this;
}
- k = entity;
- entity.j = this;
}
public Vec3D G() {
@@ -961,30 +1001,24 @@ public abstract class Entity {
}
public boolean J() {
- return c(1);
+ return this.c(1);
}
public void b(boolean flag) {
- a(1, flag);
+ this.a(1, flag);
}
- protected boolean c(int i1) {
- return (af.a(0) & 1 << i1) != 0;
+ protected boolean c(int i) {
+ return (this.datawatcher.a(0) & 1 << i) != 0;
}
- protected void a(int i1, boolean flag) {
- byte byte0 = af.a(0);
+ protected void a(int i, boolean flag) {
+ byte b0 = this.datawatcher.a(0);
if (flag) {
- af.b(0, ((Byte.valueOf((byte) (byte0 | 1 << i1)))));
+ this.datawatcher.b(0, Byte.valueOf((byte) (b0 | 1 << i)));
} else {
- af.b(0, ((Byte.valueOf((byte) (byte0 & ~(1 << i1))))));
+ this.datawatcher.b(0, Byte.valueOf((byte) (b0 & ~(1 << i))));
}
}
-
- // CraftBukkit start
- public org.bukkit.entity.Entity getBukkitEntity(){
- return this.bukkitEntity;
- }
- // CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntityAnimals.java b/src/main/java/net/minecraft/server/EntityAnimal.java
index 01050e00..103440e8 100644
--- a/src/main/java/net/minecraft/server/EntityAnimals.java
+++ b/src/main/java/net/minecraft/server/EntityAnimal.java
@@ -5,22 +5,19 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftAnimals;
// CraftBukkit end
-public abstract class EntityAnimals extends EntityCreature implements IAnimals {
+public abstract class EntityAnimal extends EntityCreature implements IAnimal {
- public EntityAnimals(World world) {
+ public EntityAnimal(World world) {
super(world);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftAnimals(server, this);
// CraftBukkit end
}
protected float a(int i, int j, int k) {
- if (l.a(i, j - 1, k) == Block.u.bi) {
- return 10F;
- } else {
- return l.l(i, j, k) - 0.5F;
- }
+ return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id ? 10.0F : this.world.l(i, j, k) - 0.5F;
}
public void a(NBTTagCompound nbttagcompound) {
@@ -32,11 +29,11 @@ public abstract class EntityAnimals extends EntityCreature implements IAnimals {
}
public boolean b() {
- int i = MathHelper.b(p);
- int j = MathHelper.b(z.b);
- int k = MathHelper.b(r);
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.boundingBox.b);
+ int k = MathHelper.b(this.locZ);
- return l.a(i, j - 1, k) == Block.u.bi && l.j(i, j, k) > 8 && super.b();
+ return this.world.getTypeId(i, j - 1, k) == Block.GRASS.id && this.world.j(i, j, k) > 8 && super.b();
}
public int c() {
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 5ac3746b..d2164c65 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -10,278 +10,280 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end
-
public class EntityArrow extends Entity {
- private int c;
- private int d;
- private int e;
- private int f;
- private boolean ak;
- public int a;
+ private int c = -1;
+ private int d = -1;
+ private int e = -1;
+ private int f = 0;
+ private boolean ak = false;
+ public int a = 0;
public EntityLiving b;
private int al;
- private int am;
-
+ private int am = 0;
+
public EntityArrow(World world) {
super(world);
- c = -1;
- d = -1;
- e = -1;
- f = 0;
- ak = false;
- a = 0;
- am = 0;
- a(0.5F, 0.5F);
-
+ this.a(0.5F, 0.5F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftArrow(server, this);
// CraftBukkit end
}
- public EntityArrow(World world, double d1, double d2, double d3) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- a(d1, d2, d3);
- H = 0.0F;
+ public EntityArrow(World world, double d0, double d1, double d2) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.a(0.5F, 0.5F);
+ this.a(d0, d1, d2);
+ this.height = 0.0F;
}
public EntityArrow(World world, EntityLiving entityliving) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- b = entityliving;
- c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w);
- p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
- q -= 0.10000000149011612D;
- r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
- a(p, q, r);
- H = 0.0F;
- s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F);
- u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F);
- t = -MathHelper.a((w / 180F) * 3.141593F);
- a(s, t, u, 1.5F, 1.0F);
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.b = entityliving;
+ this.a(0.5F, 0.5F);
+ this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
+ this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.locY -= 0.10000000149011612D;
+ this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.a(this.locX, this.locY, this.locZ);
+ this.height = 0.0F;
+ this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(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.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F));
+ this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
}
protected void a() {}
- public void a(double d1, double d2, double d3, float f1, float f2) {
- float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- d1 /= f3;
- d2 /= f3;
- d3 /= f3;
- d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d1 *= f1;
- d2 *= f1;
- d3 *= f1;
- s = d1;
- t = d2;
- u = d3;
- float f4 = MathHelper.a(d1 * d1 + d3 * d3);
-
- x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D);
- y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D);
- al = 0;
+ public void a(double d0, double d1, double d2, float f, float f1) {
+ float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ d0 /= (double) f2;
+ d1 /= (double) f2;
+ d2 /= (double) f2;
+ d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d0 *= (double) f;
+ d1 *= (double) f;
+ d2 *= (double) f;
+ this.motX = d0;
+ this.motY = d1;
+ this.motZ = d2;
+ float f3 = MathHelper.a(d0 * d0 + d2 * d2);
+
+ this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
+ this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
+ this.al = 0;
}
public void b_() {
super.b_();
- if (y == 0.0F && x == 0.0F) {
- float f1 = MathHelper.a(s * s + u * u);
+ if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) {
+ float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
- x = v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- y = w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D);
+ this.lastYaw = this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+ this.lastPitch = this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D);
}
- if (a > 0) {
- a--;
+
+ if (this.a > 0) {
+ --this.a;
}
- if (ak) {
- int i = l.a(c, d, e);
-
- if (i != f) {
- ak = false;
- s *= W.nextFloat() * 0.2F;
- t *= W.nextFloat() * 0.2F;
- u *= W.nextFloat() * 0.2F;
- al = 0;
- am = 0;
- } else {
- al++;
- if (al == 1200) {
- q();
+
+ if (this.ak) {
+ int i = this.world.getTypeId(this.c, this.d, this.e);
+
+ if (i == this.f) {
+ ++this.al;
+ if (this.al == 1200) {
+ this.q();
}
+
return;
}
+
+ this.ak = false;
+ this.motX *= (double) (this.random.nextFloat() * 0.2F);
+ this.motY *= (double) (this.random.nextFloat() * 0.2F);
+ this.motZ *= (double) (this.random.nextFloat() * 0.2F);
+ this.al = 0;
+ this.am = 0;
} else {
- am++;
+ ++this.am;
}
- Vec3D vec3d = Vec3D.b(p, q, r);
- Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
- MovingObjectPosition movingobjectposition = l.a(vec3d, vec3d1);
- vec3d = Vec3D.b(p, q, r);
- vec3d1 = Vec3D.b(p + s, q + t, r + u);
+ Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
+
+ vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
+
Entity entity = null;
- List list = l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
- double d1 = 0.0D;
+ List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
+ double d0 = 0.0D;
- for (int j = 0; j < list.size(); j++) {
+ float f1;
+
+ for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
- if (!entity1.c_() || entity1 == b && am < 5) {
- continue;
- }
- float f5 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.z.b(f5, f5, f5);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
+ if (entity1.c_() && (entity1 != this.b || this.am >= 5)) {
+ f1 = 0.3F;
+ AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f1, (double) f1, (double) f1);
+ MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
- if (movingobjectposition1 == null) {
- continue;
- }
- double d2 = vec3d.a(movingobjectposition1.f);
+ if (movingobjectposition1 != null) {
+ double d1 = vec3d.a(movingobjectposition1.f);
- if (d2 < d1 || d1 == 0.0D) {
- entity = entity1;
- d1 = d2;
+ if (d1 < d0 || d0 == 0.0D) {
+ entity = entity1;
+ d0 = d1;
+ }
+ }
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
+
+ float f2;
+
if (movingobjectposition != null) {
if (movingobjectposition.g != null) {
// CraftBukkit start
- boolean bounce;
+ boolean stick;
if (entity instanceof EntityLiving) {
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
//TODO decide if we should create DamageCause.ARROW, DamageCause.PROJECTILE
// or leave as DamageCause.ENTITY_ATTACK
- org.bukkit.entity.Entity shooter = (b == null)?null:b.getBukkitEntity();
+ org.bukkit.entity.Entity shooter = (this.b == null) ? null : this.b.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
// TODO deal with arrows being fired from a non-entity
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 4;
- EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
- server.getPluginManager().callEvent(edbpe);
- if(!edbpe.isCancelled()) {
+ EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
+ server.getPluginManager().callEvent(event);
+ if(!event.isCancelled()) {
// this function returns if the arrow should stick in or not, i.e. !bounce
- bounce = !movingobjectposition.g.a(((Entity) (b)), edbpe.getDamage());
+ stick = movingobjectposition.g.a(this.b, event.getDamage());
} else {
// event was cancelled, get if the arrow should bounce or not
- bounce = edbpe.getBounce();
+ stick = !event.getBounce();
}
} else {
- bounce = !movingobjectposition.g.a(((Entity) (b)), 4);
+ stick = movingobjectposition.g.a(this.b, 4);
}
- if (!bounce) {
- // CraftBukkit end
- l.a(((Entity) (this)), "random.drr", 1.0F, 1.2F / (W.nextFloat() * 0.2F + 0.9F));
- q();
+ if (stick) {
+ // CraftBukkit end
+ this.world.a(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
+ this.q();
} else {
- s *= -0.10000000149011612D;
- t *= -0.10000000149011612D;
- u *= -0.10000000149011612D;
- v += 180F;
- x += 180F;
- am = 0;
+ this.motX *= -0.10000000149011612D;
+ this.motY *= -0.10000000149011612D;
+ this.motZ *= -0.10000000149011612D;
+ this.yaw += 180.0F;
+ this.lastYaw += 180.0F;
+ this.am = 0;
}
} else {
- c = movingobjectposition.b;
- d = movingobjectposition.c;
- e = movingobjectposition.d;
- f = l.a(c, d, e);
- s = (float) (movingobjectposition.f.a - p);
- t = (float) (movingobjectposition.f.b - q);
- u = (float) (movingobjectposition.f.c - r);
- float f2 = MathHelper.a(s * s + t * t + u * u);
-
- p -= (s / (double) f2) * 0.05000000074505806D;
- q -= (t / (double) f2) * 0.05000000074505806D;
- r -= (u / (double) f2) * 0.05000000074505806D;
- l.a(((Entity) (this)), "random.drr", 1.0F, 1.2F / (W.nextFloat() * 0.2F + 0.9F));
- ak = true;
- a = 7;
+ this.c = movingobjectposition.b;
+ this.d = movingobjectposition.c;
+ this.e = movingobjectposition.d;
+ this.f = this.world.getTypeId(this.c, this.d, this.e);
+ this.motX = (double) ((float) (movingobjectposition.f.a - this.locX));
+ this.motY = (double) ((float) (movingobjectposition.f.b - this.locY));
+ this.motZ = (double) ((float) (movingobjectposition.f.c - this.locZ));
+ f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
+ this.locX -= this.motX / (double) f2 * 0.05000000074505806D;
+ this.locY -= this.motY / (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.ak = true;
+ this.a = 7;
}
}
- p += s;
- q += t;
- r += u;
- float f3 = MathHelper.a(s * s + u * u);
- v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- for (w = (float) ((Math.atan2(t, f3) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) {
+ this.locX += this.motX;
+ this.locY += this.motY;
+ this.locZ += this.motZ;
+ f2 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f2) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
;
}
- for (; w - y >= 180F; y += 360F) {
- ;
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
}
- for (; v - x < -180F; x -= 360F) {
- ;
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
}
- for (; v - x >= 180F; x += 360F) {
- ;
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
}
- w = y + (w - y) * 0.2F;
- v = x + (v - x) * 0.2F;
- float f4 = 0.99F;
- float f6 = 0.03F;
- if (v()) {
- for (int k = 0; k < 4; k++) {
- float f7 = 0.25F;
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
+ float f3 = 0.99F;
- l.a("bubble", p - s * (double) f7, q - t * (double) f7, r - u * (double) f7, s, t, u);
+ f1 = 0.03F;
+ if (this.v()) {
+ for (int k = 0; k < 4; ++k) {
+ float f4 = 0.25F;
+
+ this.world.a("bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ);
}
- f4 = 0.8F;
+ f3 = 0.8F;
}
- s *= f4;
- t *= f4;
- u *= f4;
- t -= f6;
- a(p, q, r);
+
+ this.motX *= (double) f3;
+ this.motY *= (double) f3;
+ this.motZ *= (double) f3;
+ this.motY -= (double) f1;
+ this.a(this.locX, this.locY, this.locZ);
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("xTile", (short) c);
- nbttagcompound.a("yTile", (short) d);
- nbttagcompound.a("zTile", (short) e);
- nbttagcompound.a("inTile", (byte) f);
- nbttagcompound.a("shake", (byte) a);
- nbttagcompound.a("inGround", (byte) (ak ? 1 : 0));
+ nbttagcompound.a("xTile", (short) this.c);
+ nbttagcompound.a("yTile", (short) this.d);
+ nbttagcompound.a("zTile", (short) this.e);
+ nbttagcompound.a("inTile", (byte) this.f);
+ nbttagcompound.a("shake", (byte) this.a);
+ nbttagcompound.a("inGround", (byte) (this.ak ? 1 : 0));
}
public void b(NBTTagCompound nbttagcompound) {
- c = ((int) (nbttagcompound.c("xTile")));
- d = ((int) (nbttagcompound.c("yTile")));
- e = ((int) (nbttagcompound.c("zTile")));
- f = nbttagcompound.b("inTile") & 0xff;
- a = nbttagcompound.b("shake") & 0xff;
- ak = nbttagcompound.b("inGround") == 1;
+ this.c = nbttagcompound.c("xTile");
+ this.d = nbttagcompound.c("yTile");
+ this.e = nbttagcompound.c("zTile");
+ this.f = nbttagcompound.b("inTile") & 255;
+ this.a = nbttagcompound.b("shake") & 255;
+ this.ak = nbttagcompound.b("inGround") == 1;
}
- public void b(EntityPlayer entityplayer) {
- if (l.z) {
- return;
- }
- if (ak && b == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) {
- l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F);
- entityplayer.c(((Entity) (this)), 1);
- q();
+ public void b(EntityHuman entityhuman) {
+ if (!this.world.isStatic) {
+ if (this.ak && this.b == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
+ this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
+ entityhuman.c(this, 1);
+ this.q();
+ }
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java
index 0e929470..7511397a 100644
--- a/src/main/java/net/minecraft/server/EntityBoat.java
+++ b/src/main/java/net/minecraft/server/EntityBoat.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
@@ -19,7 +18,7 @@ import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
// CraftBukkit end
-public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
+public class EntityBoat extends Entity {
public int a;
public int b;
@@ -32,27 +31,44 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
private double am;
// CraftBukkit start
- /**@deprecated*/
- private CraftBoat boat;
- /**@deprecated*/
- public CraftEntity getCraftEntity() {
- return boat;
+ private void handleCreation(World world) {
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.VEHICLE_CREATE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
+ server.getPluginManager().callEvent(event);
+ }
+
+ public void c(Entity entity) {
+ CraftServer server = ((WorldServer) this.world).getServer();
+ Type eventType = Type.VEHICLE_COLLISION_ENTITY;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
+
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ super.c(entity);
}
// CraftBukkit end
public EntityBoat(World world) {
super(world);
- a = 0;
- b = 0;
- c = 1;
- i = true;
- a(1.5F, 0.6F);
- H = J / 2.0F;
- M = false;
+ this.a = 0;
+ this.b = 0;
+ this.c = 1;
+ this.i = true;
+ this.a(1.5F, 0.6F);
+ this.height = this.width / 2.0F;
+ this.M = false;
- handleCreation(world); // CraftBukkit
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ handleCreation(world);
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftBoat(server, this);
// CraftBukkit end
}
@@ -60,325 +76,324 @@ public class EntityBoat extends Entity implements CraftMappable { // CraftBukkit
protected void a() {}
public AxisAlignedBB d(Entity entity) {
- return entity.z;
+ return entity.boundingBox;
}
public AxisAlignedBB u() {
- return z;
+ return this.boundingBox;
}
public boolean z() {
return true;
}
- public EntityBoat(World world, double d1, double d2, double d3) {
+ public EntityBoat(World world, double d0, double d1, double d2) {
this(world);
- a(d1, d2 + (double) H, d3);
- s = 0.0D;
- t = 0.0D;
- u = 0.0D;
- m = d1;
- n = d2;
- o = d3;
+ this.a(d0, d1 + (double) this.height, d2);
+ this.motX = 0.0D;
+ this.motY = 0.0D;
+ this.motZ = 0.0D;
+ this.lastX = d0;
+ this.lastY = d1;
+ this.lastZ = d2;
handleCreation(world); // CraftBukkit
}
- // CraftBukkit start
- private void handleCreation(World world) {
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.VEHICLE_CREATE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
- server.getPluginManager().callEvent(event);
- }
- // CraftBukkit end
-
public double k() {
- return (double) J * 0.0D - 0.30000001192092896D;
+ return (double) this.width * 0.0D - 0.30000001192092896D;
}
public boolean a(Entity entity, int i) {
- // CraftBukkit start
- Type eventType = Type.VEHICLE_DAMAGE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity attacker = (entity == null)?null:entity.getBukkitEntity();
- int damage = i;
-
- VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage);
- ((WorldServer) l).getServer().getPluginManager().callEvent(event);
+ if (!this.world.isStatic && !this.dead) {
+ // CraftBukkit start
+ Type eventType = Type.VEHICLE_DAMAGE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity attacker = (entity == null) ? null : entity.getBukkitEntity();
+ int damage = i;
- if (event.isCancelled()) {
- return true;
- }
- // CraftBukkit end
+ VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, attacker, damage);
+ ((WorldServer) this.world).getServer().getPluginManager().callEvent(event);
- if (this.l.z || G) {
- return true;
- }
- c = -c;
- b = 10;
- a += i * 10;
- y();
- if (a > 40) {
- for (int j = 0; j < 3; j++) {
- a(Block.x.bi, 1, 0.0F);
+ if (event.isCancelled()) {
+ return true;
}
+ // CraftBukkit end
+
+ this.c = -this.c;
+ this.b = 10;
+ this.a += i * 10;
+ this.y();
+ if (this.a > 40) {
+ int j;
- for (int l = 0; l < 2; l++) {
- a(Item.B.ba, 1, 0.0F);
+ for (j = 0; j < 3; ++j) {
+ this.a(Block.WOOD.id, 1, 0.0F);
+ }
+
+ for (j = 0; j < 2; ++j) {
+ this.a(Item.STICK.id, 1, 0.0F);
+ }
+
+ this.q();
}
- q();
+ return true;
+ } else {
+ return true;
}
- return true;
}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public void b_() {
// CraftBukkit start
- double prevX = p;
- double prevY = q;
- double prevZ = r;
- float prevYaw = v;
- float prevPitch = w;
+ double prevX = this.locX;
+ double prevY = this.locY;
+ double prevZ = this.locZ;
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
// CraftBukkit end
super.b_();
- if (b > 0) {
- b--;
+ if (this.b > 0) {
+ --this.b;
}
- if (a > 0) {
- a--;
+
+ if (this.a > 0) {
+ --this.a;
}
- m = p;
- n = q;
- o = r;
- int i = 5;
- double d1 = 0.0D;
-
- for (int j = 0; j < i; j++) {
- double d2 = (z.b + ((z.e - z.b) * (double) (j + 0)) / (double) i) - 0.125D;
- double d3 = (z.b + ((z.e - z.b) * (double) (j + 1)) / (double) i) - 0.125D;
- AxisAlignedBB axisalignedbb = AxisAlignedBB.b(z.a, d2, z.c, z.d, d3, z.f);
-
- if (this.l.b(axisalignedbb, Material.f)) {
- d1 += 1.0D / (double) i;
+
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ byte b0 = 5;
+ double d0 = 0.0D;
+
+ for (int i = 0; i < b0; ++i) {
+ double d1 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 0) / (double) b0 - 0.125D;
+ double d2 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (i + 1) / (double) b0 - 0.125D;
+ AxisAlignedBB axisalignedbb = AxisAlignedBB.b(this.boundingBox.a, d1, this.boundingBox.c, this.boundingBox.d, d2, this.boundingBox.f);
+
+ if (this.world.b(axisalignedbb, Material.WATER)) {
+ d0 += 1.0D / (double) b0;
}
}
- if (this.l.z) {
- if (d > 0) {
- double d4 = p + (e - p) / (double) d;
- double d7 = q + (f - q) / (double) d;
- double d10 = r + (ak - r) / (double) d;
- double d13;
+ double d3;
+ double d4;
+ double d5;
+ double d6;
- for (d13 = al - (double) v; d13 < -180D; d13 += 360D) {
+ if (this.world.isStatic) {
+ if (this.d > 0) {
+ d3 = this.locX + (this.e - this.locX) / (double) this.d;
+ d4 = this.locY + (this.f - this.locY) / (double) this.d;
+ d5 = this.locZ + (this.ak - this.locZ) / (double) this.d;
+
+ for (d6 = this.al - (double) this.yaw; d6 < -180.0D; d6 += 360.0D) {
;
}
- for (; d13 >= 180D; d13 -= 360D) {
- ;
+
+ while (d6 >= 180.0D) {
+ d6 -= 360.0D;
}
- v += ((float) (d13 / (double) d));
- w += ((float) ((am - (double) w) / (double) d));
- d--;
- a(d4, d7, d10);
- b(v, w);
+
+ this.yaw = (float) ((double) this.yaw + d6 / (double) this.d);
+ this.pitch = (float) ((double) this.pitch + (this.am - (double) this.pitch) / (double) this.d);
+ --this.d;
+ this.a(d3, d4, d5);
+ this.b(this.yaw, this.pitch);
} else {
- double d5 = p + s;
- double d8 = q + t;
- double d11 = r + u;
-
- a(d5, d8, d11);
- if (A) {
- s *= 0.5D;
- t *= 0.5D;
- u *= 0.5D;
+ d3 = this.locX + this.motX;
+ d4 = this.locY + this.motY;
+ d5 = this.locZ + this.motZ;
+ this.a(d3, d4, d5);
+ if (this.onGround) {
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
}
- s *= 0.99000000953674316D;
- t *= 0.94999998807907104D;
- u *= 0.99000000953674316D;
- }
- return;
- }
- double d6 = d1 * 2D - 1.0D;
- t += 0.039999999105930328D * d6;
- if (this.j != null) {
- s += this.j.s * 0.20000000000000001D;
- u += this.j.u * 0.20000000000000001D;
- }
- double d9 = 0.40000000000000002D;
+ this.motX *= 0.9900000095367432D;
+ this.motY *= 0.949999988079071D;
+ this.motZ *= 0.9900000095367432D;
+ }
+ } else {
+ d3 = d0 * 2.0D - 1.0D;
+ this.motY += 0.03999999910593033D * d3;
+ if (this.passenger != null) {
+ this.motX += this.passenger.motX * 0.2D;
+ this.motZ += this.passenger.motZ * 0.2D;
+ }
- if (s < -d9) {
- s = -d9;
- }
- if (s > d9) {
- s = d9;
- }
- if (u < -d9) {
- u = -d9;
- }
- if (u > d9) {
- u = d9;
- }
- if (A) {
- s *= 0.5D;
- t *= 0.5D;
- u *= 0.5D;
- }
- c(s, t, u);
- double d12 = Math.sqrt(s * s + u * u);
+ d4 = 0.4D;
+ if (this.motX < -d4) {
+ this.motX = -d4;
+ }
- if (d12 > 0.14999999999999999D) {
- double d14 = Math.cos(((double) v * 3.1415926535897931D) / 180D);
- double d16 = Math.sin(((double) v * 3.1415926535897931D) / 180D);
+ if (this.motX > d4) {
+ this.motX = d4;
+ }
- for (int l = 0; (double) l < 1.0D + d12 * 60D; l++) {
- double d18 = W.nextFloat() * 2.0F - 1.0F;
- double d19 = (double) (W.nextInt(2) * 2 - 1) * 0.69999999999999996D;
+ if (this.motZ < -d4) {
+ this.motZ = -d4;
+ }
- if (W.nextBoolean()) {
- double d20 = (p - d14 * d18 * 0.80000000000000004D) + d16 * d19;
- double d22 = r - d16 * d18 * 0.80000000000000004D - d14 * d19;
+ if (this.motZ > d4) {
+ this.motZ = d4;
+ }
- this.l.a("splash", d20, q - 0.125D, d22, s, t, u);
- } else {
- double d21 = p + d14 + d16 * d18 * 0.69999999999999996D;
- double d23 = (r + d16) - d14 * d18 * 0.69999999999999996D;
+ if (this.onGround) {
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
+ }
- this.l.a("splash", d21, q - 0.125D, d23, s, t, u);
+ this.c(this.motX, this.motY, this.motZ);
+ d5 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ double d7;
+
+ if (d5 > 0.15D) {
+ d6 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D);
+ d7 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D);
+
+ for (int j = 0; (double) j < 1.0D + d5 * 60.0D; ++j) {
+ double d8 = (double) (this.random.nextFloat() * 2.0F - 1.0F);
+ double d9 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D;
+ double d10;
+ double d11;
+
+ if (this.random.nextBoolean()) {
+ d10 = this.locX - d6 * d8 * 0.8D + d7 * d9;
+ d11 = this.locZ - d7 * d8 * 0.8D - d6 * d9;
+ this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ);
+ } else {
+ d10 = this.locX + d6 + d7 * d8 * 0.7D;
+ d11 = this.locZ + d7 - d6 * d8 * 0.7D;
+ this.world.a("splash", d10, this.locY - 0.125D, d11, this.motX, this.motY, this.motZ);
+ }
}
}
- }
- if (B && d12 > 0.14999999999999999D) {
- if (!this.l.z) {
- q();
- for (int i1 = 0; i1 < 3; i1++) {
- a(Block.x.bi, 1, 0.0F);
- }
- for (int j1 = 0; j1 < 2; j1++) {
- a(Item.B.ba, 1, 0.0F);
+ if (this.B && d5 > 0.15D) {
+ if (!this.world.isStatic) {
+ this.q();
+
+ int k;
+
+ for (k = 0; k < 3; ++k) {
+ this.a(Block.WOOD.id, 1, 0.0F);
+ }
+
+ for (k = 0; k < 2; ++k) {
+ this.a(Item.STICK.id, 1, 0.0F);
+ }
}
+ } else {
+ this.motX *= 0.9900000095367432D;
+ this.motY *= 0.949999988079071D;
+ this.motZ *= 0.9900000095367432D;
}
- } else {
- s *= 0.99000000953674316D;
- t *= 0.94999998807907104D;
- u *= 0.99000000953674316D;
- }
- w = 0.0F;
- double d15 = v;
- double d17 = m - p;
- double d24 = o - r;
- if (d17 * d17 + d24 * d24 > 0.001D) {
- d15 = (float) ((Math.atan2(d24, d17) * 180D) / 3.1415926535897931D);
- }
- double d25;
+ this.pitch = 0.0F;
+ d6 = (double) this.yaw;
+ d7 = this.lastX - this.locX;
+ double d12 = this.lastZ - this.locZ;
- for (d25 = d15 - (double) v; d25 >= 180D; d25 -= 360D) {
- ;
- }
- for (; d25 < -180D; d25 += 360D) {
- ;
- }
- if (d25 > 20D) {
- d25 = 20D;
- }
- if (d25 < -20D) {
- d25 = -20D;
- }
- v += ((float) (d25));
- b(v, w);
+ if (d7 * d7 + d12 * d12 > 0.0010D) {
+ d6 = (double) ((float) (Math.atan2(d12, d7) * 180.0D / 3.141592653589793D));
+ }
- // CraftBukkit start
- CraftServer server = ((WorldServer)l).getServer();
- CraftWorld world = ((WorldServer)l).getWorld();
- Type eventType = Type.VEHICLE_MOVE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
- Location to = new Location(world, p, q, r, v, w);
-
- VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to);
- server.getPluginManager().callEvent(event);
- // CraftBukkit end
+ double d13;
- List list = this.l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+ for (d13 = d6 - (double) this.yaw; d13 >= 180.0D; d13 -= 360.0D) {
+ ;
+ }
- if (list != null && list.size() > 0) {
- for (int k1 = 0; k1 < list.size(); k1++) {
- Entity entity = (Entity) list.get(k1);
+ while (d13 < -180.0D) {
+ d13 += 360.0D;
+ }
- if (entity != this.j && entity.z() && (entity instanceof EntityBoat)) {
- entity.c(((Entity) (this)));
- }
+ if (d13 > 20.0D) {
+ d13 = 20.0D;
}
- }
- if (this.j != null && this.j.G) {
- this.j = null;
- }
- }
- public void E() {
- if (j == null) {
- return;
- } else {
- double d1 = Math.cos(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D;
- double d2 = Math.sin(((double) v * 3.1415926535897931D) / 180D) * 0.40000000000000002D;
+ if (d13 < -20.0D) {
+ d13 = -20.0D;
+ }
- j.a(p + d1, q + k() + j.F(), r + d2);
- return;
+ this.yaw = (float) ((double) this.yaw + d13);
+ this.b(this.yaw, this.pitch);
+
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ CraftWorld world = ((WorldServer) this.world).getWorld();
+ Type eventType = Type.VEHICLE_MOVE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(world, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+
+ VehicleMoveEvent event = new VehicleMoveEvent(eventType, vehicle, from, to);
+ server.getPluginManager().callEvent(event);
+ // CraftBukkit end
+
+ List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+
+ if (list != null && list.size() > 0) {
+ for (int l = 0; l < list.size(); ++l) {
+ Entity entity = (Entity) list.get(l);
+
+ if (entity != this.passenger && entity.z() && entity instanceof EntityBoat) {
+ entity.c((Entity) this);
+ }
+ }
+ }
+
+ if (this.passenger != null && this.passenger.dead) {
+ this.passenger = null;
+ }
}
}
- // CraftBukkit start
- public void c(Entity entity) {
- CraftServer server = ((WorldServer)l).getServer();
- Type eventType = Type.VEHICLE_COLLISION_ENTITY;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity();
-
- VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
- server.getPluginManager().callEvent(collsionEvent);
+ public void E() {
+ if (this.passenger != null) {
+ double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D;
+ double d1 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D;
- if (collsionEvent.isCancelled()) {
- return;
+ this.passenger.a(this.locX + d0, this.locY + this.k() + this.passenger.F(), this.locZ + d1);
}
-
- super.c(entity);
}
- // CraftBukkit end
protected void a(NBTTagCompound nbttagcompound) {}
protected void b(NBTTagCompound nbttagcompound) {}
- public boolean a(EntityPlayer entityplayer) {
- if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
+ public boolean a(EntityHuman entityhuman) {
+ if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true;
- }
- if (!l.z) {
- // CraftBukkit start
- CraftServer server = ((WorldServer)l).getServer();
- Type eventType = Type.VEHICLE_ENTER;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity player = entityplayer.getBukkitEntity();
-
- VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
- server.getPluginManager().callEvent(event);
+ } else {
+ if (!this.world.isStatic) {
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ Type eventType = Type.VEHICLE_ENTER;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity player = entityhuman.getBukkitEntity();
+
+ VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
- if (event.isCancelled()) {
- return true;
+ entityhuman.e(this);
}
- // CraftBukkit end
- entityplayer.e(((Entity) (this)));
+ return true;
}
- return true;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java
index 252d65fa..d99c9c2d 100644
--- a/src/main/java/net/minecraft/server/EntityChicken.java
+++ b/src/main/java/net/minecraft/server/EntityChicken.java
@@ -1,65 +1,64 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftChicken;
// CraftBukkit end
-public class EntityChicken extends EntityAnimals {
+public class EntityChicken extends EntityAnimal {
- public boolean a;
- public float b;
- public float c;
+ public boolean a = false;
+ public float b = 0.0F;
+ public float c = 0.0F;
public float f;
public float ak;
- public float al;
+ public float al = 1.0F;
public int am;
public EntityChicken(World world) {
super(world);
- a = false;
- b = 0.0F;
- c = 0.0F;
- al = 1.0F;
- aP = "/mob/chicken.png";
- a(0.3F, 0.4F);
- aZ = 4;
- am = W.nextInt(6000) + 6000;
+ this.texture = "/mob/chicken.png";
+ this.a(0.3F, 0.4F);
+ this.health = 4;
+ this.am = this.random.nextInt(6000) + 6000;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftChicken(server, this);
// CraftBukkit end
}
public void o() {
super.o();
- ak = b;
- f = c;
- c += ((float) ((double) (A ? -1 : 4) * 0.29999999999999999D));
- if (c < 0.0F) {
- c = 0.0F;
+ this.ak = this.b;
+ this.f = this.c;
+ this.c = (float) ((double) this.c + (double) (this.onGround ? -1 : 4) * 0.3D);
+ if (this.c < 0.0F) {
+ this.c = 0.0F;
}
- if (c > 1.0F) {
- c = 1.0F;
+
+ if (this.c > 1.0F) {
+ this.c = 1.0F;
}
- if (!A && al < 1.0F) {
- al = 1.0F;
+
+ if (!this.onGround && this.al < 1.0F) {
+ this.al = 1.0F;
}
- al *= 0.90000000000000002D;
- if (!A && t < 0.0D) {
- t *= 0.59999999999999998D;
+
+ this.al = (float) ((double) this.al * 0.9D);
+ if (!this.onGround && this.motY < 0.0D) {
+ this.motY *= 0.6D;
}
- b += al * 2.0F;
- if (!l.z && --am <= 0) {
- l.a(((Entity) (this)), "mob.chickenplop", 1.0F, (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
- a(Item.aN.ba, 1);
- am = W.nextInt(6000) + 6000;
+
+ this.b += this.al * 2.0F;
+ if (!this.world.isStatic && --this.am <= 0) {
+ this.world.a(this, "mob.chickenplop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.a(Item.EGG.id, 1);
+ this.am = this.random.nextInt(6000) + 6000;
}
}
- protected void a(float f1) {}
+ protected void a(float f) {}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
@@ -82,6 +81,6 @@ public class EntityChicken extends EntityAnimals {
}
protected int h() {
- return Item.J.ba;
+ return Item.FEATHER.id;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java
index a6dabbd6..6a672695 100644
--- a/src/main/java/net/minecraft/server/EntityCow.java
+++ b/src/main/java/net/minecraft/server/EntityCow.java
@@ -5,14 +5,15 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCow;
// CraftBukkit end
-public class EntityCow extends EntityAnimals {
+public class EntityCow extends EntityAnimal {
public EntityCow(World world) {
super(world);
- aP = "/mob/cow.png";
- a(0.9F, 1.3F);
+ this.texture = "/mob/cow.png";
+ this.a(0.9F, 1.3F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftCow(server, this);
// CraftBukkit end
}
@@ -42,14 +43,14 @@ public class EntityCow extends EntityAnimals {
}
protected int h() {
- return Item.aD.ba;
+ return Item.LEATHER.id;
}
- public boolean a(EntityPlayer entityplayer) {
- ItemStack itemstack = entityplayer.an.e();
+ public boolean a(EntityHuman entityhuman) {
+ ItemStack itemstack = entityhuman.inventory.e();
- if (itemstack != null && itemstack.c == Item.au.ba) {
- entityplayer.an.a(entityplayer.an.c, new ItemStack(Item.aE));
+ if (itemstack != null && itemstack.id == Item.BUCKET.id) {
+ entityhuman.inventory.a(entityhuman.inventory.c, new ItemStack(Item.MILK_BUCKET));
return true;
} else {
return false;
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
index 98afd9cd..26c8c7e9 100644
--- a/src/main/java/net/minecraft/server/EntityCreature.java
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
@@ -1,11 +1,12 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftMonster;
import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.entity.CraftCreature;
import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit end
@@ -14,155 +15,159 @@ public class EntityCreature extends EntityLiving {
private PathEntity a;
protected Entity d;
- protected boolean e;
+ protected boolean e = false;
public EntityCreature(World world) {
super(world);
- e = false;
- // CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
- this.bukkitEntity = new CraftCreature(server, this);
- // CraftBukkit end
}
protected void d() {
- e = false;
- float f = 16F;
+ this.e = false;
+ float f = 16.0F;
- if (d == null) {
+ if (this.d == null) {
// CraftBukkit start
- Entity target = l();
- if(target != null) {
+ Entity target = this.l();
+ if (target != null) {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER);
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event);
- if(!event.isCancelled()) {
- if(event.getTarget() == null) {
- d = null;
+ if (!event.isCancelled()) {
+ if (event.getTarget() == null) {
+ this.d = null;
} else {
- d = ((CraftEntity) event.getTarget()).getHandle();
+ this.d = ((CraftEntity) event.getTarget()).getHandle();
}
}
}
// CraftBukkit end
- if (d != null) {
- a = l.a(((Entity) (this)), d, f);
+ if (this.d != null) {
+ this.a = this.world.a(this, this.d, f);
}
- } else if (!d.B()) {
+ } else if (!this.d.B()) {
// CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED);
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event);
- if(!event.isCancelled()) {
- if(event.getTarget() == null) {
- d = null;
+ if (!event.isCancelled()) {
+ if (event.getTarget() == null) {
+ this.d = null;
} else {
- d = ((CraftEntity) event.getTarget()).getHandle();
+ this.d = ((CraftEntity) event.getTarget()).getHandle();
}
}
// CraftBukkit end
} else {
- float f1 = d.a(((Entity) (this)));
+ float f1 = this.d.a((Entity) this);
- if (i(d)) {
- a(d, f1);
+ if (this.i(this.d)) {
+ this.a(this.d, f1);
}
}
- if (!e && d != null && (a == null || W.nextInt(20) == 0)) {
- a = l.a(((Entity) (this)), d, f);
- } else if (a == null && W.nextInt(80) == 0 || W.nextInt(80) == 0) {
+
+ if (!this.e && this.d != null && (this.a == null || this.random.nextInt(20) == 0)) {
+ this.a = this.world.a(this, this.d, f);
+ } else if (this.a == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0) {
boolean flag = false;
+ int i = -1;
int j = -1;
int k = -1;
- int i1 = -1;
- float f2 = -99999F;
+ float f2 = -99999.0F;
- for (int j1 = 0; j1 < 10; j1++) {
- int k1 = MathHelper.b((p + (double) W.nextInt(13)) - 6D);
- int l1 = MathHelper.b((q + (double) W.nextInt(7)) - 3D);
- int i2 = MathHelper.b((r + (double) W.nextInt(13)) - 6D);
- float f3 = a(k1, l1, i2);
+ for (int l = 0; l < 10; ++l) {
+ int i1 = MathHelper.b(this.locX + (double) this.random.nextInt(13) - 6.0D);
+ int j1 = MathHelper.b(this.locY + (double) this.random.nextInt(7) - 3.0D);
+ int k1 = MathHelper.b(this.locZ + (double) this.random.nextInt(13) - 6.0D);
+ float f3 = this.a(i1, j1, k1);
if (f3 > f2) {
f2 = f3;
- j = k1;
- k = l1;
- i1 = i2;
+ i = i1;
+ j = j1;
+ k = k1;
flag = true;
}
}
if (flag) {
- a = l.a(((Entity) (this)), j, k, i1, 10F);
+ this.a = this.world.a(this, i, j, k, 10.0F);
}
}
- int i = MathHelper.b(z.b);
- boolean flag1 = v();
- boolean flag2 = x();
- w = 0.0F;
- if (a == null || W.nextInt(100) == 0) {
- super.d();
- a = null;
- return;
- }
- Vec3D vec3d = a.a(((Entity) (this)));
-
- for (double d1 = I * 2.0F; vec3d != null && vec3d.d(p, vec3d.b, r) < d1 * d1;) {
- a.a();
- if (a.b()) {
- vec3d = null;
- a = null;
- } else {
- vec3d = a.a(((Entity) (this)));
- }
- }
+ int l1 = MathHelper.b(this.boundingBox.b);
+ boolean flag1 = this.v();
+ boolean flag2 = this.x();
- bA = false;
- if (vec3d != null) {
- double d2 = vec3d.a - p;
- double d3 = vec3d.c - r;
- double d4 = vec3d.b - (double) i;
- float f4 = (float) ((Math.atan2(d3, d2) * 180D) / 3.1415927410125732D) - 90F;
- float f5 = f4 - v;
-
- by = bC;
- for (; f5 < -180F; f5 += 360F) {
- ;
- }
- for (; f5 >= 180F; f5 -= 360F) {
- ;
- }
- if (f5 > 30F) {
- f5 = 30F;
+ this.pitch = 0.0F;
+ if (this.a != null && this.random.nextInt(100) != 0) {
+ Vec3D vec3d = this.a.a(this);
+ double d0 = (double) (this.length * 2.0F);
+
+ while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) {
+ this.a.a();
+ if (this.a.b()) {
+ vec3d = null;
+ this.a = null;
+ } else {
+ vec3d = this.a.a(this);
+ }
}
- if (f5 < -30F) {
- f5 = -30F;
+
+ this.bA = false;
+ if (vec3d != null) {
+ double d1 = vec3d.a - this.locX;
+ double d2 = vec3d.c - this.locZ;
+ double d3 = vec3d.b - (double) l1;
+ float f4 = (float) (Math.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F;
+ float f5 = f4 - this.yaw;
+
+ for (this.by = this.bC; f5 < -180.0F; f5 += 360.0F) {
+ ;
+ }
+
+ while (f5 >= 180.0F) {
+ f5 -= 360.0F;
+ }
+
+ if (f5 > 30.0F) {
+ f5 = 30.0F;
+ }
+
+ if (f5 < -30.0F) {
+ f5 = -30.0F;
+ }
+
+ this.yaw += f5;
+ if (this.e && this.d != null) {
+ double d4 = this.d.locX - this.locX;
+ double d5 = this.d.locZ - this.locZ;
+ float f6 = this.yaw;
+
+ this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F;
+ f5 = (f6 - this.yaw + 90.0F) * 3.1415927F / 180.0F;
+ this.bx = -MathHelper.a(f5) * this.by * 1.0F;
+ this.by = MathHelper.b(f5) * this.by * 1.0F;
+ }
+
+ if (d3 > 0.0D) {
+ this.bA = true;
+ }
}
- v += f5;
- if (e && d != null) {
- double d5 = d.p - p;
- double d6 = d.r - r;
- float f7 = v;
- v = (float) ((Math.atan2(d6, d5) * 180D) / 3.1415927410125732D) - 90F;
- float f6 = (((f7 - v) + 90F) * 3.141593F) / 180F;
+ if (this.d != null) {
+ this.b(this.d, 30.0F);
+ }
- bx = -MathHelper.a(f6) * by * 1.0F;
- by = MathHelper.b(f6) * by * 1.0F;
+ if (this.B) {
+ this.bA = true;
}
- if (d4 > 0.0D) {
- bA = true;
+
+ if (this.random.nextFloat() < 0.8F && (flag1 || flag2)) {
+ this.bA = true;
}
- }
- if (d != null) {
- b(d, 30F);
- }
- if (B) {
- bA = true;
- }
- if (W.nextFloat() < 0.8F && (flag1 || flag2)) {
- bA = true;
+ } else {
+ super.d();
+ this.a = null;
}
}
@@ -177,10 +182,10 @@ public class EntityCreature extends EntityLiving {
}
public boolean b() {
- int i = MathHelper.b(p);
- int j = MathHelper.b(z.b);
- int k = MathHelper.b(r);
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.boundingBox.b);
+ int k = MathHelper.b(this.locZ);
- return super.b() && a(i, j, k) >= 0.0F;
+ return super.b() && this.a(i, j, k) >= 0.0F;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java
index 3427bac3..fed190f9 100644
--- a/src/main/java/net/minecraft/server/EntityCreeper.java
+++ b/src/main/java/net/minecraft/server/EntityCreeper.java
@@ -1,29 +1,29 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftCreeper;
// CraftBukkit end
-public class EntityCreeper extends EntityMobs {
+
+public class EntityCreeper extends EntityMonster {
int a;
int b;
public EntityCreeper(World world) {
super(world);
- aP = "/mob/creeper.png";
+ this.texture = "/mob/creeper.png";
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftCreeper(server, this);
// CraftBukkit end
}
protected void a() {
super.a();
- af.a(16, ((Byte.valueOf((byte) -1))));
+ this.datawatcher.a(16, Byte.valueOf((byte) -1));
}
public void a(NBTTagCompound nbttagcompound) {
@@ -35,21 +35,24 @@ public class EntityCreeper extends EntityMobs {
}
public void b_() {
- b = a;
- if (l.z) {
- int i = K();
+ this.b = this.a;
+ if (this.world.isStatic) {
+ int i = this.K();
- if (i > 0 && a == 0) {
- l.a(((Entity) (this)), "random.fuse", 1.0F, 0.5F);
+ if (i > 0 && this.a == 0) {
+ this.world.a(this, "random.fuse", 1.0F, 0.5F);
}
- a += i;
- if (a < 0) {
- a = 0;
+
+ this.a += i;
+ if (this.a < 0) {
+ this.a = 0;
}
- if (a >= 30) {
- a = 30;
+
+ if (this.a >= 30) {
+ this.a = 30;
}
}
+
super.b_();
}
@@ -64,42 +67,44 @@ public class EntityCreeper extends EntityMobs {
public void f(Entity entity) {
super.f(entity);
if (entity instanceof EntitySkeleton) {
- a(Item.aY.ba + W.nextInt(2), 1);
+ this.a(Item.GOLD_RECORD.id + this.random.nextInt(2), 1);
}
}
- protected void a(Entity entity, float f1) {
- int i = K();
+ protected void a(Entity entity, float f) {
+ int i = this.K();
- if (i <= 0 && f1 < 3F || i > 0 && f1 < 7F) {
- if (a == 0) {
- l.a(((Entity) (this)), "random.fuse", 1.0F, 0.5F);
- }
- a(1);
- a++;
- if (a >= 30) {
- l.a(((Entity) (this)), p, q, r, 3F);
- q();
+ if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) {
+ this.a(-1);
+ --this.a;
+ if (this.a < 0) {
+ this.a = 0;
}
- e = true;
} else {
- a(-1);
- a--;
- if (a < 0) {
- a = 0;
+ if (this.a == 0) {
+ this.world.a(this, "random.fuse", 1.0F, 0.5F);
}
+
+ this.a(1);
+ ++this.a;
+ if (this.a >= 30) {
+ this.world.a(this, this.locX, this.locY, this.locZ, 3.0F);
+ this.q();
+ }
+
+ this.e = true;
}
}
protected int h() {
- return Item.K.ba;
+ return Item.SULPHUR.id;
}
private int K() {
- return ((int) (af.a(16)));
+ return this.datawatcher.a(16);
}
private void a(int i) {
- af.b(16, ((Byte.valueOf((byte) i))));
+ this.datawatcher.b(16, Byte.valueOf((byte) i));
}
}
diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java
index 7aaae478..5927a36f 100644
--- a/src/main/java/net/minecraft/server/EntityEgg.java
+++ b/src/main/java/net/minecraft/server/EntityEgg.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.entity.Egg;
@@ -18,28 +17,22 @@ import org.bukkit.event.player.PlayerEggThrowEvent;
public class EntityEgg extends Entity {
- private int b;
- private int c;
- private int d;
- private int e;
- private boolean f;
- public int a;
+ private int b = -1;
+ private int c = -1;
+ private int d = -1;
+ private int e = 0;
+ private boolean f = false;
+ public int a = 0;
private EntityLiving ak;
private int al;
- private int am;
+ private int am = 0;
public EntityEgg(World world) {
super(world);
- b = -1;
- c = -1;
- d = -1;
- e = 0;
- f = false;
- a = 0;
- am = 0;
- a(0.25F, 0.25F);
+ this.a(0.25F, 0.25F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftEgg(server, this);
// CraftBukkit end
}
@@ -47,117 +40,117 @@ public class EntityEgg extends Entity {
protected void a() {}
public EntityEgg(World world, EntityLiving entityliving) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- ak = entityliving;
- c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w);
- p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
- q -= 0.10000000149011612D;
- r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
- a(p, q, r);
- H = 0.0F;
- float f1 = 0.4F;
-
- s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- t = -MathHelper.a((w / 180F) * 3.141593F) * f1;
- a(s, t, u, 1.5F, 1.0F);
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.ak = entityliving;
+ this.a(0.25F, 0.25F);
+ this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
+ this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.locY -= 0.10000000149011612D;
+ this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.a(this.locX, this.locY, this.locZ);
+ this.height = 0.0F;
+ float f = 0.4F;
+
+ this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
+ this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
}
- public EntityEgg(World world, double d1, double d2, double d3) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- al = 0;
- a(d1, d2, d3);
- H = 0.0F;
+ public EntityEgg(World world, double d0, double d1, double d2) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.al = 0;
+ this.a(0.25F, 0.25F);
+ this.a(d0, d1, d2);
+ this.height = 0.0F;
}
- public void a(double d1, double d2, double d3, float f1, float f2) {
- float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- d1 /= f3;
- d2 /= f3;
- d3 /= f3;
- d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d1 *= f1;
- d2 *= f1;
- d3 *= f1;
- s = d1;
- t = d2;
- u = d3;
- float f4 = MathHelper.a(d1 * d1 + d3 * d3);
-
- x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D);
- y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D);
- al = 0;
+ public void a(double d0, double d1, double d2, float f, float f1) {
+ float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ d0 /= (double) f2;
+ d1 /= (double) f2;
+ d2 /= (double) f2;
+ d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d0 *= (double) f;
+ d1 *= (double) f;
+ d2 *= (double) f;
+ this.motX = d0;
+ this.motY = d1;
+ this.motZ = d2;
+ float f3 = MathHelper.a(d0 * d0 + d2 * d2);
+
+ this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
+ this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
+ this.al = 0;
}
public void b_() {
- O = p;
- P = q;
- Q = r;
+ this.O = this.locX;
+ this.P = this.locY;
+ this.Q = this.locZ;
super.b_();
- if (a > 0) {
- a--;
+ if (this.a > 0) {
+ --this.a;
}
- if (f) {
- int i = this.l.a(b, c, d);
-
- if (i != e) {
- f = false;
- s *= W.nextFloat() * 0.2F;
- t *= W.nextFloat() * 0.2F;
- u *= W.nextFloat() * 0.2F;
- al = 0;
- am = 0;
- } else {
- al++;
- if (al == 1200) {
- q();
+
+ if (this.f) {
+ int i = this.world.getTypeId(this.b, this.c, this.d);
+
+ if (i == this.e) {
+ ++this.al;
+ if (this.al == 1200) {
+ this.q();
}
+
return;
}
+
+ this.f = false;
+ this.motX *= (double) (this.random.nextFloat() * 0.2F);
+ this.motY *= (double) (this.random.nextFloat() * 0.2F);
+ this.motZ *= (double) (this.random.nextFloat() * 0.2F);
+ this.al = 0;
+ this.am = 0;
} else {
- am++;
+ ++this.am;
}
- Vec3D vec3d = Vec3D.b(p, q, r);
- Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
- MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
- vec3d = Vec3D.b(p, q, r);
- vec3d1 = Vec3D.b(p + s, q + t, r + u);
+ Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
+
+ vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
- if (!this.l.z) {
+
+ if (!this.world.isStatic) {
Entity entity = null;
- List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
- double d1 = 0.0D;
+ List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
+ double d0 = 0.0D;
- for (int l = 0; l < list.size(); l++) {
- Entity entity1 = (Entity) list.get(l);
+ for (int j = 0; j < list.size(); ++j) {
+ Entity entity1 = (Entity) list.get(j);
- if (!entity1.c_() || entity1 == ak && am < 5) {
- continue;
- }
- float f4 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.z.b(f4, f4, f4);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
+ if (entity1.c_() && (entity1 != this.ak || this.am >= 5)) {
+ float f = 0.3F;
+ AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
+ MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
- if (movingobjectposition1 == null) {
- continue;
- }
- double d2 = vec3d.a(movingobjectposition1.f);
+ if (movingobjectposition1 != null) {
+ double d1 = vec3d.a(movingobjectposition1.f);
- if (d2 < d1 || d1 == 0.0D) {
- entity = entity1;
- d1 = d2;
+ if (d1 < d0 || d0 == 0.0D) {
+ entity = entity1;
+ d0 = d1;
+ }
+ }
}
}
@@ -165,54 +158,53 @@ public class EntityEgg extends Entity {
movingobjectposition = new MovingObjectPosition(entity);
}
}
+
if (movingobjectposition != null) {
+ // CraftBukkit start
if (movingobjectposition.g != null) {
- // CraftBukkit start
- boolean bounce;
+ boolean stick;
if (movingobjectposition.g instanceof EntityLiving) {
- CraftServer server = ((WorldServer) this.l).getServer();
- org.bukkit.entity.Entity shooter = (ak == null)?null:ak.getBukkitEntity();
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity shooter = (this.ak == null) ? null : this.ak.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0;
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
- server.getPluginManager().callEvent(edbpe);
+ EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
+ server.getPluginManager().callEvent(event);
- if(!edbpe.isCancelled()) {
+ if(!event.isCancelled()) {
// this function returns if the egg should stick or not, i.e. !bounce
- bounce = !movingobjectposition.g.a(((Entity) (ak)), edbpe.getDamage());
+ stick = movingobjectposition.g.a(this.ak, event.getDamage());
} else {
// event was cancelled, get if the egg should bounce or not
- bounce = edbpe.getBounce();
+ stick = !event.getBounce();
}
} else {
- bounce = !movingobjectposition.g.a(((Entity) (ak)), 0);
+ stick = movingobjectposition.g.a(this.ak, 0);
}
- if (!bounce) {
- // CraftBukkit end
- ;
+
+ if (stick) {
+ ; // Original code does nothing *yet*
}
}
// CraftBukkit start
- boolean hatching = !this.l.z && W.nextInt(8) == 0;
- byte numHatching = (hatching && W.nextInt(32) == 0) ? (byte) 4 : (byte) 1;
+ boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0;
+ byte numHatching = (this.random.nextInt(32) == 0) ? (byte) 4 : (byte) 1;
if (!hatching) {
numHatching = 0;
}
MobType hatchingType = MobType.CHICKEN;
- if (ak instanceof EntityPlayerMP) {
- CraftServer server = ((WorldServer) l).getServer();
+ if (this.ak instanceof EntityPlayer) {
+ CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.PLAYER_EGG_THROW;
- Player player = (ak == null)?null:(Player) ak.getBukkitEntity();
+ Player player = (this.ak == null) ? null : (Player) this.ak.getBukkitEntity();
- PlayerEggThrowEvent event = new PlayerEggThrowEvent(
- eventType, player, (Egg)this.bukkitEntity, hatching,
- numHatching, hatchingType);
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(eventType, player, (Egg)this.getBukkitEntity(), hatching, numHatching, hatchingType);
server.getPluginManager().callEvent(event);
hatching = event.isHatching();
numHatching = event.getNumHatches();
@@ -224,116 +216,124 @@ public class EntityEgg extends Entity {
Entity entity = null;
switch (hatchingType) {
case CHICKEN:
- entity = new EntityChicken(this.l);
+ entity = new EntityChicken(this.world);
break;
case COW:
- entity = new EntityCow(this.l);
+ entity = new EntityCow(this.world);
break;
case CREEPER:
- entity = new EntityCreeper(this.l);
+ entity = new EntityCreeper(this.world);
break;
case GHAST:
- entity = new EntityGhast(this.l);
+ entity = new EntityGhast(this.world);
break;
case PIG:
- entity = new EntityPig(this.l);
+ entity = new EntityPig(this.world);
break;
case PIG_ZOMBIE:
- entity = new EntityPigZombie(this.l);
+ entity = new EntityPigZombie(this.world);
break;
case SHEEP:
- entity = new EntitySheep(this.l);
+ entity = new EntitySheep(this.world);
break;
case SKELETON:
- entity = new EntitySkeleton(this.l);
+ entity = new EntitySkeleton(this.world);
break;
case SPIDER:
- entity = new EntitySpider(this.l);
+ entity = new EntitySpider(this.world);
break;
case ZOMBIE:
- entity = new EntityZombie(this.l);
+ entity = new EntityZombie(this.world);
break;
case SQUID:
- entity = new EntitySquid(this.l);
+ entity = new EntitySquid(this.world);
break;
default:
- entity = new EntityChicken(this.l);
+ entity = new EntityChicken(this.world);
break;
}
- entity.c(p, q, r, v, 0.0F);
- this.l.a(entity);
+
+ entity.c(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
+ this.world.a(entity);
}
}
// CraftBukkit end
- for (int j = 0; j < 8; j++) {
- this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D);
+ for (int l = 0; l < 8; ++l) {
+ this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
}
- q();
+ this.q();
}
- p += s;
- q += t;
- r += u;
- float f1 = MathHelper.a(s * s + u * u);
- v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) {
+ this.locX += this.motX;
+ this.locY += this.motY;
+ this.locZ += this.motZ;
+ float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
;
}
- for (; w - y >= 180F; y += 360F) {
- ;
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
}
- for (; v - x < -180F; x -= 360F) {
- ;
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
}
- for (; v - x >= 180F; x += 360F) {
- ;
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
}
- w = y + (w - y) * 0.2F;
- v = x + (v - x) * 0.2F;
+
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.99F;
- float f5 = 0.03F;
+ float f3 = 0.03F;
- if (v()) {
- for (int i1 = 0; i1 < 4; i1++) {
- float f3 = 0.25F;
+ if (this.v()) {
+ for (int i1 = 0; i1 < 4; ++i1) {
+ float f4 = 0.25F;
- this.l.a("bubble", p - s * (double) f3, q - t * (double) f3, r - u * (double) f3, s, t, u);
+ this.world.a("bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ);
}
f2 = 0.8F;
}
- s *= f2;
- t *= f2;
- u *= f2;
- t -= f5;
- a(p, q, r);
+
+ this.motX *= (double) f2;
+ this.motY *= (double) f2;
+ this.motZ *= (double) f2;
+ this.motY -= (double) f3;
+ this.a(this.locX, this.locY, this.locZ);
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("xTile", (short) b);
- nbttagcompound.a("yTile", (short) c);
- nbttagcompound.a("zTile", (short) d);
- nbttagcompound.a("inTile", (byte) e);
- nbttagcompound.a("shake", (byte) a);
- nbttagcompound.a("inGround", (byte) (f ? 1 : 0));
+ nbttagcompound.a("xTile", (short) this.b);
+ nbttagcompound.a("yTile", (short) this.c);
+ nbttagcompound.a("zTile", (short) this.d);
+ nbttagcompound.a("inTile", (byte) this.e);
+ nbttagcompound.a("shake", (byte) this.a);
+ nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0));
}
public void b(NBTTagCompound nbttagcompound) {
- b = ((int) (nbttagcompound.c("xTile")));
- c = ((int) (nbttagcompound.c("yTile")));
- d = ((int) (nbttagcompound.c("zTile")));
- e = nbttagcompound.b("inTile") & 0xff;
- a = nbttagcompound.b("shake") & 0xff;
- f = nbttagcompound.b("inGround") == 1;
+ this.b = nbttagcompound.c("xTile");
+ this.c = nbttagcompound.c("yTile");
+ this.d = nbttagcompound.c("zTile");
+ this.e = nbttagcompound.b("inTile") & 255;
+ this.a = nbttagcompound.b("shake") & 255;
+ this.f = nbttagcompound.b("inGround") == 1;
}
- public void b(EntityPlayer entityplayer) {
- if (f && ak == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) {
- l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F);
- entityplayer.c(((Entity) (this)), 1);
- q();
+ public void b(EntityHuman entityhuman) {
+ if (this.f && this.ak == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
+ this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
+ entityhuman.c(this, 1);
+ this.q();
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntityFallingSand.java b/src/main/java/net/minecraft/server/EntityFallingSand.java
index f9a95a9b..250dcf5e 100644
--- a/src/main/java/net/minecraft/server/EntityFallingSand.java
+++ b/src/main/java/net/minecraft/server/EntityFallingSand.java
@@ -8,81 +8,81 @@ import org.bukkit.craftbukkit.entity.CraftFallingSand;
public class EntityFallingSand extends Entity {
public int a;
- public int b;
+ public int b = 0;
public EntityFallingSand(World world) {
super(world);
- b = 0;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFallingSand(server, this);
// CraftBukkit end
}
- public EntityFallingSand(World world, double d, double d1, double d2, int i) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
- a = i;
+ public EntityFallingSand(World world, double d0, double d1, double d2, int i) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.a = i;
this.i = true;
- a(0.98F, 0.98F);
- H = J / 2.0F;
- a(d, d1, d2);
- s = 0.0D;
- t = 0.0D;
- u = 0.0D;
- M = false;
- m = d;
- n = d1;
- o = d2;
+ this.a(0.98F, 0.98F);
+ this.height = this.width / 2.0F;
+ this.a(d0, d1, d2);
+ this.motX = 0.0D;
+ this.motY = 0.0D;
+ this.motZ = 0.0D;
+ this.M = false;
+ this.lastX = d0;
+ this.lastY = d1;
+ this.lastZ = d2;
}
protected void a() {}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public void b_() {
- if (a == 0) {
- q();
- return;
- }
- m = p;
- n = q;
- o = r;
- b++;
- t -= 0.039999999105930328D;
- c(s, t, u);
- s *= 0.98000001907348633D;
- t *= 0.98000001907348633D;
- u *= 0.98000001907348633D;
- int i = MathHelper.b(p);
- int j = MathHelper.b(q);
- int k = MathHelper.b(r);
+ if (this.a == 0) {
+ this.q();
+ } else {
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ ++this.b;
+ this.motY -= 0.03999999910593033D;
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.9800000190734863D;
+ this.motY *= 0.9800000190734863D;
+ this.motZ *= 0.9800000190734863D;
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.locY);
+ int k = MathHelper.b(this.locZ);
- if (l.a(i, j, k) == a) {
- l.e(i, j, k, 0);
- }
- if (A) {
- s *= 0.69999998807907104D;
- u *= 0.69999998807907104D;
- t *= -0.5D;
- q();
- if ((!l.a(a, i, j, k, true) || !l.e(i, j, k, a)) && !l.z) {
- a(a, 1);
+ if (this.world.getTypeId(i, j, k) == this.a) {
+ this.world.e(i, j, k, 0);
+ }
+
+ if (this.onGround) {
+ this.motX *= 0.699999988079071D;
+ this.motZ *= 0.699999988079071D;
+ this.motY *= -0.5D;
+ this.q();
+ if ((!this.world.a(this.a, i, j, k, true) || !this.world.e(i, j, k, this.a)) && !this.world.isStatic) {
+ this.a(this.a, 1);
+ }
+ } else if (this.b > 100 && !this.world.isStatic) {
+ this.a(this.a, 1);
+ this.q();
}
- } else if (b > 100 && !l.z) {
- a(a, 1);
- q();
}
}
protected void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Tile", (byte) a);
+ nbttagcompound.a("Tile", (byte) this.a);
}
protected void b(NBTTagCompound nbttagcompound) {
- a = nbttagcompound.b("Tile") & 0xff;
+ this.a = nbttagcompound.b("Tile") & 255;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java
index ee5ba52b..4785270b 100644
--- a/src/main/java/net/minecraft/server/EntityFireball.java
+++ b/src/main/java/net/minecraft/server/EntityFireball.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftFireball;
@@ -11,215 +10,218 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
// CraftBukkit end
-
public class EntityFireball extends Entity {
- private int e;
- private int f;
- private int ak;
- private int al;
- private boolean am;
- public int a;
+ private int e = -1;
+ private int f = -1;
+ private int ak = -1;
+ private int al = 0;
+ private boolean am = false;
+ public int a = 0;
private EntityLiving an;
private int ao;
- private int ap;
+ private int ap = 0;
public double b;
public double c;
public double d;
public EntityFireball(World world) {
super(world);
- e = -1;
- f = -1;
- ak = -1;
- al = 0;
- am = false;
- a = 0;
- ap = 0;
- a(1.0F, 1.0F);
-
+ this.a(1.0F, 1.0F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFireball(server, this);
// CraftBukkit end
}
protected void a() {}
- public EntityFireball(World world, EntityLiving entityliving, double d1, double d2, double d3) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- an = entityliving;
- c(entityliving.p, entityliving.q, entityliving.r, entityliving.v, entityliving.w);
- a(p, q, r);
- H = 0.0F;
- s = t = u = 0.0D;
- d1 += W.nextGaussian() * 0.40000000000000002D;
- d2 += W.nextGaussian() * 0.40000000000000002D;
- d3 += W.nextGaussian() * 0.40000000000000002D;
- double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- b = (d1 / d4) * 0.10000000000000001D;
- c = (d2 / d4) * 0.10000000000000001D;
- d = (d3 / d4) * 0.10000000000000001D;
+ public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.an = entityliving;
+ this.a(1.0F, 1.0F);
+ this.c(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
+ this.a(this.locX, this.locY, this.locZ);
+ this.height = 0.0F;
+ this.motX = this.motY = this.motZ = 0.0D;
+ d0 += this.random.nextGaussian() * 0.4D;
+ d1 += this.random.nextGaussian() * 0.4D;
+ d2 += this.random.nextGaussian() * 0.4D;
+ double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ this.b = d0 / d3 * 0.1D;
+ this.c = d1 / d3 * 0.1D;
+ this.d = d2 / d3 * 0.1D;
}
public void b_() {
super.b_();
- Z = 10;
- if (a > 0) {
- a--;
+ this.fireTicks = 10;
+ if (this.a > 0) {
+ --this.a;
}
- if (am) {
- int i = l.a(e, f, ak);
-
- if (i != al) {
- am = false;
- s *= W.nextFloat() * 0.2F;
- t *= W.nextFloat() * 0.2F;
- u *= W.nextFloat() * 0.2F;
- ao = 0;
- ap = 0;
- } else {
- ao++;
- if (ao == 1200) {
- q();
+
+ if (this.am) {
+ int i = this.world.getTypeId(this.e, this.f, this.ak);
+
+ if (i == this.al) {
+ ++this.ao;
+ if (this.ao == 1200) {
+ this.q();
}
+
return;
}
+
+ this.am = false;
+ this.motX *= (double) (this.random.nextFloat() * 0.2F);
+ this.motY *= (double) (this.random.nextFloat() * 0.2F);
+ this.motZ *= (double) (this.random.nextFloat() * 0.2F);
+ this.ao = 0;
+ this.ap = 0;
} else {
- ap++;
+ ++this.ap;
}
- Vec3D vec3d = Vec3D.b(p, q, r);
- Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
- MovingObjectPosition movingobjectposition = l.a(vec3d, vec3d1);
- vec3d = Vec3D.b(p, q, r);
- vec3d1 = Vec3D.b(p + s, q + t, r + u);
+ Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
+
+ vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
+
Entity entity = null;
- List list = l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
- double d1 = 0.0D;
+ List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
+ double d0 = 0.0D;
- for (int j = 0; j < list.size(); j++) {
+ for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
- if (!entity1.c_() || entity1 == an && ap < 25) {
- continue;
- }
- float f3 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.z.b(f3, f3, f3);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
+ if (entity1.c_() && (entity1 != this.an || this.ap >= 25)) {
+ float f = 0.3F;
+ AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
+ MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
- if (movingobjectposition1 == null) {
- continue;
- }
- double d2 = vec3d.a(movingobjectposition1.f);
+ if (movingobjectposition1 != null) {
+ double d1 = vec3d.a(movingobjectposition1.f);
- if (d2 < d1 || d1 == 0.0D) {
- entity = entity1;
- d1 = d2;
+ if (d1 < d0 || d0 == 0.0D) {
+ entity = entity1;
+ d0 = d1;
+ }
+ }
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
+
if (movingobjectposition != null) {
+ // CraftBukkit start
if (movingobjectposition.g != null) {
- // CraftBukkit start
- boolean bounce;
+ boolean stick;
if (movingobjectposition.g instanceof EntityLiving) {
- CraftServer server = ((WorldServer) this.l).getServer();
- org.bukkit.entity.Entity shooter = (an == null)?null:an.getBukkitEntity();
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity shooter = (this.an == null) ? null : this.an.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0;
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
- server.getPluginManager().callEvent(edbpe);
+ EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
+ server.getPluginManager().callEvent(event);
- if(!edbpe.isCancelled()) {
+ if(!event.isCancelled()) {
// this function returns if the fireball should stick or not, i.e. !bounce
- bounce = !movingobjectposition.g.a(((Entity) (an)), edbpe.getDamage());
+ stick = movingobjectposition.g.a(this.an, event.getDamage());
} else {
// event was cancelled, get if the fireball should bounce or not
- bounce = edbpe.getBounce();
+ stick = !event.getBounce();
}
} else {
- bounce = !movingobjectposition.g.a(((Entity) (an)), 0);
+ stick = movingobjectposition.g.a(this.an, 0);
}
- if (!bounce) {
+ if (stick) {
// CraftBukkit end
;
}
}
- l.a(((Entity) (null)), p, q, r, 1.0F, true);
- q();
+ // CraftBukkit end
+
+ this.world.a((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true);
+ this.q();
}
- p += s;
- q += t;
- r += u;
- float f1 = MathHelper.a(s * s + u * u);
- v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) {
+ this.locX += this.motX;
+ this.locY += this.motY;
+ this.locZ += this.motZ;
+ float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
;
}
- for (; w - y >= 180F; y += 360F) {
- ;
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
}
- for (; v - x < -180F; x -= 360F) {
- ;
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
}
- for (; v - x >= 180F; x += 360F) {
- ;
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
}
- w = y + (w - y) * 0.2F;
- v = x + (v - x) * 0.2F;
+
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.95F;
- if (v()) {
- for (int k = 0; k < 4; k++) {
- float f4 = 0.25F;
+ if (this.v()) {
+ for (int k = 0; k < 4; ++k) {
+ float f3 = 0.25F;
- l.a("bubble", p - s * (double) f4, q - t * (double) f4, r - u * (double) f4, s, t, u);
+ this.world.a("bubble", this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ);
}
f2 = 0.8F;
}
- s += b;
- t += c;
- u += d;
- s *= f2;
- t *= f2;
- u *= f2;
- l.a("smoke", p, q + 0.5D, r, 0.0D, 0.0D, 0.0D);
- a(p, q, r);
+
+ this.motX += this.b;
+ this.motY += this.c;
+ this.motZ += this.d;
+ this.motX *= (double) f2;
+ this.motY *= (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.a(this.locX, this.locY, this.locZ);
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("xTile", (short) e);
- nbttagcompound.a("yTile", (short) f);
- nbttagcompound.a("zTile", (short) ak);
- nbttagcompound.a("inTile", (byte) al);
- nbttagcompound.a("shake", (byte) a);
- nbttagcompound.a("inGround", (byte) (am ? 1 : 0));
+ nbttagcompound.a("xTile", (short) this.e);
+ nbttagcompound.a("yTile", (short) this.f);
+ nbttagcompound.a("zTile", (short) this.ak);
+ nbttagcompound.a("inTile", (byte) this.al);
+ nbttagcompound.a("shake", (byte) this.a);
+ nbttagcompound.a("inGround", (byte) (this.am ? 1 : 0));
}
public void b(NBTTagCompound nbttagcompound) {
- e = ((int) (nbttagcompound.c("xTile")));
- f = ((int) (nbttagcompound.c("yTile")));
- ak = ((int) (nbttagcompound.c("zTile")));
- al = nbttagcompound.b("inTile") & 0xff;
- a = nbttagcompound.b("shake") & 0xff;
- am = nbttagcompound.b("inGround") == 1;
+ this.e = nbttagcompound.c("xTile");
+ this.f = nbttagcompound.c("yTile");
+ this.ak = nbttagcompound.c("zTile");
+ this.al = nbttagcompound.b("inTile") & 255;
+ this.a = nbttagcompound.b("shake") & 255;
+ this.am = nbttagcompound.b("inGround") == 1;
}
public boolean c_() {
@@ -227,18 +229,19 @@ public class EntityFireball extends Entity {
}
public boolean a(Entity entity, int i) {
- y();
+ this.y();
if (entity != null) {
Vec3D vec3d = entity.G();
if (vec3d != null) {
- s = vec3d.a;
- t = vec3d.b;
- u = vec3d.c;
- b = s * 0.10000000000000001D;
- c = t * 0.10000000000000001D;
- d = u * 0.10000000000000001D;
+ this.motX = vec3d.a;
+ this.motY = vec3d.b;
+ this.motZ = vec3d.c;
+ this.b = this.motX * 0.1D;
+ this.c = this.motY * 0.1D;
+ this.d = this.motZ * 0.1D;
}
+
return true;
} else {
return false;
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
index 4d63e7c0..a654b0a5 100644
--- a/src/main/java/net/minecraft/server/EntityFish.java
+++ b/src/main/java/net/minecraft/server/EntityFish.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftFish;
@@ -13,17 +12,17 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntityFish extends Entity {
- private int d;
- private int e;
- private int f;
- private int ak;
- private boolean al;
- public int a;
- public EntityPlayer b;
+ private int d = -1;
+ private int e = -1;
+ private int f = -1;
+ private int ak = 0;
+ private boolean al = false;
+ public int a = 0;
+ public EntityHuman b;
private int am;
- private int an;
- private int ao;
- public Entity c;
+ private int an = 0;
+ private int ao = 0;
+ public Entity c = null;
private int ap;
private double aq;
private double ar;
@@ -33,332 +32,345 @@ public class EntityFish extends Entity {
public EntityFish(World world) {
super(world);
- d = -1;
- e = -1;
- f = -1;
- ak = 0;
- al = false;
- a = 0;
- an = 0;
- ao = 0;
- c = null;
- a(0.25F, 0.25F);
+ this.a(0.25F, 0.25F);
+
//CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFish(server, this);
//CraftBukkit end
}
protected void a() {}
- public EntityFish(World world, EntityPlayer entityplayer) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- b = entityplayer;
- b.aE = this;
- c(entityplayer.p, (entityplayer.q + 1.6200000000000001D) - (double) entityplayer.H, entityplayer.r, entityplayer.v, entityplayer.w);
- p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
- q -= 0.10000000149011612D;
- r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
- a(p, q, r);
- H = 0.0F;
- float f1 = 0.4F;
-
- s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- t = -MathHelper.a((w / 180F) * 3.141593F) * f1;
- a(s, t, u, 1.5F, 1.0F);
+ public EntityFish(World world, EntityHuman entityhuman) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.b = entityhuman;
+ this.b.hookedFish = this;
+ this.a(0.25F, 0.25F);
+ this.c(entityhuman.locX, entityhuman.locY + 1.62D - (double) entityhuman.height, entityhuman.locZ, entityhuman.yaw, entityhuman.pitch);
+ this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.locY -= 0.10000000149011612D;
+ this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.a(this.locX, this.locY, this.locZ);
+ this.height = 0.0F;
+ float f = 0.4F;
+
+ this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
+ this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
}
- public void a(double d1, double d2, double d3, float f1, float f2) {
- float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- d1 /= f3;
- d2 /= f3;
- d3 /= f3;
- d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d1 *= f1;
- d2 *= f1;
- d3 *= f1;
- s = d1;
- t = d2;
- u = d3;
- float f4 = MathHelper.a(d1 * d1 + d3 * d3);
-
- x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D);
- y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D);
- am = 0;
+ public void a(double d0, double d1, double d2, float f, float f1) {
+ float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ d0 /= (double) f2;
+ d1 /= (double) f2;
+ d2 /= (double) f2;
+ d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d0 *= (double) f;
+ d1 *= (double) f;
+ d2 *= (double) f;
+ this.motX = d0;
+ this.motY = d1;
+ this.motZ = d2;
+ float f3 = MathHelper.a(d0 * d0 + d2 * d2);
+
+ this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
+ this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
+ this.am = 0;
}
public void b_() {
super.b_();
- if (ap > 0) {
- double d1 = p + (aq - p) / (double) ap;
- double d2 = q + (ar - q) / (double) ap;
- double d3 = r + (as - r) / (double) ap;
- double d4;
+ if (this.ap > 0) {
+ double d0 = this.locX + (this.aq - this.locX) / (double) this.ap;
+ double d1 = this.locY + (this.ar - this.locY) / (double) this.ap;
+ double d2 = this.locZ + (this.as - this.locZ) / (double) this.ap;
- for (d4 = at - (double) v; d4 < -180D; d4 += 360D) {
- ;
- }
- for (; d4 >= 180D; d4 -= 360D) {
+ double d3;
+
+ for (d3 = this.at - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) {
;
}
- v += ((float) (d4 / (double) ap));
- w += ((float) ((au - (double) w) / (double) ap));
- ap--;
- a(d1, d2, d3);
- b(v, w);
- return;
- }
- if (!this.l.z) {
- ItemStack itemstack = b.P();
- if (b.G || !b.B() || itemstack == null || itemstack.a() != Item.aP || b(((Entity) (b))) > 1024D) {
- q();
- b.aE = null;
- return;
+ while (d3 >= 180.0D) {
+ d3 -= 360.0D;
}
- if (c != null) {
- if (c.G) {
- c = null;
- } else {
- p = c.p;
- q = c.z.b + (double) c.J * 0.80000000000000004D;
- r = c.r;
+
+ this.yaw = (float) ((double) this.yaw + d3 / (double) this.ap);
+ this.pitch = (float) ((double) this.pitch + (this.au - (double) this.pitch) / (double) this.ap);
+ --this.ap;
+ this.a(d0, d1, d2);
+ this.b(this.yaw, this.pitch);
+ } else {
+ if (!this.world.isStatic) {
+ ItemStack itemstack = this.b.P();
+
+ // CraftBukkit - cast this.b to Entity
+ if (this.b.dead || !this.b.B() || itemstack == null || itemstack.a() != Item.FISHING_ROD || this.b((Entity) this.b) > 1024.0D) {
+ this.q();
+ this.b.hookedFish = null;
return;
}
+
+ if (this.c != null) {
+ if (!this.c.dead) {
+ this.locX = this.c.locX;
+ this.locY = this.c.boundingBox.b + (double) this.c.width * 0.8D;
+ this.locZ = this.c.locZ;
+ return;
+ }
+
+ this.c = null;
+ }
}
- }
- if (a > 0) {
- a--;
- }
- if (al) {
- int i = this.l.a(d, e, f);
-
- if (i != ak) {
- al = false;
- s *= W.nextFloat() * 0.2F;
- t *= W.nextFloat() * 0.2F;
- u *= W.nextFloat() * 0.2F;
- am = 0;
- an = 0;
- } else {
- am++;
- if (am == 1200) {
- q();
+
+ if (this.a > 0) {
+ --this.a;
+ }
+
+ if (this.al) {
+ int i = this.world.getTypeId(this.d, this.e, this.f);
+
+ if (i == this.ak) {
+ ++this.am;
+ if (this.am == 1200) {
+ this.q();
+ }
+
+ return;
}
- return;
+
+ this.al = false;
+ this.motX *= (double) (this.random.nextFloat() * 0.2F);
+ this.motY *= (double) (this.random.nextFloat() * 0.2F);
+ this.motZ *= (double) (this.random.nextFloat() * 0.2F);
+ this.am = 0;
+ this.an = 0;
+ } else {
+ ++this.an;
}
- } else {
- an++;
- }
- Vec3D vec3d = Vec3D.b(p, q, r);
- Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
- MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
-
- vec3d = Vec3D.b(p, q, r);
- vec3d1 = Vec3D.b(p + s, q + t, r + u);
- if (movingobjectposition != null) {
- vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
- }
- Entity entity = null;
- List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
- double d5 = 0.0D;
- for (int j = 0; j < list.size(); j++) {
- Entity entity1 = (Entity) list.get(j);
+ Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
- if (!entity1.c_() || entity1 == b && an < 5) {
- continue;
+ vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ if (movingobjectposition != null) {
+ vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
- float f3 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.z.b(f3, f3, f3);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
- if (movingobjectposition1 == null) {
- continue;
+ Entity entity = null;
+ List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
+ double d4 = 0.0D;
+
+ double d5;
+
+ for (int j = 0; j < list.size(); ++j) {
+ Entity entity1 = (Entity) list.get(j);
+
+ if (entity1.c_() && (entity1 != this.b || this.an >= 5)) {
+ float f = 0.3F;
+ AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
+ MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
+
+ if (movingobjectposition1 != null) {
+ d5 = vec3d.a(movingobjectposition1.f);
+ if (d5 < d4 || d4 == 0.0D) {
+ entity = entity1;
+ d4 = d5;
+ }
+ }
+ }
}
- double d6 = vec3d.a(movingobjectposition1.f);
- if (d6 < d5 || d5 == 0.0D) {
- entity = entity1;
- d5 = d6;
+ if (entity != null) {
+ movingobjectposition = new MovingObjectPosition(entity);
}
- }
- if (entity != null) {
- movingobjectposition = new MovingObjectPosition(entity);
- }
- if (movingobjectposition != null) {
- if (movingobjectposition.g != null) {
- // CraftBukkit start
- // TODO add EntityDamagedByProjectileEvent : fishing hook?
- boolean bounce;
- if (movingobjectposition.g instanceof EntityLiving) {
- CraftServer server = ((WorldServer) this.l).getServer();
- org.bukkit.entity.Entity shooter = (b == null)?null:b.getBukkitEntity();
- org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
- org.bukkit.entity.Entity projectile = this.getBukkitEntity();
- DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
- int damage = 0;
-
- // TODO @see EntityArrow#162
- EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
- server.getPluginManager().callEvent(edbpe);
-
- if(!edbpe.isCancelled()) {
- // this function returns if the fish should stick or not, i.e. !bounce
- bounce = !movingobjectposition.g.a(((Entity) (b)), edbpe.getDamage());
+ if (movingobjectposition != null) {
+ if (movingobjectposition.g != null) {
+ // CraftBukkit start
+ // TODO add EntityDamagedByProjectileEvent : fishing hook?
+ boolean stick;
+ if (movingobjectposition.g instanceof EntityLiving) {
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity shooter = (this.b == null) ? null : this.b.getBukkitEntity();
+ org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
+ org.bukkit.entity.Entity projectile = this.getBukkitEntity();
+ DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
+ int damage = 0;
+
+ // TODO @see EntityArrow#162
+ EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
+ server.getPluginManager().callEvent(event);
+
+ if(!event.isCancelled()) {
+ // this function returns if the fish should stick or not, i.e. !bounce
+ stick = movingobjectposition.g.a(this.b, event.getDamage());
+ } else {
+ // event was cancelled, get if the fish should bounce or not
+ stick = !event.getBounce();
+ }
} else {
- // event was cancelled, get if the fish should bounce or not
- bounce = edbpe.getBounce();
+ stick = movingobjectposition.g.a(this.b, 0);
+ }
+ if (!stick) {
+ c = movingobjectposition.g;
}
- } else {
- bounce = !movingobjectposition.g.a(((Entity) (b)), 0);
- }
- if (!bounce) {
// CraftBukkit end
- c = movingobjectposition.g;
+ } else {
+ this.al = true;
}
- } else {
- al = true;
}
- }
- if (al) {
- return;
- }
- c(s, t, u);
- float f1 = MathHelper.a(s * s + u * u);
- v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) {
- ;
- }
- for (; w - y >= 180F; y += 360F) {
- ;
- }
- for (; v - x < -180F; x -= 360F) {
- ;
- }
- for (; v - x >= 180F; x += 360F) {
- ;
- }
- w = y + (w - y) * 0.2F;
- v = x + (v - x) * 0.2F;
- float f2 = 0.92F;
+ if (!this.al) {
+ this.c(this.motX, this.motY, this.motZ);
+ float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
- if (A || B) {
- f2 = 0.5F;
- }
- int k = 5;
- double d8 = 0.0D;
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
- for (int l = 0; l < k; l++) {
- double d9 = ((z.b + ((z.e - z.b) * (double) (l + 0)) / (double) k) - 0.125D) + 0.125D;
- double d10 = ((z.b + ((z.e - z.b) * (double) (l + 1)) / (double) k) - 0.125D) + 0.125D;
- AxisAlignedBB axisalignedbb1 = AxisAlignedBB.b(z.a, d9, z.c, z.d, d10, z.f);
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
+ ;
+ }
- if (this.l.b(axisalignedbb1, Material.f)) {
- d8 += 1.0D / (double) k;
- }
- }
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
+ }
- if (d8 > 0.0D) {
- if (ao > 0) {
- ao--;
- } else if (W.nextInt(500) == 0) {
- ao = W.nextInt(30) + 10;
- t -= 0.20000000298023224D;
- this.l.a(((Entity) (this)), "random.splash", 0.25F, 1.0F + (W.nextFloat() - W.nextFloat()) * 0.4F);
- float f4 = MathHelper.b(z.b);
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
+ }
- for (int i1 = 0; (float) i1 < 1.0F + I * 20F; i1++) {
- float f5 = (W.nextFloat() * 2.0F - 1.0F) * I;
- float f7 = (W.nextFloat() * 2.0F - 1.0F) * I;
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
+ }
+
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
+ float f2 = 0.92F;
- this.l.a("bubble", p + (double) f5, f4 + 1.0F, r + (double) f7, s, t - (double) (W.nextFloat() * 0.2F), u);
+ if (this.onGround || this.B) {
+ f2 = 0.5F;
}
- for (int j1 = 0; (float) j1 < 1.0F + I * 20F; j1++) {
- float f6 = (W.nextFloat() * 2.0F - 1.0F) * I;
- float f8 = (W.nextFloat() * 2.0F - 1.0F) * I;
+ byte b0 = 5;
+ double d6 = 0.0D;
+
+ for (int k = 0; k < b0; ++k) {
+ double d7 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (k + 0) / (double) b0 - 0.125D + 0.125D;
+ double d8 = this.boundingBox.b + (this.boundingBox.e - this.boundingBox.b) * (double) (k + 1) / (double) b0 - 0.125D + 0.125D;
+ AxisAlignedBB axisalignedbb1 = AxisAlignedBB.b(this.boundingBox.a, d7, this.boundingBox.c, this.boundingBox.d, d8, this.boundingBox.f);
- this.l.a("splash", p + (double) f6, f4 + 1.0F, r + (double) f8, s, t, u);
+ if (this.world.b(axisalignedbb1, Material.WATER)) {
+ d6 += 1.0D / (double) b0;
+ }
}
- }
- }
- if (ao > 0) {
- t -= (double) (W.nextFloat() * W.nextFloat() * W.nextFloat()) * 0.20000000000000001D;
- }
- double d7 = d8 * 2D - 1.0D;
- t += 0.039999999105930328D * d7;
- if (d8 > 0.0D) {
- f2 = (float) ((double) f2 * 0.90000000000000002D);
- t *= 0.80000000000000004D;
+ if (d6 > 0.0D) {
+ if (this.ao > 0) {
+ --this.ao;
+ } else if (this.random.nextInt(500) == 0) {
+ this.ao = this.random.nextInt(30) + 10;
+ this.motY -= 0.20000000298023224D;
+ this.world.a(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
+ float f3 = (float) MathHelper.b(this.boundingBox.b);
+
+ int l;
+ float f4;
+ float f5;
+
+ for (l = 0; (float) l < 1.0F + this.length * 20.0F; ++l) {
+ f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ this.world.a("bubble", this.locX + (double) f4, (double) (f3 + 1.0F), this.locZ + (double) f5, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ);
+ }
+
+ for (l = 0; (float) l < 1.0F + this.length * 20.0F; ++l) {
+ f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length;
+ this.world.a("splash", this.locX + (double) f4, (double) (f3 + 1.0F), this.locZ + (double) f5, this.motX, this.motY, this.motZ);
+ }
+ }
+ }
+
+ if (this.ao > 0) {
+ this.motY -= (double) (this.random.nextFloat() * this.random.nextFloat() * this.random.nextFloat()) * 0.2D;
+ }
+
+ d5 = d6 * 2.0D - 1.0D;
+ this.motY += 0.03999999910593033D * d5;
+ if (d6 > 0.0D) {
+ f2 = (float) ((double) f2 * 0.9D);
+ this.motY *= 0.8D;
+ }
+
+ this.motX *= (double) f2;
+ this.motY *= (double) f2;
+ this.motZ *= (double) f2;
+ this.a(this.locX, this.locY, this.locZ);
+ }
}
- s *= f2;
- t *= f2;
- u *= f2;
- a(p, q, r);
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("xTile", (short) d);
- nbttagcompound.a("yTile", (short) e);
- nbttagcompound.a("zTile", (short) f);
- nbttagcompound.a("inTile", (byte) ak);
- nbttagcompound.a("shake", (byte) a);
- nbttagcompound.a("inGround", (byte) (al ? 1 : 0));
+ nbttagcompound.a("xTile", (short) this.d);
+ nbttagcompound.a("yTile", (short) this.e);
+ nbttagcompound.a("zTile", (short) this.f);
+ nbttagcompound.a("inTile", (byte) this.ak);
+ nbttagcompound.a("shake", (byte) this.a);
+ nbttagcompound.a("inGround", (byte) (this.al ? 1 : 0));
}
public void b(NBTTagCompound nbttagcompound) {
- d = ((int) (nbttagcompound.c("xTile")));
- e = ((int) (nbttagcompound.c("yTile")));
- f = ((int) (nbttagcompound.c("zTile")));
- ak = nbttagcompound.b("inTile") & 0xff;
- a = nbttagcompound.b("shake") & 0xff;
- al = nbttagcompound.b("inGround") == 1;
+ this.d = nbttagcompound.c("xTile");
+ this.e = nbttagcompound.c("yTile");
+ this.f = nbttagcompound.c("zTile");
+ this.ak = nbttagcompound.b("inTile") & 255;
+ this.a = nbttagcompound.b("shake") & 255;
+ this.al = nbttagcompound.b("inGround") == 1;
}
public int d() {
- byte byte0 = 0;
-
- if (c != null) {
- double d1 = b.p - p;
- double d2 = b.q - q;
- double d3 = b.r - r;
- double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
- double d5 = 0.10000000000000001D;
-
- c.s += d1 * d5;
- c.t += d2 * d5 + (double) MathHelper.a(d4) * 0.080000000000000002D;
- c.u += d3 * d5;
- byte0 = 3;
- } else if (ao > 0) {
- EntityItem entityitem = new EntityItem(l, p, q, r, new ItemStack(Item.aS));
- double d6 = b.p - p;
- double d7 = b.q - q;
- double d8 = b.r - r;
- double d9 = MathHelper.a(d6 * d6 + d7 * d7 + d8 * d8);
- double d10 = 0.10000000000000001D;
-
- entityitem.s = d6 * d10;
- entityitem.t = d7 * d10 + (double) MathHelper.a(d9) * 0.080000000000000002D;
- entityitem.u = d8 * d10;
- l.a(((Entity) (entityitem)));
- byte0 = 1;
+ byte b0 = 0;
+
+ if (this.c != null) {
+ double d0 = this.b.locX - this.locX;
+ double d1 = this.b.locY - this.locY;
+ double d2 = this.b.locZ - this.locZ;
+ double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+ double d4 = 0.1D;
+
+ this.c.motX += d0 * d4;
+ this.c.motY += d1 * d4 + (double) MathHelper.a(d3) * 0.08D;
+ this.c.motZ += d2 * d4;
+ b0 = 3;
+ } else if (this.ao > 0) {
+ 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 d6 = this.b.locY - this.locY;
+ double d7 = this.b.locZ - this.locZ;
+ double d8 = (double) MathHelper.a(d5 * d5 + d6 * d6 + d7 * d7);
+ double d9 = 0.1D;
+
+ entityitem.motX = d5 * d9;
+ entityitem.motY = d6 * d9 + (double) MathHelper.a(d8) * 0.08D;
+ entityitem.motZ = d7 * d9;
+ this.world.a((Entity) entityitem);
+ b0 = 1;
}
- if (al) {
- byte0 = 2;
+
+ if (this.al) {
+ b0 = 2;
}
- q();
- b.aE = null;
- return ((int) (byte0));
+
+ this.q();
+ this.b.hookedFish = null;
+ return b0;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityFlying.java b/src/main/java/net/minecraft/server/EntityFlying.java
index 06666c66..faa58552 100644
--- a/src/main/java/net/minecraft/server/EntityFlying.java
+++ b/src/main/java/net/minecraft/server/EntityFlying.java
@@ -9,8 +9,9 @@ public class EntityFlying extends EntityLiving {
public EntityFlying(World world) {
super(world);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftFlying(server, this);
// CraftBukkit end
}
@@ -18,56 +19,60 @@ public class EntityFlying extends EntityLiving {
protected void a(float f) {}
public void c(float f, float f1) {
- if (v()) {
- a(f, f1, 0.02F);
- c(s, t, u);
- s *= 0.80000001192092896D;
- t *= 0.80000001192092896D;
- u *= 0.80000001192092896D;
- } else if (x()) {
- a(f, f1, 0.02F);
- c(s, t, u);
- s *= 0.5D;
- t *= 0.5D;
- u *= 0.5D;
+ if (this.v()) {
+ this.a(f, f1, 0.02F);
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.800000011920929D;
+ this.motY *= 0.800000011920929D;
+ this.motZ *= 0.800000011920929D;
+ } else if (this.x()) {
+ this.a(f, f1, 0.02F);
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
} else {
float f2 = 0.91F;
- if (A) {
- f2 = 0.5460001F;
- int i = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r));
+ if (this.onGround) {
+ f2 = 0.54600006F;
+ int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (i > 0) {
- f2 = Block.m[i].bu * 0.91F;
+ f2 = Block.byId[i].frictionFactor * 0.91F;
}
}
- float f3 = 0.1627714F / (f2 * f2 * f2);
- a(f, f1, A ? 0.1F * f3 : 0.02F);
+ float f3 = 0.16277136F / (f2 * f2 * f2);
+
+ this.a(f, f1, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F;
- if (A) {
- f2 = 0.5460001F;
- int j = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r));
+ if (this.onGround) {
+ f2 = 0.54600006F;
+ int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (j > 0) {
- f2 = Block.m[j].bu * 0.91F;
+ f2 = Block.byId[j].frictionFactor * 0.91F;
}
}
- c(s, t, u);
- s *= f2;
- t *= f2;
- u *= f2;
+
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= (double) f2;
+ this.motY *= (double) f2;
+ this.motZ *= (double) f2;
}
- bl = bm;
- double d = p - m;
- double d1 = r - o;
- float f4 = MathHelper.a(d * d + d1 * d1) * 4F;
+
+ this.bl = this.bm;
+ double d0 = this.locX - this.lastX;
+ double d1 = this.locZ - this.lastZ;
+ float f4 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F;
if (f4 > 1.0F) {
f4 = 1.0F;
}
- bm += (f4 - bm) * 0.4F;
- bn += bm;
+
+ this.bm += (f4 - this.bm) * 0.4F;
+ this.bn += this.bm;
}
public boolean m() {
diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java
index 931861b1..e62bcab3 100644
--- a/src/main/java/net/minecraft/server/EntityGhast.java
+++ b/src/main/java/net/minecraft/server/EntityGhast.java
@@ -1,122 +1,122 @@
package net.minecraft.server;
-import java.util.List;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftGhast;
// CraftBukkit end
-public class EntityGhast extends EntityFlying implements IMobs {
+public class EntityGhast extends EntityFlying implements IMonster {
- public int a;
+ public int a = 0;
public double b;
public double c;
public double d;
- private Entity ak;
- private int al;
- public int e;
- public int f;
+ private Entity ak = null;
+ private int al = 0;
+ public int e = 0;
+ public int f = 0;
public EntityGhast(World world) {
super(world);
- a = 0;
- ak = null;
- al = 0;
- e = 0;
- f = 0;
- aP = "/mob/ghast.png";
- a(4F, 4F);
- ae = true;
+ this.texture = "/mob/ghast.png";
+ this.a(4.0F, 4.0F);
+ this.ae = true;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftGhast(server, this);
// CraftBukkit end
}
protected void d() {
- if (l.k == 0) {
- q();
+ if (this.world.k == 0) {
+ this.q();
}
- e = f;
- double d1 = b - p;
- double d2 = c - q;
- double d3 = d - r;
- double d4 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- if (d4 < 1.0D || d4 > 60D) {
- b = p + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F);
- c = q + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F);
- d = r + (double) ((W.nextFloat() * 2.0F - 1.0F) * 16F);
+
+ this.e = this.f;
+ double d0 = this.b - this.locX;
+ double d1 = this.c - this.locY;
+ double d2 = this.d - this.locZ;
+ double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ if (d3 < 1.0D || d3 > 60.0D) {
+ this.b = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
+ this.c = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
+ this.d = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F);
}
- if (a-- <= 0) {
- a += W.nextInt(5) + 2;
- if (a(b, c, d, d4)) {
- s += (d1 / d4) * 0.10000000000000001D;
- t += (d2 / d4) * 0.10000000000000001D;
- u += (d3 / d4) * 0.10000000000000001D;
+
+ if (this.a-- <= 0) {
+ this.a += this.random.nextInt(5) + 2;
+ if (this.a(this.b, this.c, this.d, d3)) {
+ this.motX += d0 / d3 * 0.1D;
+ this.motY += d1 / d3 * 0.1D;
+ this.motZ += d2 / d3 * 0.1D;
} else {
- b = p;
- c = q;
- d = r;
+ this.b = this.locX;
+ this.c = this.locY;
+ this.d = this.locZ;
}
}
- if (ak != null && ak.G) {
- ak = null;
+
+ if (this.ak != null && this.ak.dead) {
+ this.ak = null;
}
- if (ak == null || al-- <= 0) {
- ak = ((Entity) (l.a(((Entity) (this)), 100D)));
- if (ak != null) {
- al = 20;
+
+ if (this.ak == null || this.al-- <= 0) {
+ this.ak = this.world.a(this, 100.0D);
+ if (this.ak != null) {
+ this.al = 20;
}
}
- double d5 = 64D;
- if (ak != null && ak.b(((Entity) (this))) < d5 * d5) {
- double d6 = ak.p - p;
- double d7 = (ak.z.b + (double) (ak.J / 2.0F)) - (q + (double) (J / 2.0F));
- double d8 = ak.r - r;
+ double d4 = 64.0D;
+
+ if (this.ak != null && this.ak.b((Entity) this) < d4 * d4) {
+ double d5 = this.ak.locX - this.locX;
+ double d6 = this.ak.boundingBox.b + (double) (this.ak.width / 2.0F) - (this.locY + (double) (this.width / 2.0F));
+ double d7 = this.ak.locZ - this.locZ;
- aI = v = (-(float) Math.atan2(d6, d8) * 180F) / 3.141593F;
- if (i(ak)) {
- if (f == 10) {
- l.a(((Entity) (this)), "mob.ghast.charge", i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
+ this.aI = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F;
+ if (this.i(this.ak)) {
+ if (this.f == 10) {
+ this.world.a(this, "mob.ghast.charge", this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
- f++;
- if (f == 20) {
- l.a(((Entity) (this)), "mob.ghast.fireball", i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
- EntityFireball entityfireball = new EntityFireball(l, ((EntityLiving) (this)), d6, d7, d8);
- double d9 = 4D;
- Vec3D vec3d = c(1.0F);
-
- entityfireball.p = p + vec3d.a * d9;
- entityfireball.q = q + (double) (J / 2.0F) + 0.5D;
- entityfireball.r = r + vec3d.c * d9;
- l.a(((Entity) (entityfireball)));
- f = -40;
+
+ ++this.f;
+ if (this.f == 20) {
+ this.world.a(this, "mob.ghast.fireball", this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ EntityFireball entityfireball = new EntityFireball(this.world, this, d5, d6, d7);
+ double d8 = 4.0D;
+ Vec3D vec3d = this.c(1.0F);
+
+ entityfireball.locX = this.locX + vec3d.a * d8;
+ entityfireball.locY = this.locY + (double) (this.width / 2.0F) + 0.5D;
+ entityfireball.locZ = this.locZ + vec3d.c * d8;
+ this.world.a((Entity) entityfireball);
+ this.f = -40;
}
- } else if (f > 0) {
- f--;
+ } else if (this.f > 0) {
+ --this.f;
}
} else {
- aI = v = (-(float) Math.atan2(s, u) * 180F) / 3.141593F;
- if (f > 0) {
- f--;
+ this.aI = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F;
+ if (this.f > 0) {
+ --this.f;
}
}
- aP = f <= 10 ? "/mob/ghast.png" : "/mob/ghast_fire.png";
+
+ this.texture = this.f > 10 ? "/mob/ghast_fire.png" : "/mob/ghast.png";
}
- private boolean a(double d1, double d2, double d3, double d4) {
- double d5 = (b - p) / d4;
- double d6 = (c - q) / d4;
- double d7 = (d - r) / d4;
- AxisAlignedBB axisalignedbb = z.b();
+ private boolean a(double d0, double d1, double d2, double d3) {
+ double d4 = (this.b - this.locX) / d3;
+ double d5 = (this.c - this.locY) / d3;
+ double d6 = (this.d - this.locZ) / d3;
+ AxisAlignedBB axisalignedbb = this.boundingBox.b();
- for (int k = 1; (double) k < d4; k++) {
- axisalignedbb.d(d5, d6, d7);
- if (l.a(((Entity) (this)), axisalignedbb).size() > 0) {
+ for (int i = 1; (double) i < d3; ++i) {
+ axisalignedbb.d(d4, d5, d6);
+ if (this.world.a((Entity) this, axisalignedbb).size() > 0) {
return false;
}
}
@@ -137,15 +137,15 @@ public class EntityGhast extends EntityFlying implements IMobs {
}
protected int h() {
- return Item.K.ba;
+ return Item.SULPHUR.id;
}
protected float i() {
- return 10F;
+ return 10.0F;
}
public boolean b() {
- return W.nextInt(20) == 0 && super.b() && l.k > 0;
+ return this.random.nextInt(20) == 0 && super.b() && this.world.k > 0;
}
public int j() {
diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
new file mode 100644
index 00000000..5eaf8730
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
@@ -0,0 +1,28 @@
+package net.minecraft.server;
+
+// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.entity.CraftGiant;
+// CraftBukkit stop
+
+public class EntityGiantZombie extends EntityMonster {
+
+ public EntityGiantZombie(World world) {
+ super(world);
+ this.texture = "/mob/zombie.png";
+ this.bC = 0.5F;
+ this.c = 50;
+ this.health *= 10;
+ this.height *= 6.0F;
+ this.a(this.length * 6.0F, this.width * 6.0F);
+
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ this.bukkitEntity = new CraftGiant(server, this);
+ // CraftBukkit end
+ }
+
+ protected float a(int i, int j, int k) {
+ return this.world.l(i, j, k) - 0.5F;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
new file mode 100644
index 00000000..7988a32b
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -0,0 +1,391 @@
+package net.minecraft.server;
+
+import java.util.List;
+
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
+// CraftBukkit end
+
+public abstract class EntityHuman extends EntityLiving {
+
+ public InventoryPlayer inventory = new InventoryPlayer(this);
+ public Container defaultContainer;
+ public Container activeContainer;
+ public byte aq = 0;
+ public int ar = 0;
+ public float as;
+ public float at;
+ public boolean au = false;
+ public int av = 0;
+ public String name;
+ public int dimension;
+ public double ay;
+ public double az;
+ public double aA;
+ public double aB;
+ public double aC;
+ public double aD;
+ private int a = 0;
+ public EntityFish hookedFish = null;
+
+ public EntityHuman(World world) {
+ super(world);
+ this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic);
+ this.activeContainer = this.defaultContainer;
+ this.height = 1.62F;
+ this.c((double) world.spawnX + 0.5D, (double) (world.spawnY + 1), (double) world.spawnZ + 0.5D, 0.0F, 0.0F);
+ this.health = 20;
+ this.aS = "humanoid";
+ this.aR = 180.0F;
+ this.maxFireTicks = 20;
+ this.texture = "/mob/char.png";
+
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ this.bukkitEntity = new CraftHumanEntity(server, this);
+ // CraftBukkit end
+ }
+
+ public void b_() {
+ super.b_();
+ if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.b(this)) {
+ this.L();
+ this.activeContainer = this.defaultContainer;
+ }
+
+ this.ay = this.aB;
+ this.az = this.aC;
+ this.aA = this.aD;
+ double d0 = this.locX - this.aB;
+ double d1 = this.locY - this.aC;
+ double d2 = this.locZ - this.aD;
+ double d3 = 10.0D;
+
+ if (d0 > d3) {
+ this.ay = this.aB = this.locX;
+ }
+
+ if (d2 > d3) {
+ this.aA = this.aD = this.locZ;
+ }
+
+ if (d1 > d3) {
+ this.az = this.aC = this.locY;
+ }
+
+ if (d0 < -d3) {
+ this.ay = this.aB = this.locX;
+ }
+
+ if (d2 < -d3) {
+ this.aA = this.aD = this.locZ;
+ }
+
+ if (d1 < -d3) {
+ this.az = this.aC = this.locY;
+ }
+
+ this.aB += d0 * 0.25D;
+ this.aD += d2 * 0.25D;
+ this.aC += d1 * 0.25D;
+ }
+
+ protected void L() {
+ this.activeContainer = this.defaultContainer;
+ }
+
+ public void D() {
+ super.D();
+ this.as = this.at;
+ this.at = 0.0F;
+ }
+
+ protected void d() {
+ if (this.au) {
+ ++this.av;
+ if (this.av == 8) {
+ this.av = 0;
+ this.au = false;
+ }
+ } else {
+ this.av = 0;
+ }
+
+ this.aY = (float) this.av / 8.0F;
+ }
+
+ public void o() {
+ if (this.world.k == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) {
+ this.d(1);
+ }
+
+ this.inventory.f();
+ this.as = this.at;
+ super.o();
+ float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+ float f1 = (float) Math.atan(-this.motY * 0.20000000298023224D) * 15.0F;
+
+ if (f > 0.1F) {
+ f = 0.1F;
+ }
+
+ if (!this.onGround || this.health <= 0) {
+ f = 0.0F;
+ }
+
+ if (this.onGround || this.health <= 0) {
+ f1 = 0.0F;
+ }
+
+ this.at += (f - this.at) * 0.4F;
+ this.bh += (f1 - this.bh) * 0.8F;
+ if (this.health > 0) {
+ List list = this.world.b((Entity) this, this.boundingBox.b(1.0D, 0.0D, 1.0D));
+
+ if (list != null) {
+ for (int i = 0; i < list.size(); ++i) {
+ Entity entity = (Entity) list.get(i);
+
+ if (!entity.dead) {
+ this.j(entity);
+ }
+ }
+ }
+ }
+ }
+
+ private void j(Entity entity) {
+ entity.b(this);
+ }
+
+ public void f(Entity entity) {
+ super.f(entity);
+ this.a(0.2F, 0.2F);
+ this.a(this.locX, this.locY, this.locZ);
+ this.motY = 0.10000000149011612D;
+ if (this.name.equals("Notch")) {
+ this.a(new ItemStack(Item.APPLE, 1), true);
+ }
+
+ this.inventory.h();
+ if (entity != null) {
+ this.motX = (double) (-MathHelper.b((this.bd + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
+ this.motZ = (double) (-MathHelper.a((this.bd + this.yaw) * 3.1415927F / 180.0F) * 0.1F);
+ } else {
+ this.motX = this.motZ = 0.0D;
+ }
+
+ this.height = 0.1F;
+ }
+
+ public void b(Entity entity, int i) {
+ this.ar += i;
+ }
+
+ public void O() {
+ this.a(this.inventory.b(this.inventory.c, 1), false);
+ }
+
+ public void b(ItemStack itemstack) {
+ this.a(itemstack, false);
+ }
+
+ public void a(ItemStack itemstack, boolean flag) {
+ if (itemstack != null) {
+ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.w(), this.locZ, itemstack);
+
+ entityitem.c = 40;
+ float f = 0.1F;
+ float f1;
+
+ if (flag) {
+ f1 = this.random.nextFloat() * 0.5F;
+ float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;
+
+ entityitem.motX = (double) (-MathHelper.a(f2) * f1);
+ entityitem.motZ = (double) (MathHelper.b(f2) * f1);
+ entityitem.motY = 0.20000000298023224D;
+ } else {
+ f = 0.3F;
+ entityitem.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ entityitem.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ entityitem.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
+ f = 0.02F;
+ f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
+ f *= this.random.nextFloat();
+ entityitem.motX += Math.cos((double) f1) * (double) f;
+ entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
+ entityitem.motZ += Math.sin((double) f1) * (double) f;
+ }
+
+ this.a(entityitem);
+ }
+ }
+
+ protected void a(EntityItem entityitem) {
+ this.world.a((Entity) entityitem);
+ }
+
+ public float a(Block block) {
+ float f = this.inventory.a(block);
+
+ if (this.a(Material.WATER)) {
+ f /= 5.0F;
+ }
+
+ if (!this.onGround) {
+ f /= 5.0F;
+ }
+
+ return f;
+ }
+
+ public boolean b(Block block) {
+ return this.inventory.b(block);
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ super.b(nbttagcompound);
+ NBTTagList nbttaglist = nbttagcompound.k("Inventory");
+
+ this.inventory.b(nbttaglist);
+ this.dimension = nbttagcompound.d("Dimension");
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ nbttagcompound.a("Inventory", (NBTBase) this.inventory.a(new NBTTagList()));
+ nbttagcompound.a("Dimension", this.dimension);
+ }
+
+ public void a(IInventory iinventory) {}
+
+ public void a(int i, int j, int k) {}
+
+ public void c(Entity entity, int i) {}
+
+ public float w() {
+ return 0.12F;
+ }
+
+ public boolean a(Entity entity, int i) {
+ this.bw = 0;
+ if (this.health <= 0) {
+ return false;
+ } else {
+ if (entity instanceof EntityMonster || entity instanceof EntityArrow) {
+ if (this.world.k == 0) {
+ i = 0;
+ }
+
+ if (this.world.k == 1) {
+ i = i / 3 + 1;
+ }
+
+ if (this.world.k == 3) {
+ i = i * 3 / 2;
+ }
+ }
+
+ return i == 0 ? false : super.a(entity, i);
+ }
+ }
+
+ protected void e(int i) {
+ int j = 25 - this.inventory.g();
+ int k = i * j + this.a;
+
+ this.inventory.c(i);
+ i = k / 25;
+ this.a = k % 25;
+ super.e(i);
+ }
+
+ public void a(TileEntityFurnace tileentityfurnace) {}
+
+ public void a(TileEntityDispenser tileentitydispenser) {}
+
+ public void a(TileEntitySign tileentitysign) {}
+
+ public void g(Entity entity) {
+ if (!entity.a(this)) {
+ ItemStack itemstack = this.P();
+
+ if (itemstack != null && entity instanceof EntityLiving) {
+ itemstack.b((EntityLiving) entity);
+ if (itemstack.count <= 0) {
+ itemstack.a(this);
+ this.Q();
+ }
+ }
+ }
+ }
+
+ public ItemStack P() {
+ return this.inventory.e();
+ }
+
+ public void Q() {
+ this.inventory.a(this.inventory.c, (ItemStack) null);
+ }
+
+ public double F() {
+ return (double) (this.height - 0.5F);
+ }
+
+ public void K() {
+ this.av = -1;
+ this.au = true;
+ }
+
+ public void h(Entity entity) {
+ int i = this.inventory.a(entity);
+
+ if (i > 0) {
+ // CraftBukkit start
+ if(entity instanceof EntityLiving) {
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity damager = this.getBukkitEntity();
+ org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
+ DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
+ int damageDone = i;
+
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()){
+ return;
+ }
+
+ entity.a(this, event.getDamage());
+ } else {
+ entity.a(this, i);
+ }
+ // CraftBukkit end
+
+ ItemStack itemstack = this.P();
+
+ if (itemstack != null && entity instanceof EntityLiving) {
+ itemstack.a((EntityLiving) entity);
+ if (itemstack.count <= 0) {
+ itemstack.a(this);
+ this.Q();
+ }
+ }
+ }
+ }
+
+ public void a(ItemStack itemstack) {}
+
+ public void q() {
+ super.q();
+ this.defaultContainer.a(this);
+ if (this.activeContainer != null) {
+ this.activeContainer.a(this);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index dfcd4517..47f33ee2 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftItem;
@@ -11,34 +9,31 @@ public class EntityItem extends Entity {
public ItemStack a;
private int e;
- public int b;
+ public int b = 0;
public int c;
- private int f;
- public float d;
+ private int f = 5;
+ public float d = (float) (Math.random() * 3.141592653589793D * 2.0D);
- public EntityItem(World world, double d1, double d2, double d3, ItemStack itemstack) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
- a(d1, d2, d3);
- a = itemstack;
- v = (float) (Math.random() * 360D);
- s = (float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D);
- t = 0.20000000298023224D;
- u = (float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D);
- M = false;
-
+ public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) {
+ super(world);
+ this.a(0.25F, 0.25F);
+ this.height = this.width / 2.0F;
+ this.a(d0, d1, d2);
+ this.a = itemstack;
+ this.yaw = (float) (Math.random() * 360.0D);
+ this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
+ this.motY = 0.20000000298023224D;
+ this.motZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D));
+ this.M = false;
}
public EntityItem(World world) {
super(world);
- b = 0;
- f = 5;
- d = (float) (Math.random() * 3.1415926535897931D * 2D);
- a(0.25F, 0.25F);
- H = J / 2.0F;
+ this.a(0.25F, 0.25F);
+ this.height = this.width / 2.0F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftItem(server, this);
// CraftBukkit end
}
@@ -47,152 +42,167 @@ public class EntityItem extends Entity {
public void b_() {
super.b_();
- if (c > 0) {
- c--;
+ if (this.c > 0) {
+ --this.c;
}
- m = p;
- n = q;
- o = r;
- t -= 0.039999999105930328D;
- if (l.c(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) == Material.g) {
- t = 0.20000000298023224D;
- s = (W.nextFloat() - W.nextFloat()) * 0.2F;
- u = (W.nextFloat() - W.nextFloat()) * 0.2F;
- l.a(((Entity) (this)), "random.fizz", 0.4F, 2.0F + W.nextFloat() * 0.4F);
+
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ this.motY -= 0.03999999910593033D;
+ if (this.world.getMaterial(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) == Material.LAVA) {
+ this.motY = 0.20000000298023224D;
+ this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
+ this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F);
+ this.world.a(this, "random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
}
- g(p, q, r);
- c(s, t, u);
- float f1 = 0.98F;
- if (A) {
- f1 = 0.5880001F;
- int i = l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r));
+ this.g(this.locX, this.locY, this.locZ);
+ this.c(this.motX, this.motY, this.motZ);
+ float f = 0.98F;
+
+ if (this.onGround) {
+ f = 0.58800006F;
+ int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
if (i > 0) {
- f1 = Block.m[i].bu * 0.98F;
+ f = Block.byId[i].frictionFactor * 0.98F;
}
}
- s *= f1;
- t *= 0.98000001907348633D;
- u *= f1;
- if (A) {
- t *= -0.5D;
+
+ this.motX *= (double) f;
+ this.motY *= 0.9800000190734863D;
+ this.motZ *= (double) f;
+ if (this.onGround) {
+ this.motY *= -0.5D;
}
- e++;
- b++;
- if (b >= 6000) {
- q();
+
+ ++this.e;
+ ++this.b;
+ if (this.b >= 6000) {
+ this.q();
}
}
public boolean v() {
- return l.a(z, Material.f, ((Entity) (this)));
+ return this.world.a(this.boundingBox, Material.WATER, this);
}
- private boolean g(double d1, double d2, double d3) {
- int i = MathHelper.b(d1);
- int j = MathHelper.b(d2);
- int k = MathHelper.b(d3);
- double d4 = d1 - (double) i;
- double d5 = d2 - (double) j;
- double d6 = d3 - (double) k;
-
- if (Block.o[l.a(i, j, k)]) {
- boolean flag = !Block.o[l.a(i - 1, j, k)];
- boolean flag1 = !Block.o[l.a(i + 1, j, k)];
- boolean flag2 = !Block.o[l.a(i, j - 1, k)];
- boolean flag3 = !Block.o[l.a(i, j + 1, k)];
- boolean flag4 = !Block.o[l.a(i, j, k - 1)];
- boolean flag5 = !Block.o[l.a(i, j, k + 1)];
- byte byte0 = -1;
- double d7 = 9999D;
-
- if (flag && d4 < d7) {
- d7 = d4;
- byte0 = 0;
+ private boolean g(double d0, double d1, double d2) {
+ int i = MathHelper.b(d0);
+ int j = MathHelper.b(d1);
+ int k = MathHelper.b(d2);
+ double d3 = d0 - (double) i;
+ double d4 = d1 - (double) j;
+ double d5 = d2 - (double) k;
+
+ if (Block.o[this.world.getTypeId(i, j, k)]) {
+ boolean flag = !Block.o[this.world.getTypeId(i - 1, j, k)];
+ boolean flag1 = !Block.o[this.world.getTypeId(i + 1, j, k)];
+ boolean flag2 = !Block.o[this.world.getTypeId(i, j - 1, k)];
+ boolean flag3 = !Block.o[this.world.getTypeId(i, j + 1, k)];
+ boolean flag4 = !Block.o[this.world.getTypeId(i, j, k - 1)];
+ boolean flag5 = !Block.o[this.world.getTypeId(i, j, k + 1)];
+ byte b0 = -1;
+ double d6 = 9999.0D;
+
+ if (flag && d3 < d6) {
+ d6 = d3;
+ b0 = 0;
}
- if (flag1 && 1.0D - d4 < d7) {
- d7 = 1.0D - d4;
- byte0 = 1;
+
+ if (flag1 && 1.0D - d3 < d6) {
+ d6 = 1.0D - d3;
+ b0 = 1;
}
- if (flag2 && d5 < d7) {
- d7 = d5;
- byte0 = 2;
+
+ if (flag2 && d4 < d6) {
+ d6 = d4;
+ b0 = 2;
}
- if (flag3 && 1.0D - d5 < d7) {
- d7 = 1.0D - d5;
- byte0 = 3;
+
+ if (flag3 && 1.0D - d4 < d6) {
+ d6 = 1.0D - d4;
+ b0 = 3;
}
- if (flag4 && d6 < d7) {
- d7 = d6;
- byte0 = 4;
+
+ if (flag4 && d5 < d6) {
+ d6 = d5;
+ b0 = 4;
}
- if (flag5 && 1.0D - d6 < d7) {
- double d8 = 1.0D - d6;
- byte0 = 5;
+ if (flag5 && 1.0D - d5 < d6) {
+ d6 = 1.0D - d5;
+ b0 = 5;
}
- float f1 = W.nextFloat() * 0.2F + 0.1F;
- if (byte0 == 0) {
- s = -f1;
+ float f = this.random.nextFloat() * 0.2F + 0.1F;
+
+ if (b0 == 0) {
+ this.motX = (double) (-f);
}
- if (byte0 == 1) {
- s = f1;
+
+ if (b0 == 1) {
+ this.motX = (double) f;
}
- if (byte0 == 2) {
- t = -f1;
+
+ if (b0 == 2) {
+ this.motY = (double) (-f);
}
- if (byte0 == 3) {
- t = f1;
+
+ if (b0 == 3) {
+ this.motY = (double) f;
}
- if (byte0 == 4) {
- u = -f1;
+
+ if (b0 == 4) {
+ this.motZ = (double) (-f);
}
- if (byte0 == 5) {
- u = f1;
+
+ if (b0 == 5) {
+ this.motZ = (double) f;
}
}
+
return false;
}
protected void b(int i) {
- a(((Entity) (null)), i);
+ this.a((Entity) null, i);
}
public boolean a(Entity entity, int i) {
- y();
- f -= i;
- if (f <= 0) {
- q();
+ this.y();
+ this.f -= i;
+ if (this.f <= 0) {
+ this.q();
}
+
return false;
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Health", (short) f);
- nbttagcompound.a("Age", (short) b);
- nbttagcompound.a("Item", a.a(new NBTTagCompound()));
+ nbttagcompound.a("Health", (short) ((byte) this.f));
+ nbttagcompound.a("Age", (short) this.b);
+ nbttagcompound.a("Item", this.a.a(new NBTTagCompound()));
}
public void b(NBTTagCompound nbttagcompound) {
- f = nbttagcompound.c("Health") & 0xff;
- b = ((int) (nbttagcompound.c("Age")));
+ this.f = nbttagcompound.c("Health") & 255;
+ this.b = nbttagcompound.c("Age");
NBTTagCompound nbttagcompound1 = nbttagcompound.j("Item");
- a = new ItemStack(nbttagcompound1);
+ this.a = new ItemStack(nbttagcompound1);
}
- public void b(EntityPlayer entityplayer) {
- if (l.z) {
- return;
- }
- int i = a.a;
+ public void b(EntityHuman entityhuman) {
+ if (!this.world.isStatic) {
+ int i = this.a.count;
- if (c == 0 && entityplayer.an.a(a)) {
- l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F);
- entityplayer.c(((Entity) (this)), i);
- q();
+ if (this.c == 0 && entityhuman.inventory.a(this.a)) {
+ this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
+ entityhuman.c(this, i);
+ this.q();
+ }
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntityList.java b/src/main/java/net/minecraft/server/EntityList.java
deleted file mode 100644
index 1602769b..00000000
--- a/src/main/java/net/minecraft/server/EntityList.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package net.minecraft.server;
-
-import java.io.PrintStream;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
-
-public class EntityList {
-
- private static Map a = new HashMap();
- private static Map b = new HashMap();
- private static Map c = new HashMap();
- private static Map d = new HashMap();
-
- public EntityList() {}
-
- private static void a(Class class1, String s, int i) {
- a.put(((s)), ((class1)));
- b.put(((class1)), ((s)));
- c.put(((Integer.valueOf(i))), ((class1)));
- d.put(((class1)), ((Integer.valueOf(i))));
- }
-
- public static Entity a(String s, World world) {
- Entity entity = null;
-
- try {
- Class class1 = (Class) a.get(((s)));
-
- if (class1 != null) {
- entity = (Entity) class1.getConstructor(new Class[] {
- net.minecraft.server.World.class
- }).newInstance(new Object[] {
- world
- });
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- return entity;
- }
-
- public static Entity a(NBTTagCompound nbttagcompound, World world) {
- Entity entity = null;
-
- try {
- Class class1 = (Class) a.get(((nbttagcompound.h("id"))));
-
- if (class1 != null) {
- entity = (Entity) class1.getConstructor(new Class[] {
- net.minecraft.server.World.class
- }).newInstance(new Object[] {
- world
- });
- }
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- if (entity != null) {
- entity.e(nbttagcompound);
- } else {
- System.out.println((new StringBuilder()).append("Skipping Entity with id ").append(nbttagcompound.h("id")).toString());
- }
- return entity;
- }
-
- public static int a(Entity entity) {
- return ((Integer) d.get(((((entity)).getClass())))).intValue();
- }
-
- public static String b(Entity entity) {
- return (String) b.get(((((entity)).getClass())));
- }
-
- static {
- a(net.minecraft.server.EntityArrow.class, "Arrow", 10);
- a(net.minecraft.server.EntitySnowball.class, "Snowball", 11);
- a(net.minecraft.server.EntityItem.class, "Item", 1);
- a(net.minecraft.server.EntityPainting.class, "Painting", 9);
- a(net.minecraft.server.EntityLiving.class, "Mob", 48);
- a(net.minecraft.server.EntityMobs.class, "Monster", 49);
- a(net.minecraft.server.EntityCreeper.class, "Creeper", 50);
- a(net.minecraft.server.EntitySkeleton.class, "Skeleton", 51);
- a(net.minecraft.server.EntitySpider.class, "Spider", 52);
- a(net.minecraft.server.EntityZombieSimple.class, "Giant", 53);
- a(net.minecraft.server.EntityZombie.class, "Zombie", 54);
- a(net.minecraft.server.EntitySlime.class, "Slime", 55);
- a(net.minecraft.server.EntityGhast.class, "Ghast", 56);
- a(net.minecraft.server.EntityPigZombie.class, "PigZombie", 57);
- a(net.minecraft.server.EntityPig.class, "Pig", 90);
- a(net.minecraft.server.EntitySheep.class, "Sheep", 91);
- a(net.minecraft.server.EntityCow.class, "Cow", 92);
- a(net.minecraft.server.EntityChicken.class, "Chicken", 93);
- a(net.minecraft.server.EntitySquid.class, "Squid", 94);
- a(net.minecraft.server.EntityTNTPrimed.class, "PrimedTnt", 20);
- a(net.minecraft.server.EntityFallingSand.class, "FallingSand", 21);
- a(net.minecraft.server.EntityMinecart.class, "Minecart", 40);
- a(net.minecraft.server.EntityBoat.class, "Boat", 41);
- }
-}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 17d62bee..6f344290 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
@@ -12,39 +11,39 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public abstract class EntityLiving extends Entity {
- public int aF;
+ public int maxNoDamageTicks = 20;
public float aG;
public float aH;
- public float aI;
- public float aJ;
+ public float aI = 0.0F;
+ public float aJ = 0.0F;
protected float aK;
protected float aL;
protected float aM;
protected float aN;
- protected boolean aO;
- protected String aP;
- protected boolean aQ;
- protected float aR;
- protected String aS;
- protected float aT;
- protected int aU;
- protected float aV;
- public boolean aW;
+ protected boolean aO = true;
+ protected String texture = "/mob/char.png";
+ protected boolean aQ = true;
+ protected float aR = 0.0F;
+ protected String aS = null;
+ protected float aT = 1.0F;
+ protected int aU = 0;
+ protected float aV = 0.0F;
+ public boolean aW = false;
public float aX;
public float aY;
- public int aZ;
+ public int health = 10;
public int ba;
private int a;
- public int bb;
+ public int hurtTicks;
public int bc;
- public float bd;
- public int be;
- public int bf;
+ public float bd = 0.0F;
+ public int deathTicks = 0;
+ public int attackTicks = 0;
public float bg;
public float bh;
- protected boolean bi;
- public int bj;
- public float bk;
+ protected boolean bi = false;
+ public int bj = -1;
+ public float bk = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D);
public float bl;
public float bm;
public float bn;
@@ -54,54 +53,29 @@ public abstract class EntityLiving extends Entity {
protected double br;
protected double bs;
protected double bt;
- float bu;
- protected int bv;
- protected int bw;
+ float bu = 0.0F;
+ protected int lastDamage = 0;
+ protected int bw = 0;
protected float bx;
protected float by;
protected float bz;
- protected boolean bA;
- protected float bB;
- protected float bC;
+ protected boolean bA = false;
+ protected float bB = 0.0F;
+ protected float bC = 0.7F;
private Entity b;
- private int c;
+ private int c = 0;
public EntityLiving(World world) {
super(world);
- aF = 20;
- aI = 0.0F;
- aJ = 0.0F;
- aO = true;
- aP = "/mob/char.png";
- aQ = true;
- aR = 0.0F;
- aS = null;
- aT = 1.0F;
- aU = 0;
- aV = 0.0F;
- aW = false;
- bd = 0.0F;
- be = 0;
- bf = 0;
- bi = false;
- bj = -1;
- bk = (float) (Math.random() * 0.89999997615814209D + 0.10000000149011612D);
- bu = 0.0F;
- bv = 0;
- bw = 0;
- bA = false;
- bB = 0.0F;
- bC = 0.7F;
- c = 0;
- aZ = 10;
- i = true;
- aH = (float) (Math.random() + 1.0D) * 0.01F;
- a(p, q, r);
- aG = (float) Math.random() * 12398F;
- v = (float) (Math.random() * 3.1415927410125732D * 2D);
- S = 0.5F;
+ this.i = true;
+ this.aH = (float) (Math.random() + 1.0D) * 0.01F;
+ this.a(this.locX, this.locY, this.locZ);
+ this.aG = (float) Math.random() * 12398.0F;
+ this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
+ this.S = 0.5F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftLivingEntity(server, this);
// CraftBukkit end
}
@@ -109,19 +83,19 @@ public abstract class EntityLiving extends Entity {
protected void a() {}
public boolean i(Entity entity) {
- return l.a(Vec3D.b(p, q + (double) w(), r), Vec3D.b(entity.p, entity.q + (double) entity.w(), entity.r)) == null;
+ return this.world.a(Vec3D.b(this.locX, this.locY + (double) this.w(), this.locZ), Vec3D.b(entity.locX, entity.locY + (double) entity.w(), entity.locZ)) == null;
}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public boolean z() {
- return !G;
+ return !this.dead;
}
public float w() {
- return J * 0.85F;
+ return this.width * 0.85F;
}
public int c() {
@@ -129,257 +103,297 @@ public abstract class EntityLiving extends Entity {
}
public void r() {
- aX = aY;
+ this.aX = this.aY;
super.r();
- if (W.nextInt(1000) < a++) {
- a = -c();
- String s = e();
+ if (this.random.nextInt(1000) < this.a++) {
+ this.a = -this.c();
+ String s = this.e();
if (s != null) {
- this.l.a(((Entity) (this)), s, i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
+ this.world.a(this, s, this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
}
- if (B() && C()) {
+
+ if (this.B() && this.C()) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity victim = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.SUFFOCATION;
- EntityDamageEvent evt = new EntityDamageEvent(victim, damageType, 1);
- server.getPluginManager().callEvent(evt);
-
- if (!evt.isCancelled()){
- a(((Entity) (null)), 1);
+ EntityDamageEvent event = new EntityDamageEvent(victim, damageType, 1);
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()){
+ this.a((Entity) null, 1);
}
// CraftBukkit end
}
- if (ae || this.l.z) {
- Z = 0;
+
+ if (this.ae || this.world.isStatic) {
+ this.fireTicks = 0;
}
- if (B() && a(Material.f) && !d_()) {
- ad--;
- if (ad == -20) {
- ad = 0;
- for (int k = 0; k < 8; k++) {
- float f1 = W.nextFloat() - W.nextFloat();
- float f2 = W.nextFloat() - W.nextFloat();
- float f3 = W.nextFloat() - W.nextFloat();
- this.l.a("bubble", p + (double) f1, q + (double) f2, r + (double) f3, this.s, t, u);
+ int i;
+
+ if (this.B() && this.a(Material.WATER) && !this.d_()) {
+ --this.airTicks;
+ if (this.airTicks == -20) {
+ this.airTicks = 0;
+
+ for (i = 0; i < 8; ++i) {
+ float f = this.random.nextFloat() - this.random.nextFloat();
+ float f1 = this.random.nextFloat() - this.random.nextFloat();
+ float f2 = this.random.nextFloat() - this.random.nextFloat();
+
+ this.world.a("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ);
}
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING;
int damageDone = 2;
- EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone);
- server.getPluginManager().callEvent(ede);
+ EntityDamageEvent event = new EntityDamageEvent(damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
- if (!ede.isCancelled()){
- a(((Entity) (null)), ede.getDamage());
+ if (!event.isCancelled()){
+ this.a((Entity) null, event.getDamage());
}
// CraftBukkit end
}
- Z = 0;
+
+ this.fireTicks = 0;
} else {
- ad = aa;
+ this.airTicks = this.maxAirTicks;
}
- bg = bh;
- if (bf > 0) {
- bf--;
+
+ this.bg = this.bh;
+ if (this.attackTicks > 0) {
+ --this.attackTicks;
}
- if (bb > 0) {
- bb--;
+
+ if (this.hurtTicks > 0) {
+ --this.hurtTicks;
}
- if (ac > 0) {
- ac--;
+
+ if (this.noDamageTicks > 0) {
+ --this.noDamageTicks;
}
- if (aZ <= 0) {
- be++;
- if (be > 20) {
- T();
- q();
- for (int l = 0; l < 20; l++) {
- double d1 = W.nextGaussian() * 0.02D;
- double d2 = W.nextGaussian() * 0.02D;
- double d3 = W.nextGaussian() * 0.02D;
- this.l.a("explode", (p + (double) (W.nextFloat() * I * 2.0F)) - (double) I, q + (double) (W.nextFloat() * J), (r + (double) (W.nextFloat() * I * 2.0F)) - (double) I, d1, d2, d3);
+ if (this.health <= 0) {
+ ++this.deathTicks;
+ if (this.deathTicks > 20) {
+ this.T();
+ this.q();
+
+ for (i = 0; i < 20; ++i) {
+ double d0 = this.random.nextGaussian() * 0.02D;
+ double d1 = this.random.nextGaussian() * 0.02D;
+ double d2 = this.random.nextGaussian() * 0.02D;
+
+ this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, this.locY + (double) (this.random.nextFloat() * this.width), this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, d0, d1, d2);
}
}
}
- aN = aM;
- aJ = aI;
- x = v;
- y = w;
+
+ this.aN = this.aM;
+ this.aJ = this.aI;
+ this.lastYaw = this.yaw;
+ this.lastPitch = this.pitch;
}
public void R() {
- for (int k = 0; k < 20; k++) {
- double d1 = W.nextGaussian() * 0.02D;
- double d2 = W.nextGaussian() * 0.02D;
- double d3 = W.nextGaussian() * 0.02D;
- double d4 = 10D;
+ for (int i = 0; i < 20; ++i) {
+ double d0 = this.random.nextGaussian() * 0.02D;
+ double d1 = this.random.nextGaussian() * 0.02D;
+ double d2 = this.random.nextGaussian() * 0.02D;
+ double d3 = 10.0D;
- l.a("explode", (p + (double) (W.nextFloat() * I * 2.0F)) - (double) I - d1 * d4, (q + (double) (W.nextFloat() * J)) - d2 * d4, (r + (double) (W.nextFloat() * I * 2.0F)) - (double) I - d3 * d4, d1, d2, d3);
+ this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.width) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length - d2 * d3, d0, d1, d2);
}
}
public void D() {
super.D();
- aK = aL;
- aL = 0.0F;
+ this.aK = this.aL;
+ this.aL = 0.0F;
}
public void b_() {
super.b_();
- o();
- double d1 = p - m;
- double d2 = r - o;
- float f1 = MathHelper.a(d1 * d1 + d2 * d2);
- float f2 = aI;
+ this.o();
+ double d0 = this.locX - this.lastX;
+ double d1 = this.locZ - this.lastZ;
+ float f = MathHelper.a(d0 * d0 + d1 * d1);
+ float f1 = this.aI;
+ float f2 = 0.0F;
+
+ this.aK = this.aL;
float f3 = 0.0F;
- aK = aL;
- float f4 = 0.0F;
-
- if (f1 > 0.05F) {
- f4 = 1.0F;
- f3 = f1 * 3F;
- f2 = ((float) Math.atan2(d2, d1) * 180F) / 3.141593F - 90F;
+ if (f > 0.05F) {
+ f3 = 1.0F;
+ f2 = f * 3.0F;
+ f1 = (float) Math.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F;
}
- if (aY > 0.0F) {
- f2 = v;
+
+ if (this.aY > 0.0F) {
+ f1 = this.yaw;
}
- if (!A) {
- f4 = 0.0F;
+
+ if (!this.onGround) {
+ f3 = 0.0F;
}
- aL = aL + (f4 - aL) * 0.3F;
- float f5;
- for (f5 = f2 - aI; f5 < -180F; f5 += 360F) {
+ this.aL += (f3 - this.aL) * 0.3F;
+
+ float f4;
+
+ for (f4 = f1 - this.aI; f4 < -180.0F; f4 += 360.0F) {
;
}
- for (; f5 >= 180F; f5 -= 360F) {
- ;
+
+ while (f4 >= 180.0F) {
+ f4 -= 360.0F;
}
- aI += f5 * 0.3F;
- float f6;
- for (f6 = v - aI; f6 < -180F; f6 += 360F) {
+ this.aI += f4 * 0.3F;
+
+ float f5;
+
+ for (f5 = this.yaw - this.aI; f5 < -180.0F; f5 += 360.0F) {
;
}
- for (; f6 >= 180F; f6 -= 360F) {
- ;
+
+ while (f5 >= 180.0F) {
+ f5 -= 360.0F;
}
- boolean flag = f6 < -90F || f6 >= 90F;
- if (f6 < -75F) {
- f6 = -75F;
+ boolean flag = f5 < -90.0F || f5 >= 90.0F;
+
+ if (f5 < -75.0F) {
+ f5 = -75.0F;
}
- if (f6 >= 75F) {
- f6 = 75F;
+
+ if (f5 >= 75.0F) {
+ f5 = 75.0F;
}
- aI = v - f6;
- if (f6 * f6 > 2500F) {
- aI += f6 * 0.2F;
+
+ this.aI = this.yaw - f5;
+ if (f5 * f5 > 2500.0F) {
+ this.aI += f5 * 0.2F;
}
+
if (flag) {
- f3 *= -1F;
+ f2 *= -1.0F;
}
- for (; v - x < -180F; x -= 360F) {
- ;
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
}
- for (; v - x >= 180F; x += 360F) {
- ;
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
}
- for (; aI - aJ < -180F; aJ -= 360F) {
- ;
+
+ while (this.aI - this.aJ < -180.0F) {
+ this.aJ -= 360.0F;
}
- for (; aI - aJ >= 180F; aJ += 360F) {
- ;
+
+ while (this.aI - this.aJ >= 180.0F) {
+ this.aJ += 360.0F;
}
- for (; w - y < -180F; y -= 360F) {
- ;
+
+ while (this.pitch - this.lastPitch < -180.0F) {
+ this.lastPitch -= 360.0F;
}
- for (; w - y >= 180F; y += 360F) {
- ;
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
}
- aM += f3;
+
+ this.aM += f2;
}
- protected void a(float f1, float f2) {
- super.a(f1, f2);
+ protected void a(float f, float f1) {
+ super.a(f, f1);
}
- public void d(int k) {
- if (aZ <= 0) {
- return;
- }
- aZ += k;
- if (aZ > 20) {
- aZ = 20;
+ public void d(int i) {
+ if (this.health > 0) {
+ this.health += i;
+ if (this.health > 20) {
+ this.health = 20;
+ }
+
+ this.noDamageTicks = this.maxNoDamageTicks / 2;
}
- ac = aF / 2;
}
- public boolean a(Entity entity, int k) {
- if (l.z) {
- return false;
- }
- bw = 0;
- if (aZ <= 0) {
+ public boolean a(Entity entity, int i) {
+ if (this.world.isStatic) {
return false;
- }
- bm = 1.5F;
- boolean flag = true;
-
- if ((float) ac > (float) aF / 2.0F) {
- if (k <= bv) {
- return false;
- }
- e(k - bv);
- bv = k;
- flag = false;
} else {
- bv = k;
- ba = aZ;
- ac = aF;
- e(k);
- bb = bc = 10;
- }
- bd = 0.0F;
- if (flag) {
- l.a(((Entity) (this)), (byte) 2);
- y();
- if (entity != null) {
- double d1 = entity.p - p;
- double d2;
-
- for (d2 = entity.r - r; d1 * d1 + d2 * d2 < 0.0001D; d2 = (Math.random() - Math.random()) * 0.01D) {
- d1 = (Math.random() - Math.random()) * 0.01D;
+ this.bw = 0;
+ if (this.health <= 0) {
+ return false;
+ } else {
+ this.bm = 1.5F;
+ boolean flag = true;
+
+ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
+ if (i <= this.lastDamage) {
+ return false;
+ }
+
+ this.e(i - this.lastDamage);
+ this.lastDamage = i;
+ flag = false;
+ } else {
+ this.lastDamage = i;
+ this.ba = this.health;
+ this.noDamageTicks = this.maxNoDamageTicks;
+ this.e(i);
+ this.hurtTicks = this.bc = 10;
}
- bd = (float) ((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - v;
- a(entity, k, d1, d2);
- } else {
- bd = (int) (Math.random() * 2D) * 180;
- }
- }
- if (aZ <= 0) {
- if (flag) {
- l.a(((Entity) (this)), g(), i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
+ this.bd = 0.0F;
+ if (flag) {
+ this.world.a(this, (byte) 2);
+ this.y();
+ if (entity != null) {
+ double d0 = entity.locX - this.locX;
+
+ double d1;
+
+ for (d1 = entity.locZ - this.locZ; d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
+ d0 = (Math.random() - Math.random()) * 0.01D;
+ }
+
+ this.bd = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw;
+ this.a(entity, i, d0, d1);
+ } else {
+ this.bd = (float) ((int) (Math.random() * 2.0D) * 180);
+ }
+ }
+
+ if (this.health <= 0) {
+ if (flag) {
+ this.world.a(this, this.g(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ }
+
+ this.f(entity);
+ } else if (flag) {
+ this.world.a(this, this.f(), this.i(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ }
+
+ return true;
}
- f(entity);
- } else if (flag) {
- l.a(((Entity) (this)), f(), i(), (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
}
- return true;
}
- protected void e(int k) {
- aZ -= k;
+ protected void e(int i) {
+ this.health -= i;
}
protected float i() {
@@ -398,40 +412,42 @@ public abstract class EntityLiving extends Entity {
return "random.hurt";
}
- public void a(Entity entity, int k, double d1, double d2) {
- float f1 = MathHelper.a(d1 * d1 + d2 * d2);
- float f2 = 0.4F;
+ public void a(Entity entity, int i, double d0, double d1) {
+ float f = MathHelper.a(d0 * d0 + d1 * d1);
+ float f1 = 0.4F;
- s /= 2D;
- t /= 2D;
- u /= 2D;
- s -= (d1 / (double) f1) * (double) f2;
- t += 0.40000000596046448D;
- u -= (d2 / (double) f1) * (double) f2;
- if (t > 0.40000000596046448D) {
- t = 0.40000000596046448D;
+ this.motX /= 2.0D;
+ this.motY /= 2.0D;
+ this.motZ /= 2.0D;
+ this.motX -= d0 / (double) f * (double) f1;
+ this.motY += 0.4000000059604645D;
+ this.motZ -= d1 / (double) f * (double) f1;
+ if (this.motY > 0.4000000059604645D) {
+ this.motY = 0.4000000059604645D;
}
}
public void f(Entity entity) {
- if (aU > 0 && entity != null) {
- entity.b(((Entity) (this)), aU);
+ if (this.aU > 0 && entity != null) {
+ entity.b(this, this.aU);
}
- bi = true;
- if (!l.z) {
- g_();
+
+ this.bi = true;
+ if (!this.world.isStatic) {
+ this.g_();
}
- l.a(((Entity) (this)), (byte) 3);
+
+ this.world.a(this, (byte) 3);
}
protected void g_() {
- int k = h();
+ int i = this.h();
- if (k > 0) {
- int l = W.nextInt(3);
+ if (i > 0) {
+ int j = this.random.nextInt(3);
- for (int i1 = 0; i1 < l; i1++) {
- a(k, 1);
+ for (int k = 0; k < j; ++k) {
+ this.a(i, 1);
}
}
}
@@ -440,134 +456,141 @@ public abstract class EntityLiving extends Entity {
return 0;
}
- protected void a(float f1) {
- int k = (int) Math.ceil(f1 - 3F);
+ protected void a(float f) {
+ int i = (int) Math.ceil((double) (f - 3.0F));
- if (k > 0) {
+ if (i > 0) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
org.bukkit.entity.Entity victim = this.getBukkitEntity();
DamageCause damageType = EntityDamageEvent.DamageCause.FALL;
- EntityDamageEvent evt = new EntityDamageEvent(victim, damageType, k);
- server.getPluginManager().callEvent(evt);
-
- if (!evt.isCancelled()){
- a(((Entity) (null)), k);
+ EntityDamageEvent event = new EntityDamageEvent(victim, damageType, i);
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()){
+ this.a((Entity) null, i);
}
// CraftBukkit end
-
- int l = this.l.a(MathHelper.b(p), MathHelper.b(q - 0.20000000298023224D - (double) H), MathHelper.b(r));
- if (l > 0) {
- StepSound stepsound = Block.m[l].br;
+ int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.locY - 0.20000000298023224D - (double) this.height), MathHelper.b(this.locZ));
+
+ if (j > 0) {
+ StepSound stepsound = Block.byId[j].stepSound;
- this.l.a(((Entity) (this)), stepsound.c(), stepsound.a() * 0.5F, stepsound.b() * 0.75F);
+ this.world.a(this, stepsound.c(), stepsound.a() * 0.5F, stepsound.b() * 0.75F);
}
}
}
- public void c(float f1, float f2) {
- if (v()) {
- double d1 = q;
+ public void c(float f, float f1) {
+ double d0;
- a(f1, f2, 0.02F);
- c(s, t, u);
- s *= 0.80000001192092896D;
- t *= 0.80000001192092896D;
- u *= 0.80000001192092896D;
- t -= 0.02D;
- if (B && b(s, ((t + 0.60000002384185791D) - q) + d1, u)) {
- t = 0.30000001192092896D;
+ if (this.v()) {
+ d0 = this.locY;
+ this.a(f, f1, 0.02F);
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.800000011920929D;
+ this.motY *= 0.800000011920929D;
+ this.motZ *= 0.800000011920929D;
+ this.motY -= 0.02D;
+ if (this.B && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
+ this.motY = 0.30000001192092896D;
}
- } else if (x()) {
- double d2 = q;
-
- a(f1, f2, 0.02F);
- c(s, t, u);
- s *= 0.5D;
- t *= 0.5D;
- u *= 0.5D;
- t -= 0.02D;
- if (B && b(s, ((t + 0.60000002384185791D) - q) + d2, u)) {
- t = 0.30000001192092896D;
+ } else if (this.x()) {
+ d0 = this.locY;
+ this.a(f, f1, 0.02F);
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
+ this.motY -= 0.02D;
+ if (this.B && this.b(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) {
+ this.motY = 0.30000001192092896D;
}
} else {
- float f3 = 0.91F;
+ float f2 = 0.91F;
- if (A) {
- f3 = 0.5460001F;
- int k = this.l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r));
+ if (this.onGround) {
+ f2 = 0.54600006F;
+ int i = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
- if (k > 0) {
- f3 = Block.m[k].bu * 0.91F;
+ if (i > 0) {
+ f2 = Block.byId[i].frictionFactor * 0.91F;
}
}
- float f4 = 0.1627714F / (f3 * f3 * f3);
- a(f1, f2, A ? 0.1F * f4 : 0.02F);
- f3 = 0.91F;
- if (A) {
- f3 = 0.5460001F;
- int l = this.l.a(MathHelper.b(p), MathHelper.b(z.b) - 1, MathHelper.b(r));
+ float f3 = 0.16277136F / (f2 * f2 * f2);
- if (l > 0) {
- f3 = Block.m[l].bu * 0.91F;
+ this.a(f, f1, this.onGround ? 0.1F * f3 : 0.02F);
+ f2 = 0.91F;
+ if (this.onGround) {
+ f2 = 0.54600006F;
+ int j = this.world.getTypeId(MathHelper.b(this.locX), MathHelper.b(this.boundingBox.b) - 1, MathHelper.b(this.locZ));
+
+ if (j > 0) {
+ f2 = Block.byId[j].frictionFactor * 0.91F;
}
}
- if (m()) {
- N = 0.0F;
- if (t < -0.14999999999999999D) {
- t = -0.14999999999999999D;
+
+ if (this.m()) {
+ this.fallDistance = 0.0F;
+ if (this.motY < -0.15D) {
+ this.motY = -0.15D;
}
}
- c(s, t, u);
- if (B && m()) {
- t = 0.20000000000000001D;
+
+ this.c(this.motX, this.motY, this.motZ);
+ if (this.B && this.m()) {
+ this.motY = 0.2D;
}
- t -= 0.080000000000000002D;
- t *= 0.98000001907348633D;
- s *= f3;
- u *= f3;
+
+ this.motY -= 0.08D;
+ this.motY *= 0.9800000190734863D;
+ this.motX *= (double) f2;
+ this.motZ *= (double) f2;
}
- bl = bm;
- double d3 = p - m;
- double d4 = r - o;
- float f5 = MathHelper.a(d3 * d3 + d4 * d4) * 4F;
- if (f5 > 1.0F) {
- f5 = 1.0F;
+ this.bl = this.bm;
+ d0 = this.locX - this.lastX;
+ double d1 = this.locZ - this.lastZ;
+ float f4 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F;
+
+ if (f4 > 1.0F) {
+ f4 = 1.0F;
}
- bm += (f5 - bm) * 0.4F;
- bn += bm;
+
+ this.bm += (f4 - this.bm) * 0.4F;
+ this.bn += this.bm;
}
public boolean m() {
- int k = MathHelper.b(p);
- int l = MathHelper.b(z.b);
- int i1 = MathHelper.b(r);
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.boundingBox.b);
+ int k = MathHelper.b(this.locZ);
- return this.l.a(k, l, i1) == Block.aF.bi || this.l.a(k, l + 1, i1) == Block.aF.bi;
+ return this.world.getTypeId(i, j, k) == Block.LADDER.id || this.world.getTypeId(i, j + 1, k) == Block.LADDER.id;
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Health", (short) aZ);
- nbttagcompound.a("HurtTime", (short) bb);
- nbttagcompound.a("DeathTime", (short) be);
- nbttagcompound.a("AttackTime", (short) bf);
+ nbttagcompound.a("Health", (short) this.health);
+ nbttagcompound.a("HurtTime", (short) this.hurtTicks);
+ nbttagcompound.a("DeathTime", (short) this.deathTicks);
+ nbttagcompound.a("AttackTime", (short) this.attackTicks);
}
public void b(NBTTagCompound nbttagcompound) {
- aZ = ((int) (nbttagcompound.c("Health")));
+ this.health = nbttagcompound.c("Health");
if (!nbttagcompound.a("Health")) {
- aZ = 10;
+ this.health = 10;
}
- bb = ((int) (nbttagcompound.c("HurtTime")));
- be = ((int) (nbttagcompound.c("DeathTime")));
- bf = ((int) (nbttagcompound.c("AttackTime")));
+
+ this.hurtTicks = nbttagcompound.c("HurtTime");
+ this.deathTicks = nbttagcompound.c("DeathTime");
+ this.attackTicks = nbttagcompound.c("AttackTime");
}
public boolean B() {
- return !G && aZ > 0;
+ return !this.dead && this.health > 0;
}
public boolean d_() {
@@ -575,189 +598,208 @@ public abstract class EntityLiving extends Entity {
}
public void o() {
- if (bo > 0) {
- double d1 = p + (bp - p) / (double) bo;
- double d2 = q + (bq - q) / (double) bo;
- double d3 = r + (br - r) / (double) bo;
- double d4;
+ if (this.bo > 0) {
+ double d0 = this.locX + (this.bp - this.locX) / (double) this.bo;
+ double d1 = this.locY + (this.bq - this.locY) / (double) this.bo;
+ double d2 = this.locZ + (this.br - this.locZ) / (double) this.bo;
+
+ double d3;
- for (d4 = bs - (double) v; d4 < -180D; d4 += 360D) {
+ for (d3 = this.bs - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) {
;
}
- for (; d4 >= 180D; d4 -= 360D) {
- ;
+
+ while (d3 >= 180.0D) {
+ d3 -= 360.0D;
}
- v += ((float) (d4 / (double) bo));
- w += ((float) ((bt - (double) w) / (double) bo));
- bo--;
- a(d1, d2, d3);
- b(v, w);
- }
- if (aZ <= 0) {
- bA = false;
- bx = 0.0F;
- by = 0.0F;
- bz = 0.0F;
- } else if (!aW) {
- d();
- }
- boolean flag = v();
- boolean flag1 = x();
-
- if (bA) {
+
+ this.yaw = (float) ((double) this.yaw + d3 / (double) this.bo);
+ this.pitch = (float) ((double) this.pitch + (this.bt - (double) this.pitch) / (double) this.bo);
+ --this.bo;
+ this.a(d0, d1, d2);
+ this.b(this.yaw, this.pitch);
+ }
+
+ if (this.health <= 0) {
+ this.bA = false;
+ this.bx = 0.0F;
+ this.by = 0.0F;
+ this.bz = 0.0F;
+ } else if (!this.aW) {
+ this.d();
+ }
+
+ boolean flag = this.v();
+ boolean flag1 = this.x();
+
+ if (this.bA) {
if (flag) {
- t += 0.039999999105930328D;
+ this.motY += 0.03999999910593033D;
} else if (flag1) {
- t += 0.039999999105930328D;
- } else if (A) {
- S();
+ this.motY += 0.03999999910593033D;
+ } else if (this.onGround) {
+ this.S();
}
}
- bx *= 0.98F;
- by *= 0.98F;
- bz *= 0.9F;
- c(bx, by);
- List list = l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+
+ this.bx *= 0.98F;
+ this.by *= 0.98F;
+ this.bz *= 0.9F;
+ this.c(this.bx, this.by);
+ List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if (list != null && list.size() > 0) {
- for (int k = 0; k < list.size(); k++) {
- Entity entity = (Entity) list.get(k);
+ for (int i = 0; i < list.size(); ++i) {
+ Entity entity = (Entity) list.get(i);
if (entity.z()) {
- entity.c(((Entity) (this)));
+ entity.c((Entity) this);
}
}
}
}
protected void S() {
- t = 0.41999998688697815D;
+ this.motY = 0.41999998688697815D;
}
protected void d() {
- bw++;
- EntityPlayer entityplayer = l.a(((Entity) (this)), -1D);
+ ++this.bw;
+ EntityHuman entityhuman = this.world.a(this, -1.0D);
- if (entityplayer != null) {
- double d1 = ((Entity) (entityplayer)).p - p;
- double d2 = ((Entity) (entityplayer)).q - q;
- double d3 = ((Entity) (entityplayer)).r - r;
- double d4 = d1 * d1 + d2 * d2 + d3 * d3;
+ if (entityhuman != null) {
+ double d0 = entityhuman.locX - this.locX;
+ double d1 = entityhuman.locY - this.locY;
+ double d2 = entityhuman.locZ - this.locZ;
+ double d3 = d0 * d0 + d1 * d1 + d2 * d2;
- if (d4 > 16384D) {
- q();
+ if (d3 > 16384.0D) {
+ this.q();
}
- if (bw > 600 && W.nextInt(800) == 0) {
- if (d4 < 1024D) {
- bw = 0;
+
+ if (this.bw > 600 && this.random.nextInt(800) == 0) {
+ if (d3 < 1024.0D) {
+ this.bw = 0;
} else {
- q();
+ this.q();
}
}
}
- bx = 0.0F;
- by = 0.0F;
- float f1 = 8F;
- if (W.nextFloat() < 0.02F) {
- EntityPlayer entityplayer1 = l.a(((Entity) (this)), f1);
+ this.bx = 0.0F;
+ this.by = 0.0F;
+ float f = 8.0F;
- if (entityplayer1 != null) {
- b = ((Entity) (entityplayer1));
- c = 10 + W.nextInt(20);
+ if (this.random.nextFloat() < 0.02F) {
+ entityhuman = this.world.a(this, (double) f);
+ if (entityhuman != null) {
+ this.b = entityhuman;
+ this.c = 10 + this.random.nextInt(20);
} else {
- bz = (W.nextFloat() - 0.5F) * 20F;
+ this.bz = (this.random.nextFloat() - 0.5F) * 20.0F;
}
}
- if (b != null) {
- b(b, 10F);
- if (c-- <= 0 || b.G || b.b(((Entity) (this))) > (double) (f1 * f1)) {
- b = null;
+
+ if (this.b != null) {
+ this.b(this.b, 10.0F);
+ if (this.c-- <= 0 || this.b.dead || this.b.b((Entity) this) > (double) (f * f)) {
+ this.b = null;
}
} else {
- if (W.nextFloat() < 0.05F) {
- bz = (W.nextFloat() - 0.5F) * 20F;
+ if (this.random.nextFloat() < 0.05F) {
+ this.bz = (this.random.nextFloat() - 0.5F) * 20.0F;
}
- v += bz;
- w = bB;
+
+ this.yaw += this.bz;
+ this.pitch = this.bB;
}
- boolean flag = v();
- boolean flag1 = x();
+
+ boolean flag = this.v();
+ boolean flag1 = this.x();
if (flag || flag1) {
- bA = W.nextFloat() < 0.8F;
+ this.bA = this.random.nextFloat() < 0.8F;
}
}
- public void b(Entity entity, float f1) {
- double d1 = entity.p - p;
- double d2 = entity.r - r;
- double d3;
+ public void b(Entity entity, float f) {
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
+ double d2;
if (entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) entity;
- d3 = (entityliving.q + (double) entityliving.w()) - (q + (double) w());
+ d2 = entityliving.locY + (double) entityliving.w() - (this.locY + (double) this.w());
} else {
- d3 = (entity.z.b + entity.z.e) / 2D - (q + (double) w());
+ d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.w());
}
- double d4 = MathHelper.a(d1 * d1 + d2 * d2);
- float f2 = (float) ((Math.atan2(d2, d1) * 180D) / 3.1415927410125732D) - 90F;
- float f3 = (float) ((Math.atan2(d3, d4) * 180D) / 3.1415927410125732D);
- w = -b(w, f3, f1);
- v = b(v, f2, f1);
+ double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1);
+ float f1 = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
+ float f2 = (float) (Math.atan2(d2, d3) * 180.0D / 3.1415927410125732D);
+
+ this.pitch = -this.b(this.pitch, f2, f);
+ this.yaw = this.b(this.yaw, f1, f);
}
- private float b(float f1, float f2, float f3) {
- float f4;
+ private float b(float f, float f1, float f2) {
+ float f3;
- for (f4 = f2 - f1; f4 < -180F; f4 += 360F) {
+ for (f3 = f1 - f; f3 < -180.0F; f3 += 360.0F) {
;
}
- for (; f4 >= 180F; f4 -= 360F) {
- ;
+
+ while (f3 >= 180.0F) {
+ f3 -= 360.0F;
}
- if (f4 > f3) {
- f4 = f3;
+
+ if (f3 > f2) {
+ f3 = f2;
}
- if (f4 < -f3) {
- f4 = -f3;
+
+ if (f3 < -f2) {
+ f3 = -f2;
}
- return f1 + f4;
+
+ return f + f3;
}
public void T() {}
public boolean b() {
- return l.a(z) && l.a(((Entity) (this)), z).size() == 0 && !l.b(z);
+ return this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox);
}
protected void t() {
- a(((Entity) (null)), 4);
+ this.a((Entity) null, 4);
}
public Vec3D G() {
- return c(1.0F);
+ return this.c(1.0F);
}
- public Vec3D c(float f1) {
- if (f1 == 1.0F) {
- float f2 = MathHelper.b(-v * 0.01745329F - 3.141593F);
- float f4 = MathHelper.a(-v * 0.01745329F - 3.141593F);
- float f6 = -MathHelper.b(-w * 0.01745329F);
- float f8 = MathHelper.a(-w * 0.01745329F);
+ public Vec3D c(float f) {
+ float f1;
+ float f2;
+ float f3;
+ float f4;
- return Vec3D.b(f4 * f6, f8, f2 * f6);
+ if (f == 1.0F) {
+ f1 = MathHelper.b(-this.yaw * 0.017453292F - 3.1415927F);
+ f2 = MathHelper.a(-this.yaw * 0.017453292F - 3.1415927F);
+ f3 = -MathHelper.b(-this.pitch * 0.017453292F);
+ f4 = MathHelper.a(-this.pitch * 0.017453292F);
+ return Vec3D.b((double) (f2 * f3), (double) f4, (double) (f1 * f3));
} else {
- float f3 = y + (w - y) * f1;
- float f5 = x + (v - x) * f1;
- float f7 = MathHelper.b(-f5 * 0.01745329F - 3.141593F);
- float f9 = MathHelper.a(-f5 * 0.01745329F - 3.141593F);
- float f10 = -MathHelper.b(-f3 * 0.01745329F);
- float f11 = MathHelper.a(-f3 * 0.01745329F);
-
- return Vec3D.b(f9 * f10, f11, f7 * f10);
+ f1 = this.lastPitch + (this.pitch - this.lastPitch) * f;
+ f2 = this.lastYaw + (this.yaw - this.lastYaw) * f;
+ f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
+ f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
+ float f5 = -MathHelper.b(-f1 * 0.017453292F);
+ float f6 = MathHelper.a(-f1 * 0.017453292F);
+
+ return Vec3D.b((double) (f4 * f5), (double) f6, (double) (f3 * f5));
}
}
diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java
index d28adc0f..c328fd8c 100644
--- a/src/main/java/net/minecraft/server/EntityMinecart.java
+++ b/src/main/java/net/minecraft/server/EntityMinecart.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.Location;
@@ -17,9 +16,9 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.vehicle.*;
// CraftBukkit end
-public class EntityMinecart extends Entity implements IInventory, CraftMappable { // CraftBukkit
+public class EntityMinecart extends Entity implements IInventory {
- private ItemStack al[];
+ private ItemStack[] al;
public int a;
public int b;
public int c;
@@ -28,69 +27,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public int e;
public double f;
public double ak;
- private static final int an[][][] = {
- {
- {
- 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[][][] an = 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 ao;
private double ap;
private double aq;
@@ -99,10 +36,8 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
private double at;
// CraftBukkit start
- protected org.bukkit.entity.Entity bukkitPoweredMinecart; //CraftBukkit
- protected org.bukkit.entity.Entity bukkitStorageMinecart; //CraftBukkit
- /**@deprecated*/
- private CraftMinecart minecart;
+ protected org.bukkit.entity.Entity bukkitPoweredMinecart;
+ protected org.bukkit.entity.Entity bukkitStorageMinecart;
private boolean slowWhenEmpty = true;
private double derailedX = 0.5;
@@ -111,30 +46,46 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
private double flyingX = 0.94999998807907104;
private double flyingY = 0.94999998807907104;
private double flyingZ = 0.94999998807907104;
- /**@deprecated*/
- public CraftEntity getCraftEntity() {
- return minecart;
- }
public ItemStack[] getContents() {
return this.al;
}
+
+ private void handleCreation(World world) {
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.VEHICLE_CREATE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
+ server.getPluginManager().callEvent(event);
+ }
+
+ @Override
+ public org.bukkit.entity.Entity getBukkitEntity(){
+ if (this.d == CraftMinecart.Type.StorageMinecart.getId()) {
+ return this.bukkitStorageMinecart;
+ } else if (this.d == CraftMinecart.Type.PoweredMinecart.getId()) {
+ return this.bukkitPoweredMinecart;
+ } else {
+ return this.bukkitEntity;
+ }
+ }
// CraftBukkit end
public EntityMinecart(World world) {
super(world);
- al = new ItemStack[36];
- a = 0;
- b = 0;
- c = 1;
- am = false;
- i = true;
- a(0.98F, 0.7F);
- H = J / 2.0F;
- M = false;
+ this.al = new ItemStack[36];
+ this.a = 0;
+ this.b = 0;
+ this.c = 1;
+ this.am = false;
+ this.i = true;
+ this.a(0.98F, 0.7F);
+ this.height = this.width / 2.0F;
+ this.M = false;
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftMinecart(server, this);
this.bukkitPoweredMinecart = new CraftPoweredMinecart(server, this);
this.bukkitStorageMinecart = new CraftStorageMinecart(server, this);
@@ -145,7 +96,7 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
protected void a() {}
public AxisAlignedBB d(Entity entity) {
- return entity.z;
+ return entity.boundingBox;
}
public AxisAlignedBB u() {
@@ -156,102 +107,90 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
return true;
}
- public EntityMinecart(World world, double d1, double d2, double d3, int i) {
+ public EntityMinecart(World world, double d0, double d1, double d2, int i) {
this(world);
- a(d1, d2 + (double) H, d3);
- s = 0.0D;
- t = 0.0D;
- u = 0.0D;
- m = d1;
- n = d2;
- o = d3;
- d = i;
- }
-
- // CraftBukkit start
- private void handleCreation(World world) {
- CraftServer server = ((WorldServer) world).getServer();
- Type eventType = Type.VEHICLE_CREATE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
-
- VehicleCreateEvent event = new VehicleCreateEvent(eventType, vehicle);
- server.getPluginManager().callEvent(event);
+ this.a(d0, d1 + (double) this.height, d2);
+ this.motX = 0.0D;
+ this.motY = 0.0D;
+ this.motZ = 0.0D;
+ this.lastX = d0;
+ this.lastY = d1;
+ this.lastZ = d2;
+ this.d = i;
}
- // CraftBukkit end
public double k() {
- return (double) J * 0.0D - 0.30000001192092896D;
+ return (double) this.width * 0.0D - 0.30000001192092896D;
}
public boolean a(Entity entity, int i) {
- // CraftBukkit start
- Type eventType = Type.VEHICLE_DAMAGE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity passenger = (entity == null)?null:entity.getBukkitEntity();
- int damage = i;
-
- VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, passenger, damage);
- ((WorldServer)l).getServer().getPluginManager().callEvent(event);
+ if (!this.world.isStatic && !this.dead) {
+ // CraftBukkit start
+ Type eventType = Type.VEHICLE_DAMAGE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity passenger = (entity == null) ? null : entity.getBukkitEntity();
+ int damage = i;
- if (event.isCancelled()) {
- return true;
- }
- i = event.getDamage();
- // CraftBukkit end
+ VehicleDamageEvent event = new VehicleDamageEvent(eventType, vehicle, passenger, damage);
+ ((WorldServer)this.world).getServer().getPluginManager().callEvent(event);
- if (l.z || G) {
- return true;
- }
- c = -c;
- b = 10;
- y();
- a += i * 10;
- if (a > 40) {
- a(Item.ax.ba, 1, 0.0F);
- if (d == 1) {
- a(Block.au.bi, 1, 0.0F);
- } else if (d == 2) {
- a(Block.aB.bi, 1, 0.0F);
+ if (event.isCancelled()) {
+ return true;
+ }
+ i = event.getDamage();
+ // CraftBukkit end
+
+ this.c = -this.c;
+ this.b = 10;
+ this.y();
+ this.a += i * 10;
+ if (this.a > 40) {
+ this.a(Item.MINECART.id, 1, 0.0F);
+ if (this.d == 1) {
+ this.a(Block.CHEST.id, 1, 0.0F);
+ } else if (this.d == 2) {
+ this.a(Block.FURNACE.id, 1, 0.0F);
+ }
+
+ this.q();
}
- q();
+
+ return true;
+ } else {
+ return true;
}
- return true;
}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public void q() {
- label0:
- for (int i = 0; i < h_(); i++) {
- ItemStack itemstack = a(i);
+ for (int i = 0; i < this.h_(); ++i) {
+ ItemStack itemstack = this.a(i);
- if (itemstack == null) {
- continue;
- }
- float f1 = W.nextFloat() * 0.8F + 0.1F;
- float f2 = W.nextFloat() * 0.8F + 0.1F;
- float f3 = W.nextFloat() * 0.8F + 0.1F;
+ if (itemstack != null) {
+ float f = this.random.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.random.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.random.nextFloat() * 0.8F + 0.1F;
- do {
- if (itemstack.a <= 0) {
- continue label0;
- }
- int j = W.nextInt(21) + 10;
+ while (itemstack.count > 0) {
+ int j = this.random.nextInt(21) + 10;
- if (j > itemstack.a) {
- j = itemstack.a;
- }
- itemstack.a -= j;
- EntityItem entityitem = new EntityItem(l, p + (double) f1, q + (double) f2, r + (double) f3, new ItemStack(itemstack.c, j, itemstack.h()));
- float f4 = 0.05F;
+ if (j > itemstack.count) {
+ j = itemstack.count;
+ }
+
+ 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()));
+ float f3 = 0.05F;
- entityitem.s = (float) W.nextGaussian() * f4;
- entityitem.t = (float) W.nextGaussian() * f4 + 0.2F;
- entityitem.u = (float) W.nextGaussian() * f4;
- l.a(((Entity) (entityitem)));
- } while (true);
+ entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
+ entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
+ entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
+ this.world.a((Entity) entityitem);
+ }
+ }
}
super.q();
@@ -259,478 +198,492 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public void b_() {
// CraftBukkit start
- double prevX = p;
- double prevY = q;
- double prevZ = r;
- float prevYaw = v;
- float prevPitch = w;
+ double prevX = this.locX;
+ double prevY = this.locY;
+ double prevZ = this.locZ;
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
// CraftBukkit end
- if (b > 0) {
- b--;
+
+ if (this.b > 0) {
+ --this.b;
}
- if (a > 0) {
- a--;
+
+ if (this.a > 0) {
+ --this.a;
}
- if (this.l.z && ao > 0) {
- if (ao > 0) {
- double d1 = p + (ap - p) / (double) ao;
- double d2 = q + (aq - q) / (double) ao;
- double d3 = r + (ar - r) / (double) ao;
- double d4;
-
- for (d4 = as - (double) v; d4 < -180D; d4 += 360D) {
+
+ double d0;
+
+ if (this.world.isStatic && this.ao > 0) {
+ if (this.ao > 0) {
+ double d1 = this.locX + (this.ap - this.locX) / (double) this.ao;
+ double d2 = this.locY + (this.aq - this.locY) / (double) this.ao;
+ double d3 = this.locZ + (this.ar - this.locZ) / (double) this.ao;
+
+ for (d0 = this.as - (double) this.yaw; d0 < -180.0D; d0 += 360.0D) {
;
}
- for (; d4 >= 180D; d4 -= 360D) {
- ;
+
+ while (d0 >= 180.0D) {
+ d0 -= 360.0D;
}
- v += ((float) (d4 / (double) ao));
- w += ((float) ((at - (double) w) / (double) ao));
- ao--;
- a(d1, d2, d3);
- b(v, w);
+
+ this.yaw = (float) ((double) this.yaw + d0 / (double) this.ao);
+ this.pitch = (float) ((double) this.pitch + (this.at - (double) this.pitch) / (double) this.ao);
+ --this.ao;
+ this.a(d1, d2, d3);
+ this.b(this.yaw, this.pitch);
} else {
- a(p, q, r);
- b(v, w);
+ this.a(this.locX, this.locY, this.locZ);
+ this.b(this.yaw, this.pitch);
}
- return;
- }
- m = p;
- n = q;
- o = r;
- t -= 0.039999999105930328D;
- int i = MathHelper.b(p);
- int j = MathHelper.b(q);
- int l = MathHelper.b(r);
-
- if (this.l.a(i, j - 1, l) == Block.aG.bi) {
- j--;
- }
- double d6 = 0.40000000000000002D;
- boolean flag = false;
- double d5 = 0.0078125D;
-
- if (this.l.a(i, j, l) == Block.aG.bi) {
- Vec3D vec3d = g(p, q, r);
- int i1 = this.l.b(i, j, l);
+ } else {
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ this.motY -= 0.03999999910593033D;
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.locY);
+ int k = MathHelper.b(this.locZ);
- q = j;
- if (i1 >= 2 && i1 <= 5) {
- q = j + 1;
+ if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
+ --j;
}
- if (i1 == 2) {
- s -= d5;
- }
- if (i1 == 3) {
- s += d5;
- }
- if (i1 == 4) {
- u += d5;
- }
- if (i1 == 5) {
- u -= d5;
- }
- int ai[][] = an[i1];
- double d7 = ai[1][0] - ai[0][0];
- double d8 = ai[1][2] - ai[0][2];
- double d9 = Math.sqrt(d7 * d7 + d8 * d8);
- double d10 = s * d7 + u * d8;
-
- if (d10 < 0.0D) {
- d7 = -d7;
- d8 = -d8;
- }
- double d11 = Math.sqrt(s * s + u * u);
-
- s = (d11 * d7) / d9;
- u = (d11 * d8) / d9;
- double d14 = 0.0D;
- double d15 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
- double d16 = (double) l + 0.5D + (double) ai[0][2] * 0.5D;
- double d17 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
- double d18 = (double) l + 0.5D + (double) ai[1][2] * 0.5D;
-
- d7 = d17 - d15;
- d8 = d18 - d16;
- if (d7 == 0.0D) {
- p = (double) i + 0.5D;
- d14 = r - (double) l;
- } else if (d8 == 0.0D) {
- r = (double) l + 0.5D;
- d14 = p - (double) i;
- } else {
- double d19 = p - d15;
- double d21 = r - d16;
- double d23 = (d19 * d7 + d21 * d8) * 2D;
- d14 = d23;
- }
- p = d15 + d7 * d14;
- r = d16 + d8 * d14;
- a(p, q + (double) H, r);
- double d20 = s;
- double d22 = u;
-
- if (this.j != null) {
- d20 *= 0.75D;
- d22 *= 0.75D;
- }
- if (d20 < -d6) {
- d20 = -d6;
- }
- if (d20 > d6) {
- d20 = d6;
- }
- if (d22 < -d6) {
- d22 = -d6;
- }
- if (d22 > d6) {
- d22 = d6;
- }
- c(d20, 0.0D, d22);
- if (ai[0][1] != 0 && MathHelper.b(p) - i == ai[0][0] && MathHelper.b(r) - l == ai[0][2]) {
- a(p, q + (double) ai[0][1], r);
- } else if (ai[1][1] != 0 && MathHelper.b(p) - i == ai[1][0] && MathHelper.b(r) - l == ai[1][2]) {
- a(p, q + (double) ai[1][1], r);
- }
- if (this.j != null || !slowWhenEmpty) { // CraftBukkit
- s *= 0.99699997901916504D;
- t *= 0.0D;
- u *= 0.99699997901916504D;
- } else {
- if (d == 2) {
- double d24 = MathHelper.a(f * f + ak * ak);
-
- if (d24 > 0.01D) {
- flag = true;
- f /= d24;
- ak /= d24;
- double d25 = 0.040000000000000001D;
-
- s *= 0.80000001192092896D;
- t *= 0.0D;
- u *= 0.80000001192092896D;
- s += f * d25;
- u += ak * d25;
- } else {
- s *= 0.89999997615814209D;
- t *= 0.0D;
- u *= 0.89999997615814209D;
+ double d4 = 0.4D;
+ boolean flag = false;
+
+ d0 = 0.0078125D;
+ if (this.world.getTypeId(i, j, k) == Block.RAILS.id) {
+ Vec3D vec3d = this.g(this.locX, this.locY, this.locZ);
+ int l = this.world.getData(i, j, k);
+
+ this.locY = (double) j;
+ if (l >= 2 && l <= 5) {
+ this.locY = (double) (j + 1);
+ }
+
+ if (l == 2) {
+ this.motX -= d0;
+ }
+
+ if (l == 3) {
+ this.motX += d0;
+ }
+
+ if (l == 4) {
+ this.motZ += d0;
+ }
+
+ if (l == 5) {
+ this.motZ -= d0;
+ }
+
+ int[][] aint = an[l];
+ double d5 = (double) (aint[1][0] - aint[0][0]);
+ double d6 = (double) (aint[1][2] - aint[0][2]);
+ double d7 = Math.sqrt(d5 * d5 + d6 * d6);
+ double d8 = this.motX * d5 + this.motZ * d6;
+
+ if (d8 < 0.0D) {
+ d5 = -d5;
+ d6 = -d6;
+ }
+
+ double d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.motX = d9 * d5 / d7;
+ this.motZ = d9 * d6 / d7;
+ double d10 = 0.0D;
+ double d11 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
+ double d12 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
+ double d13 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
+ double d14 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
+
+ d5 = d13 - d11;
+ d6 = d14 - d12;
+ double d15;
+ double d16;
+ double d17;
+
+ if (d5 == 0.0D) {
+ this.locX = (double) i + 0.5D;
+ d10 = this.locZ - (double) k;
+ } else if (d6 == 0.0D) {
+ this.locZ = (double) k + 0.5D;
+ d10 = this.locX - (double) i;
+ } else {
+ d15 = this.locX - d11;
+ d17 = this.locZ - d12;
+ d16 = (d15 * d5 + d17 * d6) * 2.0D;
+ d10 = d16;
+ }
+
+ this.locX = d11 + d5 * d10;
+ this.locZ = d12 + d6 * d10;
+ this.a(this.locX, this.locY + (double) this.height, this.locZ);
+ d15 = this.motX;
+ d17 = this.motZ;
+ if (this.passenger != null) {
+ d15 *= 0.75D;
+ d17 *= 0.75D;
+ }
+
+ if (d15 < -d4) {
+ d15 = -d4;
+ }
+
+ if (d15 > d4) {
+ d15 = d4;
+ }
+
+ if (d17 < -d4) {
+ d17 = -d4;
+ }
+
+ if (d17 > d4) {
+ d17 = d4;
+ }
+
+ this.c(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]) {
+ this.a(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]) {
+ this.a(this.locX, this.locY + (double) aint[1][1], this.locZ);
+ }
+
+ if (this.passenger != null) {
+ this.motX *= 0.996999979019165D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.996999979019165D;
+ } else {
+ if (this.d == 2) {
+ d16 = (double) MathHelper.a(this.f * this.f + this.ak * this.ak);
+ if (d16 > 0.01D) {
+ flag = true;
+ this.f /= d16;
+ this.ak /= d16;
+ double d18 = 0.04D;
+
+ this.motX *= 0.800000011920929D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.800000011920929D;
+ this.motX += this.f * d18;
+ this.motZ += this.ak * d18;
+ } else {
+ this.motX *= 0.8999999761581421D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.8999999761581421D;
+ }
}
+
+ this.motX *= 0.9599999785423279D;
+ this.motY *= 0.0D;
+ this.motZ *= 0.9599999785423279D;
}
- s *= 0.95999997854232788D;
- t *= 0.0D;
- u *= 0.95999997854232788D;
- }
- Vec3D vec3d1 = g(p, q, r);
- if (vec3d1 != null && vec3d != null) {
- double d26 = (vec3d.b - vec3d1.b) * 0.050000000000000003D;
- double d12 = Math.sqrt(s * s + u * u);
+ Vec3D vec3d1 = this.g(this.locX, this.locY, this.locZ);
+
+ if (vec3d1 != null && vec3d != null) {
+ double d19 = (vec3d.b - vec3d1.b) * 0.05D;
- if (d12 > 0.0D) {
- s = (s / d12) * (d12 + d26);
- u = (u / d12) * (d12 + d26);
+ d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ if (d9 > 0.0D) {
+ this.motX = this.motX / d9 * (d9 + d19);
+ this.motZ = this.motZ / d9 * (d9 + d19);
+ }
+
+ this.a(this.locX, vec3d1.b, this.locZ);
}
- a(p, vec3d1.b, r);
- }
- int j1 = MathHelper.b(p);
- int k1 = MathHelper.b(r);
- if (j1 != i || k1 != l) {
- double d13 = Math.sqrt(s * s + u * u);
+ int i1 = MathHelper.b(this.locX);
+ int j1 = MathHelper.b(this.locZ);
- s = d13 * (double) (j1 - i);
- u = d13 * (double) (k1 - l);
- }
- if (d == 2) {
- double d27 = MathHelper.a(f * f + ak * ak);
-
- if (d27 > 0.01D && s * s + u * u > 0.001D) {
- f /= d27;
- ak /= d27;
- if (f * s + ak * u < 0.0D) {
- f = 0.0D;
- ak = 0.0D;
- } else {
- f = s;
- ak = u;
+ if (i1 != i || j1 != k) {
+ d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+ this.motX = d9 * (double) (i1 - i);
+ this.motZ = d9 * (double) (j1 - k);
+ }
+
+ if (this.d == 2) {
+ double d20 = (double) MathHelper.a(this.f * this.f + this.ak * this.ak);
+
+ if (d20 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) {
+ this.f /= d20;
+ this.ak /= d20;
+ if (this.f * this.motX + this.ak * this.motZ < 0.0D) {
+ this.f = 0.0D;
+ this.ak = 0.0D;
+ } else {
+ this.f = this.motX;
+ this.ak = this.motZ;
+ }
}
}
+ } else {
+ if (this.motX < -d4) {
+ this.motX = -d4;
+ }
+
+ if (this.motX > d4) {
+ this.motX = d4;
+ }
+
+ if (this.motZ < -d4) {
+ this.motZ = -d4;
+ }
+
+ if (this.motZ > d4) {
+ this.motZ = d4;
+ }
+
+ if (this.onGround) {
+ this.motX *= 0.5D;
+ this.motY *= 0.5D;
+ this.motZ *= 0.5D;
+ }
+
+ this.c(this.motX, this.motY, this.motZ);
+ if (!this.onGround) {
+ this.motX *= 0.949999988079071D;
+ this.motY *= 0.949999988079071D;
+ this.motZ *= 0.949999988079071D;
+ }
}
- } else {
- if (s < -d6) {
- s = -d6;
- }
- if (s > d6) {
- s = d6;
- }
- if (u < -d6) {
- u = -d6;
- }
- if (u > d6) {
- u = d6;
+
+ this.pitch = 0.0F;
+ double d21 = this.lastX - this.locX;
+ double d22 = this.lastZ - this.locZ;
+
+ if (d21 * d21 + d22 * d22 > 0.0010D) {
+ this.yaw = (float) (Math.atan2(d22, d21) * 180.0D / 3.141592653589793D);
+ if (this.am) {
+ this.yaw += 180.0F;
+ }
}
- if (A) {
- // CraftBukkit start
- s *= derailedX;
- t *= derailedY;
- u *= derailedZ;
- // CraftBukkit end
+
+ double d23;
+
+ for (d23 = (double) (this.yaw - this.lastYaw); d23 >= 180.0D; d23 -= 360.0D) {
+ ;
}
- c(s, t, u);
- if (!A) {
- // CraftBukkit start
- s *= flyingX;
- t *= flyingY;
- u *= flyingZ;
- // CraftBukkit end
+
+ while (d23 < -180.0D) {
+ d23 += 360.0D;
}
- }
- w = 0.0F;
- double d28 = m - p;
- double d29 = o - r;
-
- if (d28 * d28 + d29 * d29 > 0.001D) {
- v = (float) ((Math.atan2(d29, d28) * 180D) / 3.1415926535897931D);
- if (am) {
- v += 180F;
+
+ if (d23 < -170.0D || d23 >= 170.0D) {
+ this.yaw += 180.0F;
+ this.am = !this.am;
}
- }
- double d30;
- for (d30 = v - x; d30 >= 180D; d30 -= 360D) {
- ;
- }
- for (; d30 < -180D; d30 += 360D) {
- ;
- }
- if (d30 < -170D || d30 >= 170D) {
- v += 180F;
- am = !am;
- }
- b(v, w);
+ this.b(this.yaw, this.pitch);
- // CraftBukkit start
- CraftServer server = ((WorldServer)this.l).getServer();
- CraftWorld world = ((WorldServer)this.l).getWorld();
- Type eventType = Type.VEHICLE_MOVE;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
- Location to = new Location(world, p, q, r, v, w);
-
- VehicleMoveEvent event = new VehicleMoveEvent(eventType , vehicle , from, to);
- server.getPluginManager().callEvent(event);
- // CraftBukkit end
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ CraftWorld world = ((WorldServer) this.world).getWorld();
+ Type eventType = Type.VEHICLE_MOVE;
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ Location from = new Location(world, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(world, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
- List list = this.l.b(((Entity) (this)), z.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
+ VehicleMoveEvent event = new VehicleMoveEvent(eventType , vehicle , from, to);
+ server.getPluginManager().callEvent(event);
+ // CraftBukkit end
- if (list != null && list.size() > 0) {
- for (int l1 = 0; l1 < list.size(); l1++) {
- Entity entity = (Entity) list.get(l1);
+ List list = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D));
- if (entity != this.j && entity.z() && (entity instanceof EntityMinecart)) {
- entity.c(((Entity) (this)));
+ if (list != null && list.size() > 0) {
+ for (int k1 = 0; k1 < list.size(); ++k1) {
+ Entity entity = (Entity) list.get(k1);
+
+ if (entity != this.passenger && entity.z() && entity instanceof EntityMinecart) {
+ entity.c((Entity) this);
+ }
}
}
- }
- if (this.j != null && this.j.G) {
- this.j = null;
- }
- if (flag && W.nextInt(4) == 0) {
- e--;
- if (e < 0) {
- f = ak = 0.0D;
+
+ if (this.passenger != null && this.passenger.dead) {
+ this.passenger = null;
+ }
+
+ if (flag && this.random.nextInt(4) == 0) {
+ --this.e;
+ if (this.e < 0) {
+ this.f = this.ak = 0.0D;
+ }
+
+ this.world.a("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D);
}
- this.l.a("largesmoke", p, q + 0.80000000000000004D, r, 0.0D, 0.0D, 0.0D);
}
}
- public Vec3D g(double d1, double d2, double d3) {
- int i = MathHelper.b(d1);
- int j = MathHelper.b(d2);
- int l = MathHelper.b(d3);
+ public Vec3D g(double d0, double d1, double d2) {
+ int i = MathHelper.b(d0);
+ int j = MathHelper.b(d1);
+ int k = MathHelper.b(d2);
- if (this.l.a(i, j - 1, l) == Block.aG.bi) {
- j--;
+ if (this.world.getTypeId(i, j - 1, k) == Block.RAILS.id) {
+ --j;
}
- if (this.l.a(i, j, l) == Block.aG.bi) {
- int i1 = this.l.b(i, j, l);
- d2 = j;
- if (i1 >= 2 && i1 <= 5) {
- d2 = j + 1;
- }
- int ai[][] = an[i1];
- double d4 = 0.0D;
- double d5 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
- double d6 = (double) j + 0.5D + (double) ai[0][1] * 0.5D;
- double d7 = (double) l + 0.5D + (double) ai[0][2] * 0.5D;
- double d8 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
- double d9 = (double) j + 0.5D + (double) ai[1][1] * 0.5D;
- double d10 = (double) l + 0.5D + (double) ai[1][2] * 0.5D;
- double d11 = d8 - d5;
- double d12 = (d9 - d6) * 2D;
- double d13 = d10 - d7;
-
- if (d11 == 0.0D) {
- d1 = (double) i + 0.5D;
- d4 = d3 - (double) l;
- } else if (d13 == 0.0D) {
- d3 = (double) l + 0.5D;
- d4 = d1 - (double) i;
+ if (this.world.getTypeId(i, j, k) == Block.RAILS.id) {
+ int l = this.world.getData(i, j, k);
+
+ d1 = (double) j;
+ if (l >= 2 && l <= 5) {
+ d1 = (double) (j + 1);
+ }
+
+ int[][] aint = an[l];
+ double d3 = 0.0D;
+ 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 d6 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
+ double d7 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
+ double d8 = (double) j + 0.5D + (double) aint[1][1] * 0.5D;
+ double d9 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
+ double d10 = d7 - d4;
+ double d11 = (d8 - d5) * 2.0D;
+ double d12 = d9 - d6;
+
+ if (d10 == 0.0D) {
+ d0 = (double) i + 0.5D;
+ d3 = d2 - (double) k;
+ } else if (d12 == 0.0D) {
+ d2 = (double) k + 0.5D;
+ d3 = d0 - (double) i;
} else {
- double d14 = d1 - d5;
- double d15 = d3 - d7;
- double d16 = (d14 * d11 + d15 * d13) * 2D;
+ double d13 = d0 - d4;
+ double d14 = d2 - d6;
+ double d15 = (d13 * d10 + d14 * d12) * 2.0D;
- d4 = d16;
+ d3 = d15;
}
- d1 = d5 + d11 * d4;
- d2 = d6 + d12 * d4;
- d3 = d7 + d13 * d4;
- if (d12 < 0.0D) {
- d2++;
+
+ d0 = d4 + d10 * d3;
+ d1 = d5 + d11 * d3;
+ d2 = d6 + d12 * d3;
+ if (d11 < 0.0D) {
+ ++d1;
}
- if (d12 > 0.0D) {
- d2 += 0.5D;
+
+ if (d11 > 0.0D) {
+ d1 += 0.5D;
}
- return Vec3D.b(d1, d2, d3);
+
+ return Vec3D.b(d0, d1, d2);
} else {
return null;
}
}
protected void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Type", d);
- if (d == 2) {
- nbttagcompound.a("PushX", f);
- nbttagcompound.a("PushZ", ak);
- nbttagcompound.a("Fuel", (short) e);
- } else if (d == 1) {
+ nbttagcompound.a("Type", this.d);
+ if (this.d == 2) {
+ nbttagcompound.a("PushX", this.f);
+ nbttagcompound.a("PushZ", this.ak);
+ nbttagcompound.a("Fuel", (short) this.e);
+ } else if (this.d == 1) {
NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < al.length; i++) {
- if (al[i] != null) {
+ for (int i = 0; i < this.al.length; ++i) {
+ if (this.al[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i);
- al[i].a(nbttagcompound1);
- nbttaglist.a(((NBTBase) (nbttagcompound1)));
+ this.al[i].a(nbttagcompound1);
+ nbttaglist.a((NBTBase) nbttagcompound1);
}
}
- nbttagcompound.a("Items", ((NBTBase) (nbttaglist)));
+ nbttagcompound.a("Items", (NBTBase) nbttaglist);
}
}
protected void b(NBTTagCompound nbttagcompound) {
- d = nbttagcompound.d("Type");
- if (d == 2) {
- f = nbttagcompound.g("PushX");
- ak = nbttagcompound.g("PushZ");
- e = ((int) (nbttagcompound.c("Fuel")));
- } else if (d == 1) {
+ this.d = nbttagcompound.d("Type");
+ if (this.d == 2) {
+ this.f = nbttagcompound.g("PushX");
+ this.ak = nbttagcompound.g("PushZ");
+ this.e = nbttagcompound.c("Fuel");
+ } else if (this.d == 1) {
NBTTagList nbttaglist = nbttagcompound.k("Items");
- al = new ItemStack[h_()];
- for (int i = 0; i < nbttaglist.b(); i++) {
+ this.al = new ItemStack[this.h_()];
+
+ for (int i = 0; i < nbttaglist.b(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
- int j = nbttagcompound1.b("Slot") & 0xff;
+ int j = nbttagcompound1.b("Slot") & 255;
- if (j >= 0 && j < al.length) {
- al[j] = new ItemStack(nbttagcompound1);
+ if (j >= 0 && j < this.al.length) {
+ this.al[j] = new ItemStack(nbttagcompound1);
}
}
}
}
public void c(Entity entity) {
- if (l.z) {
- return;
- }
- if (entity == j) {
- return;
- }
-
- // CraftBukkit start
- CraftServer server = ((WorldServer)l).getServer();
- Type eventType = Type.VEHICLE_COLLISION_ENTITY;
- Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity hitEntity = (entity == null)?null:entity.getBukkitEntity();
-
- VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity);
- server.getPluginManager().callEvent(collsionEvent);
-
- if (collsionEvent.isCancelled()) {
- return;
- }
-
- if ((entity instanceof EntityLiving) && !(entity instanceof EntityPlayer) && d == 0 && s * s + u * u > 0.01D && j == null && entity.k == null) {
- if (!collsionEvent.isPickupCancelled()) {
- eventType = Type.VEHICLE_ENTER;
-
- VehicleEnterEvent enterEvent = new VehicleEnterEvent(eventType, vehicle, hitEntity);
- server.getPluginManager().callEvent(enterEvent);
-
- if (!enterEvent.isCancelled()) {
- entity.e(((Entity) (this)));
+ if (!this.world.isStatic) {
+ if (entity != this.passenger) {
+ 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) {
+ entity.e((Entity) this);
}
- }
- }
- // CraftBukkit end
- double d1 = entity.p - p;
- double d2 = entity.r - r;
- double d3 = d1 * d1 + d2 * d2;
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
+ double d2 = d0 * d0 + d1 * d1;
- // CraftBukkit
- if (d3 >= 9.9999997473787516E-005D && !collsionEvent.isCollisionCancelled()) {
- d3 = MathHelper.a(d3);
- d1 /= d3;
- d2 /= d3;
- double d4 = 1.0D / d3;
+ if (d2 >= 9.999999747378752E-5D) {
+ d2 = (double) MathHelper.a(d2);
+ d0 /= d2;
+ d1 /= d2;
+ double d3 = 1.0D / d2;
- if (d4 > 1.0D) {
- d4 = 1.0D;
- }
- d1 *= d4;
- d2 *= d4;
- d1 *= 0.10000000149011612D;
- d2 *= 0.10000000149011612D;
- d1 *= 1.0F - U;
- d2 *= 1.0F - U;
- d1 *= 0.5D;
- d2 *= 0.5D;
- if (entity instanceof EntityMinecart) {
- double d5 = entity.s + s;
- double d6 = entity.u + u;
-
- if (((EntityMinecart) entity).d == 2 && d != 2) {
- s *= 0.20000000298023224D;
- u *= 0.20000000298023224D;
- f(entity.s - d1, 0.0D, entity.u - d2);
- entity.s *= 0.69999998807907104D;
- entity.u *= 0.69999998807907104D;
- } else if (((EntityMinecart) entity).d != 2 && d == 2) {
- entity.s *= 0.20000000298023224D;
- entity.u *= 0.20000000298023224D;
- entity.f(s + d1, 0.0D, u + d2);
- s *= 0.69999998807907104D;
- u *= 0.69999998807907104D;
- } else {
- d5 /= 2D;
- d6 /= 2D;
- s *= 0.20000000298023224D;
- u *= 0.20000000298023224D;
- f(d5 - d1, 0.0D, d6 - d2);
- entity.s *= 0.20000000298023224D;
- entity.u *= 0.20000000298023224D;
- entity.f(d5 + d1, 0.0D, d6 + d2);
+ if (d3 > 1.0D) {
+ d3 = 1.0D;
+ }
+
+ d0 *= d3;
+ d1 *= d3;
+ d0 *= 0.10000000149011612D;
+ d1 *= 0.10000000149011612D;
+ d0 *= (double) (1.0F - this.U);
+ d1 *= (double) (1.0F - this.U);
+ d0 *= 0.5D;
+ d1 *= 0.5D;
+ if (entity instanceof EntityMinecart) {
+ double d4 = entity.motX + this.motX;
+ double d5 = entity.motZ + this.motZ;
+
+ if (((EntityMinecart) entity).d == 2 && this.d != 2) {
+ this.motX *= 0.20000000298023224D;
+ this.motZ *= 0.20000000298023224D;
+ this.f(entity.motX - d0, 0.0D, entity.motZ - d1);
+ entity.motX *= 0.699999988079071D;
+ entity.motZ *= 0.699999988079071D;
+ } else if (((EntityMinecart) entity).d != 2 && this.d == 2) {
+ entity.motX *= 0.20000000298023224D;
+ entity.motZ *= 0.20000000298023224D;
+ entity.f(this.motX + d0, 0.0D, this.motZ + d1);
+ this.motX *= 0.699999988079071D;
+ this.motZ *= 0.699999988079071D;
+ } else {
+ d4 /= 2.0D;
+ d5 /= 2.0D;
+ this.motX *= 0.20000000298023224D;
+ this.motZ *= 0.20000000298023224D;
+ this.f(d4 - d0, 0.0D, d5 - d1);
+ entity.motX *= 0.20000000298023224D;
+ entity.motZ *= 0.20000000298023224D;
+ entity.f(d4 + d0, 0.0D, d5 + d1);
+ }
+ } else {
+ this.f(-d0, 0.0D, -d1);
+ entity.f(d0 / 4.0D, 0.0D, d1 / 4.0D);
+ }
}
- } else {
- f(-d1, 0.0D, -d2);
- entity.f(d1 / 4D, 0.0D, d2 / 4D);
}
}
}
@@ -740,32 +693,34 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
}
public ItemStack a(int i) {
- return al[i];
+ return this.al[i];
}
public ItemStack b(int i, int j) {
- if (al[i] != null) {
- if (al[i].a <= j) {
- ItemStack itemstack = al[i];
+ if (this.al[i] != null) {
+ ItemStack itemstack;
- al[i] = null;
+ if (this.al[i].count <= j) {
+ itemstack = this.al[i];
+ this.al[i] = null;
return itemstack;
- }
- ItemStack itemstack1 = al[i].a(j);
+ } else {
+ itemstack = this.al[i].a(j);
+ if (this.al[i].count == 0) {
+ this.al[i] = null;
+ }
- if (al[i].a == 0) {
- al[i] = null;
+ return itemstack;
}
- return itemstack1;
} else {
return null;
}
}
public void a(int i, ItemStack itemstack) {
- al[i] = itemstack;
- if (itemstack != null && itemstack.a > c()) {
- itemstack.a = c();
+ this.al[i] = itemstack;
+ if (itemstack != null && itemstack.count > this.c()) {
+ itemstack.count = this.c();
}
}
@@ -779,18 +734,19 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
public void d() {}
- public boolean a(EntityPlayer entityplayer) {
- if (d == 0) {
- if (j != null && (j instanceof EntityPlayer) && j != entityplayer) {
+ public boolean a(EntityHuman entityhuman) {
+ if (this.d == 0) {
+ if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) {
return true;
}
- if (!l.z) {
+
+ if (!this.world.isStatic) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.VEHICLE_ENTER;
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
- org.bukkit.entity.Entity player = (entityplayer == null)?null:entityplayer.getBukkitEntity();
-
+ org.bukkit.entity.Entity player = (entityhuman == null) ? null : entityhuman.getBukkitEntity();
+
VehicleEnterEvent event = new VehicleEnterEvent(eventType, vehicle, player);
server.getPluginManager().callEvent(event);
@@ -799,44 +755,31 @@ public class EntityMinecart extends Entity implements IInventory, CraftMappable
}
// CraftBukkit end
- entityplayer.e(((Entity) (this)));
+ entityhuman.e(this);
}
- } else if (d == 1) {
- if (!l.z) {
- entityplayer.a(((IInventory) (this)));
+ } else if (this.d == 1) {
+ if (!this.world.isStatic) {
+ entityhuman.a((IInventory) this);
}
- } else if (d == 2) {
- ItemStack itemstack = entityplayer.an.e();
+ } else if (this.d == 2) {
+ ItemStack itemstack = entityhuman.inventory.e();
- if (itemstack != null && itemstack.c == Item.k.ba) {
- if (--itemstack.a == 0) {
- entityplayer.an.a(entityplayer.an.c, ((ItemStack) (null)));
+ if (itemstack != null && itemstack.id == Item.COAL.id) {
+ if (--itemstack.count == 0) {
+ entityhuman.inventory.a(entityhuman.inventory.c, (ItemStack) null);
}
- e += 1200;
+
+ this.e += 1200;
}
- f = p - entityplayer.p;
- ak = r - entityplayer.r;
+
+ this.f = this.locX - entityhuman.locX;
+ this.ak = this.locZ - entityhuman.locZ;
}
+
return true;
}
- public boolean a_(EntityPlayer entityplayer) {
- if (G) {
- return false;
- }
- return entityplayer.b(((Entity) (this))) <= 64D;
+ public boolean a_(EntityHuman entityhuman) {
+ return this.dead ? false : entityhuman.b((Entity) this) <= 64.0D;
}
-
- // CraftBukkit start
- @Override
- public org.bukkit.entity.Entity getBukkitEntity(){
- if (this.d == CraftMinecart.Type.StorageMinecart.getId()) {
- return this.bukkitStorageMinecart;
- } else if (this.d == CraftMinecart.Type.PoweredMinecart.getId()) {
- return this.bukkitPoweredMinecart;
- } else {
- return this.bukkitEntity;
- }
- }
- // CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntityMobs.java b/src/main/java/net/minecraft/server/EntityMobs.java
deleted file mode 100644
index e75b345c..00000000
--- a/src/main/java/net/minecraft/server/EntityMobs.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package net.minecraft.server;
-
-import java.util.Random;
-
-// CraftBukkit start
-import org.bukkit.craftbukkit.entity.CraftMonster;
-import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.entity.CraftEntity;
-
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
-import org.bukkit.event.entity.EntityTargetEvent;
-import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
-// CraftBukkit end
-
-public class EntityMobs extends EntityCreature implements IMobs {
-
- protected int c;
-
- public EntityMobs(World world) {
- super(world);
- c = 2;
- aZ = 20;
- // CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
- this.bukkitEntity = new CraftMonster(server, this);
- // CraftBukkit end
- }
-
- public void o() {
- float f = b(1.0F);
-
- if (f > 0.5F) {
- bw += 2;
- }
- super.o();
- }
-
- public void b_() {
- super.b_();
- if (l.k == 0) {
- q();
- }
- }
-
- protected Entity l() {
- EntityPlayer entityplayer = l.a(((Entity) (this)), 16D);
-
- if (entityplayer != null && i(((Entity) (entityplayer)))) {
- return ((Entity) (entityplayer));
- } else {
- return null;
- }
- }
-
- public boolean a(Entity entity, int i) {
- if (super.a(entity, i)) {
- if (j == entity || k == entity) {
- return true;
- }
- if (entity != this) {
- // CraftBukkit start
- org.bukkit.entity.Entity bukkitTarget = null;
- if(entity != null) {
- bukkitTarget = entity.getBukkitEntity();
- }
- EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
- CraftServer server = ((WorldServer) this.l).getServer();
- server.getPluginManager().callEvent(event);
- if(!event.isCancelled()) {
- if(event.getTarget() == null) {
- d = null;
- } else {
- d = ((CraftEntity) event.getTarget()).getHandle();
- }
- }
- // CraftBukkit end
- }
- return true;
- } else {
- return false;
- }
- }
-
- protected void a(Entity entity, float f) {
- if ((double) f < 2.5D && entity.z.e > z.b && entity.z.b < z.e) {
- bf = 20;
- // CraftBukkit start
- if(entity instanceof EntityLiving) {
- CraftServer server = ((WorldServer) l).getServer();
- org.bukkit.entity.Entity damager = this.getBukkitEntity();
- org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
- DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
- int damageDone = c;
-
- EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(edbee);
-
- if (!edbee.isCancelled()){
- entity.a(((Entity) (this)), edbee.getDamage());
- }
- } else {
- entity.a(((Entity) (this)), c);
- }
- // CraftBukkit end
- }
- }
-
- protected float a(int i, int j, int k) {
- return 0.5F - l.l(i, j, k);
- }
-
- public void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
- }
-
- public void b(NBTTagCompound nbttagcompound) {
- super.b(nbttagcompound);
- }
-
- public boolean b() {
- int i = MathHelper.b(p);
- int j = MathHelper.b(z.b);
- int k = MathHelper.b(r);
-
- if (l.a(EnumSkyBlock.a, i, j, k) > W.nextInt(32)) {
- return false;
- } else {
- int i1 = l.j(i, j, k);
-
- return i1 <= W.nextInt(8) && super.b();
- }
- }
-}
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java
new file mode 100644
index 00000000..ea511fca
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityMonster.java
@@ -0,0 +1,132 @@
+package net.minecraft.server;
+
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftMonster;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+// CraftBukkit end
+
+public class EntityMonster extends EntityCreature implements IMonster {
+
+ protected int c = 2;
+
+ public EntityMonster(World world) {
+ super(world);
+ this.health = 20;
+
+ // CraftBukkit start
+ CraftServer server = ((WorldServer) this.world).getServer();
+ this.bukkitEntity = new CraftMonster(server, this);
+ // CraftBukkit end
+ }
+
+ public void o() {
+ float f = this.b(1.0F);
+
+ if (f > 0.5F) {
+ this.bw += 2;
+ }
+
+ super.o();
+ }
+
+ public void b_() {
+ super.b_();
+ if (this.world.k == 0) {
+ this.q();
+ }
+ }
+
+ protected Entity l() {
+ EntityHuman entityhuman = this.world.a(this, 16.0D);
+
+ return entityhuman != null && this.i(entityhuman) ? entityhuman : null;
+ }
+
+ public boolean a(Entity entity, int i) {
+ if (super.a(entity, i)) {
+ if (this.passenger != entity && this.vehicle != entity) {
+ if (entity != this) {
+ // CraftBukkit start
+ org.bukkit.entity.Entity bukkitTarget = null;
+ if (entity != null) {
+ bukkitTarget = entity.getBukkitEntity();
+ }
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
+ CraftServer server = ((WorldServer) this.world).getServer();
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ if (event.getTarget() == null) {
+ d = null;
+ } else {
+ d = ((CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+ // CraftBukkit end
+ }
+
+ return true;
+ } else {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ protected void a(Entity entity, float f) {
+ if ((double) f < 2.5D && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
+ this.attackTicks = 20;
+ // CraftBukkit start
+ if(entity instanceof EntityLiving) {
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity damager = this.getBukkitEntity();
+ org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
+ DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
+ int damageDone = this.c;
+
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()){
+ entity.a(this, event.getDamage());
+ }
+ } else {
+ entity.a(this, this.c);
+ }
+ // CraftBukkit end
+ }
+ }
+
+ protected float a(int i, int j, int k) {
+ return 0.5F - this.world.l(i, j, k);
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ super.b(nbttagcompound);
+ }
+
+ public boolean b() {
+ int i = MathHelper.b(this.locX);
+ int j = MathHelper.b(this.boundingBox.b);
+ int k = MathHelper.b(this.locZ);
+
+ if (this.world.a(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) {
+ return false;
+ } else {
+ int l = this.world.j(i, j, k);
+
+ return l <= this.random.nextInt(8) && super.b();
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java
index cc9f9193..33a78e9c 100644
--- a/src/main/java/net/minecraft/server/EntityPainting.java
+++ b/src/main/java/net/minecraft/server/EntityPainting.java
@@ -1,6 +1,7 @@
package net.minecraft.server;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
@@ -18,158 +19,175 @@ public class EntityPainting extends Entity {
public EntityPainting(World world) {
super(world);
- f = 0;
- a = 0;
- H = 0.0F;
- a(0.5F, 0.5F);
+ this.f = 0;
+ this.a = 0;
+ this.height = 0.0F;
+ this.a(0.5F, 0.5F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPainting(server, this);
// CraftBukkit end
}
public EntityPainting(World world, int i, int j, int k, int l) {
this(world);
- b = i;
- c = j;
- d = k;
+ this.b = i;
+ this.c = j;
+ this.d = k;
ArrayList arraylist = new ArrayList();
- EnumArt aenumart[] = EnumArt.values();
+ EnumArt[] aenumart = EnumArt.values();
int i1 = aenumart.length;
- for (int j1 = 0; j1 < i1; j1++) {
+ for (int j1 = 0; j1 < i1; ++j1) {
EnumArt enumart = aenumart[j1];
- e = enumart;
- a(l);
- if (d()) {
- ((List) (arraylist)).add(((enumart)));
+ this.e = enumart;
+ this.a(l);
+ if (this.d()) {
+ arraylist.add(enumart);
}
}
- if (((List) (arraylist)).size() > 0) {
- e = (EnumArt) ((List) (arraylist)).get(W.nextInt(((List) (arraylist)).size()));
+ if (arraylist.size() > 0) {
+ this.e = (EnumArt) arraylist.get(this.random.nextInt(arraylist.size()));
}
- a(l);
+
+ this.a(l);
}
protected void a() {}
public void a(int i) {
- a = i;
- x = v = i * 90;
- float f1 = e.A;
- float f2 = e.B;
- float f3 = e.A;
-
- if (i == 0 || i == 2) {
- f3 = 0.5F;
+ this.a = i;
+ this.lastYaw = this.yaw = (float) (i * 90);
+ float f = (float) this.e.A;
+ float f1 = (float) this.e.B;
+ float f2 = (float) this.e.A;
+
+ if (i != 0 && i != 2) {
+ f = 0.5F;
} else {
- f1 = 0.5F;
+ f2 = 0.5F;
}
- f1 /= 32F;
- f2 /= 32F;
- f3 /= 32F;
- float f4 = (float) b + 0.5F;
- float f5 = (float) c + 0.5F;
- float f6 = (float) d + 0.5F;
- float f7 = 0.5625F;
+
+ f /= 32.0F;
+ f1 /= 32.0F;
+ f2 /= 32.0F;
+ float f3 = (float) this.b + 0.5F;
+ float f4 = (float) this.c + 0.5F;
+ float f5 = (float) this.d + 0.5F;
+ float f6 = 0.5625F;
if (i == 0) {
- f6 -= f7;
+ f5 -= f6;
}
+
if (i == 1) {
- f4 -= f7;
+ f3 -= f6;
}
+
if (i == 2) {
- f6 += f7;
+ f5 += f6;
}
+
if (i == 3) {
- f4 += f7;
+ f3 += f6;
}
+
if (i == 0) {
- f4 -= d(e.A);
+ f3 -= this.d(this.e.A);
}
+
if (i == 1) {
- f6 += d(e.A);
+ f5 += this.d(this.e.A);
}
+
if (i == 2) {
- f4 += d(e.A);
+ f3 += this.d(this.e.A);
}
+
if (i == 3) {
- f6 -= d(e.A);
+ f5 -= this.d(this.e.A);
}
- f5 += d(e.B);
- a((double)f4, (double)f5, (double)f6); // CraftBukkit -- forcecast all arguments to double
- float f8 = -0.00625F;
- z.c(f4 - f1 - f8, f5 - f2 - f8, f6 - f3 - f8, f4 + f1 + f8, f5 + f2 + f8, f6 + f3 + f8);
+ f4 += this.d(this.e.B);
+ this.a((double) f3, (double) f4, (double) f5);
+ float f7 = -0.00625F;
+
+ this.boundingBox.c((double) (f3 - f - f7), (double) (f4 - f1 - f7), (double) (f5 - f2 - f7), (double) (f3 + f + f7), (double) (f4 + f1 + f7), (double) (f5 + f2 + f7));
}
private float d(int i) {
- if (i == 32) {
- return 0.5F;
- }
- return i != 64 ? 0.0F : 0.5F;
+ return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F);
}
public void b_() {
- if (f++ == 100 && !l.z) {
- f = 0;
- if (!d()) {
- q();
- l.a(((Entity) (new EntityItem(l, p, q, r, new ItemStack(Item.aq)))));
+ if (this.f++ == 100 && !this.world.isStatic) {
+ this.f = 0;
+ if (!this.d()) {
+ this.q();
+ this.world.a((Entity) (new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))));
}
}
}
public boolean d() {
- if (this.l.a(((Entity) (this)), z).size() > 0) {
+ if (this.world.a((Entity) this, this.boundingBox).size() > 0) {
return false;
- }
- int i = e.A / 16;
- int j = e.B / 16;
- int k = b;
- int l = c;
- int i1 = d;
+ } else {
+ int i = this.e.A / 16;
+ int j = this.e.B / 16;
+ int k = this.b;
+ int l = this.c;
+ int i1 = this.d;
+
+ if (this.a == 0) {
+ k = MathHelper.b(this.locX - (double) ((float) this.e.A / 32.0F));
+ }
- if (a == 0) {
- k = MathHelper.b(p - (double) ((float) e.A / 32F));
- }
- if (a == 1) {
- i1 = MathHelper.b(r - (double) ((float) e.A / 32F));
- }
- if (a == 2) {
- k = MathHelper.b(p - (double) ((float) e.A / 32F));
- }
- if (a == 3) {
- i1 = MathHelper.b(r - (double) ((float) e.A / 32F));
- }
- l = MathHelper.b(q - (double) ((float) e.B / 32F));
- for (int j1 = 0; j1 < i; j1++) {
- for (int k1 = 0; k1 < j; k1++) {
- Material material;
+ if (this.a == 1) {
+ i1 = MathHelper.b(this.locZ - (double) ((float) this.e.A / 32.0F));
+ }
- if (a == 0 || a == 2) {
- material = this.l.c(k + j1, l + k1, d);
- } else {
- material = this.l.c(b, l + k1, i1 + j1);
- }
- if (!material.a()) {
- return false;
+ if (this.a == 2) {
+ k = MathHelper.b(this.locX - (double) ((float) this.e.A / 32.0F));
+ }
+
+ if (this.a == 3) {
+ i1 = MathHelper.b(this.locZ - (double) ((float) this.e.A / 32.0F));
+ }
+
+ l = MathHelper.b(this.locY - (double) ((float) this.e.B / 32.0F));
+
+ int j1;
+
+ for (int k1 = 0; k1 < i; ++k1) {
+ for (j1 = 0; j1 < j; ++j1) {
+ Material material;
+
+ if (this.a != 0 && this.a != 2) {
+ material = this.world.getMaterial(this.b, l + j1, i1 + k1);
+ } else {
+ material = this.world.getMaterial(k + k1, l + j1, this.d);
+ }
+
+ if (!material.isBuildable()) {
+ return false;
+ }
}
}
- }
- List list = this.l.b(((Entity) (this)), z);
+ List list = this.world.b((Entity) this, this.boundingBox);
- for (int l1 = 0; l1 < list.size(); l1++) {
- if (list.get(l1) instanceof EntityPainting) {
- return false;
+ for (j1 = 0; j1 < list.size(); ++j1) {
+ if (list.get(j1) instanceof EntityPainting) {
+ return false;
+ }
}
- }
- return true;
+ return true;
+ }
}
public boolean c_() {
@@ -177,42 +195,44 @@ public class EntityPainting extends Entity {
}
public boolean a(Entity entity, int i) {
- if (!G && !l.z) {
- q();
- y();
- l.a(((Entity) (new EntityItem(l, p, q, r, new ItemStack(Item.aq)))));
+ if (!this.dead && !this.world.isStatic) {
+ this.q();
+ this.y();
+ this.world.a((Entity) (new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))));
}
+
return true;
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Dir", (byte) a);
- nbttagcompound.a("Motive", e.z);
- nbttagcompound.a("TileX", b);
- nbttagcompound.a("TileY", c);
- nbttagcompound.a("TileZ", d);
+ nbttagcompound.a("Dir", (byte) this.a);
+ nbttagcompound.a("Motive", this.e.z);
+ nbttagcompound.a("TileX", this.b);
+ nbttagcompound.a("TileY", this.c);
+ nbttagcompound.a("TileZ", this.d);
}
public void b(NBTTagCompound nbttagcompound) {
- a = ((int) (nbttagcompound.b("Dir")));
- b = nbttagcompound.d("TileX");
- c = nbttagcompound.d("TileY");
- d = nbttagcompound.d("TileZ");
+ this.a = nbttagcompound.b("Dir");
+ this.b = nbttagcompound.d("TileX");
+ this.c = nbttagcompound.d("TileY");
+ this.d = nbttagcompound.d("TileZ");
String s = nbttagcompound.h("Motive");
- EnumArt aenumart[] = EnumArt.values();
+ EnumArt[] aenumart = EnumArt.values();
int i = aenumart.length;
- for (int j = 0; j < i; j++) {
+ for (int j = 0; j < i; ++j) {
EnumArt enumart = aenumart[j];
- if (enumart.z.equals(((s)))) {
- e = enumart;
+ if (enumart.z.equals(s)) {
+ this.e = enumart;
}
}
- if (e == null) {
- e = EnumArt.a;
+ if (this.e == null) {
+ this.e = EnumArt.KEBAB;
}
- a(a);
+
+ this.a(this.a);
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java
index 634beea0..5f85d83b 100644
--- a/src/main/java/net/minecraft/server/EntityPig.java
+++ b/src/main/java/net/minecraft/server/EntityPig.java
@@ -5,30 +5,31 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftPig;
// CraftBukkit end
-public class EntityPig extends EntityAnimals {
+public class EntityPig extends EntityAnimal {
public EntityPig(World world) {
super(world);
- aP = "/mob/pig.png";
- a(0.9F, 0.9F);
+ this.texture = "/mob/pig.png";
+ this.a(0.9F, 0.9F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPig(server, this);
// CraftBukkit end
}
protected void a() {
- af.a(16, ((Byte.valueOf((byte) 0))));
+ this.datawatcher.a(16, Byte.valueOf((byte) 0));
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.a("Saddle", K());
+ nbttagcompound.a("Saddle", this.K());
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- a(nbttagcompound.l("Saddle"));
+ this.a(nbttagcompound.l("Saddle"));
}
protected String e() {
@@ -43,9 +44,9 @@ public class EntityPig extends EntityAnimals {
return "mob.pigdeath";
}
- public boolean a(EntityPlayer entityplayer) {
- if (K() && !l.z && (j == null || j == entityplayer)) {
- entityplayer.e(((Entity) (this)));
+ public boolean a(EntityHuman entityhuman) {
+ if (this.K() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) {
+ entityhuman.e(this);
return true;
} else {
return false;
@@ -53,18 +54,18 @@ public class EntityPig extends EntityAnimals {
}
protected int h() {
- return Item.ao.ba;
+ return Item.PORK.id;
}
public boolean K() {
- return (af.a(16) & 1) != 0;
+ return (this.datawatcher.a(16) & 1) != 0;
}
public void a(boolean flag) {
if (flag) {
- af.b(16, ((Byte.valueOf((byte) 1))));
+ this.datawatcher.b(16, Byte.valueOf((byte) 1));
} else {
- af.b(16, ((Byte.valueOf((byte) 0))));
+ this.datawatcher.b(16, Byte.valueOf((byte) 0));
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java
index 18e768ec..39b80214 100644
--- a/src/main/java/net/minecraft/server/EntityPigZombie.java
+++ b/src/main/java/net/minecraft/server/EntityPigZombie.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
@@ -13,52 +12,48 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
public class EntityPigZombie extends EntityZombie {
- private int a;
- private int b;
- private static final ItemStack f;
+ private int a = 0;
+ private int b = 0;
+ private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1);
public EntityPigZombie(World world) {
super(world);
- a = 0;
- b = 0;
- aP = "/mob/pigzombie.png";
- bC = 0.5F;
- c = 5;
- ae = true;
+ this.texture = "/mob/pigzombie.png";
+ this.bC = 0.5F;
+ this.c = 5;
+ this.ae = true;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftPigZombie(server, this);
// CraftBukkit end
}
public void b_() {
- bC = d == null ? 0.5F : 0.95F;
- if (b > 0 && --b == 0) {
- l.a(((Entity) (this)), "mob.zombiepig.zpigangry", i() * 2.0F, ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) * 1.8F);
+ this.bC = this.d != null ? 0.95F : 0.5F;
+ if (this.b > 0 && --this.b == 0) {
+ this.world.a(this, "mob.zombiepig.zpigangry", this.i() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F);
}
+
super.b_();
}
public boolean b() {
- return l.k > 0 && l.a(z) && l.a(((Entity) (this)), z).size() == 0 && !l.b(z);
+ return this.world.k > 0 && this.world.a(this.boundingBox) && this.world.a((Entity) this, this.boundingBox).size() == 0 && !this.world.b(this.boundingBox);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.a("Anger", (short) a);
+ nbttagcompound.a("Anger", (short) this.a);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- a = ((int) (nbttagcompound.c("Anger")));
+ this.a = nbttagcompound.c("Anger");
}
protected Entity l() {
- if (a == 0) {
- return null;
- } else {
- return super.l();
- }
+ return this.a == 0 ? null : super.l();
}
public void o() {
@@ -66,10 +61,10 @@ public class EntityPigZombie extends EntityZombie {
}
public boolean a(Entity entity, int i) {
- if (entity instanceof EntityPlayer) {
- List list = l.b(((Entity) (this)), z.b(32D, 32D, 32D));
+ if (entity instanceof EntityHuman) {
+ List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D));
- for (int j = 0; j < list.size(); j++) {
+ for (int j = 0; j < list.size(); ++j) {
Entity entity1 = (Entity) list.get(j);
if (entity1 instanceof EntityPigZombie) {
@@ -79,27 +74,28 @@ public class EntityPigZombie extends EntityZombie {
}
}
- g(entity);
+ this.g(entity);
}
+
return super.a(entity, i);
}
private void g(Entity entity) {
// CraftBukkit start
org.bukkit.entity.Entity bukkitTarget = null;
- if(entity != null) {
+ if (entity != null) {
bukkitTarget = entity.getBukkitEntity();
}
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event);
- if(!event.isCancelled()) {
- if(event.getTarget() == null) {
- d = null;
+ if (!event.isCancelled()) {
+ if (event.getTarget() == null) {
+ this.d = null;
} else {
- d = ((CraftEntity) event.getTarget()).getHandle();
- a = 400 + W.nextInt(400);
- b = W.nextInt(40);
+ this.d = ((CraftEntity) event.getTarget()).getHandle();
+ this.a = 400 + this.random.nextInt(400);
+ this.b = this.random.nextInt(40);
}
}
// CraftBukkit end
@@ -118,10 +114,6 @@ public class EntityPigZombie extends EntityZombie {
}
protected int h() {
- return Item.ap.ba;
- }
-
- static {
- f = new ItemStack(Item.E, 1);
+ return Item.GRILLED_PORK.id;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 4cc6e137..cb259c9a 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -1,383 +1,288 @@
package net.minecraft.server;
+import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
-import java.util.Random;
+import java.util.Set;
// CraftBukkit start
-import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
// CraftBukkit end
-public abstract class EntityPlayer extends EntityLiving {
-
- public InventoryPlayer an;
- public CraftingInventoryCB ao;
- public CraftingInventoryCB ap;
- public byte aq;
- public int ar;
- public float as;
- public float at;
- public boolean au;
- public int av;
- public String aw;
- public int ax;
- public double ay;
- public double az;
- public double aA;
- public double aB;
- public double aC;
- public double aD;
- private int a;
- public EntityFish aE;
-
- public EntityPlayer(World world) {
+public class EntityPlayer extends EntityHuman implements ICrafting {
+
+ public NetServerHandler a;
+ public MinecraftServer b;
+ public ItemInWorldManager c;
+ public double d;
+ public double e;
+ public List f = new LinkedList();
+ public Set ak = new HashSet();
+ public double al;
+ private int bD = -99999999;
+ private int bE = 60;
+ private ItemStack[] bF = new ItemStack[] { null, null, null, null, null};
+ private int bG = 0;
+ public boolean am;
+
+ public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
super(world);
- an = new InventoryPlayer(this);
- aq = 0;
- ar = 0;
- au = false;
- av = 0;
- a = 0;
- aE = null;
- ao = ((CraftingInventoryCB) (new CraftingInventoryPlayerCB(an, !world.z)));
- ap = ao;
- H = 1.62F;
- c((double) world.m + 0.5D, world.n + 1, (double) world.o + 0.5D, 0.0F, 0.0F);
- aZ = 20;
- aS = "humanoid";
- aR = 180F;
- Y = 20;
- aP = "/mob/char.png";
+ int i = world.spawnX;
+ int j = world.spawnZ;
+ int k = world.spawnY;
+
+ if (!world.q.e) {
+ i += this.random.nextInt(20) - 10;
+ k = world.e(i, j);
+ j += this.random.nextInt(20) - 10;
+ }
+
+ this.c((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F);
+ this.b = minecraftserver;
+ this.S = 0.0F;
+ iteminworldmanager.a = this;
+ this.name = s;
+ this.c = iteminworldmanager;
+ this.height = 0.0F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
- this.bukkitEntity = new CraftHumanEntity(server, this);
+ CraftServer server = ((WorldServer) this.world).getServer();
+ this.bukkitEntity = new CraftPlayer(server, this);
// CraftBukkit end
}
- public void b_() {
- super.b_();
- if (!l.z && ap != null && !ap.b(this)) {
- L();
- ap = ao;
- }
- ay = aB;
- az = aC;
- aA = aD;
- double d1 = p - aB;
- double d2 = q - aC;
- double d3 = r - aD;
- double d4 = 10D;
-
- if (d1 > d4) {
- ay = aB = p;
- }
- if (d3 > d4) {
- aA = aD = r;
- }
- if (d2 > d4) {
- az = aC = q;
- }
- if (d1 < -d4) {
- ay = aB = p;
- }
- if (d3 < -d4) {
- aA = aD = r;
- }
- if (d2 < -d4) {
- az = aC = q;
- }
- aB += d1 * 0.25D;
- aD += d3 * 0.25D;
- aC += d2 * 0.25D;
+ public void l() {
+ this.activeContainer.a((ICrafting) this);
}
- protected void L() {
- ap = ao;
+ public ItemStack[] I() {
+ return this.bF;
}
- public void D() {
- super.D();
- as = at;
- at = 0.0F;
- }
+ public void b_() {
+ --this.bE;
+ this.activeContainer.a();
+
+ for (int i = 0; i < 5; ++i) {
+ ItemStack itemstack = this.a(i);
- protected void d() {
- if (au) {
- av++;
- if (av == 8) {
- av = 0;
- au = false;
+ if (itemstack != this.bF[i]) {
+ this.b.k.a(this, new Packet5EntityEquipment(this.id, i, itemstack));
+ this.bF[i] = itemstack;
}
- } else {
- av = 0;
}
- aY = (float) av / 8F;
}
- public void o() {
- if (l.k == 0 && aZ < 20 && (X % 20) * 12 == 0) {
- d(1);
- }
- an.f();
- as = at;
- super.o();
- float f1 = MathHelper.a(s * s + u * u);
- float f2 = (float) Math.atan(-t * 0.20000000298023224D) * 15F;
+ public ItemStack a(int i) {
+ return i == 0 ? this.inventory.e() : this.inventory.b[i - 1];
+ }
- if (f1 > 0.1F) {
- f1 = 0.1F;
- }
- if (!A || aZ <= 0) {
- f1 = 0.0F;
- }
- if (A || aZ <= 0) {
- f2 = 0.0F;
- }
- at += (f1 - at) * 0.4F;
- bh += (f2 - bh) * 0.8F;
- if (aZ > 0) {
- List list = l.b(((Entity) (this)), z.b(1.0D, 0.0D, 1.0D));
+ public void f(Entity entity) {
+ this.inventory.h();
+ }
+
+ public boolean a(Entity entity, int i) {
+ if (this.bE > 0) {
+ return false;
+ } else {
+ if (!this.b.n) {
+ if (entity instanceof EntityHuman) {
+ return false;
+ }
- if (list != null) {
- for (int i = 0; i < list.size(); i++) {
- Entity entity = (Entity) list.get(i);
+ if (entity instanceof EntityArrow) {
+ EntityArrow entityarrow = (EntityArrow) entity;
- if (!entity.G) {
- j(entity);
+ if (entityarrow.b instanceof EntityHuman) {
+ return false;
}
}
}
+
+ return super.a(entity, i);
}
}
- private void j(Entity entity) {
- entity.b(this);
+ public void d(int i) {
+ super.d(i);
}
- public void f(Entity entity) {
- super.f(entity);
- a(0.2F, 0.2F);
- a(p, q, r);
- t = 0.10000000149011612D;
- if (aw.equals("Notch")) {
- a(new ItemStack(Item.h, 1), true);
- }
- an.h();
- if (entity != null) {
- s = -MathHelper.b(((bd + v) * 3.141593F) / 180F) * 0.1F;
- u = -MathHelper.a(((bd + v) * 3.141593F) / 180F) * 0.1F;
- } else {
- s = u = 0.0D;
+ public void n() {
+ super.b_();
+ ChunkCoordIntPair chunkcoordintpair = null;
+ double d0 = 0.0D;
+
+ for (int i = 0; i < this.f.size(); ++i) {
+ ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) this.f.get(i);
+ double d1 = chunkcoordintpair1.a(this);
+
+ if (i == 0 || d1 < d0) {
+ chunkcoordintpair = chunkcoordintpair1;
+ d0 = chunkcoordintpair1.a(this);
+ }
}
- H = 0.1F;
- }
- public void b(Entity entity, int i) {
- ar += i;
- }
+ if (chunkcoordintpair != null) {
+ boolean flag = false;
- public void O() {
- a(an.b(an.c, 1), false);
- }
+ if (d0 < 1024.0D) {
+ flag = true;
+ }
- public void b(ItemStack itemstack) {
- a(itemstack, false);
- }
+ if (this.a.b() < 2) {
+ flag = true;
+ }
- public void a(ItemStack itemstack, boolean flag) {
- if (itemstack == null) {
- return;
+ if (flag) {
+ this.f.remove(chunkcoordintpair);
+ this.a.b((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, this.b.e)));
+ List list = this.b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
+
+ for (int j = 0; j < list.size(); ++j) {
+ this.a((TileEntity) list.get(j));
+ }
+ }
}
- EntityItem entityitem = new EntityItem(l, p, (q - 0.30000001192092896D) + (double) w(), r, itemstack);
- entityitem.c = 40;
- float f1 = 0.1F;
+ if (this.health != this.bD) {
+ this.a.b((Packet) (new Packet8UpdateHealth(this.health)));
+ this.bD = this.health;
+ }
+ }
- if (flag) {
- float f3 = W.nextFloat() * 0.5F;
- float f5 = W.nextFloat() * 3.141593F * 2.0F;
+ private void a(TileEntity tileentity) {
+ if (tileentity != null) {
+ Packet packet = tileentity.g();
- entityitem.s = -MathHelper.a(f5) * f3;
- entityitem.u = MathHelper.b(f5) * f3;
- entityitem.t = 0.20000000298023224D;
- } else {
- float f2 = 0.3F;
-
- entityitem.s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
- entityitem.u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f2;
- entityitem.t = -MathHelper.a((w / 180F) * 3.141593F) * f2 + 0.1F;
- f2 = 0.02F;
- float f4 = W.nextFloat() * 3.141593F * 2.0F;
-
- f2 *= W.nextFloat();
- entityitem.s += Math.cos(f4) * (double) f2;
- entityitem.t += (W.nextFloat() - W.nextFloat()) * 0.1F;
- entityitem.u += Math.sin(f4) * (double) f2;
+ if (packet != null) {
+ this.a.b(packet);
+ }
}
- a(entityitem);
}
- protected void a(EntityItem entityitem) {
- l.a(((Entity) (entityitem)));
+ public void o() {
+ this.motX = this.motY = this.motZ = 0.0D;
+ this.bA = false;
+ super.o();
}
- public float a(Block block) {
- float f1 = an.a(block);
+ public void c(Entity entity, int i) {
+ if (!entity.dead) {
+ if (entity instanceof EntityItem) {
+ this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
+ }
- if (a(Material.f)) {
- f1 /= 5F;
- }
- if (!A) {
- f1 /= 5F;
+ if (entity instanceof EntityArrow) {
+ this.b.k.a(entity, new Packet22Collect(entity.id, this.id));
+ }
}
- return f1;
- }
- public boolean b(Block block) {
- return an.b(block);
+ super.c(entity, i);
+ this.activeContainer.a();
}
- public void b(NBTTagCompound nbttagcompound) {
- super.b(nbttagcompound);
- NBTTagList nbttaglist = nbttagcompound.k("Inventory");
+ public void K() {
+ if (!this.au) {
+ this.av = -1;
+ this.au = true;
+ this.b.k.a(this, new Packet18ArmAnimation(this, 1));
+ }
+ }
- an.b(nbttaglist);
- ax = nbttagcompound.d("Dimension");
+ public float w() {
+ return 1.62F;
}
- public void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
- nbttagcompound.a("Inventory", ((NBTBase) (an.a(new NBTTagList()))));
- nbttagcompound.a("Dimension", ax);
+ public void e(Entity entity) {
+ // CraftBukkit start
+ setPassengerOf(entity);
}
- public void a(IInventory iinventory) {}
+ public void setPassengerOf(Entity entity) {
+ // e(null) doesn't really fly for overloaded methods,
+ // so this method is needed
- public void a(int i, int k, int l) {}
+ super.setPassengerOf(entity);
+ // CraftBukkit end
+ this.a.b((Packet) (new Packet39AttachEntity(this, this.vehicle)));
+ this.a.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ }
- public void c(Entity entity, int i) {}
+ protected void a(double d0, boolean flag) {}
- public float w() {
- return 0.12F;
+ public void b(double d0, boolean flag) {
+ super.a(d0, flag);
}
- public boolean a(Entity entity, int i) {
- bw = 0;
- if (aZ <= 0) {
- return false;
- }
- if ((entity instanceof EntityMobs) || (entity instanceof EntityArrow)) {
- if (l.k == 0) {
- i = 0;
- }
- if (l.k == 1) {
- i = i / 3 + 1;
- }
- if (l.k == 3) {
- i = (i * 3) / 2;
- }
- }
- if (i == 0) {
- return false;
- } else {
- return super.a(entity, i);
- }
+ private void U() {
+ this.bG = this.bG % 100 + 1;
}
- protected void e(int i) {
- int k = 25 - an.g();
- int l = i * k + a;
-
- an.c(i);
- i = l / 25;
- a = l % 25;
- super.e(i);
+ public void a(int i, int j, int k) {
+ this.U();
+ this.a.b((Packet) (new Packet100OpenWindow(this.bG, 1, "Crafting", 9)));
+ this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k);
+ this.activeContainer.f = this.bG;
+ this.activeContainer.a((ICrafting) this);
}
- public void a(TileEntityFurnace tileentityfurnace) {}
-
- public void a(TileEntityDispenser tileentitydispenser) {}
+ public void a(IInventory iinventory) {
+ this.U();
+ this.a.b((Packet) (new Packet100OpenWindow(this.bG, 0, iinventory.b(), iinventory.h_())));
+ this.activeContainer = new ContainerChest(this.inventory, iinventory);
+ this.activeContainer.f = this.bG;
+ this.activeContainer.a((ICrafting) this);
+ }
- public void a(TileEntitySign tileentitysign) {}
+ public void a(TileEntityFurnace tileentityfurnace) {
+ this.U();
+ this.a.b((Packet) (new Packet100OpenWindow(this.bG, 2, tileentityfurnace.b(), tileentityfurnace.h_())));
+ this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace);
+ this.activeContainer.f = this.bG;
+ this.activeContainer.a((ICrafting) this);
+ }
- public void g(Entity entity) {
- if (entity.a(this)) {
- return;
- }
- ItemStack itemstack = P();
+ public void a(TileEntityDispenser tileentitydispenser) {
+ this.U();
+ this.a.b((Packet) (new Packet100OpenWindow(this.bG, 3, tileentitydispenser.b(), tileentitydispenser.h_())));
+ this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser);
+ this.activeContainer.f = this.bG;
+ this.activeContainer.a((ICrafting) this);
+ }
- if (itemstack != null && (entity instanceof EntityLiving)) {
- itemstack.b((EntityLiving) entity);
- if (itemstack.a <= 0) {
- itemstack.a(this);
- Q();
+ public void a(Container container, int i, ItemStack itemstack) {
+ if (!(container.a(i) instanceof SlotResult)) {
+ if (!this.am) {
+ this.a.b((Packet) (new Packet103SetSlot(container.f, i, itemstack)));
}
}
}
- public ItemStack P() {
- return an.e();
+ public void a(Container container, List list) {
+ this.a.b((Packet) (new Packet104WindowItems(container.f, list)));
+ this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
}
- public void Q() {
- an.a(an.c, ((ItemStack) (null)));
+ public void a(Container container, int i, int j) {
+ this.a.b((Packet) (new Packet105CraftProgressBar(container.f, i, j)));
}
- public double F() {
- return (double) (H - 0.5F);
- }
+ public void a(ItemStack itemstack) {}
- public void K() {
- av = -1;
- au = true;
+ public void L() {
+ this.a.b((Packet) (new Packet101CloseWindow(this.activeContainer.f)));
+ this.N();
}
- public void h(Entity entity) {
- int i = an.a(entity);
-
- if (i > 0) {
- // CraftBukkit start
- if(entity instanceof EntityLiving) {
- CraftServer server = ((WorldServer) l).getServer();
- org.bukkit.entity.Entity damager = this.getBukkitEntity();
- org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
- DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
- int damageDone = i;
-
- EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(edbee);
-
- if (!edbee.isCancelled()){
- entity.a(((Entity) this), edbee.getDamage());
- } else {
- return;
- }
- } else {
- entity.a(((Entity) (this)), i);
- }
- // CraftBukkit end
- ItemStack itemstack = P();
-
- if (itemstack != null && (entity instanceof EntityLiving)) {
- itemstack.a((EntityLiving) entity);
- if (itemstack.a <= 0) {
- itemstack.a(this);
- Q();
- }
- }
+ public void M() {
+ if (!this.am) {
+ this.a.b((Packet) (new Packet103SetSlot(-1, -1, this.inventory.i())));
}
}
- public void a(ItemStack itemstack) {}
-
- public void q() {
- super.q();
- ao.a(this);
- if (ap != null) {
- ap.a(this);
- }
+ public void N() {
+ this.activeContainer.a((EntityHuman) this);
+ this.activeContainer = this.defaultContainer;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayerMP.java b/src/main/java/net/minecraft/server/EntityPlayerMP.java
deleted file mode 100644
index 41390b9c..00000000
--- a/src/main/java/net/minecraft/server/EntityPlayerMP.java
+++ /dev/null
@@ -1,292 +0,0 @@
-package net.minecraft.server;
-
-import java.util.*;
-
-// CraftBukkit start
-import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
-// CraftBukkit end
-
-public class EntityPlayerMP extends EntityPlayer implements ICrafting {
-
- public NetServerHandler a;
- public MinecraftServer b;
- public ItemInWorldManager c;
- public double d;
- public double e;
- public List f;
- public Set ak;
- public double al;
- private int bD;
- private int bE;
- private ItemStack bF[] = {
- null, null, null, null, null
- };
- private int bG;
- public boolean am;
-
- public EntityPlayerMP(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) {
- super(world);
- f = ((List) (new LinkedList()));
- ak = ((Set) (new HashSet()));
- bD = 0xfa0a1f01;
- bE = 60;
- bG = 0;
- int i = world.m;
- int j = world.o;
- int k = world.n;
-
- if (!world.q.e) {
- i += W.nextInt(20) - 10;
- k = world.e(i, j);
- j += W.nextInt(20) - 10;
- }
- c((double) i + 0.5D, k, (double) j + 0.5D, 0.0F, 0.0F);
- b = minecraftserver;
- S = 0.0F;
- iteminworldmanager.a = ((EntityPlayer) (this));
- aw = s;
- c = iteminworldmanager;
- H = 0.0F;
- // CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
- this.bukkitEntity = new CraftPlayer(server, this);
- // CraftBukkit end
- }
-
- public void l() {
- ap.a(((ICrafting) (this)));
- }
-
- public ItemStack[] I() {
- return bF;
- }
-
- public void b_() {
- bE--;
- ap.a();
- for (int i = 0; i < 5; i++) {
- ItemStack itemstack = a(i);
-
- if (itemstack != bF[i]) {
- b.k.a(((Entity) (this)), ((Packet) (new Packet5PlayerInventory(g, i, itemstack))));
- bF[i] = itemstack;
- }
- }
- }
-
- public ItemStack a(int i) {
- if (i == 0) {
- return an.e();
- } else {
- return an.b[i - 1];
- }
- }
-
- public void f(Entity entity) {
- an.h();
- }
-
- public boolean a(Entity entity, int i) {
- if (bE > 0) {
- return false;
- }
- if (!b.n) {
- if (entity instanceof EntityPlayer) {
- return false;
- }
- if (entity instanceof EntityArrow) {
- EntityArrow entityarrow = (EntityArrow) entity;
-
- if (entityarrow.b instanceof EntityPlayer) {
- return false;
- }
- }
- }
- return super.a(entity, i);
- }
-
- public void d(int i) {
- super.d(i);
- }
-
- public void n() {
- super.b_();
- ChunkCoordIntPair chunkcoordintpair = null;
- double d1 = 0.0D;
-
- for (int i = 0; i < f.size(); i++) {
- ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) f.get(i);
- double d2 = chunkcoordintpair1.a(((Entity) (this)));
-
- if (i == 0 || d2 < d1) {
- chunkcoordintpair = chunkcoordintpair1;
- d1 = chunkcoordintpair1.a(((Entity) (this)));
- }
- }
-
- if (chunkcoordintpair != null) {
- boolean flag = false;
-
- if (d1 < 1024D) {
- flag = true;
- }
- if (a.b() < 2) {
- flag = true;
- }
- if (flag) {
- f.remove(((chunkcoordintpair)));
- a.b(((Packet) (new Packet51MapChunk(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, 16, 128, 16, ((World) (b.e))))));
- List list = b.e.d(chunkcoordintpair.a * 16, 0, chunkcoordintpair.b * 16, chunkcoordintpair.a * 16 + 16, 128, chunkcoordintpair.b * 16 + 16);
-
- for (int j = 0; j < list.size(); j++) {
- a((TileEntity) list.get(j));
- }
- }
- }
- if (aZ != bD) {
- a.b(((Packet) (new Packet8(aZ))));
- bD = aZ;
- }
- }
-
- private void a(TileEntity tileentity) {
- if (tileentity != null) {
- Packet packet = tileentity.g();
-
- if (packet != null) {
- a.b(packet);
- }
- }
- }
-
- public void o() {
- s = t = u = 0.0D;
- bA = false;
- super.o();
- }
-
- public void c(Entity entity, int i) {
- if (!entity.G) {
- if (entity instanceof EntityItem) {
- b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
- }
- if (entity instanceof EntityArrow) {
- b.k.a(entity, ((Packet) (new Packet22Collect(entity.g, g))));
- }
- }
- super.c(entity, i);
- ap.a();
- }
-
- public void K() {
- if (!au) {
- av = -1;
- au = true;
- b.k.a(((Entity) (this)), ((Packet) (new Packet18ArmAnimation(((Entity) (this)), 1))));
- }
- }
-
- public float w() {
- return 1.62F;
- }
-
- public void e(Entity entity) {
- // CraftBukkit start
- setPassengerOf(entity);
- }
-
- public void setPassengerOf(Entity entity) {
- // e(null) doesn't really fly for overloaded methods,
- // so this method is needed
-
- // CraftBukkit end
- super.setPassengerOf(entity);
- a.b(((Packet) (new Packet39(((Entity) (this)), k))));
- a.a(p, q, r, v, w);
- }
-
- protected void a(double d1, boolean flag) {}
-
- public void b(double d1, boolean flag) {
- super.a(d1, flag);
- }
-
- private void U() {
- bG = bG % 100 + 1;
- }
-
- public void a(int i, int j, int k) {
- U();
- a.b(((Packet) (new Packet100(bG, 1, "Crafting", 9))));
- ap = ((CraftingInventoryCB) (new CraftingInventoryWorkbenchCB(an, l, i, j, k)));
- ap.f = bG;
- ap.a(((ICrafting) (this)));
- }
-
- public void a(IInventory iinventory) {
- U();
- a.b(((Packet) (new Packet100(bG, 0, iinventory.b(), iinventory.h_()))));
- ap = ((CraftingInventoryCB) (new CraftingInventoryChestCB(((IInventory) (an)), iinventory)));
- ap.f = bG;
- ap.a(((ICrafting) (this)));
- }
-
- public void a(TileEntityFurnace tileentityfurnace) {
- U();
- a.b(((Packet) (new Packet100(bG, 2, tileentityfurnace.b(), tileentityfurnace.h_()))));
- ap = ((CraftingInventoryCB) (new CraftingInventoryFurnaceCB(((IInventory) (an)), tileentityfurnace)));
- ap.f = bG;
- ap.a(((ICrafting) (this)));
- }
-
- public void a(TileEntityDispenser tileentitydispenser) {
- U();
- a.b(((Packet) (new Packet100(bG, 3, tileentitydispenser.b(), tileentitydispenser.h_()))));
- ap = ((CraftingInventoryCB) (new CraftingInventoryDispenserCB(((IInventory) (an)), tileentitydispenser)));
- ap.f = bG;
- ap.a(((ICrafting) (this)));
- }
-
- public void a(CraftingInventoryCB craftinginventorycb, int i, ItemStack itemstack) {
- if (craftinginventorycb.a(i) instanceof SlotCrafting) {
- return;
- }
- if (am) {
- return;
- } else {
- a.b(((Packet) (new Packet103(craftinginventorycb.f, i, itemstack))));
- return;
- }
- }
-
- public void a(CraftingInventoryCB craftinginventorycb, List list) {
- a.b(((Packet) (new Packet104(craftinginventorycb.f, list))));
- a.b(((Packet) (new Packet103(-1, -1, an.i()))));
- }
-
- public void a(CraftingInventoryCB craftinginventorycb, int i, int j) {
- a.b(((Packet) (new Packet105(craftinginventorycb.f, i, j))));
- }
-
- public void a(ItemStack itemstack) {}
-
- public void L() {
- a.b(((Packet) (new Packet101(ap.f))));
- N();
- }
-
- public void M() {
- if (am) {
- return;
- } else {
- a.b(((Packet) (new Packet103(-1, -1, an.i()))));
- return;
- }
- }
-
- public void N() {
- ap.a(((EntityPlayer) (this)));
- ap = ao;
- }
-}
diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java
index 725624a9..987ed311 100644
--- a/src/main/java/net/minecraft/server/EntitySheep.java
+++ b/src/main/java/net/minecraft/server/EntitySheep.java
@@ -7,85 +7,53 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSheep;
// CraftBukkit end
-public class EntitySheep extends EntityAnimals {
-
- public static final float a[][] = {
- {
- 1.0F, 1.0F, 1.0F
- }, {
- 0.95F, 0.7F, 0.2F
- }, {
- 0.9F, 0.5F, 0.85F
- }, {
- 0.6F, 0.7F, 0.95F
- }, {
- 0.9F, 0.9F, 0.2F
- }, {
- 0.5F, 0.8F, 0.1F
- }, {
- 0.95F, 0.7F, 0.8F
- }, {
- 0.3F, 0.3F, 0.3F
- }, {
- 0.6F, 0.6F, 0.6F
- }, {
- 0.3F, 0.6F, 0.7F
- }, {
- 0.7F, 0.4F, 0.9F
- }, {
- 0.2F, 0.4F, 0.8F
- }, {
- 0.5F, 0.4F, 0.3F
- }, {
- 0.4F, 0.5F, 0.2F
- }, {
- 0.8F, 0.3F, 0.3F
- }, {
- 0.1F, 0.1F, 0.1F
- }
- };
+public class EntitySheep extends EntityAnimal {
+
+ public static final float[][] a = new float[][] { { 1.0F, 1.0F, 1.0F}, { 0.95F, 0.7F, 0.2F}, { 0.9F, 0.5F, 0.85F}, { 0.6F, 0.7F, 0.95F}, { 0.9F, 0.9F, 0.2F}, { 0.5F, 0.8F, 0.1F}, { 0.95F, 0.7F, 0.8F}, { 0.3F, 0.3F, 0.3F}, { 0.6F, 0.6F, 0.6F}, { 0.3F, 0.6F, 0.7F}, { 0.7F, 0.4F, 0.9F}, { 0.2F, 0.4F, 0.8F}, { 0.5F, 0.4F, 0.3F}, { 0.4F, 0.5F, 0.2F}, { 0.8F, 0.3F, 0.3F}, { 0.1F, 0.1F, 0.1F}};
public EntitySheep(World world) {
super(world);
- aP = "/mob/sheep.png";
- a(0.9F, 1.3F);
+ this.texture = "/mob/sheep.png";
+ this.a(0.9F, 1.3F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSheep(server, this);
// CraftBukkit end
}
protected void a() {
super.a();
- af.a(16, ((new Byte((byte) 0))));
+ this.datawatcher.a(16, new Byte((byte) 0));
}
public boolean a(Entity entity, int i) {
- if (!l.z && !f_() && (entity instanceof EntityLiving)) {
- a(true);
- int j = 1 + W.nextInt(3);
+ if (!this.world.isStatic && !this.f_() && entity instanceof EntityLiving) {
+ this.a(true);
+ int j = 1 + this.random.nextInt(3);
- for (int k = 0; k < j; k++) {
- EntityItem entityitem = a(new ItemStack(Block.ab.bi, 1, e_()), 1.0F);
+ for (int k = 0; k < j; ++k) {
+ EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.e_()), 1.0F);
- entityitem.t += W.nextFloat() * 0.05F;
- entityitem.s += (W.nextFloat() - W.nextFloat()) * 0.1F;
- entityitem.u += (W.nextFloat() - W.nextFloat()) * 0.1F;
+ entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
+ entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
+ entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
}
}
+
return super.a(entity, i);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.a("Sheared", f_());
- nbttagcompound.a("Color", (byte) e_());
+ nbttagcompound.a("Sheared", this.f_());
+ nbttagcompound.a("Color", (byte) this.e_());
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- a(nbttagcompound.l("Sheared"));
- a(((int) (nbttagcompound.b("Color"))));
+ this.a(nbttagcompound.l("Sheared"));
+ this.a(nbttagcompound.b("Color"));
}
protected String e() {
@@ -101,38 +69,32 @@ public class EntitySheep extends EntityAnimals {
}
public int e_() {
- return af.a(16) & 0xf;
+ return this.datawatcher.a(16) & 15;
}
public void a(int i) {
- byte byte0 = af.a(16);
+ byte b0 = this.datawatcher.a(16);
- af.b(16, ((Byte.valueOf((byte) (byte0 & 0xf0 | i & 0xf)))));
+ this.datawatcher.b(16, Byte.valueOf((byte) (b0 & 240 | i & 15)));
}
public boolean f_() {
- return (af.a(16) & 0x10) != 0;
+ return (this.datawatcher.a(16) & 16) != 0;
}
public void a(boolean flag) {
- byte byte0 = af.a(16);
+ byte b0 = this.datawatcher.a(16);
if (flag) {
- af.b(16, ((Byte.valueOf((byte) (byte0 | 0x10)))));
+ this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 16)));
} else {
- af.b(16, ((Byte.valueOf((byte) (byte0 & 0xffffffef)))));
+ this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -17)));
}
}
public static int a(Random random) {
int i = random.nextInt(100);
- if (i < 5) {
- return 15;
- }
- if (i < 10) {
- return 7;
- }
- return i >= 15 ? 0 : 8;
+ return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : 0));
}
}
diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java
index 8b22a5d7..6387dc72 100644
--- a/src/main/java/net/minecraft/server/EntitySkeleton.java
+++ b/src/main/java/net/minecraft/server/EntitySkeleton.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftSkeleton;
import org.bukkit.craftbukkit.CraftServer;
@@ -9,15 +7,16 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent;
// CraftBukkit end
-public class EntitySkeleton extends EntityMobs {
+public class EntitySkeleton extends EntityMonster {
- private static final ItemStack a;
+ private static final ItemStack a = new ItemStack(Item.BOW, 1);
public EntitySkeleton(World world) {
super(world);
- aP = "/mob/skeleton.png";
+ this.texture = "/mob/skeleton.png";
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSkeleton(server, this);
// CraftBukkit end
}
@@ -35,44 +34,46 @@ public class EntitySkeleton extends EntityMobs {
}
public void o() {
- if (l.b()) {
- float f1 = b(1.0F);
+ if (this.world.b()) {
+ float f = this.b(1.0F);
- if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) {
+ if (f > 0.5F && this.world.i(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
Type eventType = Type.ENTITY_COMBUST;
org.bukkit.entity.Entity entity = this.getBukkitEntity();
EntityCombustEvent event = new EntityCombustEvent(eventType, entity);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- Z = 300;
+ this.fireTicks = 300;
}
// CraftBukkit end
}
}
+
super.o();
}
- protected void a(Entity entity, float f1) {
- if (f1 < 10F) {
- double d = entity.p - p;
- double d1 = entity.r - r;
+ protected void a(Entity entity, float f) {
+ if (f < 10.0F) {
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
- if (bf == 0) {
- EntityArrow entityarrow = new EntityArrow(l, ((EntityLiving) (this)));
+ if (this.attackTicks == 0) {
+ EntityArrow entityarrow = new EntityArrow(this.world, this);
- entityarrow.q += 1.3999999761581421D;
- double d2 = entity.q - 0.20000000298023224D - entityarrow.q;
- float f2 = MathHelper.a(d * d + d1 * d1) * 0.2F;
+ ++entityarrow.locY;
+ double d2 = entity.locY - 0.20000000298023224D - entityarrow.locY;
+ float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F;
- l.a(((Entity) (this)), "random.bow", 1.0F, 1.0F / (W.nextFloat() * 0.4F + 0.8F));
- l.a(((Entity) (entityarrow)));
- entityarrow.a(d, d2 + (double) f2, d1, 0.6F, 12F);
- bf = 30;
+ this.world.a(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
+ this.world.a((Entity) entityarrow);
+ entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F);
+ this.attackTicks = 30;
}
- v = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
- e = true;
+
+ this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
+ this.e = true;
}
}
@@ -85,23 +86,22 @@ public class EntitySkeleton extends EntityMobs {
}
protected int h() {
- return Item.j.ba;
+ return Item.ARROW.id;
}
protected void g_() {
- int i = W.nextInt(3);
+ int i = this.random.nextInt(3);
- for (int j = 0; j < i; j++) {
- a(Item.j.ba, 1);
- }
+ int j;
- i = W.nextInt(3);
- for (int k = 0; k < i; k++) {
- a(Item.aV.ba, 1);
+ for (j = 0; j < i; ++j) {
+ this.a(Item.ARROW.id, 1);
}
- }
- static {
- a = new ItemStack(Item.i, 1);
+ i = this.random.nextInt(3);
+
+ for (j = 0; j < i; ++j) {
+ this.a(Item.BONE.id, 1);
+ }
}
}
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
index 6e4eb685..c2ad891b 100644
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -1,118 +1,122 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSlime;
// CraftBukkit stop
-public class EntitySlime extends EntityLiving implements IMobs {
+public class EntitySlime extends EntityLiving implements IMonster {
public float a;
public float b;
- private int d;
- public int c;
+ private int d = 0;
+ public int c = 1;
public EntitySlime(World world) {
super(world);
- d = 0;
- c = 1;
- aP = "/mob/slime.png";
- c = 1 << W.nextInt(3);
- H = 0.0F;
- d = W.nextInt(20) + 10;
- a(c);
+ this.texture = "/mob/slime.png";
+ this.c = 1 << this.random.nextInt(3);
+ this.height = 0.0F;
+ this.d = this.random.nextInt(20) + 10;
+ this.a(this.c);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSlime(server, this);
// CraftBukkit end
}
- public void a(int j) {
- c = j;
- a(0.6F * (float) j, 0.6F * (float) j);
- aZ = j * j;
- a(p, q, r);
+ public void a(int i) {
+ this.c = i;
+ this.a(0.6F * (float) i, 0.6F * (float) i);
+ this.health = i * i;
+ this.a(this.locX, this.locY, this.locZ);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- nbttagcompound.a("Size", c - 1);
+ nbttagcompound.a("Size", this.c - 1);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- c = nbttagcompound.d("Size") + 1;
+ this.c = nbttagcompound.d("Size") + 1;
}
public void b_() {
- b = a;
- boolean flag = A;
+ this.b = this.a;
+ boolean flag = this.onGround;
super.b_();
- if (A && !flag) {
- for (int j = 0; j < c * 8; j++) {
- float f1 = W.nextFloat() * 3.141593F * 2.0F;
- float f2 = W.nextFloat() * 0.5F + 0.5F;
- float f3 = MathHelper.a(f1) * (float) c * 0.5F * f2;
- float f4 = MathHelper.b(f1) * (float) c * 0.5F * f2;
-
- l.a("slime", p + (double) f3, z.b, r + (double) f4, 0.0D, 0.0D, 0.0D);
+ if (this.onGround && !flag) {
+ for (int i = 0; i < this.c * 8; ++i) {
+ float f = this.random.nextFloat() * 3.1415927F * 2.0F;
+ float f1 = this.random.nextFloat() * 0.5F + 0.5F;
+ float f2 = MathHelper.a(f) * (float) this.c * 0.5F * f1;
+ float f3 = MathHelper.b(f) * (float) this.c * 0.5F * f1;
+
+ this.world.a("slime", this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D);
}
- if (c > 2) {
- l.a(((Entity) (this)), "mob.slime", i(), ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) / 0.8F);
+ if (this.c > 2) {
+ this.world.a(this, "mob.slime", this.i(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
- a = -0.5F;
+
+ this.a = -0.5F;
}
- a = a * 0.6F;
+
+ this.a *= 0.6F;
}
protected void d() {
- EntityPlayer entityplayer = l.a(((Entity) (this)), 16D);
+ EntityHuman entityhuman = this.world.a(this, 16.0D);
- if (entityplayer != null) {
- b(((Entity) (entityplayer)), 10F);
+ if (entityhuman != null) {
+ this.b(entityhuman, 10.0F);
}
- if (A && d-- <= 0) {
- d = W.nextInt(20) + 10;
- if (entityplayer != null) {
- d /= 3;
+
+ if (this.onGround && this.d-- <= 0) {
+ this.d = this.random.nextInt(20) + 10;
+ if (entityhuman != null) {
+ this.d /= 3;
}
- bA = true;
- if (c > 1) {
- l.a(((Entity) (this)), "mob.slime", i(), ((W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F) * 0.8F);
+
+ this.bA = true;
+ if (this.c > 1) {
+ this.world.a(this, "mob.slime", this.i(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
}
- a = 1.0F;
- bx = 1.0F - W.nextFloat() * 2.0F;
- by = 1 * c;
+
+ this.a = 1.0F;
+ this.bx = 1.0F - this.random.nextFloat() * 2.0F;
+ this.by = (float) (1 * this.c);
} else {
- bA = false;
- if (A) {
- bx = by = 0.0F;
+ this.bA = false;
+ if (this.onGround) {
+ this.bx = this.by = 0.0F;
}
}
}
public void q() {
- if (c > 1 && aZ == 0) {
- for (int j = 0; j < 4; j++) {
- float f1 = (((float) (j % 2) - 0.5F) * (float) c) / 4F;
- float f2 = (((float) (j / 2) - 0.5F) * (float) c) / 4F;
- EntitySlime entityslime = new EntitySlime(l);
-
- entityslime.a(c / 2);
- entityslime.c(p + (double) f1, q + 0.5D, r + (double) f2, W.nextFloat() * 360F, 0.0F);
- l.a(((Entity) (entityslime)));
+ if (this.c > 1 && this.health == 0) {
+ for (int i = 0; i < 4; ++i) {
+ float f = ((float) (i % 2) - 0.5F) * (float) this.c / 4.0F;
+ float f1 = ((float) (i / 2) - 0.5F) * (float) this.c / 4.0F;
+ EntitySlime entityslime = new EntitySlime(this.world);
+
+ entityslime.a(this.c / 2);
+ entityslime.c(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
+ this.world.a((Entity) entityslime);
}
}
+
super.q();
}
- public void b(EntityPlayer entityplayer) {
- if (c > 1 && i(((Entity) (entityplayer))) && (double) a(((Entity) (entityplayer))) < 0.59999999999999998D * (double) c && entityplayer.a(((Entity) (this)), c)) {
- l.a(((Entity) (this)), "mob.slimeattack", 1.0F, (W.nextFloat() - W.nextFloat()) * 0.2F + 1.0F);
+ public void b(EntityHuman entityhuman) {
+ // CraftBukkit - add cast to Entity VVVVVVVV
+ if (this.c > 1 && this.i(entityhuman) && (double) this.a((Entity) entityhuman) < 0.6D * (double) this.c && entityhuman.a(this, this.c)) {
+ this.world.a(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
}
@@ -125,17 +129,13 @@ public class EntitySlime extends EntityLiving implements IMobs {
}
protected int h() {
- if (c == 1) {
- return Item.aK.ba;
- } else {
- return 0;
- }
+ return this.c == 1 ? Item.SLIME_BALL.id : 0;
}
public boolean b() {
- Chunk chunk = l.b(MathHelper.b(p), MathHelper.b(r));
+ Chunk chunk = this.world.b(MathHelper.b(this.locX), MathHelper.b(this.locZ));
- return (c == 1 || l.k > 0) && W.nextInt(10) == 0 && chunk.a(0x3ad8025fL).nextInt(10) == 0 && q < 16D;
+ return (this.c == 1 || this.world.k > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 16.0D;
}
protected float i() {
diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java
index 72bfc6e0..7567fd0e 100644
--- a/src/main/java/net/minecraft/server/EntitySnowball.java
+++ b/src/main/java/net/minecraft/server/EntitySnowball.java
@@ -1,7 +1,6 @@
package net.minecraft.server;
import java.util.List;
-import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
@@ -13,28 +12,22 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntitySnowball extends Entity {
- private int b;
- private int c;
- private int d;
- private int e;
- private boolean f;
- public int a;
+ private int b = -1;
+ private int c = -1;
+ private int d = -1;
+ private int e = 0;
+ private boolean f = false;
+ public int a = 0;
private EntityLiving ak;
private int al;
- private int am;
+ private int am = 0;
public EntitySnowball(World world) {
super(world);
- b = -1;
- c = -1;
- d = -1;
- e = 0;
- f = false;
- a = 0;
- am = 0;
- a(0.25F, 0.25F);
+ this.a(0.25F, 0.25F);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSnowball(server, this);
// CraftBukkit end
}
@@ -42,117 +35,117 @@ public class EntitySnowball extends Entity {
protected void a() {}
public EntitySnowball(World world, EntityLiving entityliving) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- ak = entityliving;
- c(entityliving.p, entityliving.q + (double) entityliving.w(), entityliving.r, entityliving.v, entityliving.w);
- p -= MathHelper.b((v / 180F) * 3.141593F) * 0.16F;
- q -= 0.10000000149011612D;
- r -= MathHelper.a((v / 180F) * 3.141593F) * 0.16F;
- a(p, q, r);
- H = 0.0F;
- float f1 = 0.4F;
-
- s = -MathHelper.a((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- u = MathHelper.b((v / 180F) * 3.141593F) * MathHelper.b((w / 180F) * 3.141593F) * f1;
- t = -MathHelper.a((w / 180F) * 3.141593F) * f1;
- a(s, t, u, 1.5F, 1.0F);
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.ak = entityliving;
+ this.a(0.25F, 0.25F);
+ this.c(entityliving.locX, entityliving.locY + (double) entityliving.w(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
+ this.locX -= (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.locY -= 0.10000000149011612D;
+ this.locZ -= (double) (MathHelper.a(this.yaw / 180.0F * 3.1415927F) * 0.16F);
+ this.a(this.locX, this.locY, this.locZ);
+ this.height = 0.0F;
+ float f = 0.4F;
+
+ this.motX = (double) (-MathHelper.a(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motZ = (double) (MathHelper.b(this.yaw / 180.0F * 3.1415927F) * MathHelper.b(this.pitch / 180.0F * 3.1415927F) * f);
+ this.motY = (double) (-MathHelper.a(this.pitch / 180.0F * 3.1415927F) * f);
+ this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F);
}
- public EntitySnowball(World world, double d1, double d2, double d3) {
- // CraftBukkit start
- this(world);
- // CraftBukkit end
-
- al = 0;
- a(d1, d2, d3);
- H = 0.0F;
+ public EntitySnowball(World world, double d0, double d1, double d2) {
+ this(world); // CraftBukkit super->this so we assign the entity
+
+ this.al = 0;
+ this.a(0.25F, 0.25F);
+ this.a(d0, d1, d2);
+ this.height = 0.0F;
}
- public void a(double d1, double d2, double d3, float f1, float f2) {
- float f3 = MathHelper.a(d1 * d1 + d2 * d2 + d3 * d3);
-
- d1 /= f3;
- d2 /= f3;
- d3 /= f3;
- d1 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d2 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d3 += W.nextGaussian() * 0.0074999998323619366D * (double) f2;
- d1 *= f1;
- d2 *= f1;
- d3 *= f1;
- s = d1;
- t = d2;
- u = d3;
- float f4 = MathHelper.a(d1 * d1 + d3 * d3);
-
- x = v = (float) ((Math.atan2(d1, d3) * 180D) / 3.1415927410125732D);
- y = w = (float) ((Math.atan2(d2, f4) * 180D) / 3.1415927410125732D);
- al = 0;
+ public void a(double d0, double d1, double d2, float f, float f1) {
+ float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ d0 /= (double) f2;
+ d1 /= (double) f2;
+ d2 /= (double) f2;
+ d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1;
+ d0 *= (double) f;
+ d1 *= (double) f;
+ d2 *= (double) f;
+ this.motX = d0;
+ this.motY = d1;
+ this.motZ = d2;
+ float f3 = MathHelper.a(d0 * d0 + d2 * d2);
+
+ this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D);
+ this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D);
+ this.al = 0;
}
public void b_() {
- O = p;
- P = q;
- Q = r;
+ this.O = this.locX;
+ this.P = this.locY;
+ this.Q = this.locZ;
super.b_();
- if (a > 0) {
- a--;
+ if (this.a > 0) {
+ --this.a;
}
- if (f) {
- int i = this.l.a(b, c, d);
-
- if (i != e) {
- f = false;
- s *= W.nextFloat() * 0.2F;
- t *= W.nextFloat() * 0.2F;
- u *= W.nextFloat() * 0.2F;
- al = 0;
- am = 0;
- } else {
- al++;
- if (al == 1200) {
- q();
+
+ if (this.f) {
+ int i = this.world.getTypeId(this.b, this.c, this.d);
+
+ if (i == this.e) {
+ ++this.al;
+ if (this.al == 1200) {
+ this.q();
}
+
return;
}
+
+ this.f = false;
+ this.motX *= (double) (this.random.nextFloat() * 0.2F);
+ this.motY *= (double) (this.random.nextFloat() * 0.2F);
+ this.motZ *= (double) (this.random.nextFloat() * 0.2F);
+ this.al = 0;
+ this.am = 0;
} else {
- am++;
+ ++this.am;
}
- Vec3D vec3d = Vec3D.b(p, q, r);
- Vec3D vec3d1 = Vec3D.b(p + s, q + t, r + u);
- MovingObjectPosition movingobjectposition = this.l.a(vec3d, vec3d1);
- vec3d = Vec3D.b(p, q, r);
- vec3d1 = Vec3D.b(p + s, q + t, r + u);
+ Vec3D vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ Vec3D vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
+ MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1);
+
+ vec3d = Vec3D.b(this.locX, this.locY, this.locZ);
+ vec3d1 = Vec3D.b(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
if (movingobjectposition != null) {
vec3d1 = Vec3D.b(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c);
}
- if (!this.l.z) {
+
+ if (!this.world.isStatic) {
Entity entity = null;
- List list = this.l.b(((Entity) (this)), z.a(s, t, u).b(1.0D, 1.0D, 1.0D));
- double d1 = 0.0D;
+ List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D));
+ double d0 = 0.0D;
- for (int k = 0; k < list.size(); k++) {
- Entity entity1 = (Entity) list.get(k);
+ for (int j = 0; j < list.size(); ++j) {
+ Entity entity1 = (Entity) list.get(j);
- if (!entity1.c_() || entity1 == ak && am < 5) {
- continue;
- }
- float f4 = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.z.b(f4, f4, f4);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
+ if (entity1.c_() && (entity1 != this.ak || this.am >= 5)) {
+ float f = 0.3F;
+ AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f);
+ MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
- if (movingobjectposition1 == null) {
- continue;
- }
- double d2 = vec3d.a(movingobjectposition1.f);
+ if (movingobjectposition1 != null) {
+ double d1 = vec3d.a(movingobjectposition1.f);
- if (d2 < d1 || d1 == 0.0D) {
- entity = entity1;
- d1 = d2;
+ if (d1 < d0 || d0 == 0.0D) {
+ entity = entity1;
+ d0 = d1;
+ }
+ }
}
}
@@ -160,105 +153,114 @@ public class EntitySnowball extends Entity {
movingobjectposition = new MovingObjectPosition(entity);
}
}
+
if (movingobjectposition != null) {
+ // CraftBukkit start
if (movingobjectposition.g != null) {
- // CraftBukkit start
- boolean bounce;
+ boolean stick;
if (movingobjectposition.g instanceof EntityLiving) {
- CraftServer server = ((WorldServer) this.l).getServer();
- org.bukkit.entity.Entity shooter = (ak == null)?null:ak.getBukkitEntity();
+ CraftServer server = ((WorldServer) this.world).getServer();
+ org.bukkit.entity.Entity shooter = (this.ak == null) ? null : this.ak.getBukkitEntity();
org.bukkit.entity.Entity damagee = movingobjectposition.g.getBukkitEntity();
org.bukkit.entity.Entity projectile = this.getBukkitEntity();
DamageCause damageCause = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
int damage = 0;
// TODO @see EntityArrow#162
- EntityDamageByProjectileEvent edbpe = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
- server.getPluginManager().callEvent(edbpe);
+ EntityDamageByProjectileEvent event = new EntityDamageByProjectileEvent(shooter, damagee, projectile, damageCause, damage);
+ server.getPluginManager().callEvent(event);
- if(!edbpe.isCancelled()) {
+ if(!event.isCancelled()) {
// this function returns if the snowball should stick or not, i.e. !bounce
- bounce = !movingobjectposition.g.a(((Entity) (ak)), edbpe.getDamage());
+ stick = movingobjectposition.g.a(this.ak, event.getDamage());
} else {
// event was cancelled, get if the snowball should bounce or not
- bounce = edbpe.getBounce();
+ stick = !event.getBounce();
}
} else {
- bounce = !movingobjectposition.g.a(((Entity) (ak)), 0);
+ stick = movingobjectposition.g.a(this.ak, 0);
}
- if (!bounce) {
- // CraftBukkit end
+ if (stick) {
;
}
+ // CraftBukkit end
}
- for (int j = 0; j < 8; j++) {
- this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D);
+
+ for (int k = 0; k < 8; ++k) {
+ this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D);
}
- q();
+ this.q();
}
- p += s;
- q += t;
- r += u;
- float f1 = MathHelper.a(s * s + u * u);
- v = (float) ((Math.atan2(s, u) * 180D) / 3.1415927410125732D);
- for (w = (float) ((Math.atan2(t, f1) * 180D) / 3.1415927410125732D); w - y < -180F; y -= 360F) {
+ this.locX += this.motX;
+ this.locY += this.motY;
+ this.locZ += this.motZ;
+ float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
;
}
- for (; w - y >= 180F; y += 360F) {
- ;
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
}
- for (; v - x < -180F; x -= 360F) {
- ;
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
}
- for (; v - x >= 180F; x += 360F) {
- ;
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
}
- w = y + (w - y) * 0.2F;
- v = x + (v - x) * 0.2F;
+
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
float f2 = 0.99F;
- float f5 = 0.03F;
+ float f3 = 0.03F;
- if (v()) {
- for (int l = 0; l < 4; l++) {
- float f3 = 0.25F;
+ if (this.v()) {
+ for (int l = 0; l < 4; ++l) {
+ float f4 = 0.25F;
- this.l.a("bubble", p - s * (double) f3, q - t * (double) f3, r - u * (double) f3, s, t, u);
+ this.world.a("bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ);
}
f2 = 0.8F;
}
- s *= f2;
- t *= f2;
- u *= f2;
- t -= f5;
- a(p, q, r);
+
+ this.motX *= (double) f2;
+ this.motY *= (double) f2;
+ this.motZ *= (double) f2;
+ this.motY -= (double) f3;
+ this.a(this.locX, this.locY, this.locZ);
}
public void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("xTile", (short) b);
- nbttagcompound.a("yTile", (short) c);
- nbttagcompound.a("zTile", (short) d);
- nbttagcompound.a("inTile", (byte) e);
- nbttagcompound.a("shake", (byte) a);
- nbttagcompound.a("inGround", (byte) (f ? 1 : 0));
+ nbttagcompound.a("xTile", (short) this.b);
+ nbttagcompound.a("yTile", (short) this.c);
+ nbttagcompound.a("zTile", (short) this.d);
+ nbttagcompound.a("inTile", (byte) this.e);
+ nbttagcompound.a("shake", (byte) this.a);
+ nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0));
}
public void b(NBTTagCompound nbttagcompound) {
- b = ((int) (nbttagcompound.c("xTile")));
- c = ((int) (nbttagcompound.c("yTile")));
- d = ((int) (nbttagcompound.c("zTile")));
- e = nbttagcompound.b("inTile") & 0xff;
- a = nbttagcompound.b("shake") & 0xff;
- f = nbttagcompound.b("inGround") == 1;
+ this.b = nbttagcompound.c("xTile");
+ this.c = nbttagcompound.c("yTile");
+ this.d = nbttagcompound.c("zTile");
+ this.e = nbttagcompound.b("inTile") & 255;
+ this.a = nbttagcompound.b("shake") & 255;
+ this.f = nbttagcompound.b("inGround") == 1;
}
- public void b(EntityPlayer entityplayer) {
- if (f && ak == entityplayer && a <= 0 && entityplayer.an.a(new ItemStack(Item.j, 1))) {
- l.a(((Entity) (this)), "random.pop", 0.2F, ((W.nextFloat() - W.nextFloat()) * 0.7F + 1.0F) * 2.0F);
- entityplayer.c(((Entity) (this)), 1);
- q();
+ public void b(EntityHuman entityhuman) {
+ if (this.f && this.ak == entityhuman && this.a <= 0 && entityhuman.inventory.a(new ItemStack(Item.ARROW, 1))) {
+ this.world.a(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
+ entityhuman.c(this, 1);
+ this.q();
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java
index 77bd7eb4..02c81814 100644
--- a/src/main/java/net/minecraft/server/EntitySpider.java
+++ b/src/main/java/net/minecraft/server/EntitySpider.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftEntity;
@@ -10,30 +8,31 @@ import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
// CraftBukkit stop
-public class EntitySpider extends EntityMobs {
+public class EntitySpider extends EntityMonster {
public EntitySpider(World world) {
super(world);
- aP = "/mob/spider.png";
- a(1.4F, 0.9F);
- bC = 0.8F;
+ this.texture = "/mob/spider.png";
+ this.a(1.4F, 0.9F);
+ this.bC = 0.8F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSpider(server, this);
// CraftBukkit end
}
public double k() {
- return (double) J * 0.75D - 0.5D;
+ return (double) this.width * 0.75D - 0.5D;
}
protected Entity l() {
- float f1 = b(1.0F);
+ float f = this.b(1.0F);
- if (f1 < 0.5F) {
- double d = 16D;
+ if (f < 0.5F) {
+ double d0 = 16.0D;
- return ((Entity) (l.a(((Entity) (this)), d)));
+ return this.world.a(this, d0);
} else {
return null;
}
@@ -51,16 +50,16 @@ public class EntitySpider extends EntityMobs {
return "mob.spiderdeath";
}
- protected void a(Entity entity, float f1) {
- float f2 = b(1.0F);
+ protected void a(Entity entity, float f) {
+ float f1 = this.b(1.0F);
- if (f2 > 0.5F && W.nextInt(100) == 0) {
+ if (f1 > 0.5F && this.random.nextInt(100) == 0) {
// CraftBukkit start
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET);
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
server.getPluginManager().callEvent(event);
- if(!event.isCancelled()) {
- if(event.getTarget() == null) {
+ if (!event.isCancelled()) {
+ if (event.getTarget() == null) {
this.d = null;
} else {
this.d = ((CraftEntity) event.getTarget()).getHandle();
@@ -68,19 +67,20 @@ public class EntitySpider extends EntityMobs {
return;
}
// CraftBukkit end
- }
- if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
- if (A) {
- double d = entity.p - p;
- double d1 = entity.r - r;
- float f3 = MathHelper.a(d * d + d1 * d1);
-
- s = (d / (double) f3) * 0.5D * 0.80000001192092896D + s * 0.20000000298023224D;
- u = (d1 / (double) f3) * 0.5D * 0.80000001192092896D + u * 0.20000000298023224D;
- t = 0.40000000596046448D;
- }
} else {
- super.a(entity, f1);
+ if (f > 2.0F && f < 6.0F && this.random.nextInt(10) == 0) {
+ if (this.onGround) {
+ double d0 = entity.locX - this.locX;
+ double d1 = entity.locZ - this.locZ;
+ float f2 = MathHelper.a(d0 * d0 + d1 * d1);
+
+ this.motX = d0 / (double) f2 * 0.5D * 0.800000011920929D + this.motX * 0.20000000298023224D;
+ this.motZ = d1 / (double) f2 * 0.5D * 0.800000011920929D + this.motZ * 0.20000000298023224D;
+ this.motY = 0.4000000059604645D;
+ }
+ } else {
+ super.a(entity, f);
+ }
}
}
@@ -93,10 +93,10 @@ public class EntitySpider extends EntityMobs {
}
protected int h() {
- return Item.I.ba;
+ return Item.STRING.id;
}
public boolean m() {
- return B;
+ return this.B;
}
}
diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java
index 4e8fdb70..a13757c6 100644
--- a/src/main/java/net/minecraft/server/EntitySquid.java
+++ b/src/main/java/net/minecraft/server/EntitySquid.java
@@ -1,50 +1,35 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftSquid;
// CraftBukkit stop
-public class EntitySquid extends EntityWaterMob {
-
- public float a;
- public float b;
- public float c;
- public float f;
- public float ak;
- public float al;
- public float am;
- public float an;
- private float ao;
- private float ap;
- private float aq;
- private float ar;
- private float as;
- private float at;
+public class EntitySquid extends EntityWaterAnimal {
+
+ public float a = 0.0F;
+ public float b = 0.0F;
+ public float c = 0.0F;
+ public float f = 0.0F;
+ public float ak = 0.0F;
+ public float al = 0.0F;
+ public float am = 0.0F;
+ public float an = 0.0F;
+ private float ao = 0.0F;
+ private float ap = 0.0F;
+ private float aq = 0.0F;
+ private float ar = 0.0F;
+ private float as = 0.0F;
+ private float at = 0.0F;
public EntitySquid(World world) {
super(world);
- a = 0.0F;
- b = 0.0F;
- c = 0.0F;
- f = 0.0F;
- ak = 0.0F;
- al = 0.0F;
- am = 0.0F;
- an = 0.0F;
- ao = 0.0F;
- ap = 0.0F;
- aq = 0.0F;
- ar = 0.0F;
- as = 0.0F;
- at = 0.0F;
- aP = "/mob/squid.png";
- a(0.95F, 0.95F);
- ap = (1.0F / (W.nextFloat() + 1.0F)) * 0.2F;
+ this.texture = "/mob/squid.png";
+ this.a(0.95F, 0.95F);
+ this.ap = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftSquid(server, this);
// CraftBukkit end
}
@@ -78,18 +63,18 @@ public class EntitySquid extends EntityWaterMob {
}
protected void g_() {
- int j = W.nextInt(3) + 1;
+ int i = this.random.nextInt(3) + 1;
- for (int k = 0; k < j; k++) {
- a(new ItemStack(Item.aU, 1, 0), 0.0F);
+ for (int j = 0; j < i; ++j) {
+ this.a(new ItemStack(Item.INK_SACK, 1, 0), 0.0F);
}
}
- public boolean a(EntityPlayer entityplayer) {
- ItemStack itemstack = entityplayer.an.e();
+ public boolean a(EntityHuman entityhuman) {
+ ItemStack itemstack = entityhuman.inventory.e();
- if (itemstack != null && itemstack.c == Item.au.ba) {
- entityplayer.an.a(entityplayer.an.c, new ItemStack(Item.aE));
+ if (itemstack != null && itemstack.id == Item.BUCKET.id) {
+ entityhuman.inventory.a(entityhuman.inventory.c, new ItemStack(Item.MILK_BUCKET));
return true;
} else {
return false;
@@ -97,72 +82,76 @@ public class EntitySquid extends EntityWaterMob {
}
public boolean v() {
- return l.a(z.b(0.0D, -0.60000002384185791D, 0.0D), Material.f, ((Entity) (this)));
+ return this.world.a(this.boundingBox.b(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this);
}
public void o() {
super.o();
- b = a;
- f = c;
- al = ak;
- an = am;
- ak += ap;
- if (ak > 6.283185F) {
- ak -= 6.283185F;
- if (W.nextInt(10) == 0) {
- ap = (1.0F / (W.nextFloat() + 1.0F)) * 0.2F;
+ this.b = this.a;
+ this.f = this.c;
+ this.al = this.ak;
+ this.an = this.am;
+ this.ak += this.ap;
+ if (this.ak > 6.2831855F) {
+ this.ak -= 6.2831855F;
+ if (this.random.nextInt(10) == 0) {
+ this.ap = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
}
}
- if (v()) {
- if (ak < 3.141593F) {
- float f1 = ak / 3.141593F;
-
- am = MathHelper.a(f1 * f1 * 3.141593F) * 3.141593F * 0.25F;
- if ((double) f1 > 0.75D) {
- ao = 1.0F;
- aq = 1.0F;
+
+ if (this.v()) {
+ float f;
+
+ if (this.ak < 3.1415927F) {
+ f = this.ak / 3.1415927F;
+ this.am = MathHelper.a(f * f * 3.1415927F) * 3.1415927F * 0.25F;
+ if ((double) f > 0.75D) {
+ this.ao = 1.0F;
+ this.aq = 1.0F;
} else {
- aq = aq * 0.8F;
+ this.aq *= 0.8F;
}
} else {
- am = 0.0F;
- ao = ao * 0.9F;
- aq = aq * 0.99F;
+ this.am = 0.0F;
+ this.ao *= 0.9F;
+ this.aq *= 0.99F;
}
- if (!aW) {
- s = ar * ao;
- t = as * ao;
- u = at * ao;
+
+ if (!this.aW) {
+ this.motX = (double) (this.ar * this.ao);
+ this.motY = (double) (this.as * this.ao);
+ this.motZ = (double) (this.at * this.ao);
}
- float f2 = MathHelper.a(s * s + u * u);
- aI += ((-(float) Math.atan2(s, u) * 180F) / 3.141593F - aI) * 0.1F;
- v = aI;
- c = c + 3.141593F * aq * 1.5F;
- a += ((-(float) Math.atan2(f2, t) * 180F) / 3.141593F - a) * 0.1F;
+ f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
+ this.aI += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aI) * 0.1F;
+ this.yaw = this.aI;
+ this.c += 3.1415927F * this.aq * 1.5F;
+ this.a += (-((float) Math.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.a) * 0.1F;
} else {
- am = MathHelper.e(MathHelper.a(ak)) * 3.141593F * 0.25F;
- if (!aW) {
- s = 0.0D;
- t -= 0.080000000000000002D;
- t *= 0.98000001907348633D;
- u = 0.0D;
+ this.am = MathHelper.e(MathHelper.a(this.ak)) * 3.1415927F * 0.25F;
+ if (!this.aW) {
+ this.motX = 0.0D;
+ this.motY -= 0.08D;
+ this.motY *= 0.9800000190734863D;
+ this.motZ = 0.0D;
}
- a += ((float) ((double) (-90F - a) * 0.02D));
+
+ this.a = (float) ((double) this.a + (double) (-90.0F - this.a) * 0.02D);
}
}
- public void c(float f1, float f2) {
- c(s, t, u);
+ public void c(float f, float f1) {
+ this.c(this.motX, this.motY, this.motZ);
}
protected void d() {
- if (W.nextInt(50) == 0 || !ab || ar == 0.0F && as == 0.0F && at == 0.0F) {
- float f1 = W.nextFloat() * 3.141593F * 2.0F;
+ if (this.random.nextInt(50) == 0 || !this.ab || this.ar == 0.0F && this.as == 0.0F && this.at == 0.0F) {
+ float f = this.random.nextFloat() * 3.1415927F * 2.0F;
- ar = MathHelper.b(f1) * 0.2F;
- as = -0.1F + W.nextFloat() * 0.2F;
- at = MathHelper.a(f1) * 0.2F;
+ this.ar = MathHelper.b(f) * 0.2F;
+ this.as = -0.1F + this.random.nextFloat() * 0.2F;
+ this.at = MathHelper.a(f) * 0.2F;
}
}
}
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index f0a5a8d2..fc85674c 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -11,70 +11,72 @@ public class EntityTNTPrimed extends Entity {
public EntityTNTPrimed(World world) {
super(world);
- a = 0;
- i = true;
- a(0.98F, 0.98F);
- H = J / 2.0F;
+ this.a = 0;
+ this.i = true;
+ this.a(0.98F, 0.98F);
+ this.height = this.width / 2.0F;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftTNTPrimed(server, this);
// CraftBukkit end
}
- public EntityTNTPrimed(World world, double d1, double d2, double d3) {
+ public EntityTNTPrimed(World world, double d0, double d1, double d2) {
this(world);
- a(d1, d2, d3);
- float f = (float) (Math.random() * 3.1415927410125732D * 2D);
+ this.a(d0, d1, d2);
+ float f = (float) (Math.random() * 3.1415927410125732D * 2.0D);
- s = -MathHelper.a((f * 3.141593F) / 180F) * 0.02F;
- t = 0.20000000298023224D;
- u = -MathHelper.b((f * 3.141593F) / 180F) * 0.02F;
- M = false;
- a = 80;
- m = d1;
- n = d2;
- o = d3;
+ this.motX = (double) (-MathHelper.a(f * 3.1415927F / 180.0F) * 0.02F);
+ this.motY = 0.20000000298023224D;
+ this.motZ = (double) (-MathHelper.b(f * 3.1415927F / 180.0F) * 0.02F);
+ this.M = false;
+ this.a = 80;
+ this.lastX = d0;
+ this.lastY = d1;
+ this.lastZ = d2;
}
protected void a() {}
public boolean c_() {
- return !G;
+ return !this.dead;
}
public void b_() {
- m = p;
- n = q;
- o = r;
- t -= 0.039999999105930328D;
- c(s, t, u);
- s *= 0.98000001907348633D;
- t *= 0.98000001907348633D;
- u *= 0.98000001907348633D;
- if (A) {
- s *= 0.69999998807907104D;
- u *= 0.69999998807907104D;
- t *= -0.5D;
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+ this.motY -= 0.03999999910593033D;
+ this.c(this.motX, this.motY, this.motZ);
+ this.motX *= 0.9800000190734863D;
+ this.motY *= 0.9800000190734863D;
+ this.motZ *= 0.9800000190734863D;
+ if (this.onGround) {
+ this.motX *= 0.699999988079071D;
+ this.motZ *= 0.699999988079071D;
+ this.motY *= -0.5D;
}
- if (a-- <= 0) {
- q();
- d();
+
+ if (this.a-- <= 0) {
+ this.q();
+ this.d();
} else {
- l.a("smoke", p, q + 0.5D, r, 0.0D, 0.0D, 0.0D);
+ this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
}
}
private void d() {
- float f = 4F;
+ float f = 4.0F;
- l.a(((Entity) (null)), p, q, r, f);
+ this.world.a((Entity) null, this.locX, this.locY, this.locZ, f);
}
protected void a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("Fuse", (byte) a);
+ nbttagcompound.a("Fuse", (byte) this.a);
}
protected void b(NBTTagCompound nbttagcompound) {
- a = ((int) (nbttagcompound.b("Fuse")));
+ this.a = nbttagcompound.b("Fuse");
}
}
diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java
deleted file mode 100644
index cd6fe4be..00000000
--- a/src/main/java/net/minecraft/server/EntityTracker.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package net.minecraft.server;
-
-import java.util.*;
-
-public class EntityTracker {
-
- private Set a;
- private MCHashTable b;
- private MinecraftServer c;
- private int d;
-
- public EntityTracker(MinecraftServer minecraftserver) {
- a = ((Set) (new HashSet()));
- b = new MCHashTable();
- c = minecraftserver;
- d = minecraftserver.f.a();
- }
-
- public void a(Entity entity) {
- if (entity instanceof EntityPlayerMP) {
- a(entity, 512, 2);
- EntityPlayerMP entityplayermp = (EntityPlayerMP) entity;
- Iterator iterator = a.iterator();
-
- do {
- if (!iterator.hasNext()) {
- break;
- }
- EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
-
- if (entitytrackerentry.a != entityplayermp) {
- entitytrackerentry.b(entityplayermp);
- }
- } while (true);
- } else if (entity instanceof EntityFish) {
- a(entity, 64, 5, true);
- } else if (entity instanceof EntityArrow) {
- a(entity, 64, 5, true);
- } else if (entity instanceof EntitySnowball) {
- a(entity, 64, 5, true);
- } else if (entity instanceof EntityEgg) {
- a(entity, 64, 5, true);
- } else if (entity instanceof EntityItem) {
- a(entity, 64, 20, true);
- } else if (entity instanceof EntityMinecart) {
- a(entity, 160, 5, true);
- } else if (entity instanceof EntityBoat) {
- a(entity, 160, 5, true);
- } else if (entity instanceof EntitySquid) {
- a(entity, 160, 3, true);
- } else if (entity instanceof IAnimals) {
- a(entity, 160, 3);
- } else if (entity instanceof EntityTNTPrimed) {
- a(entity, 160, 10, true);
- } else if (entity instanceof EntityFallingSand) {
- a(entity, 160, 20, true);
- } else if (entity instanceof EntityPainting) {
- a(entity, 160, 0x7fffffff, false);
- }
- }
-
- public void a(Entity entity, int i, int j) {
- a(entity, i, j, false);
- }
-
- public void a(Entity entity, int i, int j, boolean flag) {
- if (i > d) {
- i = d;
- }
- if (b.b(entity.g)) {
- throw new IllegalStateException("Entity is already tracked!");
- } else {
- EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j, flag);
-
- a.add(((entitytrackerentry)));
- b.a(entity.g, ((entitytrackerentry)));
- entitytrackerentry.b(c.e.d);
- return;
- }
- }
-
- public void b(Entity entity) {
- if (entity instanceof EntityPlayerMP) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) entity;
- EntityTrackerEntry entitytrackerentry1;
-
- for (Iterator iterator = a.iterator(); iterator.hasNext(); entitytrackerentry1.a(entityplayermp)) {
- entitytrackerentry1 = (EntityTrackerEntry) iterator.next();
- }
- }
- EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.d(entity.g);
-
- if (entitytrackerentry != null) {
- a.remove(((entitytrackerentry)));
- entitytrackerentry.a();
- }
- }
-
- public void a() {
- ArrayList arraylist = new ArrayList();
- Iterator iterator = a.iterator();
-
- do {
- if (!iterator.hasNext()) {
- break;
- }
- EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) iterator.next();
-
- entitytrackerentry.a(c.e.d);
- if (entitytrackerentry.m && (entitytrackerentry.a instanceof EntityPlayerMP)) {
- ((List) (arraylist)).add((((EntityPlayerMP) entitytrackerentry.a)));
- }
- } while (true);
- label0:
- for (int i = 0; i < ((List) (arraylist)).size(); i++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) ((List) (arraylist)).get(i);
- Iterator iterator1 = a.iterator();
-
- do {
- if (!iterator1.hasNext()) {
- continue label0;
- }
- EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry) iterator1.next();
-
- if (entitytrackerentry1.a != entityplayermp) {
- entitytrackerentry1.b(entityplayermp);
- }
- } while (true);
- }
- }
-
- public void a(Entity entity, Packet packet) {
- EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.a(entity.g);
-
- if (entitytrackerentry != null) {
- entitytrackerentry.a(packet);
- }
- }
-
- public void b(Entity entity, Packet packet) {
- EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) b.a(entity.g);
-
- if (entitytrackerentry != null) {
- entitytrackerentry.b(packet);
- }
- }
-
- public void a(EntityPlayerMP entityplayermp) {
- EntityTrackerEntry entitytrackerentry;
-
- for (Iterator iterator = a.iterator(); iterator.hasNext(); entitytrackerentry.c(entityplayermp)) {
- entitytrackerentry = (EntityTrackerEntry) iterator.next();
- }
- }
-}
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
deleted file mode 100644
index 6fdb67e9..00000000
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ /dev/null
@@ -1,252 +0,0 @@
-package net.minecraft.server;
-
-import java.util.*;
-
-public class EntityTrackerEntry {
-
- public Entity a;
- public int b;
- public int c;
- public int d;
- public int e;
- public int f;
- public int g;
- public int h;
- public double i;
- public double j;
- public double k;
- public int l;
- private double o;
- private double p;
- private double q;
- private boolean r;
- private boolean s;
- public boolean m;
- public Set n;
-
- public EntityTrackerEntry(Entity entity, int i1, int j1, boolean flag) {
- l = 0;
- r = false;
- m = false;
- n = ((Set) (new HashSet()));
- a = entity;
- b = i1;
- c = j1;
- s = flag;
- d = MathHelper.b(entity.p * 32D);
- e = MathHelper.b(entity.q * 32D);
- f = MathHelper.b(entity.r * 32D);
- g = MathHelper.d((entity.v * 256F) / 360F);
- h = MathHelper.d((entity.w * 256F) / 360F);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof EntityTrackerEntry) {
- return ((EntityTrackerEntry) obj).a.g == a.g;
- } else {
- return false;
- }
- }
-
- public int hashCode() {
- return a.g;
- }
-
- public void a(List list) {
- m = false;
- if (!r || a.d(o, p, q) > 16D) {
- o = a.p;
- p = a.q;
- q = a.r;
- r = true;
- m = true;
- b(list);
- }
- if (++l % c == 0) {
- int i1 = MathHelper.b(a.p * 32D);
- int j1 = MathHelper.b(a.q * 32D);
- int k1 = MathHelper.b(a.r * 32D);
- int l1 = MathHelper.d((a.v * 256F) / 360F);
- int i2 = MathHelper.d((a.w * 256F) / 360F);
- boolean flag = i1 != d || j1 != e || k1 != f;
- boolean flag1 = l1 != g || i2 != h;
- int j2 = i1 - d;
- int k2 = j1 - e;
- int l2 = k1 - f;
- Object obj = null;
-
- if (j2 < -128 || j2 >= 128 || k2 < -128 || k2 >= 128 || l2 < -128 || l2 >= 128) {
- obj = ((new Packet34EntityTeleport(a.g, i1, j1, k1, (byte) l1, (byte) i2)));
- } else if (flag && flag1) {
- obj = ((new Packet33RelEntityMoveLook(a.g, (byte) j2, (byte) k2, (byte) l2, (byte) l1, (byte) i2)));
- } else if (flag) {
- obj = ((new Packet31RelEntityMove(a.g, (byte) j2, (byte) k2, (byte) l2)));
- } else if (flag1) {
- obj = ((new Packet32EntityLook(a.g, (byte) l1, (byte) i2)));
- } else {
- obj = ((new Packet30Entity(a.g)));
- }
- if (s) {
- double d1 = a.s - i;
- double d2 = a.t - j;
- double d3 = a.u - k;
- double d4 = 0.02D;
- double d5 = d1 * d1 + d2 * d2 + d3 * d3;
-
- if (d5 > d4 * d4 || d5 > 0.0D && a.s == 0.0D && a.t == 0.0D && a.u == 0.0D) {
- i = a.s;
- j = a.t;
- k = a.u;
- a(((Packet) (new Packet28(a.g, i, j, k))));
- }
- }
- if (obj != null) {
- a(((Packet) (obj)));
- }
- DataWatcher datawatcher = a.p();
-
- if (datawatcher.a()) {
- b(((Packet) (new Packet40(a.g, datawatcher))));
- }
- d = i1;
- e = j1;
- f = k1;
- g = l1;
- h = i2;
- }
- if (a.E) {
- b(((Packet) (new Packet28(a))));
- a.E = false;
- }
- }
-
- public void a(Packet packet) {
- EntityPlayerMP entityplayermp;
-
- for (Iterator iterator = n.iterator(); iterator.hasNext(); entityplayermp.a.b(packet)) {
- entityplayermp = (EntityPlayerMP) iterator.next();
- }
- }
-
- public void b(Packet packet) {
- a(packet);
- if (a instanceof EntityPlayerMP) {
- ((EntityPlayerMP) a).a.b(packet);
- }
- }
-
- public void a() {
- a(((Packet) (new Packet29DestroyEntity(a.g))));
- }
-
- public void a(EntityPlayerMP entityplayermp) {
- if (n.contains(((entityplayermp)))) {
- n.remove(((entityplayermp)));
- }
- }
-
- public void b(EntityPlayerMP entityplayermp) {
- if (entityplayermp == a) {
- return;
- }
- double d1 = entityplayermp.p - (double) (d / 32);
- double d2 = entityplayermp.r - (double) (f / 32);
-
- if (d1 >= (double) (-b) && d1 <= (double) b && d2 >= (double) (-b) && d2 <= (double) b) {
- if (!n.contains(((entityplayermp)))) {
- n.add(((entityplayermp)));
- entityplayermp.a.b(b());
- if (s) {
- entityplayermp.a.b(((Packet) (new Packet28(a.g, a.s, a.t, a.u))));
- }
- ItemStack aitemstack[] = a.I();
-
- if (aitemstack != null) {
- for (int i1 = 0; i1 < aitemstack.length; i1++) {
- entityplayermp.a.b(((Packet) (new Packet5PlayerInventory(a.g, i1, aitemstack[i1]))));
- }
- }
- }
- } else if (n.contains(((entityplayermp)))) {
- n.remove(((entityplayermp)));
- entityplayermp.a.b(((Packet) (new Packet29DestroyEntity(a.g))));
- }
- }
-
- public void b(List list) {
- for (int i1 = 0; i1 < list.size(); i1++) {
- b((EntityPlayerMP) list.get(i1));
- }
- }
-
- private Packet b() {
- if (a instanceof EntityItem) {
- EntityItem entityitem = (EntityItem) a;
- Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem);
-
- entityitem.p = (double) packet21pickupspawn.b / 32D;
- entityitem.q = (double) packet21pickupspawn.c / 32D;
- entityitem.r = (double) packet21pickupspawn.d / 32D;
- return ((Packet) (packet21pickupspawn));
- }
- if (a instanceof EntityPlayerMP) {
- return ((Packet) (new Packet20NamedEntitySpawn((EntityPlayer) a)));
- }
- if (a instanceof EntityMinecart) {
- EntityMinecart entityminecart = (EntityMinecart) a;
-
- if (entityminecart.d == 0) {
- return ((Packet) (new Packet23VehicleSpawn(a, 10)));
- }
- if (entityminecart.d == 1) {
- return ((Packet) (new Packet23VehicleSpawn(a, 11)));
- }
- if (entityminecart.d == 2) {
- return ((Packet) (new Packet23VehicleSpawn(a, 12)));
- }
- }
- if (a instanceof EntityBoat) {
- return ((Packet) (new Packet23VehicleSpawn(a, 1)));
- }
- if (a instanceof IAnimals) {
- return ((Packet) (new Packet24MobSpawn((EntityLiving) a)));
- }
- if (a instanceof EntityFish) {
- return ((Packet) (new Packet23VehicleSpawn(a, 90)));
- }
- if (a instanceof EntityArrow) {
- return ((Packet) (new Packet23VehicleSpawn(a, 60)));
- }
- if (a instanceof EntitySnowball) {
- return ((Packet) (new Packet23VehicleSpawn(a, 61)));
- }
- if (a instanceof EntityEgg) {
- return ((Packet) (new Packet23VehicleSpawn(a, 62)));
- }
- if (a instanceof EntityTNTPrimed) {
- return ((Packet) (new Packet23VehicleSpawn(a, 50)));
- }
- if (a instanceof EntityFallingSand) {
- EntityFallingSand entityfallingsand = (EntityFallingSand) a;
-
- if (entityfallingsand.a == Block.E.bi) {
- return ((Packet) (new Packet23VehicleSpawn(a, 70)));
- }
- if (entityfallingsand.a == Block.F.bi) {
- return ((Packet) (new Packet23VehicleSpawn(a, 71)));
- }
- }
- if (a instanceof EntityPainting) {
- return ((Packet) (new Packet25((EntityPainting) a)));
- } else {
- throw new IllegalArgumentException((new StringBuilder()).append("Don't know how to add ").append(((((a)).getClass()))).append("!").toString());
- }
- }
-
- public void c(EntityPlayerMP entityplayermp) {
- if (n.contains(((entityplayermp)))) {
- n.remove(((entityplayermp)));
- entityplayermp.a.b(((Packet) (new Packet29DestroyEntity(a.g))));
- }
- }
-}
diff --git a/src/main/java/net/minecraft/server/EntityWaterMob.java b/src/main/java/net/minecraft/server/EntityWaterAnimal.java
index bc8c5feb..cf9c3bfa 100644
--- a/src/main/java/net/minecraft/server/EntityWaterMob.java
+++ b/src/main/java/net/minecraft/server/EntityWaterAnimal.java
@@ -5,12 +5,13 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.CraftWaterMob;
// CraftBukkit stop
-public class EntityWaterMob extends EntityCreature implements IAnimals {
+public class EntityWaterAnimal extends EntityCreature implements IAnimal {
- public EntityWaterMob(World world) {
+ public EntityWaterAnimal(World world) {
super(world);
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftWaterMob(server, this);
// CraftBukkit end
}
@@ -28,7 +29,7 @@ public class EntityWaterMob extends EntityCreature implements IAnimals {
}
public boolean b() {
- return l.a(z);
+ return this.world.a(this.boundingBox);
}
public int c() {
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index cae35d82..3a9fad59 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -7,34 +7,36 @@ import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityCombustEvent;
// CraftBukkit end
-public class EntityZombie extends EntityMobs {
+public class EntityZombie extends EntityMonster {
public EntityZombie(World world) {
super(world);
- aP = "/mob/zombie.png";
- bC = 0.5F;
- c = 5;
+ this.texture = "/mob/zombie.png";
+ this.bC = 0.5F;
+ this.c = 5;
+
// CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
this.bukkitEntity = new CraftZombie(server, this);
// CraftBukkit end
}
public void o() {
- if (l.b()) {
- float f1 = b(1.0F);
+ if (this.world.b()) {
+ float f = this.b(1.0F);
- if (f1 > 0.5F && l.i(MathHelper.b(p), MathHelper.b(q), MathHelper.b(r)) && W.nextFloat() * 30F < (f1 - 0.4F) * 2.0F) {
+ if (f > 0.5F && this.world.i(MathHelper.b(this.locX), MathHelper.b(this.locY), MathHelper.b(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
// CraftBukkit start
- CraftServer server = ((WorldServer) l).getServer();
+ CraftServer server = ((WorldServer) this.world).getServer();
EntityCombustEvent event = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity());
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- Z = 300;
+ this.fireTicks = 300;
}
// CraftBukkit end
}
}
+
super.o();
}
@@ -51,6 +53,6 @@ public class EntityZombie extends EntityMobs {
}
protected int h() {
- return Item.J.ba;
+ return Item.FEATHER.id;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityZombieSimple.java b/src/main/java/net/minecraft/server/EntityZombieSimple.java
deleted file mode 100644
index 7fcbf6a4..00000000
--- a/src/main/java/net/minecraft/server/EntityZombieSimple.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package net.minecraft.server;
-
-// CraftBukkit start
-import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.entity.CraftGiant;
-// CraftBukkit stop
-
-public class EntityZombieSimple extends EntityMobs {
-
- public EntityZombieSimple(World world) {
- super(world);
- aP = "/mob/zombie.png";
- bC = 0.5F;
- c = 50;
- aZ *= 10;
- H *= 6F;
- a(I * 6F, J * 6F);
- // CraftBukkit start
- CraftServer server = ((WorldServer) this.l).getServer();
- this.bukkitEntity = new CraftGiant(server, this);
- // CraftBukkit end
- }
-
- protected float a(int i, int j, int k) {
- return l.l(i, j, k) - 0.5F;
- }
-}
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index 3344eb35..3dd9a4fd 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -1,127 +1,127 @@
package net.minecraft.server;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
// CraftBukkit start
import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
-
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
-
import org.bukkit.Location;
-
// CraftBukkit end
-import java.util.*;
-
public class Explosion {
- public boolean a;
- private Random h;
+ public boolean a = false;
+ private Random h = new Random();
private World i;
public double b;
public double c;
public double d;
public Entity e;
public float f;
- public Set g;
-
- public Explosion(World world, Entity entity, double d1, double d2, double d3, float f1) {
- a = false;
- h = new Random();
- g = ((Set) (new HashSet()));
- i = world;
- e = entity;
- f = f1;
- b = d1;
- c = d2;
- d = d3;
-
+ public Set g = new HashSet();
+
+ public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) {
+ this.i = world;
+ this.e = entity;
+ this.f = f;
+ this.b = d0;
+ this.c = d1;
+ this.d = d2;
}
public void a() {
- float f1 = f;
- int j = 16;
-
- for (int k = 0; k < j; k++) {
- for (int i1 = 0; i1 < j; i1++) {
- label0:
- for (int k1 = 0; k1 < j; k1++) {
- if (k != 0 && k != j - 1 && i1 != 0 && i1 != j - 1 && k1 != 0 && k1 != j - 1) {
- continue;
- }
- double d1 = ((float) k / ((float) j - 1.0F)) * 2.0F - 1.0F;
- double d2 = ((float) i1 / ((float) j - 1.0F)) * 2.0F - 1.0F;
- double d3 = ((float) k1 / ((float) j - 1.0F)) * 2.0F - 1.0F;
- double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
-
- d1 /= d4;
- d2 /= d4;
- d3 /= d4;
- float f2 = f * (0.7F + i.l.nextFloat() * 0.6F);
- double d5 = b;
- double d7 = c;
- double d9 = d;
- float f3 = 0.3F;
-
- do {
- if (f2 <= 0.0F) {
- continue label0;
+ float f = this.f;
+ byte b0 = 16;
+
+ int i;
+ int j;
+ int k;
+ double d0;
+ double d1;
+ double d2;
+
+ for (i = 0; i < b0; ++i) {
+ for (j = 0; j < b0; ++j) {
+ for (k = 0; k < b0; ++k) {
+ if (i == 0 || i == b0 - 1 || j == 0 || j == b0 - 1 || k == 0 || k == b0 - 1) {
+ double d3 = (double) ((float) i / ((float) b0 - 1.0F) * 2.0F - 1.0F);
+ double d4 = (double) ((float) j / ((float) b0 - 1.0F) * 2.0F - 1.0F);
+ double d5 = (double) ((float) k / ((float) b0 - 1.0F) * 2.0F - 1.0F);
+ double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
+
+ d3 /= d6;
+ d4 /= d6;
+ d5 /= d6;
+ float f1 = this.f * (0.7F + this.i.l.nextFloat() * 0.6F);
+
+ d0 = this.b;
+ d1 = this.c;
+ d2 = this.d;
+
+ for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
+ int l = MathHelper.b(d0);
+ int i1 = MathHelper.b(d1);
+ int j1 = MathHelper.b(d2);
+ int k1 = this.i.getTypeId(l, i1, j1);
+
+ if (k1 > 0) {
+ f1 -= (Block.byId[k1].a(this.e) + 0.3F) * f2;
+ }
+
+ if (f1 > 0.0F) {
+ this.g.add(new ChunkPosition(l, i1, j1));
+ }
+
+ d0 += d3 * (double) f2;
+ d1 += d4 * (double) f2;
+ d2 += d5 * (double) f2;
}
- int j2 = MathHelper.b(d5);
- int k2 = MathHelper.b(d7);
- int l2 = MathHelper.b(d9);
- int i3 = i.a(j2, k2, l2);
-
- if (i3 > 0) {
- f2 -= (Block.m[i3].a(e) + 0.3F) * f3;
- }
- if (f2 > 0.0F) {
- g.add(((new ChunkPosition(j2, k2, l2))));
- }
- d5 += d1 * (double) f3;
- d7 += d2 * (double) f3;
- d9 += d3 * (double) f3;
- f2 -= f3 * 0.75F;
- } while (true);
+ }
}
}
}
- f *= 2.0F;
- int l = MathHelper.b(b - (double) f - 1.0D);
- int j1 = MathHelper.b(b + (double) f + 1.0D);
- int l1 = MathHelper.b(c - (double) f - 1.0D);
- int j3 = MathHelper.b(c + (double) f + 1.0D);
- int k3 = MathHelper.b(d - (double) f - 1.0D);
- int l3 = MathHelper.b(d + (double) f + 1.0D);
- List list = i.b(e, AxisAlignedBB.b(l, l1, k3, j1, j3, l3));
- Vec3D vec3d = Vec3D.b(b, c, d);
-
- for (int i4 = 0; i4 < list.size(); i4++) {
- Entity entity = (Entity) list.get(i4);
- double d11 = entity.e(b, c, d) / (double) f;
-
- if (d11 <= 1.0D) {
- double d6 = entity.p - b;
- double d8 = entity.q - c;
- double d10 = entity.r - d;
- double d12 = MathHelper.a(d6 * d6 + d8 * d8 + d10 * d10);
-
- d6 /= d12;
- d8 /= d12;
- d10 /= d12;
- double d13 = i.a(vec3d, entity.z);
- double d14 = (1.0D - d11) * d13;
+ this.f *= 2.0F;
+ i = MathHelper.b(this.b - (double) this.f - 1.0D);
+ j = MathHelper.b(this.b + (double) this.f + 1.0D);
+ k = MathHelper.b(this.c - (double) this.f - 1.0D);
+ int l1 = MathHelper.b(this.c + (double) this.f + 1.0D);
+ int i2 = MathHelper.b(this.d - (double) this.f - 1.0D);
+ int j2 = MathHelper.b(this.d + (double) this.f + 1.0D);
+ List list = this.i.b(this.e, AxisAlignedBB.b((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2));
+ Vec3D vec3d = Vec3D.b(this.b, this.c, this.d);
+
+ for (int k2 = 0; k2 < list.size(); ++k2) {
+ Entity entity = (Entity) list.get(k2);
+ double d7 = entity.e(this.b, this.c, this.d) / (double) this.f;
+
+ if (d7 <= 1.0D) {
+ d0 = entity.locX - this.b;
+ d1 = entity.locY - this.c;
+ d2 = entity.locZ - this.d;
+ double d8 = (double) MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2);
+
+ d0 /= d8;
+ d1 /= d8;
+ d2 /= d8;
+ double d9 = (double) this.i.a(vec3d, entity.boundingBox);
+ double d10 = (1.0D - d7) * d9;
// CraftBukkit start - explosion damage hook
- CraftServer server = ((WorldServer) i).getServer();
- org.bukkit.entity.Entity damagee = (entity == null)?null:entity.getBukkitEntity();
+ CraftServer server = ((WorldServer) this.i).getServer();
+ org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity();
DamageCause damageType;
- int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D);
+ int damageDone = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * (double) this.f + 1.0D);
if(damagee == null){
// nothing was hurt
@@ -129,62 +129,61 @@ public class Explosion {
// TODO: get the x/y/z of the tnt block?
// does this even get called ever? @see EntityTNTPrimed - not BlockTNT or whatever
damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION;
- EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(edbbe);
- if (!edbbe.isCancelled()) {
- entity.a(e, edbbe.getDamage());
+ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ entity.a(this.e, event.getDamage());
}
} else {
- org.bukkit.entity.Entity damager = e.getBukkitEntity();
+ org.bukkit.entity.Entity damager = this.e.getBukkitEntity();
damageType = EntityDamageEvent.DamageCause.ENTITY_EXPLOSION;
-
- EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
- server.getPluginManager().callEvent(edbbe);
- if (!edbbe.isCancelled()) {
- entity.a(e, edbbe.getDamage());
- double d15 = d14;
+ EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone);
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.a(this.e, event.getDamage());
- entity.s += d6 * d15;
- entity.t += d8 * d15;
- entity.u += d10 * d15;
+ entity.motX += d0 * d10;
+ entity.motY += d1 * d10;
+ entity.motZ += d2 * d10;
}
}
// CraftBukkit end
}
}
- f = f1;
+ this.f = f;
ArrayList arraylist = new ArrayList();
- ((List) (arraylist)).addAll(((java.util.Collection) (g)));
- if (a) {
- for (int j4 = ((List) (arraylist)).size() - 1; j4 >= 0; j4--) {
- ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(j4);
- int i2 = chunkposition.a;
- int k4 = chunkposition.b;
- int l4 = chunkposition.c;
- int i5 = i.a(i2, k4, l4);
- int j5 = i.a(i2, k4 - 1, l4);
-
- if (i5 == 0 && Block.o[j5] && h.nextInt(3) == 0) {
- i.e(i2, k4, l4, Block.ar.bi);
+ arraylist.addAll(this.g);
+ if (this.a) {
+ for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
+ ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
+ int i3 = chunkposition.a;
+ int j3 = chunkposition.b;
+ int k3 = chunkposition.c;
+ int l3 = this.i.getTypeId(i3, j3, k3);
+ int i4 = this.i.getTypeId(i3, j3 - 1, k3);
+
+ if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) {
+ this.i.e(i3, j3, k3, Block.FIRE.id);
}
}
}
}
public void b() {
- i.a(b, c, d, "random.explode", 4F, (1.0F + (i.l.nextFloat() - i.l.nextFloat()) * 0.2F) * 0.7F);
+ this.i.a(this.b, this.c, this.d, "random.explode", 4.0F, (1.0F + (this.i.l.nextFloat() - this.i.l.nextFloat()) * 0.2F) * 0.7F);
ArrayList arraylist = new ArrayList();
- ((List) (arraylist)).addAll(((java.util.Collection) (g)));
+ arraylist.addAll(this.g);
// CraftBukkit start
- Server server = ((WorldServer) i).getServer();
- CraftWorld world = ((WorldServer) i).getWorld();
- org.bukkit.entity.Entity splode = (e == null) ? null : e.getBukkitEntity();
- Location location = new Location(world, b, c, d);
+ Server server = ((WorldServer) this.i).getServer();
+ CraftWorld world = ((WorldServer) this.i).getWorld();
+ org.bukkit.entity.Entity splode = (this.e == null) ? null : this.e.getBukkitEntity();
+ Location location = new Location(world, this.b, this.c, this.d);
List<org.bukkit.block.Block> blocklist = new ArrayList<org.bukkit.block.Block>();
for (int j = arraylist.size() - 1; j >= 0; j--) {
@@ -194,48 +193,49 @@ public class Explosion {
blocklist.add(blox);
}
}
-
+
org.bukkit.event.Event.Type eventType = EntityExplodeEvent.Type.ENTITY_EXPLODE;
- EntityExplodeEvent eee = new EntityExplodeEvent(eventType, splode, location, blocklist);
- server.getPluginManager().callEvent(eee);
-
- if (eee.isCancelled()) {
+ EntityExplodeEvent event = new EntityExplodeEvent(eventType, splode, location, blocklist);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
return;
}
// CraftBukkit end
- for (int j = ((List) (arraylist)).size() - 1; j >= 0; j--) {
- ChunkPosition chunkposition = (ChunkPosition) ((List) (arraylist)).get(j);
- int k = chunkposition.a;
- int l = chunkposition.b;
- int i1 = chunkposition.c;
- int j1 = i.a(k, l, i1);
-
- for (int k1 = 0; k1 < 1; k1++) {
- double d1 = (float) k + i.l.nextFloat();
- double d2 = (float) l + i.l.nextFloat();
- double d3 = (float) i1 + i.l.nextFloat();
- double d4 = d1 - b;
- double d5 = d2 - c;
- double d6 = d3 - d;
- double d7 = MathHelper.a(d4 * d4 + d5 * d5 + d6 * d6);
-
- d4 /= d7;
- d5 /= d7;
- d6 /= d7;
- double d8 = 0.5D / (d7 / (double) f + 0.10000000000000001D);
-
- d8 *= i.l.nextFloat() * i.l.nextFloat() + 0.3F;
- d4 *= d8;
- d5 *= d8;
- d6 *= d8;
- i.a("explode", (d1 + b * 1.0D) / 2D, (d2 + c * 1.0D) / 2D, (d3 + d * 1.0D) / 2D, d4, d5, d6);
- i.a("smoke", d1, d2, d3, d4, d5, d6);
+
+ for (int i = arraylist.size() - 1; i >= 0; --i) {
+ ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i);
+ int j = chunkposition.a;
+ int k = chunkposition.b;
+ int l = chunkposition.c;
+ int i1 = this.i.getTypeId(j, k, l);
+
+ for (int j1 = 0; j1 < 1; ++j1) {
+ double d0 = (double) ((float) j + this.i.l.nextFloat());
+ double d1 = (double) ((float) k + this.i.l.nextFloat());
+ double d2 = (double) ((float) l + this.i.l.nextFloat());
+ double d3 = d0 - this.b;
+ double d4 = d1 - this.c;
+ double d5 = d2 - this.d;
+ double d6 = (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5);
+
+ d3 /= d6;
+ d4 /= d6;
+ d5 /= d6;
+ double d7 = 0.5D / (d6 / (double) this.f + 0.1D);
+
+ d7 *= (double) (this.i.l.nextFloat() * this.i.l.nextFloat() + 0.3F);
+ d3 *= d7;
+ d4 *= d7;
+ d5 *= d7;
+ this.i.a("explode", (d0 + this.b * 1.0D) / 2.0D, (d1 + this.c * 1.0D) / 2.0D, (d2 + this.d * 1.0D) / 2.0D, d3, d4, d5);
+ this.i.a("smoke", d0, d1, d2, d3, d4, d5);
}
- if (j1 > 0) {
- Block.m[j1].a(i, k, l, i1, i.b(k, l, i1), 0.3F);
- i.e(k, l, i1, 0);
- Block.m[j1].a_(i, k, l, i1);
+ if (i1 > 0) {
+ Block.byId[i1].a(this.i, j, k, l, this.i.getData(j, k, l), 0.3F);
+ this.i.e(j, k, l, 0);
+ Block.byId[i1].a_(this.i, j, k, l);
}
}
}
diff --git a/src/main/java/net/minecraft/server/IInventory.java b/src/main/java/net/minecraft/server/IInventory.java
index f5e830ef..27d44762 100644
--- a/src/main/java/net/minecraft/server/IInventory.java
+++ b/src/main/java/net/minecraft/server/IInventory.java
@@ -1,22 +1,22 @@
-package net.minecraft.server;
-
-public interface IInventory {
-
- public abstract int h_();
-
- public abstract ItemStack a(int i);
-
- public abstract ItemStack b(int i, int j);
-
- public abstract void a(int i, ItemStack itemstack);
-
- public abstract String b();
-
- public abstract int c();
-
- public abstract void d();
-
- public abstract boolean a_(EntityPlayer entityplayer);
-
- public abstract ItemStack[] getContents(); // CraftBukkit
-}
+package net.minecraft.server;
+
+public interface IInventory {
+
+ int h_();
+
+ ItemStack a(int i);
+
+ ItemStack b(int i, int j);
+
+ void a(int i, ItemStack itemstack);
+
+ String b();
+
+ int c();
+
+ void d();
+
+ boolean a_(EntityHuman entityhuman);
+
+ public abstract ItemStack[] getContents(); // CraftBukkit
+}
diff --git a/src/main/java/net/minecraft/server/InventoryCraftResult.java b/src/main/java/net/minecraft/server/InventoryCraftResult.java
index 208c1a4c..12a06285 100644
--- a/src/main/java/net/minecraft/server/InventoryCraftResult.java
+++ b/src/main/java/net/minecraft/server/InventoryCraftResult.java
@@ -1,53 +1,51 @@
-package net.minecraft.server;
-
-public class InventoryCraftResult implements IInventory {
-
- private ItemStack a[];
-
- // CraftBukkit start
- public ItemStack[] getContents() {
- return a;
- }
- // CraftBukkit end
-
- public InventoryCraftResult() {
- a = new ItemStack[1];
- }
-
- public int h_() {
- return 1;
- }
-
- public ItemStack a(int i) {
- return a[i];
- }
-
- public String b() {
- return "Result";
- }
-
- public ItemStack b(int i, int j) {
- if (a[i] != null) {
- ItemStack itemstack = a[i];
-
- a[i] = null;
- return itemstack;
- } else {
- return null;
- }
- }
-
- public void a(int i, ItemStack itemstack) {
- a[i] = itemstack;
- }
-
- public int c() {
- return 64;
- }
-
- public void d() {}
-
- public boolean a_(EntityPlayer entityplayer) {
- return true;
- }
-}
+package net.minecraft.server;
+
+public class InventoryCraftResult implements IInventory {
+
+ private ItemStack[] a = new ItemStack[1];
+
+ // CraftBukkit start
+ public ItemStack[] getContents() {
+ return a;
+ }
+ // CraftBukkit end
+
+ public InventoryCraftResult() {}
+
+ public int h_() {
+ return 1;
+ }
+
+ public ItemStack a(int i) {
+ return this.a[i];
+ }
+
+ public String b() {
+ return "Result";
+ }
+
+ public ItemStack b(int i, int j) {
+ if (this.a[i] != null) {
+ ItemStack itemstack = this.a[i];
+
+ this.a[i] = null;
+ return itemstack;
+ } else {
+ return null;
+ }
+ }
+
+ public void a(int i, ItemStack itemstack) {
+ this.a[i] = itemstack;
+ }
+
+ public int c() {
+ return 64;
+ }
+
+ public void d() {}
+
+ public boolean a_(EntityHuman entityhuman) {
+ return true;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/InventoryCrafting.java b/src/main/java/net/minecraft/server/InventoryCrafting.java
index aa49ed42..31a58c49 100644
--- a/src/main/java/net/minecraft/server/InventoryCrafting.java
+++ b/src/main/java/net/minecraft/server/InventoryCrafting.java
@@ -1,84 +1,82 @@
-package net.minecraft.server;
-
-public class InventoryCrafting implements IInventory {
-
- private ItemStack a[];
- private int b;
- private CraftingInventoryCB c;
-
- // CraftBukkit start
- public ItemStack[] getContents() {
- return a;
- }
- // CraftBukkit end
-
- public InventoryCrafting(CraftingInventoryCB craftinginventorycb, int i, int j) {
- int k = i * j;
-
- a = new ItemStack[k];
- c = craftinginventorycb;
- b = i;
- }
-
- public int h_() {
- return a.length;
- }
-
- public ItemStack a(int i) {
- if (i >= h_()) {
- return null;
- } else {
- return a[i];
- }
- }
-
- public ItemStack a(int i, int j) {
- if (i < 0 || i >= b) {
- return null;
- } else {
- int k = i + j * b;
-
- return a(k);
- }
- }
-
- public String b() {
- return "Crafting";
- }
-
- public ItemStack b(int i, int j) {
- if (a[i] != null) {
- if (a[i].a <= j) {
- ItemStack itemstack = a[i];
-
- a[i] = null;
- c.a(((IInventory) (this)));
- return itemstack;
- }
- ItemStack itemstack1 = a[i].a(j);
-
- if (a[i].a == 0) {
- a[i] = null;
- }
- c.a(((IInventory) (this)));
- return itemstack1;
- } else {
- return null;
- }
- }
-
- public void a(int i, ItemStack itemstack) {
- a[i] = itemstack;
- c.a(((IInventory) (this)));
- }
-
- public int c() {
- return 64;
- }
-
- public void d() {}
-
- public boolean a_(EntityPlayer entityplayer) {
- return true;
- }
-}
+package net.minecraft.server;
+
+public class InventoryCrafting implements IInventory {
+
+ private ItemStack[] a;
+ private int b;
+ private Container c;
+
+ // CraftBukkit start
+ public ItemStack[] getContents() {
+ return a;
+ }
+ // CraftBukkit end
+
+ public InventoryCrafting(Container container, int i, int j) {
+ int k = i * j;
+
+ this.a = new ItemStack[k];
+ this.c = container;
+ this.b = i;
+ }
+
+ public int h_() {
+ return this.a.length;
+ }
+
+ public ItemStack a(int i) {
+ return i >= this.h_() ? null : this.a[i];
+ }
+
+ public ItemStack a(int i, int j) {
+ if (i >= 0 && i < this.b) {
+ int k = i + j * this.b;
+
+ return this.a(k);
+ } else {
+ return null;
+ }
+ }
+
+ public String b() {
+ return "Crafting";
+ }
+
+ public ItemStack b(int i, int j) {
+ if (this.a[i] != null) {
+ ItemStack itemstack;
+
+ if (this.a[i].count <= j) {
+ itemstack = this.a[i];
+ this.a[i] = null;
+ this.c.a((IInventory) this);
+ return itemstack;
+ } else {
+ itemstack = this.a[i].a(j);
+ if (this.a[i].count == 0) {
+ this.a[i] = null;
+ }
+
+ this.c.a((IInventory) this);
+ return itemstack;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public void a(int i, ItemStack itemstack) {
+ this.a[i] = itemstack;
+ this.c.a((IInventory) this);
+ }
+
+ public int c() {
+ return 64;
+ }
+
+ public void d() {}
+
+ public boolean a_(EntityHuman entityhuman) {
+ return true;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/InventoryLargeChest.java b/src/main/java/net/minecraft/server/InventoryLargeChest.java
index a766cb4f..bf2ba365 100644
--- a/src/main/java/net/minecraft/server/InventoryLargeChest.java
+++ b/src/main/java/net/minecraft/server/InventoryLargeChest.java
@@ -1,69 +1,61 @@
-package net.minecraft.server;
-
-public class InventoryLargeChest implements IInventory {
-
- private String a;
- private IInventory b;
- private IInventory c;
-
- // CraftBukkit start
- public ItemStack[] getContents() {
- ItemStack[] result = new ItemStack[h_()];
- for (int i = 0; i < result.length; i++) {
- result[i] = a(i);
- }
- return result;
- }
- // CraftBukkit end
-
- public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
- a = s;
- b = iinventory;
- c = iinventory1;
- }
-
- public int h_() {
- return b.h_() + c.h_();
- }
-
- public String b() {
- return a;
- }
-
- public ItemStack a(int i) {
- if (i >= b.h_()) {
- return c.a(i - b.h_());
- } else {
- return b.a(i);
- }
- }
-
- public ItemStack b(int i, int j) {
- if (i >= b.h_()) {
- return c.b(i - b.h_(), j);
- } else {
- return b.b(i, j);
- }
- }
-
- public void a(int i, ItemStack itemstack) {
- if (i >= b.h_()) {
- c.a(i - b.h_(), itemstack);
- } else {
- b.a(i, itemstack);
- }
- }
-
- public int c() {
- return b.c();
- }
-
- public void d() {
- b.d();
- c.d();
- }
-
- public boolean a_(EntityPlayer entityplayer) {
- return b.a_(entityplayer) && c.a_(entityplayer);
- }
-}
+package net.minecraft.server;
+
+public class InventoryLargeChest implements IInventory {
+
+ private String a;
+ private IInventory b;
+ private IInventory c;
+
+ // CraftBukkit start
+ public ItemStack[] getContents() {
+ ItemStack[] result = new ItemStack[h_()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = a(i);
+ }
+ return result;
+ }
+ // CraftBukkit end
+
+ public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
+ this.a = s;
+ this.b = iinventory;
+ this.c = iinventory1;
+ }
+
+ public int h_() {
+ return this.b.h_() + this.c.h_();
+ }
+
+ public String b() {
+ return this.a;
+ }
+
+ public ItemStack a(int i) {
+ return i >= this.b.h_() ? this.c.a(i - this.b.h_()) : this.b.a(i);
+ }
+
+ public ItemStack b(int i, int j) {
+ return i >= this.b.h_() ? this.c.b(i - this.b.h_(), j) : this.b.b(i, j);
+ }
+
+ public void a(int i, ItemStack itemstack) {
+ if (i >= this.b.h_()) {
+ this.c.a(i - this.b.h_(), itemstack);
+ } else {
+ this.b.a(i, itemstack);
+ }
+ }
+
+ public int c() {
+ return this.b.c();
+ }
+
+ public void d() {
+ this.b.d();
+ this.c.d();
+ }
+
+ public boolean a_(EntityHuman entityhuman) {
+ return this.b.a_(entityhuman) && this.c.a_(entityhuman);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/InventoryPlayer.java b/src/main/java/net/minecraft/server/InventoryPlayer.java
index 531ba841..6867dcd5 100644
--- a/src/main/java/net/minecraft/server/InventoryPlayer.java
+++ b/src/main/java/net/minecraft/server/InventoryPlayer.java
@@ -1,342 +1,344 @@
-package net.minecraft.server;
-
-public class InventoryPlayer implements IInventory {
-
- public ItemStack a[];
- public ItemStack b[];
- public int c;
- private EntityPlayer e;
- private ItemStack f;
- public boolean d;
-
- // CraftBukkit start
- public ItemStack[] getContents() {
- return a;
- }
-
- public ItemStack[] getArmorContents() {
- return b;
- }
- // CraftBukkit end
-
- public InventoryPlayer(EntityPlayer entityplayer) {
- a = new ItemStack[36];
- b = new ItemStack[4];
- c = 0;
- d = false;
- e = entityplayer;
- }
-
- public ItemStack e() {
- return a[c];
- }
-
- private int d(int k) {
- for (int l = 0; l < a.length; l++) {
- if (a[l] != null && a[l].c == k) {
- return l;
- }
- }
-
- return -1;
- }
-
- private int c(ItemStack itemstack) {
- for (int k = 0; k < a.length; k++) {
- if (a[k] != null && a[k].c == itemstack.c && a[k].c() && a[k].a < a[k].b() && a[k].a < c() && (!a[k].e() || a[k].h() == itemstack.h())) {
- return k;
- }
- }
-
- return -1;
- }
-
- private int j() {
- for (int k = 0; k < a.length; k++) {
- if (a[k] == null) {
- return k;
- }
- }
-
- return -1;
- }
-
- private int d(ItemStack itemstack) {
- int k = itemstack.c;
- int l = itemstack.a;
- int i1 = c(itemstack);
-
- if (i1 < 0) {
- i1 = j();
- }
- if (i1 < 0) {
- return l;
- }
- if (a[i1] == null) {
- a[i1] = new ItemStack(k, 0, itemstack.h());
- }
- int j1 = l;
-
- if (j1 > a[i1].b() - a[i1].a) {
- j1 = a[i1].b() - a[i1].a;
- }
- if (j1 > c() - a[i1].a) {
- j1 = c() - a[i1].a;
- }
- if (j1 == 0) {
- return l;
- } else {
- l -= j1;
- a[i1].a += j1;
- a[i1].b = 5;
- return l;
- }
- }
-
- public void f() {
- for (int k = 0; k < a.length; k++) {
- if (a[k] != null && a[k].b > 0) {
- a[k].b--;
- }
- }
- }
-
- public boolean b(int k) {
- int l = d(k);
-
- if (l < 0) {
- return false;
- }
- if (--a[l].a <= 0) {
- a[l] = null;
- }
- return true;
- }
-
- public boolean a(ItemStack itemstack) {
- if (!itemstack.f()) {
- itemstack.a = d(itemstack);
- if (itemstack.a == 0) {
- return true;
- }
- }
- int k = j();
-
- if (k >= 0) {
- a[k] = itemstack;
- a[k].b = 5;
- return true;
- } else {
- return false;
- }
- }
-
- public ItemStack b(int k, int l) {
- ItemStack aitemstack[] = a;
-
- if (k >= a.length) {
- aitemstack = b;
- k -= a.length;
- }
- if (aitemstack[k] != null) {
- if (aitemstack[k].a <= l) {
- ItemStack itemstack = aitemstack[k];
-
- aitemstack[k] = null;
- return itemstack;
- }
- ItemStack itemstack1 = aitemstack[k].a(l);
-
- if (aitemstack[k].a == 0) {
- aitemstack[k] = null;
- }
- return itemstack1;
- } else {
- return null;
- }
- }
-
- public void a(int k, ItemStack itemstack) {
- ItemStack aitemstack[] = a;
-
- if (k >= aitemstack.length) {
- k -= aitemstack.length;
- aitemstack = b;
- }
- aitemstack[k] = itemstack;
- }
-
- public float a(Block block) {
- float f1 = 1.0F;
-
- if (a[c] != null) {
- f1 *= a[c].a(block);
- }
- return f1;
- }
-
- public NBTTagList a(NBTTagList nbttaglist) {
- for (int k = 0; k < a.length; k++) {
- if (a[k] != null) {
- NBTTagCompound nbttagcompound = new NBTTagCompound();
-
- nbttagcompound.a("Slot", (byte) k);
- a[k].a(nbttagcompound);
- nbttaglist.a(((NBTBase) (nbttagcompound)));
- }
- }
-
- for (int l = 0; l < b.length; l++) {
- if (b[l] != null) {
- NBTTagCompound nbttagcompound1 = new NBTTagCompound();
-
- nbttagcompound1.a("Slot", (byte) (l + 100));
- b[l].a(nbttagcompound1);
- nbttaglist.a(((NBTBase) (nbttagcompound1)));
- }
- }
-
- return nbttaglist;
- }
-
- public void b(NBTTagList nbttaglist) {
- a = new ItemStack[36];
- b = new ItemStack[4];
- for (int k = 0; k < nbttaglist.b(); k++) {
- NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(k);
- int l = nbttagcompound.b("Slot") & 0xff;
- ItemStack itemstack = new ItemStack(nbttagcompound);
-
- if (itemstack.a() == null) {
- continue;
- }
- if (l >= 0 && l < a.length) {
- a[l] = itemstack;
- }
- if (l >= 100 && l < b.length + 100) {
- b[l - 100] = itemstack;
- }
- }
- }
-
- public int h_() {
- return a.length + 4;
- }
-
- public ItemStack a(int k) {
- ItemStack aitemstack[] = a;
-
- if (k >= aitemstack.length) {
- k -= aitemstack.length;
- aitemstack = b;
- }
- return aitemstack[k];
- }
-
- public String b() {
- return "Inventory";
- }
-
- public int c() {
- return 64;
- }
-
- public int a(Entity entity) {
- ItemStack itemstack = a(c);
-
- if (itemstack != null) {
- return itemstack.a(entity);
- } else {
- return 1;
- }
- }
-
- public boolean b(Block block) {
- if (block.bt != Material.d && block.bt != Material.e && block.bt != Material.t && block.bt != Material.s) {
- return true;
- }
- ItemStack itemstack = a(c);
-
- if (itemstack != null) {
- return itemstack.b(block);
- } else {
- return false;
- }
- }
-
- public int g() {
- int k = 0;
- int l = 0;
- int i1 = 0;
-
- for (int j1 = 0; j1 < b.length; j1++) {
- if (b[j1] != null && (b[j1].a() instanceof ItemArmor)) {
- int k1 = b[j1].i();
- int l1 = b[j1].g();
- int i2 = k1 - l1;
-
- l += i2;
- i1 += k1;
- int j2 = ((ItemArmor) b[j1].a()).bh;
-
- k += j2;
- }
- }
-
- if (i1 == 0) {
- return 0;
- } else {
- return ((k - 1) * l) / i1 + 1;
- }
- }
-
- public void c(int k) {
- for (int l = 0; l < b.length; l++) {
- if (b[l] == null || !(b[l].a() instanceof ItemArmor)) {
- continue;
- }
- b[l].b(k);
- if (b[l].a == 0) {
- b[l].a(e);
- b[l] = null;
- }
- }
-
- }
-
- public void h() {
- for (int k = 0; k < a.length; k++) {
- if (a[k] != null) {
- e.a(a[k], true);
- a[k] = null;
- }
- }
-
- for (int l = 0; l < b.length; l++) {
- if (b[l] != null) {
- e.a(b[l], true);
- b[l] = null;
- }
- }
- }
-
- public void d() {
- d = true;
- }
-
- public void b(ItemStack itemstack) {
- f = itemstack;
- e.a(itemstack);
- }
-
- public ItemStack i() {
- return f;
- }
-
- public boolean a_(EntityPlayer entityplayer) {
- if (e.G) {
- return false;
- }
- return entityplayer.b(((Entity) (e))) <= 64D;
- }
-}
+package net.minecraft.server;
+
+public class InventoryPlayer implements IInventory {
+
+ public ItemStack[] a = new ItemStack[36];
+ public ItemStack[] b = new ItemStack[4];
+ public int c = 0;
+ private EntityHuman e;
+ private ItemStack f;
+ public boolean d = false;
+
+ // CraftBukkit start
+ public ItemStack[] getContents() {
+ return a;
+ }
+
+ public ItemStack[] getArmorContents() {
+ return b;
+ }
+ // CraftBukkit end
+
+ public InventoryPlayer(EntityHuman entityhuman) {
+ this.e = entityhuman;
+ }
+
+ public ItemStack e() {
+ return this.a[this.c];
+ }
+
+ private int d(int i) {
+ for (int j = 0; j < this.a.length; ++j) {
+ if (this.a[j] != null && this.a[j].id == i) {
+ return j;
+ }
+ }
+
+ return -1;
+ }
+
+ private int c(ItemStack itemstack) {
+ for (int i = 0; i < this.a.length; ++i) {
+ if (this.a[i] != null && this.a[i].id == itemstack.id && this.a[i].c() && this.a[i].count < this.a[i].b() && this.a[i].count < this.c() && (!this.a[i].e() || this.a[i].h() == itemstack.h())) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ private int j() {
+ for (int i = 0; i < this.a.length; ++i) {
+ if (this.a[i] == null) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ private int d(ItemStack itemstack) {
+ int i = itemstack.id;
+ int j = itemstack.count;
+ int k = this.c(itemstack);
+
+ if (k < 0) {
+ k = this.j();
+ }
+
+ if (k < 0) {
+ return j;
+ } else {
+ if (this.a[k] == null) {
+ this.a[k] = new ItemStack(i, 0, itemstack.h());
+ }
+
+ int l = j;
+
+ if (j > this.a[k].b() - this.a[k].count) {
+ l = this.a[k].b() - this.a[k].count;
+ }
+
+ if (l > this.c() - this.a[k].count) {
+ l = this.c() - this.a[k].count;
+ }
+
+ if (l == 0) {
+ return j;
+ } else {
+ j -= l;
+ this.a[k].count += l;
+ this.a[k].b = 5;
+ return j;
+ }
+ }
+ }
+
+ public void f() {
+ for (int i = 0; i < this.a.length; ++i) {
+ if (this.a[i] != null && this.a[i].b > 0) {
+ --this.a[i].b;
+ }
+ }
+ }
+
+ public boolean b(int i) {
+ int j = this.d(i);
+
+ if (j < 0) {
+ return false;
+ } else {
+ if (--this.a[j].count <= 0) {
+ this.a[j] = null;
+ }
+
+ return true;
+ }
+ }
+
+ public boolean a(ItemStack itemstack) {
+ if (!itemstack.f()) {
+ itemstack.count = this.d(itemstack);
+ if (itemstack.count == 0) {
+ return true;
+ }
+ }
+
+ int i = this.j();
+
+ if (i >= 0) {
+ this.a[i] = itemstack;
+ this.a[i].b = 5;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public ItemStack b(int i, int j) {
+ ItemStack[] aitemstack = this.a;
+
+ if (i >= this.a.length) {
+ aitemstack = this.b;
+ i -= this.a.length;
+ }
+
+ if (aitemstack[i] != null) {
+ ItemStack itemstack;
+
+ if (aitemstack[i].count <= j) {
+ itemstack = aitemstack[i];
+ aitemstack[i] = null;
+ return itemstack;
+ } else {
+ itemstack = aitemstack[i].a(j);
+ if (aitemstack[i].count == 0) {
+ aitemstack[i] = null;
+ }
+
+ return itemstack;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public void a(int i, ItemStack itemstack) {
+ ItemStack[] aitemstack = this.a;
+
+ if (i >= aitemstack.length) {
+ i -= aitemstack.length;
+ aitemstack = this.b;
+ }
+
+ aitemstack[i] = itemstack;
+ }
+
+ public float a(Block block) {
+ float f = 1.0F;
+
+ if (this.a[this.c] != null) {
+ f *= this.a[this.c].a(block);
+ }
+
+ return f;
+ }
+
+ public NBTTagList a(NBTTagList nbttaglist) {
+ int i;
+ NBTTagCompound nbttagcompound;
+
+ for (i = 0; i < this.a.length; ++i) {
+ if (this.a[i] != null) {
+ nbttagcompound = new NBTTagCompound();
+ nbttagcompound.a("Slot", (byte) i);
+ this.a[i].a(nbttagcompound);
+ nbttaglist.a((NBTBase) nbttagcompound);
+ }
+ }
+
+ for (i = 0; i < this.b.length; ++i) {
+ if (this.b[i] != null) {
+ nbttagcompound = new NBTTagCompound();
+ nbttagcompound.a("Slot", (byte) (i + 100));
+ this.b[i].a(nbttagcompound);
+ nbttaglist.a((NBTBase) nbttagcompound);
+ }
+ }
+
+ return nbttaglist;
+ }
+
+ public void b(NBTTagList nbttaglist) {
+ this.a = new ItemStack[36];
+ this.b = new ItemStack[4];
+
+ for (int i = 0; i < nbttaglist.b(); ++i) {
+ NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i);
+ int j = nbttagcompound.b("Slot") & 255;
+ ItemStack itemstack = new ItemStack(nbttagcompound);
+
+ if (itemstack.a() != null) {
+ if (j >= 0 && j < this.a.length) {
+ this.a[j] = itemstack;
+ }
+
+ if (j >= 100 && j < this.b.length + 100) {
+ this.b[j - 100] = itemstack;
+ }
+ }
+ }
+ }
+
+ public int h_() {
+ return this.a.length + 4;
+ }
+
+ public ItemStack a(int i) {
+ ItemStack[] aitemstack = this.a;
+
+ if (i >= aitemstack.length) {
+ i -= aitemstack.length;
+ aitemstack = this.b;
+ }
+
+ return aitemstack[i];
+ }
+
+ public String b() {
+ return "Inventory";
+ }
+
+ public int c() {
+ return 64;
+ }
+
+ public int a(Entity entity) {
+ ItemStack itemstack = this.a(this.c);
+
+ return itemstack != null ? itemstack.a(entity) : 1;
+ }
+
+ public boolean b(Block block) {
+ if (block.material != Material.STONE && block.material != Material.ORE && block.material != Material.SNOW_BLOCK && block.material != Material.SNOW_LAYER) {
+ return true;
+ } else {
+ ItemStack itemstack = this.a(this.c);
+
+ return itemstack != null ? itemstack.b(block) : false;
+ }
+ }
+
+ public int g() {
+ int i = 0;
+ int j = 0;
+ int k = 0;
+
+ for (int l = 0; l < this.b.length; ++l) {
+ if (this.b[l] != null && this.b[l].a() instanceof ItemArmor) {
+ int i1 = this.b[l].i();
+ int j1 = this.b[l].g();
+ int k1 = i1 - j1;
+
+ j += k1;
+ k += i1;
+ int l1 = ((ItemArmor) this.b[l].a()).bh;
+
+ i += l1;
+ }
+ }
+
+ if (k == 0) {
+ return 0;
+ } else {
+ return (i - 1) * j / k + 1;
+ }
+ }
+
+ public void c(int i) {
+ for (int j = 0; j < this.b.length; ++j) {
+ if (this.b[j] != null && this.b[j].a() instanceof ItemArmor) {
+ this.b[j].b(i);
+ if (this.b[j].count == 0) {
+ this.b[j].a(this.e);
+ this.b[j] = null;
+ }
+ }
+ }
+ }
+
+ public void h() {
+ int i;
+
+ for (i = 0; i < this.a.length; ++i) {
+ if (this.a[i] != null) {
+ this.e.a(this.a[i], true);
+ this.a[i] = null;
+ }
+ }
+
+ for (i = 0; i < this.b.length; ++i) {
+ if (this.b[i] != null) {
+ this.e.a(this.b[i], true);
+ this.b[i] = null;
+ }
+ }
+ }
+
+ public void d() {
+ this.d = true;
+ }
+
+ public void b(ItemStack itemstack) {
+ this.f = itemstack;
+ this.e.a(itemstack);
+ }
+
+ public ItemStack i() {
+ return this.f;
+ }
+
+ public boolean a_(EntityHuman entityhuman) {
+ return this.e.dead ? false : entityhuman.b((Entity) this.e) <= 64.0D;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index eb971249..b1ae3950 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -17,14 +17,14 @@ public class ItemBlock extends Item {
public ItemBlock(int i) {
super(i);
- a = i + 256;
- b(Block.m[i + 256].a(2));
+ this.a = i + 256;
+ this.b(Block.byId[i + 256].a(2));
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
// CraftBukkit start
// Bail if we have nothing of the item in hand
- if (itemstack.a == 0) {
+ if (itemstack.count == 0) {
return false;
}
@@ -33,95 +33,102 @@ public class ItemBlock extends Item {
BlockFace faceClicked = CraftBlock.notchToBlockFace(l);
// CraftBukkit end
- if (world.a(i, j, k) == Block.aS.bi) {
+ if (world.getTypeId(i, j, k) == Block.SNOW.id) {
l = 0;
} else {
if (l == 0) {
- j--;
+ --j;
}
+
if (l == 1) {
- j++;
+ ++j;
}
+
if (l == 2) {
- k--;
+ --k;
}
+
if (l == 3) {
- k++;
+ ++k;
}
+
if (l == 4) {
- i--;
+ --i;
}
+
if (l == 5) {
- i++;
+ ++i;
}
}
- if (itemstack.a == 0) {
+ if (itemstack.count == 0) {
return false;
- }
-
- // CraftBukkit start
- /* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
- * rather than the block touching the face we clicked on.
- */
- org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == 78 || blockClicked.getTypeId() == 44) ? blockClicked:blockClicked.getFace(faceClicked);
- final BlockState replacedBlockState = new CraftBlockState(replacedBlock);
-
- if (world.a(a, i, j, k, false)) {
- Block block = Block.m[a];
-
- // This executes the placement of the block
- /*
- * This replaces world.b(IIIII), we're doing this because we need to
- * hook between the 'placement' and the informing to 'world' so we can
- * sanely undo this.
- *
- * Whenever the call to 'world.b' changes we need to figure out again what to
- * replace this with.
- */
- if (world.a(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
- org.bukkit.Server server = ((WorldServer) world).getServer();
- Type eventType = Type.BLOCK_PLACED;
- org.bukkit.block.Block placedBlock = blockClicked.getFace(faceClicked) ;
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- Player thePlayer = (entityplayer ==null)?null:(Player)entityplayer.getBukkitEntity();
-
- int distanceFromSpawn = (int) Math.max(Math.abs(i - world.m), Math.abs(k - world.o));
-
- // CraftBukkit hardcoded Spawn distance for now
- // TODO make spawn size configurable
- boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
-
- BlockPlaceEvent bpe = new BlockPlaceEvent(eventType, placedBlock, replacedBlockState, blockClicked, itemInHand, thePlayer, canBuild);
- server.getPluginManager().callEvent(bpe);
-
- if (bpe.isCancelled() || !bpe.canBuild()) {
- // CraftBukkit Undo!
-
- if (this.a == 79) {
- // Ice will explode if we set straight to 0
- world.b(i, j, k, 20);
- } else if ((this.a == 44) && (world.a(i, j - 1, k) == 43) && (world.a(i, j, k) == 0)) {
- // Half steps automatically set the block below to a double
- world.b(i, j - 1, k, 44);
+ } else {
+ // CraftBukkit start
+ /* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
+ * rather than the block touching the face we clicked on.
+ */
+ org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == Block.SNOW.id || blockClicked.getTypeId() == Block.STEP.id) ? blockClicked:blockClicked.getFace(faceClicked);
+ final BlockState replacedBlockState = new CraftBlockState(replacedBlock);
+ // CraftBukkit end
+
+ if (world.a(this.a, i, j, k, false)) {
+ Block block = Block.byId[this.a];
+
+ // CraftBukkit start - This executes the placement of the block
+ /*
+ * This replaces world.b(IIIII), we're doing this because we need to
+ * hook between the 'placement' and the informing to 'world' so we can
+ * sanely undo this.
+ *
+ * Whenever the call to 'world.b' changes we need to figure out again what to
+ * replace this with.
+ */
+ if (world.setTypeIdAndData(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
+ org.bukkit.Server server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_PLACED;
+ org.bukkit.block.Block placedBlock = blockClicked.getFace(faceClicked) ;
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ Player thePlayer = (entityhuman ==null) ? null : (Player) entityhuman.getBukkitEntity();
+
+ int distanceFromSpawn = (int) Math.max(Math.abs(i - world.spawnX), Math.abs(k - world.spawnZ));
+
+ // CraftBukkit hardcoded Spawn distance for now
+ // TODO make spawn size configurable
+ boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
+
+ BlockPlaceEvent event = new BlockPlaceEvent(eventType, placedBlock, replacedBlockState, blockClicked, itemInHand, thePlayer, canBuild);
+ server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || !event.canBuild()) {
+ // CraftBukkit Undo!
+
+ if (this.a == block.ICE.id) {
+ // Ice will explode if we set straight to 0
+ world.setTypeId(i, j, k, 20);
+ } else if ((this.a == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) {
+ // Half steps automatically set the block below to a double
+ world.setTypeId(i, j - 1, k, 44);
+ }
+
+ world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
+ } else {
+ world.f(i, j, k, a); // <-- world.b does this on success (tell the world)
+
+ Block.byId[this.a].c(world, i, j, k, l);
+ Block.byId[this.a].a(world, i, j, k, (EntityLiving) entityhuman);
+ world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.c(), (block.stepSound.a() + 1.0F) / 2.0F, block.stepSound.b() * 0.8F);
+ --itemstack.count;
}
-
- world.a(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getData().getData());
- } else {
- world.f(i, j, k, a); // <-- world.b does this on success (tell the world)
-
- Block.m[a].c(world, i, j, k, l);
- Block.m[a].a(world, i, j, k, ((EntityLiving) (entityplayer)));
- world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.br.c(), (block.br.a() + 1.0F) / 2.0F, block.br.b() * 0.8F);
- itemstack.a--;
+ // CraftBukkit end
}
}
+
+ return true;
}
- // CraftBukkit end
- return true;
}
public String a() {
- return Block.m[a].e();
+ return Block.byId[this.a].e();
}
}
diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java
index ade7bf24..6b3b4358 100644
--- a/src/main/java/net/minecraft/server/ItemBoat.java
+++ b/src/main/java/net/minecraft/server/ItemBoat.java
@@ -15,59 +15,61 @@ public class ItemBoat extends Item {
public ItemBoat(int i) {
super(i);
- bb = 1;
+ this.maxStackSize = 1;
}
- public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) {
+ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F;
- float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f;
- float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f;
- double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f;
- double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H;
- double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f;
- Vec3D vec3d = Vec3D.b(d, d1, d2);
- float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F);
- float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F);
- float f5 = -MathHelper.b(-f1 * 0.01745329F);
- float f6 = MathHelper.a(-f1 * 0.01745329F);
+ float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
+ float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * 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 d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
+ Vec3D vec3d = Vec3D.b(d0, d1, d2);
+ float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
+ float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
+ float f5 = -MathHelper.b(-f1 * 0.017453292F);
+ float f6 = MathHelper.a(-f1 * 0.017453292F);
float f7 = f4 * f5;
- float f8 = f6;
- float f9 = f3 * f5;
- double d3 = 5D;
- Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3);
+ float f8 = f3 * f5;
+ double d3 = 5.0D;
+ Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, true);
if (movingobjectposition == null) {
return itemstack;
- }
- if (movingobjectposition.a == EnumMovingObjectType.a) {
- int i = movingobjectposition.b;
- int j = movingobjectposition.c;
- int k = movingobjectposition.d;
+ } else {
+ if (movingobjectposition.a == EnumMovingObjectType.TILE) {
+ int i = movingobjectposition.b;
+ int j = movingobjectposition.c;
+ int k = movingobjectposition.d;
+
+ if (!world.isStatic) {
+ // CraftBukkit start - Boat placement
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
- if (!world.z) {
- // CraftBukkit start - Boat placement
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
- if (pie.isCancelled()) {
- return itemstack;
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+ // CraftBukkit end
+
+ world.a((Entity) (new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.5F), (double) ((float) k + 0.5F))));
}
- // CraftBukkit end
- world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F))));
+ --itemstack.count;
}
- itemstack.a--;
+
+ return itemstack;
}
- return itemstack;
}
}
diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java
index 017fd0d4..94820138 100644
--- a/src/main/java/net/minecraft/server/ItemBucket.java
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock;
@@ -20,123 +18,137 @@ public class ItemBucket extends Item {
public ItemBucket(int i, int j) {
super(i);
- bb = 1;
- bc = 64;
- a = j;
+ this.maxStackSize = 1;
+ this.durability = 64;
+ this.a = j;
}
- public ItemStack a(ItemStack itemstack, World world, EntityPlayer entityplayer) {
+ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
float f = 1.0F;
- float f1 = entityplayer.y + (entityplayer.w - entityplayer.y) * f;
- float f2 = entityplayer.x + (entityplayer.v - entityplayer.x) * f;
- double d = entityplayer.m + (entityplayer.p - entityplayer.m) * (double) f;
- double d1 = (entityplayer.n + (entityplayer.q - entityplayer.n) * (double) f + 1.6200000000000001D) - (double) entityplayer.H;
- double d2 = entityplayer.o + (entityplayer.r - entityplayer.o) * (double) f;
- Vec3D vec3d = Vec3D.b(d, d1, d2);
- float f3 = MathHelper.b(-f2 * 0.01745329F - 3.141593F);
- float f4 = MathHelper.a(-f2 * 0.01745329F - 3.141593F);
- float f5 = -MathHelper.b(-f1 * 0.01745329F);
- float f6 = MathHelper.a(-f1 * 0.01745329F);
+ float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f;
+ float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * 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 d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f;
+ Vec3D vec3d = Vec3D.b(d0, d1, d2);
+ float f3 = MathHelper.b(-f2 * 0.017453292F - 3.1415927F);
+ float f4 = MathHelper.a(-f2 * 0.017453292F - 3.1415927F);
+ float f5 = -MathHelper.b(-f1 * 0.017453292F);
+ float f6 = MathHelper.a(-f1 * 0.017453292F);
float f7 = f4 * f5;
- float f8 = f6;
- float f9 = f3 * f5;
- double d3 = 5D;
- Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f8 * d3, (double) f9 * d3);
- MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, a == 0);
+ float f8 = f3 * f5;
+ double d3 = 5.0D;
+ Vec3D vec3d1 = vec3d.c((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
+ MovingObjectPosition movingobjectposition = world.a(vec3d, vec3d1, this.a == 0);
if (movingobjectposition == null) {
return itemstack;
- }
- if (movingobjectposition.a == EnumMovingObjectType.a) {
- int i = movingobjectposition.b;
- int j = movingobjectposition.c;
- int k = movingobjectposition.d;
-
- if (!world.a(entityplayer, i, j, k)) {
- return itemstack;
- }
+ } else {
+ if (movingobjectposition.a == EnumMovingObjectType.TILE) {
+ int i = movingobjectposition.b;
+ int j = movingobjectposition.c;
+ int k = movingobjectposition.d;
- // CraftBukkit start - Click == placed when handling an empty bucket!
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
- // CraftBukkit end
-
- if (a == 0) {
- if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) {
- // CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return itemstack;
- }
- // CraftBukkit end
- world.e(i, j, k, 0);
- return new ItemStack(Item.av);
+ if (!world.a(entityhuman, i, j, k)) {
+ return itemstack;
}
- if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
- // CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
- if (pie.isCancelled()) {
- return itemstack;
- }
- // CraftBukkit end
- world.e(i, j, k, 0);
- return new ItemStack(Item.aw);
- }
- } else {
- if (a < 0) {
- return new ItemStack(Item.au);
- }
- if (movingobjectposition.e == 0) {
- j--;
- }
- if (movingobjectposition.e == 1) {
- j++;
- }
- if (movingobjectposition.e == 2) {
- k--;
- }
- if (movingobjectposition.e == 3) {
- k++;
- }
- if (movingobjectposition.e == 4) {
- i--;
- }
- if (movingobjectposition.e == 5) {
- i++;
- }
- if (world.e(i, j, k) || !world.c(i, j, k).a()) {
- if (world.q.d && a == Block.A.bi) {
- world.a(d + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
- for (int l = 0; l < 8; l++) {
- world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
+ // CraftBukkit start - Click == placed when handling an empty bucket!
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
+ // CraftBukkit end
+
+ if (this.a == 0) {
+ if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) {
+ // CraftBukkit start
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return itemstack;
}
- } else {
- // CraftBukkit start - bucket empty.
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
+ // CraftBukkit end
+
+ world.e(i, j, k, 0);
+ return new ItemStack(Item.WATER_BUCKET);
+ }
- if (pie.isCancelled()) {
+ if (world.getMaterial(i, j, k) == Material.LAVA && world.getData(i, j, k) == 0) {
+ // CraftBukkit start
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
return itemstack;
}
// CraftBukkit end
- world.b(i, j, k, a, 0);
+
+ world.e(i, j, k, 0);
+ return new ItemStack(Item.LAVA_BUCKET);
+ }
+ } else {
+ if (this.a < 0) {
+ return new ItemStack(Item.BUCKET);
+ }
+
+ if (movingobjectposition.e == 0) {
+ --j;
+ }
+
+ if (movingobjectposition.e == 1) {
+ ++j;
+ }
+
+ if (movingobjectposition.e == 2) {
+ --k;
+ }
+
+ if (movingobjectposition.e == 3) {
+ ++k;
+ }
+
+ if (movingobjectposition.e == 4) {
+ --i;
+ }
+
+ if (movingobjectposition.e == 5) {
+ ++i;
+ }
+
+ if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) {
+ if (world.q.d && this.a == Block.WATER.id) {
+ world.a(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.l.nextFloat() - world.l.nextFloat()) * 0.8F);
+
+ for (int l = 0; l < 8; ++l) {
+ world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
+ }
+ } else {
+ // CraftBukkit start - bucket empty.
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return itemstack;
+ }
+ // CraftBukkit end
+
+ world.b(i, j, k, this.a, 0);
+ }
+
+ return new ItemStack(Item.BUCKET);
}
- return new ItemStack(Item.au);
}
+ } else if (this.a == 0 && movingobjectposition.g instanceof EntityCow) {
+ return new ItemStack(Item.MILK_BUCKET);
}
- } else if (a == 0 && (movingobjectposition.g instanceof EntityCow)) {
- return new ItemStack(Item.aE);
+
+ return itemstack;
}
- return itemstack;
}
}
diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java
index 2ea9eb1a..8affb99b 100644
--- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java
+++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
@@ -19,59 +17,64 @@ public class ItemFlintAndSteel extends Item {
public ItemFlintAndSteel(int i) {
super(i);
- bb = 1;
- bc = 64;
+ this.maxStackSize = 1;
+ this.durability = 64;
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
- // CraftBukkit - store the clicked block
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
+ // CraftBukkit start - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
-
+ // CraftBukkit end
+
if (l == 0) {
- j--;
+ --j;
}
+
if (l == 1) {
- j++;
+ ++j;
}
+
if (l == 2) {
- k--;
+ --k;
}
+
if (l == 3) {
- k++;
+ ++k;
}
+
if (l == 4) {
- i--;
+ --i;
}
+
if (l == 5) {
- i++;
+ ++i;
}
- int i1 = world.a(i, j, k);
+
+ int i1 = world.getTypeId(i, j, k);
if (i1 == 0) {
// CraftBukkit start - Flint and steel
Type eventType = Type.PLAYER_ITEM;
- Player thePlayer = (Player) entityplayer.getBukkitEntity();
+ Player thePlayer = (Player) entityhuman.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack);
BlockFace blockFace = CraftBlock.notchToBlockFace(l);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
- boolean preventLighter = pie.isCancelled();
-
-
- IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL;
- BlockIgniteEvent bie = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer);
- craftServer.getPluginManager().callEvent(bie);
- boolean preventFire = bie.isCancelled();
+ PlayerItemEvent event = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ boolean preventLighter = event.isCancelled();
+ IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL;
+ BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer);
+ craftServer.getPluginManager().callEvent(eventIgnite);
+ boolean preventFire = eventIgnite.isCancelled();
if (preventLighter) {
return false;
}
-
+
if (preventFire) {
itemstack.b(1);
return false;
@@ -79,8 +82,9 @@ public class ItemFlintAndSteel extends Item {
// CraftBukkit end
world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F);
- world.e(i, j, k, Block.ar.bi);
+ world.e(i, j, k, Block.FIRE.id);
}
+
itemstack.b(1);
return true;
}
diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java
index d60829a7..0b4849d4 100644
--- a/src/main/java/net/minecraft/server/ItemHoe.java
+++ b/src/main/java/net/minecraft/server/ItemHoe.java
@@ -1,7 +1,5 @@
package net.minecraft.server;
-import java.util.Random;
-
// CraftBukkit start
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
@@ -17,58 +15,60 @@ public class ItemHoe extends Item {
public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) {
super(i);
- bb = 1;
- bc = enumtoolmaterial.a();
+ this.maxStackSize = 1;
+ this.durability = enumtoolmaterial.a();
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
- int i1 = world.a(i, j, k);
- Material material = world.c(i, j + 1, k);
-
- if (!material.a() && i1 == Block.u.bi || i1 == Block.v.bi) {
- // CraftBukkit start - Hoes
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockFace = CraftBlock.notchToBlockFace(1);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return false;
- }
- // CraftBukkit end
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
+ int i1 = world.getTypeId(i, j, k);
+ Material material = world.getMaterial(i, j + 1, k);
- Block block = Block.aA;
+ if ((material.isBuildable() || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) {
+ return false;
+ } else {
+ Block block = Block.SOIL;
- world.a((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.br.c(), (block.br.a() + 1.0F) / 2.0F, block.br.b() * 0.8F);
- if (world.z) {
+ world.a((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.c(), (block.stepSound.a() + 1.0F) / 2.0F, block.stepSound.b() * 0.8F);
+ if (world.isStatic) {
return true;
- }
- world.e(i, j, k, block.bi);
- itemstack.b(1);
- if (world.l.nextInt(8) == 0 && i1 == Block.u.bi) {
- int j1 = 1;
+ } else {
+ // CraftBukkit start - Hoes
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
- for (int k1 = 0; k1 < j1; k1++) {
- float f = 0.7F;
- float f1 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
- float f2 = 1.2F;
- float f3 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
- EntityItem entityitem = new EntityItem(world, (float) i + f1, (float) j + f2, (float) k + f3, new ItemStack(Item.Q));
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(1);
- entityitem.c = 10;
- world.a(((Entity) (entityitem)));
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
}
+ // CraftBukkit end
+
+ world.e(i, j, k, block.id);
+ itemstack.b(1);
+ if (world.l.nextInt(8) == 0 && i1 == Block.GRASS.id) {
+ byte b0 = 1;
+
+ for (int j1 = 0; j1 < b0; ++j1) {
+ float f = 0.7F;
+ float f1 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
+ float f2 = 1.2F;
+ float f3 = world.l.nextFloat() * f + (1.0F - f) * 0.5F;
+ EntityItem entityitem = new EntityItem(world, (double) ((float) i + f1), (double) ((float) j + f2), (double) ((float) k + f3), new ItemStack(Item.SEEDS));
+
+ entityitem.c = 10;
+ world.a((Entity) entityitem);
+ }
+ }
+
+ return true;
}
- return true;
- } else {
- return false;
}
}
}
diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java
index 701c6c27..f89b0189 100644
--- a/src/main/java/net/minecraft/server/ItemInWorldManager.java
+++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java
@@ -3,125 +3,121 @@ package net.minecraft.server;
public class ItemInWorldManager {
private World b;
- public EntityPlayer a;
+ public EntityHuman a;
private float c;
- public float d; // CraftBukkit private -> public
- private int e;
- private float f;
+ public float d = 0.0F; // CraftBukkit private -> public
+ private int e = 0;
+ private float f = 0.0F;
private int g;
private int h;
private int i;
public ItemInWorldManager(World world) {
- d = 0.0F;
- e = 0;
- f = 0.0F;
- b = world;
+ this.b = world;
}
- public void a(int j, int k, int l) {
- int i1 = b.a(j, k, l);
+ public void a(int i, int j, int k) {
+ int l = this.b.getTypeId(i, j, k);
- if (i1 > 0 && d == 0.0F) {
- Block.m[i1].b(b, j, k, l, a);
+ if (l > 0 && this.d == 0.0F) {
+ Block.byId[l].b(this.b, i, j, k, this.a);
}
- if (i1 > 0 && Block.m[i1].a(a) >= 1.0F) {
- c(j, k, l);
+
+ if (l > 0 && Block.byId[l].a(this.a) >= 1.0F) {
+ this.c(i, j, k);
}
}
public void a() {
- d = 0.0F;
- e = 0;
+ this.d = 0.0F;
+ this.e = 0;
}
- public void a(int j, int k, int l, int i1) {
- if (e > 0) {
- e--;
- return;
- }
- if (j == g && k == h && l == i) {
- int j1 = b.a(j, k, l);
-
- if (j1 == 0) {
- return;
- }
- Block block = Block.m[j1];
-
- d += block.a(a);
- f++;
- if (d >= 1.0F) {
- c(j, k, l);
- d = 0.0F;
- c = 0.0F;
- f = 0.0F;
- e = 5;
- }
+ public void a(int i, int j, int k, int l) {
+ if (this.e > 0) {
+ --this.e;
} else {
- d = 0.0F;
- c = 0.0F;
- f = 0.0F;
- g = j;
- h = k;
- i = l;
+ if (i == this.g && j == this.h && k == this.i) {
+ int i1 = this.b.getTypeId(i, j, k);
+
+ if (i1 == 0) {
+ return;
+ }
+
+ Block block = Block.byId[i1];
+
+ this.d += block.a(this.a);
+ ++this.f;
+ if (this.d >= 1.0F) {
+ this.c(i, j, k);
+ this.d = 0.0F;
+ this.c = 0.0F;
+ this.f = 0.0F;
+ this.e = 5;
+ }
+ } else {
+ this.d = 0.0F;
+ this.c = 0.0F;
+ this.f = 0.0F;
+ this.g = i;
+ this.h = j;
+ this.i = k;
+ }
}
}
- public boolean b(int j, int k, int l) {
- Block block = Block.m[b.a(j, k, l)];
- int i1 = b.b(j, k, l);
- boolean flag = b.e(j, k, l, 0);
+ public boolean b(int i, int j, int k) {
+ Block block = Block.byId[this.b.getTypeId(i, j, k)];
+ int l = this.b.getData(i, j, k);
+ boolean flag = this.b.e(i, j, k, 0);
if (block != null && flag) {
- block.a(b, j, k, l, i1);
+ block.a(this.b, i, j, k, l);
}
+
return flag;
}
- public boolean c(int j, int k, int l) {
- int i1 = b.a(j, k, l);
- int j1 = b.b(j, k, l);
- boolean flag = b(j, k, l);
- ItemStack itemstack = a.P();
+ public boolean c(int i, int j, int k) {
+ int l = this.b.getTypeId(i, j, k);
+ int i1 = this.b.getData(i, j, k);
+ boolean flag = this.b(i, j, k);
+ ItemStack itemstack = this.a.P();
if (itemstack != null) {
- itemstack.a(i1, j, k, l);
- if (itemstack.a == 0) {
- itemstack.a(a);
- a.Q();
+ itemstack.a(l, i, j, k);
+ if (itemstack.count == 0) {
+ itemstack.a(this.a);
+ this.a.Q();
}
}
- if (flag && a.b(Block.m[i1])) {
- Block.m[i1].g(b, j, k, l, j1);
+
+ if (flag && this.a.b(Block.byId[l])) {
+ Block.byId[l].g(this.b, i, j, k, i1);
}
+
return flag;
}
- public boolean a(EntityPlayer entityplayer, World world, ItemStack itemstack) {
- int j = itemstack.a;
- ItemStack itemstack1 = itemstack.a(world, entityplayer);
+ public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack) {
+ int i = itemstack.count;
+ ItemStack itemstack1 = itemstack.a(world, entityhuman);
- if (itemstack1 != itemstack || itemstack1 != null && itemstack1.a != j) {
- entityplayer.an.a[entityplayer.an.c] = itemstack1;
- if (itemstack1.a == 0) {
- entityplayer.an.a[entityplayer.an.c] = null;
+ if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i)) {
+ return false;
+ } else {
+ entityhuman.inventory.a[entityhuman.inventory.c] = itemstack1;
+ if (itemstack1.count == 0) {
+ entityhuman.inventory.a[entityhuman.inventory.c] = null;
}
+
return true;
- } else {
- return false;
}
}
- public boolean a(EntityPlayer entityplayer, World world, ItemStack itemstack, int j, int k, int l, int i1) {
- int j1 = world.a(j, k, l);
+ public boolean a(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) {
+ int i1 = world.getTypeId(i, j, k);
- if (j1 > 0 && Block.m[j1].a(world, j, k, l, entityplayer)) {
- return true;
- }
- if (itemstack == null) {
- return false;
- } else {
- return itemstack.a(entityplayer, world, j, k, l, i1);
- }
+ return i1 > 0 && Block.byId[i1].a(world, i, j, k, entityhuman) ? true : (itemstack == null ? false : itemstack.a(entityhuman, world, i, j, k, l));
}
}
diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java
index 7d97e6fc..4da25503 100644
--- a/src/main/java/net/minecraft/server/ItemMinecart.java
+++ b/src/main/java/net/minecraft/server/ItemMinecart.java
@@ -17,36 +17,38 @@ public class ItemMinecart extends Item {
public ItemMinecart(int i, int j) {
super(i);
- bb = 1;
- a = j;
+ this.maxStackSize = 1;
+ this.a = j;
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
- int i1 = world.a(i, j, k);
-
- if (i1 == Block.aG.bi) {
- // CraftBukkit start - Minecarts
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockFace = CraftBlock.notchToBlockFace(1);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return false;
- }
- // CraftBukkit end
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
+ int i1 = world.getTypeId(i, j, k);
+
+ if (i1 == Block.RAILS.id) {
+ if (!world.isStatic) {
+
+ // CraftBukkit start - Minecarts
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(1);
- if (!world.z) {
- world.a(((Entity) (new EntityMinecart(world, (float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, a))));
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+
+ world.a((Entity) (new EntityMinecart(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.a)));
}
- itemstack.a--;
+
+ --itemstack.count;
return true;
} else {
return false;
diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java
index e28a1525..8e3cd885 100644
--- a/src/main/java/net/minecraft/server/ItemRedstone.java
+++ b/src/main/java/net/minecraft/server/ItemRedstone.java
@@ -18,51 +18,60 @@ public class ItemRedstone extends Item {
super(i);
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
- // CraftBukkit - store the clicked block
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
+ // CraftBukkit start - store the clicked block
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
-
+ // CraftBukkit end
+
if (l == 0) {
- j--;
+ --j;
}
+
if (l == 1) {
- j++;
+ ++j;
}
+
if (l == 2) {
- k--;
+ --k;
}
+
if (l == 3) {
- k++;
+ ++k;
}
+
if (l == 4) {
- i--;
+ --i;
}
+
if (l == 5) {
- i++;
+ ++i;
}
- if (!world.e(i, j, k)) {
+
+ if (!world.isEmpty(i, j, k)) {
return false;
- }
- if (Block.av.a(world, i, j, k)) {
- // CraftBukkit start - Redstone
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- BlockFace blockface = CraftBlock.notchToBlockFace(1);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return false;
+ } else {
+ if (Block.REDSTONE_WIRE.a(world, i, j, k)) {
+ // CraftBukkit start - Redstone
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+
+ --itemstack.count;
+ world.e(i, j, k, Block.REDSTONE_WIRE.id);
}
- // CraftBukkit end
- itemstack.a--;
- world.e(i, j, k, Block.av.bi);
+ return true;
}
- return true;
}
}
diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java
index cab36fde..9d4e067f 100644
--- a/src/main/java/net/minecraft/server/ItemSeeds.java
+++ b/src/main/java/net/minecraft/server/ItemSeeds.java
@@ -18,39 +18,40 @@ public class ItemSeeds extends Item {
public ItemSeeds(int i, int j) {
super(i);
- a = j;
+ this.a = j;
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
if (l != 1) {
return false;
- }
- int i1 = world.a(i, j, k);
-
- if (i1 == Block.aA.bi && world.e(i, j + 1, k)) {
- // CraftBukkit start - Seeds
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
-
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
- BlockFace blockface = CraftBlock.notchToBlockFace(1);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
+ } else {
+ int i1 = world.getTypeId(i, j, k);
+
+ if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) {
+ // CraftBukkit start - Seeds
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+
+ world.e(i, j + 1, k, this.a);
+ --itemstack.count;
+ return true;
+ } else {
return false;
}
- // CraftBukkit end
-
- world.e(i, j + 1, k, a);
- itemstack.a--;
- return true;
- } else {
- return false;
}
}
}
diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java
index e4241e95..5d68b0b6 100644
--- a/src/main/java/net/minecraft/server/ItemSign.java
+++ b/src/main/java/net/minecraft/server/ItemSign.java
@@ -15,68 +15,75 @@ public class ItemSign extends Item {
public ItemSign(int i) {
super(i);
- bc = 64;
- bb = 1;
+ this.durability = 64;
+ this.maxStackSize = 1;
}
- public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
+ public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
if (l == 0) {
return false;
- }
- if (!world.c(i, j, k).a()) {
+ } else if (!world.getMaterial(i, j, k).isBuildable()) {
return false;
- }
+ } else {
+ // CraftBukkit start - store the clicked block
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ //CraftBukkit end
- // CraftBukkit - store the clicked block
- CraftWorld craftWorld = ((WorldServer) world).getWorld();
- CraftServer craftServer = ((WorldServer) world).getServer();
- org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
-
- if (l == 1) {
- j++;
- }
- if (l == 2) {
- k--;
- }
- if (l == 3) {
- k++;
- }
- if (l == 4) {
- i--;
- }
- if (l == 5) {
- i++;
- }
- if (!Block.aD.a(world, i, j, k)) {
- return false;
- }
+ if (l == 1) {
+ ++j;
+ }
- // CraftBukkit start
- // Signs
- Type eventType = Type.PLAYER_ITEM;
- Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
- org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
- BlockFace blockface = CraftBlock.notchToBlockFace(1);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
- craftServer.getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) {
- return false;
- }
- // CraftBukkit end
+ if (l == 2) {
+ --k;
+ }
- if (l == 1) {
- world.b(i, j, k, Block.aD.bi, MathHelper.b((double) (((entityplayer.v + 180F) * 16F) / 360F) + 0.5D) & 0xf);
- } else {
- world.b(i, j, k, Block.aI.bi, l);
- }
- itemstack.a--;
- TileEntitySign tileentitysign = (TileEntitySign) world.m(i, j, k);
+ if (l == 3) {
+ ++k;
+ }
+
+ if (l == 4) {
+ --i;
+ }
+
+ if (l == 5) {
+ ++i;
+ }
+
+ if (!Block.SIGN_POST.a(world, i, j, k)) {
+ return false;
+ } else {
+ // CraftBukkit start
+ // Signs
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+ // CraftBukkit end
+
+ if (l == 1) {
+ world.b(i, j, k, Block.SIGN_POST.id, MathHelper.b((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15);
+ } else {
+ world.b(i, j, k, Block.WALL_SIGN.id, l);
+ }
+
+ --itemstack.count;
+ TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k);
+
+ if (tileentitysign != null) {
+ entityhuman.a(tileentitysign);
+ }
- if (tileentitysign != null) {
- entityplayer.a(tileentitysign);
+ return true;
+ }
}
- return true;
}
}
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 5d30421c..58f0c37e 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -2,183 +2,170 @@ package net.minecraft.server;
public final class ItemStack {
- public int a;
+ public int count;
public int b;
- public int c;
- public int d; // Craftbukkit - make public
+ public int id;
+ public int damage; // Craftbukkit - make public
public ItemStack(Block block) {
this(block, 1);
}
- public ItemStack(Block block, int k) {
- this(block.bi, k, 0);
+ public ItemStack(Block block, int i) {
+ this(block.id, i, 0);
}
- public ItemStack(Block block, int k, int l) {
- this(block.bi, k, l);
+ public ItemStack(Block block, int i, int j) {
+ this(block.id, i, j);
}
public ItemStack(Item item) {
- this(item.ba, 1, 0);
+ this(item.id, 1, 0);
}
- public ItemStack(Item item, int k) {
- this(item.ba, k, 0);
+ public ItemStack(Item item, int i) {
+ this(item.id, i, 0);
}
- public ItemStack(Item item, int k, int l) {
- this(item.ba, k, l);
+ public ItemStack(Item item, int i, int j) {
+ this(item.id, i, j);
}
- public ItemStack(int k, int l, int i1) {
- a = 0;
- c = k;
- a = l;
- d = i1;
+ public ItemStack(int i, int j, int k) {
+ this.count = 0;
+ this.id = i;
+ this.count = j;
+ this.damage = k;
}
public ItemStack(NBTTagCompound nbttagcompound) {
- a = 0;
- b(nbttagcompound);
+ this.count = 0;
+ this.b(nbttagcompound);
}
- public ItemStack a(int k) {
- a -= k;
- return new ItemStack(c, k, d);
+ public ItemStack a(int i) {
+ this.count -= i;
+ return new ItemStack(this.id, i, this.damage);
}
public Item a() {
- return Item.c[c];
+ return Item.byId[this.id];
}
- public boolean a(EntityPlayer entityplayer, World world, int k, int l, int i1, int j1) {
- return a().a(this, entityplayer, world, k, l, i1, j1);
+ public boolean a(EntityHuman entityhuman, World world, int i, int j, int k, int l) {
+ return this.a().a(this, entityhuman, world, i, j, k, l);
}
public float a(Block block) {
- return a().a(this, block);
+ return this.a().a(this, block);
}
- public ItemStack a(World world, EntityPlayer entityplayer) {
- return a().a(this, world, entityplayer);
+ public ItemStack a(World world, EntityHuman entityhuman) {
+ return this.a().a(this, world, entityhuman);
}
public NBTTagCompound a(NBTTagCompound nbttagcompound) {
- nbttagcompound.a("id", (short) c);
- nbttagcompound.a("Count", (byte) a);
- nbttagcompound.a("Damage", (short) d);
+ nbttagcompound.a("id", (short) this.id);
+ nbttagcompound.a("Count", (byte) this.count);
+ nbttagcompound.a("Damage", (short) this.damage);
return nbttagcompound;
}
public void b(NBTTagCompound nbttagcompound) {
- c = ((int) (nbttagcompound.c("id")));
- a = ((int) (nbttagcompound.b("Count")));
- d = ((int) (nbttagcompound.c("Damage")));
+ this.id = nbttagcompound.c("id");
+ this.count = nbttagcompound.b("Count");
+ this.damage = nbttagcompound.c("Damage");
}
public int b() {
- return a().b();
+ return this.a().b();
}
public boolean c() {
- return b() > 1 && (!d() || !f());
+ return this.b() > 1 && (!this.d() || !this.f());
}
public boolean d() {
- return Item.c[c].d() > 0;
+ return Item.byId[this.id].d() > 0;
}
public boolean e() {
- return Item.c[c].c();
+ return Item.byId[this.id].c();
}
public boolean f() {
- return d() && d > 0;
+ return this.d() && this.damage > 0;
}
public int g() {
- return d;
+ return this.damage;
}
public int h() {
- return d;
+ return this.damage;
}
public int i() {
- return Item.c[c].d();
+ return Item.byId[this.id].d();
}
- public void b(int k) {
- if (!d()) {
- return;
- }
- d += k;
- if (d > i()) {
- a--;
- if (a < 0) {
- a = 0;
+ public void b(int i) {
+ if (this.d()) {
+ this.damage += i;
+ if (this.damage > this.i()) {
+ --this.count;
+ if (this.count < 0) {
+ this.count = 0;
+ }
+
+ this.damage = 0;
}
- d = 0;
}
}
public void a(EntityLiving entityliving) {
- Item.c[c].a(this, entityliving);
+ Item.byId[this.id].a(this, entityliving);
}
- public void a(int k, int l, int i1, int j1) {
- Item.c[c].a(this, k, l, i1, j1);
+ public void a(int i, int j, int k, int l) {
+ Item.byId[this.id].a(this, i, j, k, l);
}
public int a(Entity entity) {
- return Item.c[c].a(entity);
+ return Item.byId[this.id].a(entity);
}
public boolean b(Block block) {
- return Item.c[c].a(block);
+ return Item.byId[this.id].a(block);
}
- public void a(EntityPlayer entityplayer) {}
+ public void a(EntityHuman entityhuman) {}
public void b(EntityLiving entityliving) {
- Item.c[c].b(this, entityliving);
+ Item.byId[this.id].b(this, entityliving);
}
public ItemStack j() {
- return new ItemStack(c, a, d);
+ return new ItemStack(this.id, this.count, this.damage);
}
public static boolean a(ItemStack itemstack, ItemStack itemstack1) {
- if (itemstack == null && itemstack1 == null) {
- return true;
- }
- if (itemstack == null || itemstack1 == null) {
- return false;
- } else {
- return itemstack.c(itemstack1);
- }
+ return itemstack == null && itemstack1 == null ? true : (itemstack != null && itemstack1 != null ? itemstack.c(itemstack1) : false);
}
private boolean c(ItemStack itemstack) {
- if (a != itemstack.a) {
- return false;
- }
- if (c != itemstack.c) {
- return false;
- }
- return d == itemstack.d;
+ return this.count != itemstack.count ? false : (this.id != itemstack.id ? false : this.damage == itemstack.damage);
}
public boolean a(ItemStack itemstack) {
- return c == itemstack.c && d == itemstack.d;
+ return this.id == itemstack.id && this.damage == itemstack.damage;
}
public static ItemStack b(ItemStack itemstack) {
- return itemstack != null ? itemstack.j() : null;
+ return itemstack == null ? null : itemstack.j();
}
public String toString() {
- return (new StringBuilder()).append(a).append("x").append(Item.c[c].a()).append("@").append(d).toString();
+ return this.count + "x" + Item.byId[this.id].a() + "@" + this.damage;
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 56755c17..37b3bd2f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1,15 +1,14 @@
package net.minecraft.server;
+import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.IOException;
-import java.io.PrintStream;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -27,184 +26,187 @@ public class MinecraftServer implements ICommandListener, Runnable {
public PropertyManager d;
public WorldServer e;
public ServerConfigurationManager f;
- private boolean o;
- public boolean g;
- int h;
+ private boolean o = true;
+ public boolean g = false;
+ int h = 0;
public String i;
public int j;
- private List p;
- private List q;
+ private List p = new ArrayList();
+ private List q = Collections.synchronizedList(new ArrayList());
public EntityTracker k;
public boolean l;
public boolean m;
public boolean n;
- public CraftServer server; // CraftBukkit
- public OptionSet options; // CraftBukkit
-
- // CraftBukkit: Added arg "OptionSet options"
- public MinecraftServer(final OptionSet options) {
- o = true;
- g = false;
- h = 0;
- p = ((List) (new ArrayList()));
- q = Collections.synchronizedList(((List) (new ArrayList())));
+ public MinecraftServer() {
new ThreadSleepForever(this);
-
- this.options = options; // CraftBukkit
+ // CraftBukkit start
+ this.options = options;
}
+ public CraftServer server;
+ public OptionSet options;
- // CraftBukkit: added throws UnknownHostException
private boolean d() throws UnknownHostException {
+ // CraftBukkit end -- added throws UnknownHostException
ThreadCommandReader threadcommandreader = new ThreadCommandReader(this);
- ((Thread) (threadcommandreader)).setDaemon(true);
- ((Thread) (threadcommandreader)).start();
+ threadcommandreader.setDaemon(true);
+ threadcommandreader.start();
ConsoleLogManager.a();
a.info("Starting minecraft server version Beta 1.2_01");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
a.warning("**** NOT ENOUGH RAM!");
a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
}
+
a.info("Loading properties");
- d = new PropertyManager(options);
- String s = d.a("server-ip", "");
+ this.d = new PropertyManager(new File("server.properties"));
+ String s = this.d.a("server-ip", "");
- l = d.a("online-mode", true);
- m = d.a("spawn-animals", true);
- n = d.a("pvp", true);
+ this.l = this.d.a("online-mode", true);
+ this.m = this.d.a("spawn-animals", true);
+ this.n = this.d.a("pvp", true);
InetAddress inetaddress = null;
if (s.length() > 0) {
inetaddress = InetAddress.getByName(s);
}
- int i1 = d.a("server-port", 25565);
- a.info((new StringBuilder()).append("Starting Minecraft server on ").append(s.length() != 0 ? s : "*").append(":").append(i1).toString());
+ int i = this.d.a("server-port", 25565);
+
+ a.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i);
+
try {
- c = new NetworkListenThread(this, inetaddress, i1);
+ this.c = new NetworkListenThread(this, inetaddress, i);
// CraftBukkit: Be more generic; IOException -> Throwable
} catch (Throwable ioexception) {
a.warning("**** FAILED TO BIND TO PORT!");
- a.log(Level.WARNING, (new StringBuilder()).append("The exception was: ").append(ioexception.toString()).toString());
+ a.log(Level.WARNING, "The exception was: " + ioexception.toString());
a.warning("Perhaps a server is already running on that port?");
return false;
}
- if (!l) {
+
+ if (!this.l) {
a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
a.warning("The server will make no attempt to authenticate usernames. Beware.");
a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
}
- f = new ServerConfigurationManager(this);
- k = new EntityTracker(this);
- String s1 = d.a("level-name", "world");
- a.info((new StringBuilder()).append("Preparing level \"").append(s1).append("\"").toString());
- c(s1);
+ this.f = new ServerConfigurationManager(this);
+ this.k = new EntityTracker(this);
+ String s1 = this.d.a("level-name", "world");
+
+ a.info("Preparing level \"" + s1 + "\"");
+ this.c(s1);
a.info("Done! For help, type \"help\" or \"?\"");
return true;
}
private void c(String s) {
a.info("Preparing start region");
- e = new WorldServer(this, new File("."), s, d.a("hellworld", false) ? -1 : 0);
- e.a(((IWorldAccess) (new WorldManager(this))));
- e.k = d.a("spawn-monsters", true) ? 1 : 0;
- e.a(d.a("spawn-monsters", true), m);
- f.a(e);
- char c1 = '\304';
- long l1 = System.currentTimeMillis();
-
- for (int i1 = -c1; i1 <= c1 && o; i1 += 16) {
- for (int j1 = -c1; j1 <= c1 && o; j1 += 16) {
- long l2 = System.currentTimeMillis();
-
- if (l2 < l1) {
- l1 = l2;
+ this.e = new WorldServer(this, new File("."), s, this.d.a("hellworld", false) ? -1 : 0);
+ this.e.a(new WorldManager(this));
+ this.e.k = this.d.a("spawn-monsters", true) ? 1 : 0;
+ this.e.a(this.d.a("spawn-monsters", true), this.m);
+ this.f.a(this.e);
+ short short1 = 196;
+ long i = System.currentTimeMillis();
+
+ for (int j = -short1; j <= short1 && this.o; j += 16) {
+ for (int k = -short1; k <= short1 && this.o; k += 16) {
+ long l = System.currentTimeMillis();
+
+ if (l < i) {
+ i = l;
}
- if (l2 > l1 + 1000L) {
- int k1 = (c1 * 2 + 1) * (c1 * 2 + 1);
- int i2 = (i1 + c1) * (c1 * 2 + 1) + (j1 + 1);
- a("Preparing spawn area", (i2 * 100) / k1);
- l1 = l2;
+ if (l > i + 1000L) {
+ int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
+ int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;
+
+ this.a("Preparing spawn area", j1 * 100 / i1);
+ i = l;
}
- e.A.d(e.m + i1 >> 4, e.o + j1 >> 4);
- while (e.d() && o) {
+
+ this.e.A.d(this.e.spawnX + j >> 4, this.e.spawnZ + k >> 4);
+
+ while (this.e.d() && this.o) {
;
}
}
}
- e();
+ this.e();
}
- private void a(String s, int i1) {
- i = s;
- j = i1;
- System.out.println((new StringBuilder()).append(s).append(": ").append(i1).append("%").toString());
+ private void a(String s, int i) {
+ this.i = s;
+ this.j = i;
+ a.info(s + ": " + i + "%");
}
private void e() {
- i = null;
- j = 0;
+ this.i = null;
+ this.j = 0;
server.loadPlugins(); // CraftBukkit
}
private void f() {
a.info("Saving chunks");
- e.a(true, ((IProgressUpdate) (null)));
+ this.e.a(true, (IProgressUpdate) null);
}
private void g() {
a.info("Stopping server");
- if(server != null) {
- server.disablePlugins();
+ if (this.f != null) {
+ this.f.d();
}
- if (f != null) {
- f.d();
- }
- if (e != null) {
- f();
+ if (this.e != null) {
+ this.f();
}
}
public void a() {
- o = false;
+ this.o = false;
}
public void run() {
try {
- if (d()) {
- long l1 = System.currentTimeMillis();
- long l2 = 0L;
+ if (this.d()) {
+ long i = System.currentTimeMillis();
+ long j = 0L;
- while (o) {
- long l3 = System.currentTimeMillis();
- long l4 = l3 - l1;
+ while (this.o) {
+ long k = System.currentTimeMillis();
+ long l = k - i;
- if (l4 > 2000L) {
- a.warning("Can't keep up! Did the system time change, or is the server overloaded?");
- l4 = 2000L;
+ if (l > 2000L) {
+ a.warning("Can\'t keep up! Did the system time change, or is the server overloaded?");
+ l = 2000L;
}
- if (l4 < 0L) {
+
+ if (l < 0L) {
a.warning("Time ran backwards! Did the system time change?");
- l4 = 0L;
+ l = 0L;
}
- l2 += l4;
- l1 = l3;
- while (l2 > 50L) {
- l2 -= 50L;
- h();
+
+ j += l;
+ i = k;
+
+ while (j > 50L) {
+ j -= 50L;
+ this.h();
}
+
Thread.sleep(1L);
}
} else {
- while (o) {
- b();
+ while (this.o) {
+ this.b();
+
try {
Thread.sleep(10L);
} catch (InterruptedException interruptedexception) {
@@ -214,9 +216,11 @@ public class MinecraftServer implements ICommandListener, Runnable {
}
} catch (Exception exception) {
exception.printStackTrace();
- a.log(Level.SEVERE, "Unexpected exception", ((Throwable) (exception)));
- while (o) {
- b();
+ a.log(Level.SEVERE, "Unexpected exception", exception);
+
+ while (this.o) {
+ this.b();
+
try {
Thread.sleep(10L);
} catch (InterruptedException interruptedexception1) {
@@ -225,8 +229,8 @@ public class MinecraftServer implements ICommandListener, Runnable {
}
} finally {
try {
- g();
- g = true;
+ this.g();
+ this.g = true;
} finally {
System.exit(0);
}
@@ -235,62 +239,217 @@ public class MinecraftServer implements ICommandListener, Runnable {
private void h() {
ArrayList arraylist = new ArrayList();
+ Iterator iterator = b.keySet().iterator();
- for (Iterator iterator = b.keySet().iterator(); iterator.hasNext();) {
+ while (iterator.hasNext()) {
String s = (String) iterator.next();
- int k1 = ((Integer) b.get(((s)))).intValue();
+ int i = ((Integer) b.get(s)).intValue();
- if (k1 > 0) {
- b.put(((s)), ((Integer.valueOf(k1 - 1))));
+ if (i > 0) {
+ b.put(s, Integer.valueOf(i - 1));
} else {
- ((List) (arraylist)).add(((s)));
+ arraylist.add(s);
}
}
- for (int i1 = 0; i1 < ((List) (arraylist)).size(); i1++) {
- b.remove(((List) (arraylist)).get(i1));
+ int j;
+
+ for (j = 0; j < arraylist.size(); ++j) {
+ b.remove(arraylist.get(j));
}
AxisAlignedBB.a();
Vec3D.a();
- h++;
- if (h % 20 == 0) {
- f.a(((Packet) (new Packet4UpdateTime(e.e))));
+ ++this.h;
+ if (this.h % 20 == 0) {
+ this.f.a((Packet) (new Packet4UpdateTime(this.e.e)));
}
- e.f();
- while (e.d()) {
+
+ this.e.f();
+
+ while (this.e.d()) {
;
}
- e.c();
- c.a();
- f.b();
- k.a();
- for (int j1 = 0; j1 < p.size(); j1++) {
- ((IUpdatePlayerListBox) p.get(j1)).a();
+
+ this.e.c();
+ this.c.a();
+ this.f.b();
+ this.k.a();
+
+ for (j = 0; j < this.p.size(); ++j) {
+ ((IUpdatePlayerListBox) this.p.get(j)).a();
}
try {
- b();
+ this.b();
} catch (Exception exception) {
- a.log(Level.WARNING, "Unexpected exception while parsing console command", ((Throwable) (exception)));
+ a.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
}
}
public void a(String s, ICommandListener icommandlistener) {
- q.add(((new ServerCommand(s, icommandlistener))));
+ this.q.add(new ServerCommand(s, icommandlistener));
}
public void b() {
- do {
- if (q.size() <= 0) {
- break;
- }
- ServerCommand servercommand = (ServerCommand) q.remove(0);
+ while (this.q.size() > 0) {
+ ServerCommand servercommand = (ServerCommand) this.q.remove(0);
String s = servercommand.a;
ICommandListener icommandlistener = servercommand.b;
String s1 = icommandlistener.c();
- if (s.toLowerCase().startsWith("#help") || s.toLowerCase().startsWith("#?")) {
+ if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) {
+ if (s.toLowerCase().startsWith("list")) {
+ icommandlistener.b("Connected players: " + this.f.c());
+ } else if (s.toLowerCase().startsWith("stop")) {
+ this.a(s1, "Stopping the server..");
+ this.o = false;
+ } else if (s.toLowerCase().startsWith("save-all")) {
+ this.a(s1, "Forcing save..");
+ this.e.a(true, (IProgressUpdate) null);
+ this.a(s1, "Save complete.");
+ } else if (s.toLowerCase().startsWith("save-off")) {
+ this.a(s1, "Disabling level saving..");
+ this.e.C = true;
+ } else if (s.toLowerCase().startsWith("save-on")) {
+ this.a(s1, "Enabling level saving..");
+ this.e.C = false;
+ } else {
+ String s2;
+
+ if (s.toLowerCase().startsWith("op ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.e(s2);
+ this.a(s1, "Opping " + s2);
+ this.f.a(s2, "§eYou are now op!");
+ } else if (s.toLowerCase().startsWith("deop ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.f(s2);
+ this.f.a(s2, "§eYou are no longer op!");
+ this.a(s1, "De-opping " + s2);
+ } else if (s.toLowerCase().startsWith("ban-ip ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.c(s2);
+ this.a(s1, "Banning ip " + s2);
+ } else if (s.toLowerCase().startsWith("pardon-ip ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.d(s2);
+ this.a(s1, "Pardoning ip " + s2);
+ } else {
+ EntityPlayer entityplayer;
+
+ if (s.toLowerCase().startsWith("ban ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.a(s2);
+ this.a(s1, "Banning " + s2);
+ entityplayer = this.f.h(s2);
+ if (entityplayer != null) {
+ entityplayer.a.a("Banned by admin");
+ }
+ } else if (s.toLowerCase().startsWith("pardon ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ this.f.b(s2);
+ this.a(s1, "Pardoning " + s2);
+ } else if (s.toLowerCase().startsWith("kick ")) {
+ s2 = s.substring(s.indexOf(" ")).trim();
+ entityplayer = null;
+
+ for (int i = 0; i < this.f.b.size(); ++i) {
+ EntityPlayer entityplayer1 = (EntityPlayer) this.f.b.get(i);
+
+ if (entityplayer1.name.equalsIgnoreCase(s2)) {
+ entityplayer = entityplayer1;
+ }
+ }
+
+ if (entityplayer != null) {
+ entityplayer.a.a("Kicked by admin");
+ this.a(s1, "Kicking " + entityplayer.name);
+ } else {
+ icommandlistener.b("Can\'t find user " + s2 + ". No kick.");
+ }
+ } else {
+ String[] astring;
+ EntityPlayer entityplayer2;
+
+ if (s.toLowerCase().startsWith("tp ")) {
+ astring = s.split(" ");
+ if (astring.length == 3) {
+ entityplayer = this.f.h(astring[1]);
+ entityplayer2 = this.f.h(astring[2]);
+ if (entityplayer == null) {
+ icommandlistener.b("Can\'t find user " + astring[1] + ". No tp.");
+ } else if (entityplayer2 == null) {
+ icommandlistener.b("Can\'t find user " + astring[2] + ". No tp.");
+ } else {
+ entityplayer.a.a(entityplayer2.locX, entityplayer2.locY, entityplayer2.locZ, entityplayer2.yaw, entityplayer2.pitch);
+ this.a(s1, "Teleporting " + astring[1] + " to " + astring[2] + ".");
+ }
+ } else {
+ icommandlistener.b("Syntax error, please provice a source and a target.");
+ }
+ } else if (s.toLowerCase().startsWith("give ")) {
+ astring = s.split(" ");
+ if (astring.length != 3 && astring.length != 4) {
+ return;
+ }
+
+ String s3 = astring[1];
+
+ entityplayer2 = this.f.h(s3);
+ if (entityplayer2 != null) {
+ try {
+ int j = Integer.parseInt(astring[2]);
+
+ if (Item.byId[j] != null) {
+ this.a(s1, "Giving " + entityplayer2.name + " some " + j);
+ int k = 1;
+
+ if (astring.length > 3) {
+ k = this.b(astring[3], 1);
+ }
+
+ if (k < 1) {
+ k = 1;
+ }
+
+ if (k > 64) {
+ k = 64;
+ }
+
+ entityplayer2.b(new ItemStack(j, k, 0));
+ } else {
+ icommandlistener.b("There\'s no item with id " + j);
+ }
+ } catch (NumberFormatException numberformatexception) {
+ icommandlistener.b("There\'s no item with id " + astring[2]);
+ }
+ } else {
+ icommandlistener.b("Can\'t find user " + s3);
+ }
+ } else if (s.toLowerCase().startsWith("say ")) {
+ s = s.substring(s.indexOf(" ")).trim();
+ a.info("[" + s1 + "] " + s);
+ this.f.a((Packet) (new Packet3Chat("§d[Server] " + s)));
+ } else if (s.toLowerCase().startsWith("tell ")) {
+ astring = s.split(" ");
+ if (astring.length >= 3) {
+ s = s.substring(s.indexOf(" ")).trim();
+ s = s.substring(s.indexOf(" ")).trim();
+ a.info("[" + s1 + "->" + astring[1] + "] " + s);
+ s = "§7" + s1 + " whispers " + s;
+ a.info(s);
+ if (!this.f.a(astring[1], (Packet) (new Packet3Chat(s)))) {
+ icommandlistener.b("There\'s no player by that name online.");
+ }
+ }
+ } else {
+ a.info("Unknown console command. Type \"help\" for help.");
+ }
+ }
+ }
+ }
+ } else {
icommandlistener.b("To run the server without a gui, start it like this:");
icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
icommandlistener.b("Console commands:");
@@ -311,181 +470,39 @@ public class MinecraftServer implements ICommandListener, Runnable {
icommandlistener.b(" save-on re-enables terrain saving");
icommandlistener.b(" list lists all currently connected players");
icommandlistener.b(" say <message> broadcasts a message to all players");
- } else if (s.toLowerCase().startsWith("#list")) {
- icommandlistener.b((new StringBuilder()).append("Connected players: ").append(f.c()).toString());
- } else if (s.toLowerCase().startsWith("#stop")) {
- a(s1, "Stopping the server..");
- o = false;
- } else if (s.toLowerCase().startsWith("#save-all")) {
- a(s1, "Forcing save..");
- e.a(true, ((IProgressUpdate) (null)));
- a(s1, "Save complete.");
- } else if (s.toLowerCase().startsWith("#save-off")) {
- a(s1, "Disabling level saving..");
- e.C = true;
- } else if (s.toLowerCase().startsWith("#save-on")) {
- a(s1, "Enabling level saving..");
- e.C = false;
- } else if (s.toLowerCase().startsWith("#op ")) {
- String s2 = s.substring(s.indexOf(" ")).trim();
-
- f.e(s2);
- a(s1, (new StringBuilder()).append("Opping ").append(s2).toString());
- f.a(s2, "\247eYou are now op!");
- } else if (s.toLowerCase().startsWith("#deop ")) {
- String s3 = s.substring(s.indexOf(" ")).trim();
-
- f.f(s3);
- f.a(s3, "\247eYou are no longer op!");
- a(s1, (new StringBuilder()).append("De-opping ").append(s3).toString());
- } else if (s.toLowerCase().startsWith("#ban-ip ")) {
- String s4 = s.substring(s.indexOf(" ")).trim();
-
- f.c(s4);
- a(s1, (new StringBuilder()).append("Banning ip ").append(s4).toString());
- } else if (s.toLowerCase().startsWith("#pardon-ip ")) {
- String s5 = s.substring(s.indexOf(" ")).trim();
-
- f.d(s5);
- a(s1, (new StringBuilder()).append("Pardoning ip ").append(s5).toString());
- } else if (s.toLowerCase().startsWith("#ban ")) {
- String s6 = s.substring(s.indexOf(" ")).trim();
-
- f.a(s6);
- a(s1, (new StringBuilder()).append("Banning ").append(s6).toString());
- EntityPlayerMP entityplayermp = f.h(s6);
-
- if (entityplayermp != null) {
- entityplayermp.a.a("Banned by admin");
- }
- } else if (s.toLowerCase().startsWith("#pardon ")) {
- String s7 = s.substring(s.indexOf(" ")).trim();
-
- f.b(s7);
- a(s1, (new StringBuilder()).append("Pardoning ").append(s7).toString());
- } else if (s.toLowerCase().startsWith("#kick ")) {
- String s8 = s.substring(s.indexOf(" ")).trim();
- EntityPlayerMP entityplayermp1 = null;
-
- for (int i1 = 0; i1 < f.b.size(); i1++) {
- EntityPlayerMP entityplayermp5 = (EntityPlayerMP) f.b.get(i1);
-
- if (entityplayermp5.aw.equalsIgnoreCase(s8)) {
- entityplayermp1 = entityplayermp5;
- }
- }
-
- if (entityplayermp1 != null) {
- entityplayermp1.a.a("Kicked by admin");
- a(s1, (new StringBuilder()).append("Kicking ").append(entityplayermp1.aw).toString());
- } else {
- icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s8).append(". No kick.").toString());
- }
- } else if (s.toLowerCase().startsWith("#tp ")) {
- String as[] = s.split(" ");
-
- if (as.length == 3) {
- EntityPlayerMP entityplayermp2 = f.h(as[1]);
- EntityPlayerMP entityplayermp3 = f.h(as[2]);
-
- if (entityplayermp2 == null) {
- icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[1]).append(". No tp.").toString());
- } else if (entityplayermp3 == null) {
- icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[2]).append(". No tp.").toString());
- } else {
- entityplayermp2.a.a(entityplayermp3.p, entityplayermp3.q, entityplayermp3.r, entityplayermp3.v, entityplayermp3.w);
- a(s1, (new StringBuilder()).append("Teleporting ").append(as[1]).append(" to ").append(as[2]).append(".").toString());
- }
- } else {
- icommandlistener.b("Syntax error, please provice a source and a target.");
- }
- } else if (s.toLowerCase().startsWith("#give ")) {
- String as1[] = s.split(" ");
-
- if (as1.length != 3 && as1.length != 4) {
- return;
- }
- String s9 = as1[1];
- EntityPlayerMP entityplayermp4 = f.h(s9);
-
- if (entityplayermp4 != null) {
- try {
- int j1 = Integer.parseInt(as1[2]);
-
- if (Item.c[j1] != null) {
- a(s1, (new StringBuilder()).append("Giving ").append(entityplayermp4.aw).append(" some ").append(j1).toString());
- int k1 = 1;
-
- if (as1.length > 3) {
- k1 = b(as1[3], 1);
- }
- if (k1 < 1) {
- k1 = 1;
- }
- if (k1 > 64) {
- k1 = 64;
- }
- entityplayermp4.b(new ItemStack(j1, k1, 0));
- } else {
- icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(j1).toString());
- }
- } catch (NumberFormatException numberformatexception) {
- icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(as1[2]).toString());
- }
- } else {
- icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s9).toString());
- }
- } else if (s.toLowerCase().startsWith("#say ")) {
- s = s.substring(s.indexOf(" ")).trim();
- a.info((new StringBuilder()).append("[").append(s1).append("] ").append(s).toString());
- f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247d[Server] ").append(s).toString()))));
- } else if (s.toLowerCase().startsWith("#tell ")) {
- String as2[] = s.split(" ");
-
- if (as2.length >= 3) {
- s = s.substring(s.indexOf(" ")).trim();
- s = s.substring(s.indexOf(" ")).trim();
- a.info((new StringBuilder()).append("[").append(s1).append("->").append(as2[1]).append("] ").append(s).toString());
- s = (new StringBuilder()).append("\2477").append(s1).append(" whispers ").append(s).toString();
- a.info(s);
- if (!f.a(as2[1], ((Packet) (new Packet3Chat(s))))) {
- icommandlistener.b("There's no player by that name online.");
- }
- }
- } else {
- a.info("Unknown console command. Type \"help\" for help.");
}
- } while (true);
+ }
}
private void a(String s, String s1) {
- String s2 = (new StringBuilder()).append(s).append(": ").append(s1).toString();
+ String s2 = s + ": " + s1;
- f.i((new StringBuilder()).append("\2477(").append(s2).append(")").toString());
+ this.f.i("§7(" + s2 + ")");
a.info(s2);
}
- private int b(String s, int i1) {
+ private int b(String s, int i) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException numberformatexception) {
- return i1;
+ return i;
}
}
public void a(IUpdatePlayerListBox iupdateplayerlistbox) {
- p.add(((iupdateplayerlistbox)));
+ this.p.add(iupdateplayerlistbox);
}
// Craftbukkit start - replaces main(String args[])
public static void main(final OptionSet options) {
try {
+ MinecraftServer minecraftserver = new MinecraftServer();
+
// CraftBukkit - remove gui
- MinecraftServer minecraftserver = new MinecraftServer(options);
(new ThreadServerApplication("Server thread", minecraftserver)).start();
} catch (Exception exception) {
- a.log(Level.SEVERE, "Failed to start the minecraft server", ((Throwable) (exception)));
+ a.log(Level.SEVERE, "Failed to start the minecraft server", exception);
}
}
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index 1d53f57f..111276f6 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -1,7 +1,8 @@
package net.minecraft.server;
-import java.io.PrintStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
import java.util.logging.Logger;
// CraftBukkit start
@@ -28,66 +29,71 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public static Logger a = Logger.getLogger("Minecraft");
public NetworkManager b;
- public boolean c;
+ public boolean c = false;
private MinecraftServer d;
- private EntityPlayerMP e;
- private int f;
+ private EntityPlayer e;
+ private int f = 0;
private double g;
private double h;
private double i;
- private boolean j;
- private Map k;
+ private boolean j = true;
+ private Map k = new HashMap();
- // CraftBukkit start - next 2 lines
+ public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
+ this.d = minecraftserver;
+ this.b = networkmanager;
+ networkmanager.a((NetHandler) this);
+ this.e = entityplayer;
+ entityplayer.a = this;
+
+ // CraftBukkit start
+ server = minecraftserver.server;
+ }
private final CraftServer server;
+ // Get position of last block hit for BlockDamageLevel.STOPPED
+ private int lastX;
+ private int lastY;
+ private int lastZ;
+
+ // Store the last block right clicked and what type it was
+ private CraftBlock lastRightClicked;
+ private int lastMaterial;
+
public CraftPlayer getPlayer() {
- return (e == null)?null:(CraftPlayer)e.getBukkitEntity();
+ return (e == null) ? null : (CraftPlayer) e.getBukkitEntity();
}
// CraftBukkit end
- public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayerMP entityplayermp) {
- c = false;
- f = 0;
- j = true;
- k = ((Map) (new HashMap()));
- d = minecraftserver;
- b = networkmanager;
- networkmanager.a(((NetHandler) (this)));
- e = entityplayermp;
- entityplayermp.a = this;
-
- // CraftBukkit - next 2 lines
- server = minecraftserver.server;
- }
public void a() {
- b.a();
- if (f++ % 20 == 0) {
- b.a(((Packet) (new Packet0KeepAlive())));
+ this.b.a();
+ if (this.f++ % 20 == 0) {
+ this.b.a((Packet) (new Packet0KeepAlive()));
}
}
public void a(String s) {
- b.a(((Packet) (new Packet255KickDisconnect(s))));
- b.c();
- d.f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247e").append(e.aw).append(" left the game.").toString()))));
- d.f.c(e);
- c = true;
+ this.b.a((Packet) (new Packet255KickDisconnect(s)));
+ this.b.c();
+ this.d.f.a((Packet) (new Packet3Chat("§e" + this.e.name + " left the game.")));
+ this.d.f.c(this.e);
+ this.c = true;
}
public void a(Packet10Flying packet10flying) {
- if (!j) {
- double d1 = packet10flying.b - h;
+ double d0;
- if (packet10flying.a == g && d1 * d1 < 0.01D && packet10flying.c == i) {
- j = true;
+ if (!this.j) {
+ d0 = packet10flying.b - this.h;
+ if (packet10flying.a == this.g && d0 * d0 < 0.01D && packet10flying.c == this.i) {
+ this.j = true;
}
}
// CraftBukkit start
Player player = getPlayer();
- Location from = new Location(player.getWorld(), g, h, i, e.v, e.w);
+ Location from = new Location(player.getWorld(), g, h, i, this.e.yaw, this.e.pitch);
Location to = player.getLocation();
if (!from.equals(to)) {
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_MOVE, player, from, to);
@@ -96,276 +102,287 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
- e.p = to.getX();
- e.q = to.getY();
- e.r = to.getZ();
- e.v = to.getYaw();
- e.w = to.getPitch();
+ this.e.locX = to.getX();
+ this.e.locY = to.getY();
+ this.e.locZ = to.getZ();
+ this.e.yaw = to.getYaw();
+ this.e.pitch = to.getPitch();
}
// CraftBukkit end
- if (j) {
- if (e.k != null) {
- float f1 = e.v;
- float f2 = e.w;
+ if (this.j) {
+ double d1;
+ double d2;
+ double d3;
+ double d4;
- e.k.E();
- double d3 = e.p;
- double d5 = e.q;
- double d7 = e.r;
- double d9 = 0.0D;
- double d10 = 0.0D;
+ if (this.e.vehicle != null) {
+ float f = this.e.yaw;
+ float f1 = this.e.pitch;
+ this.e.vehicle.E();
+ d1 = this.e.locX;
+ d2 = this.e.locY;
+ d3 = this.e.locZ;
+ double d5 = 0.0D;
+
+ d4 = 0.0D;
if (packet10flying.i) {
- f1 = packet10flying.e;
- f2 = packet10flying.f;
+ f = packet10flying.e;
+ f1 = packet10flying.f;
}
- if (packet10flying.h && packet10flying.b == -999D && packet10flying.d == -999D) {
- d9 = packet10flying.a;
- d10 = packet10flying.c;
+
+ if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -999.0D) {
+ d5 = packet10flying.a;
+ d4 = packet10flying.c;
}
- e.A = packet10flying.g;
- e.n();
- e.c(d9, 0.0D, d10);
- e.b(d3, d5, d7, f1, f2);
- e.s = d9;
- e.u = d10;
- if (e.k != null) {
- d.e.b(e.k, true);
+
+ this.e.onGround = packet10flying.g;
+ this.e.n();
+ this.e.c(d5, 0.0D, d4);
+ this.e.b(d1, d2, d3, f, f1);
+ this.e.motX = d5;
+ this.e.motZ = d4;
+ if (this.e.vehicle != null) {
+ this.d.e.b(this.e.vehicle, true);
}
- if (e.k != null) {
- e.k.E();
+
+ if (this.e.vehicle != null) {
+ this.e.vehicle.E();
}
- d.f.b(e);
- g = e.p;
- h = e.q;
- i = e.r;
- d.e.f(((Entity) (e)));
+
+ this.d.f.b(this.e);
+ this.g = this.e.locX;
+ this.h = this.e.locY;
+ this.i = this.e.locZ;
+ this.d.e.f(this.e);
return;
}
- double d2 = e.q;
-
- g = e.p;
- h = e.q;
- i = e.r;
- double d4 = e.p;
- double d6 = e.q;
- double d8 = e.r;
- float f3 = e.v;
- float f4 = e.w;
- if (packet10flying.h && packet10flying.b == -999D && packet10flying.d == -999D) {
+ d0 = this.e.locY;
+ this.g = this.e.locX;
+ this.h = this.e.locY;
+ this.i = this.e.locZ;
+ d1 = this.e.locX;
+ d2 = this.e.locY;
+ d3 = this.e.locZ;
+ float f2 = this.e.yaw;
+ float f3 = this.e.pitch;
+
+ if (packet10flying.h && packet10flying.b == -999.0D && packet10flying.d == -999.0D) {
packet10flying.h = false;
}
+
if (packet10flying.h) {
- d4 = packet10flying.a;
- d6 = packet10flying.b;
- d8 = packet10flying.c;
- double d11 = packet10flying.d - packet10flying.b;
-
- if (d11 > 1.6499999999999999D || d11 < 0.10000000000000001D) {
- a("Illegal stance");
- a.warning((new StringBuilder()).append(e.aw).append(" had an illegal stance: ").append(d11).toString());
+ d1 = packet10flying.a;
+ d2 = packet10flying.b;
+ d3 = packet10flying.c;
+ d4 = packet10flying.d - packet10flying.b;
+ if (d4 > 1.65D || d4 < 0.1D) {
+ this.a("Illegal stance");
+ a.warning(this.e.name + " had an illegal stance: " + d4);
}
- e.al = packet10flying.d;
+
+ this.e.al = packet10flying.d;
}
+
if (packet10flying.i) {
- f3 = packet10flying.e;
- f4 = packet10flying.f;
- }
- e.n();
- e.R = 0.0F;
- e.b(g, h, i, f3, f4);
- double d12 = d4 - e.p;
- double d13 = d6 - e.q;
- double d14 = d8 - e.r;
- float f5 = 0.0625F;
- boolean flag = d.e.a(((Entity) (e)), e.z.b().e(f5, f5, f5)).size() == 0;
-
- e.c(d12, d13, d14);
- d12 = d4 - e.p;
- d13 = d6 - e.q;
- if (d13 > -0.5D || d13 < 0.5D) {
- d13 = 0.0D;
- }
- d14 = d8 - e.r;
- double d15 = d12 * d12 + d13 * d13 + d14 * d14;
+ f2 = packet10flying.e;
+ f3 = packet10flying.f;
+ }
+
+ this.e.n();
+ this.e.R = 0.0F;
+ this.e.b(this.g, this.h, this.i, f2, f3);
+ d4 = d1 - this.e.locX;
+ double d6 = d2 - this.e.locY;
+ double d7 = d3 - this.e.locZ;
+ float f4 = 0.0625F;
+ boolean flag = this.d.e.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
+
+ this.e.c(d4, d6, d7);
+ d4 = d1 - this.e.locX;
+ d6 = d2 - this.e.locY;
+ 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 (d15 > 0.0625D) {
+ if (d8 > 0.0625D) {
flag1 = true;
- a.warning((new StringBuilder()).append(e.aw).append(" moved wrongly!").toString());
- System.out.println((new StringBuilder()).append("Got position ").append(d4).append(", ").append(d6).append(", ").append(d8).toString());
- System.out.println((new StringBuilder()).append("Expected ").append(e.p).append(", ").append(e.q).append(", ").append(e.r).toString());
+ a.warning(this.e.name + " moved wrongly!");
+ System.out.println("Got position " + d1 + ", " + d2 + ", " + d3);
+ System.out.println("Expected " + this.e.locX + ", " + this.e.locY + ", " + this.e.locZ);
}
- e.b(d4, d6, d8, f3, f4);
- boolean flag2 = d.e.a(((Entity) (e)), e.z.b().e(f5, f5, f5)).size() == 0;
+
+ this.e.b(d1, d2, d3, f2, f3);
+ boolean flag2 = this.d.e.a(this.e, this.e.boundingBox.b().e((double) f4, (double) f4, (double) f4)).size() == 0;
if (flag && (flag1 || !flag2)) {
- a(g, h, i, f3, f4);
+ this.a(this.g, this.h, this.i, f2, f3);
return;
}
- e.A = packet10flying.g;
- d.f.b(e);
- e.b(e.q - d2, packet10flying.g);
+
+ this.e.onGround = packet10flying.g;
+ this.d.f.b(this.e);
+ this.e.b(this.e.locY - d0, packet10flying.g);
}
}
- public void a(double d1, double d2, double d3, float f1, float f2) {
+ public void a(double d0, double d1, double d2, float f, float f1) {
// CraftBukkit start
Player player = getPlayer();
Location from = player.getLocation();
- Location to = new Location(player.getWorld(), d1, d2, d3, f1, f2);
+ Location to = new Location(player.getWorld(), d0, d1, d2, f, f1);
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
server.getPluginManager().callEvent(event);
from = event.getFrom();
to = event.isCancelled() ? from : event.getTo();
- d1 = to.getX();
- d2 = to.getY();
- d3 = to.getZ();
- f1 = to.getYaw();
- f2 = to.getPitch();
+ d0 = to.getX();
+ d1 = to.getY();
+ d2 = to.getZ();
+ f = to.getYaw();
+ f1 = to.getPitch();
// CraftBukkit end
- j = false;
- g = d1;
- h = d2;
- i = d3;
- e.b(d1, d2, d3, f1, f2);
- e.a.b(((Packet) (new Packet13PlayerLookMove(d1, d2 + 1.6200000047683716D, d2, d3, f1, f2, false))));
+ this.j = false;
+ this.g = d0;
+ this.h = d1;
+ this.i = d2;
+ this.e.b(d0, d1, d2, f, f1);
+ this.e.a.b((Packet) (new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false)));
}
- // CraftBukkit start
- // Get position of last block hit for BlockDamageLevel.STOPPED
- private int lastX;
- private int lastY;
- private int lastZ;
- // CraftBukkit end
-
public void a(Packet14BlockDig packet14blockdig) {
if (packet14blockdig.e == 4) {
- e.O();
- return;
- }
- boolean flag = d.e.B = d.f.g(e.aw);
- boolean flag1 = false;
+ this.e.O();
+ } else {
+ boolean flag = this.d.e.B = this.d.f.g(this.e.name);
+ boolean flag1 = false;
- if (packet14blockdig.e == 0) {
- flag1 = true;
- }
- if (packet14blockdig.e == 1) {
- flag1 = true;
- }
- int l = packet14blockdig.a;
- int i1 = packet14blockdig.b;
- int j1 = packet14blockdig.c;
+ if (packet14blockdig.e == 0) {
+ flag1 = true;
+ }
- if (flag1) {
- double d1 = e.p - ((double) l + 0.5D);
- double d2 = e.q - ((double) i1 + 0.5D);
- double d3 = e.r - ((double) j1 + 0.5D);
- double d4 = d1 * d1 + d2 * d2 + d3 * d3;
+ if (packet14blockdig.e == 1) {
+ flag1 = true;
+ }
- if (d4 > 36D) {
- return;
+ int i = packet14blockdig.a;
+ int j = packet14blockdig.b;
+ int k = packet14blockdig.c;
+
+ if (flag1) {
+ double d0 = this.e.locX - ((double) i + 0.5D);
+ double d1 = this.e.locY - ((double) j + 0.5D);
+ double d2 = this.e.locZ - ((double) k + 0.5D);
+ double d3 = d0 * d0 + d1 * d1 + d2 * d2;
+
+ if (d3 > 36.0D) {
+ return;
+ }
+
+ double d4 = this.e.locY;
+
+ this.e.locY = this.e.al;
+ this.e.locY = d4;
}
- double d5 = e.q;
- e.q = e.al;
- e.q = d5;
- }
- int k1 = packet14blockdig.d;
- int l1 = (int) MathHelper.e(l - d.e.m);
- int i2 = (int) MathHelper.e(j1 - d.e.o);
+ int l = packet14blockdig.d;
+ int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
+ int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
- if (l1 > i2) {
- i2 = l1;
- }
+ if (i1 > j1) {
+ j1 = i1;
+ }
- // CraftBukkit start
- CraftPlayer player = getPlayer();
- CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1);
- int blockId = block.getTypeId();
- float damage = 0;
- if(Block.m[blockId] != null) {
- damage = Block.m[blockId].a(player.getHandle()); //Get amount of damage going to block
- }
+ // CraftBukkit start
+ CraftPlayer player = getPlayer();
+ CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1);
+ int blockId = block.getTypeId();
+ float damage = 0;
+ if(Block.byId[blockId] != null) {
+ damage = Block.byId[blockId].a(player.getHandle()); //Get amount of damage going to block
+ }
+ // CraftBukkit end
- if (packet14blockdig.e == 0) {
- if (i2 > 16 || flag) {
- if(blockId > 0) {
+ if (packet14blockdig.e == 0) {
+ if (j1 > 16 || flag) {
+ // CraftBukkit start
+ if(blockId > 0) {
+ BlockDamageEvent event;
+ // If the amount of damage that the player is going to do to the block
+ // is >= 1, then the block is going to break (eg, flowers, torches)
+ if (damage >= 1.0F) {
+ event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
+ } else {
+ event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STARTED, player);
+ }
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.e.c.a(i, j, k);
+ }
+ }
+ // CraftBukkit end
+ }
+ } else if (packet14blockdig.e == 2) {
+ // CraftBukkit start - Get last block that the player hit
+ // Otherwise the block is a Bedrock @(0,0,0)
+ block = (CraftBlock) player.getWorld().getBlockAt(lastX, lastY, lastZ);
+ BlockDamageEvent event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STOPPED, player);
+ server.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.e.c.a();
+ }
+ // CraftBukkit end
+ } else if (packet14blockdig.e == 1) {
+ if (j1 > 16 || flag) {
+ // CraftBukkit start
BlockDamageEvent event;
- // If the amount of damage that the player is going to do to the block
- // is >= 1, then the block is going to break (eg, flowers, torches)
- if (damage >= 1.0F) {
+ // If the amount of damage going to the block plus the current amount
+ // of damage is greater than 1, the block is going to break.
+ if (e.c.d + damage >= 1.0F) {
event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
} else {
- event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STARTED, player);
+ event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.DIGGING, player);
}
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- e.c.a(l, i1, j1);
+ this.e.c.a(i, j, k, l);
+ } else {
+ e.c.d = 0; // Reset the amount of damage if stopping break.
}
+ // CraftBukkit end
}
- }
- } else if (packet14blockdig.e == 2) {
- // CraftBukkit start - Get last block that the player hit
- // Otherwise the block is a Bedrock @(0,0,0)
- block = (CraftBlock) player.getWorld().getBlockAt(lastX, lastY, lastZ);
- BlockDamageEvent event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.STOPPED, player);
- server.getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- e.c.a();
- }
- // CraftBukkit end
- } else if (packet14blockdig.e == 1) {
- if (i2 > 16 || flag) {
- // CraftBukkit start
- BlockDamageEvent event;
- // If the amount of damage going to the block plus the current amount
- // of damage is greater than 1, the block is going to break.
- if (e.c.d + damage >= 1.0F) {
- event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.BROKEN, player);
- } else {
- event = new BlockDamageEvent(Type.BLOCK_DAMAGED, block, BlockDamageLevel.DIGGING, player);
- }
- server.getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- e.c.a(l, i1, j1, k1);
- } else {
- e.c.d = 0; // Reset the amount of damage if stopping break.
+ } else if (packet14blockdig.e == 3) {
+ double d5 = this.e.locX - ((double) i + 0.5D);
+ double d6 = this.e.locY - ((double) j + 0.5D);
+ double d7 = this.e.locZ - ((double) k + 0.5D);
+ double d8 = d5 * d5 + d6 * d6 + d7 * d7;
+
+ if (d8 < 256.0D) {
+ this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
}
- // CraftBukkit end
}
- } else if (packet14blockdig.e == 3) {
- double d6 = e.p - ((double) l + 0.5D);
- double d7 = e.q - ((double) i1 + 0.5D);
- double d8 = e.r - ((double) j1 + 0.5D);
- double d9 = d6 * d6 + d7 * d7 + d8 * d8;
- if (d9 < 256D) {
- e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
- }
- }
-
- // CraftBukkit start
- lastX = l;
- lastY = i1;
- lastZ = j1;
- // CraftBukkit end
+ // CraftBukkit start
+ lastX = i;
+ lastY = j;
+ lastZ = k;
+ // CraftBukkit end
- d.e.B = false;
+ this.d.e.B = false;
+ }
}
- // CraftBukkit start - store the last block right clicked and what type it was
- CraftBlock lastRightClicked;
- int lastMaterial;
-
public void a(Packet15Place packet15place) {
- ItemStack itemstack = e.an.e();
- boolean flag = d.e.B = d.f.g(e.aw);
+ ItemStack itemstack = this.e.inventory.e();
+ boolean flag = this.d.e.B = this.d.f.g(this.e.name);
// CraftBukkit start
CraftBlock blockClicked = null;
@@ -373,7 +390,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (packet15place.d == 255) {
// CraftBukkit ITEM_USE -- if we have a lastRightClicked then it could be a usable location
- if (packet15place.e != null && packet15place.e.c == lastMaterial) {
+ if (packet15place.e != null && packet15place.e.id == lastMaterial) {
blockClicked = lastRightClicked;
} else if (lastMaterial == 0) {
blockClicked = lastRightClicked;
@@ -384,7 +401,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit RIGHTCLICK or BLOCK_PLACE .. or nothing
blockClicked = (CraftBlock) d.e.getWorld().getBlockAt(packet15place.a, packet15place.b, packet15place.c);
lastRightClicked = blockClicked;
- lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.c;
+ lastMaterial = (packet15place.e == null) ? 0 : packet15place.e.id;
}
if (blockClicked != null && itemstack != null) {
@@ -406,10 +423,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start
Type eventType = Type.PLAYER_ITEM;
- Player who = (e == null)?null:(Player)e.getBukkitEntity();
+ Player who = (this.e == null) ? null : (Player) this.e.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
-
- PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+
+ PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
// CraftBukkit We still call this event even in spawn protection.
// Don't call this event if using Buckets / signs
@@ -420,136 +437,149 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
case LAVA_BUCKET:
break;
default:
- server.getPluginManager().callEvent(pie);
+ server.getPluginManager().callEvent(event);
}
- if (!pie.isCancelled()) {
- int itemstackAmount = itemstack.a;
- e.c.a(((EntityPlayer) (e)), ((World) (d.e)), itemstack);
+ if (!event.isCancelled()) {
+ int itemstackAmount = itemstack.count;
+ this.e.c.a(this.e, this.d.e, itemstack);
+
// CraftBukkit notch decrements the counter by 1 in the above method with food,
// snowballs and so forth, but he does it in a place that doesnt cause the
// inventory update packet to get sent
- always = (itemstack.a != itemstackAmount);
+ always = (itemstack.count != itemstackAmount);
}
// CraftBukkit end
} else {
- int l = packet15place.a;
- int i1 = packet15place.b;
- int j1 = packet15place.c;
- int k1 = packet15place.d;
- int l1 = (int) MathHelper.e(l - d.e.m);
- int i2 = (int) MathHelper.e(j1 - d.e.o);
-
- if (l1 > i2) {
- i2 = l1;
+ int i = packet15place.a;
+ int j = packet15place.b;
+ int k = packet15place.c;
+ int l = packet15place.d;
+ int i1 = (int) MathHelper.e((float) (i - this.d.e.spawnX));
+ int j1 = (int) MathHelper.e((float) (k - this.d.e.spawnZ));
+
+ if (i1 > j1) {
+ j1 = i1;
}
- // CraftBukkit start - spawn proection moved to ItemBlock!!!
+
+ // CraftBukkit start - spawn protection moved to ItemBlock!!!
CraftItemStack craftItem = new CraftItemStack(itemstack);
Player player = getPlayer();
- BlockRightClickEvent brce = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
- server.getPluginManager().callEvent(brce);
+ BlockRightClickEvent event = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
+ server.getPluginManager().callEvent(event);
- e.c.a(((EntityPlayer) (e)), ((World) (d.e)), itemstack, l, i1, j1, k1);
+ this.e.c.a(this.e, this.d.e, itemstack, i, j, k, l);
// CraftBukkit end
- e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
- if (k1 == 0) {
- i1--;
+ this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
+ if (l == 0) {
+ --j;
}
- if (k1 == 1) {
- i1++;
+
+ if (l == 1) {
+ ++j;
}
- if (k1 == 2) {
- j1--;
+
+ if (l == 2) {
+ --k;
}
- if (k1 == 3) {
- j1++;
+
+ if (l == 3) {
+ ++k;
}
- if (k1 == 4) {
- l--;
+
+ if (l == 4) {
+ --i;
}
- if (k1 == 5) {
- l++;
+
+ if (l == 5) {
+ ++i;
}
- e.a.b(((Packet) (new Packet53BlockChange(l, i1, j1, ((World) (d.e))))));
+
+ this.e.a.b((Packet) (new Packet53BlockChange(i, j, k, this.d.e)));
}
- if (itemstack != null && itemstack.a == 0) {
- e.an.a[e.an.c] = null;
+
+ if (itemstack != null && itemstack.count == 0) {
+ this.e.inventory.a[this.e.inventory.c] = null;
}
- e.am = true;
- e.an.a[e.an.c] = ItemStack.b(e.an.a[e.an.c]);
- Slot slot = e.ap.a(((IInventory) (e.an)), e.an.c);
- e.ap.a();
- e.am = false;
+ this.e.am = true;
+ this.e.inventory.a[this.e.inventory.c] = ItemStack.b(this.e.inventory.a[this.e.inventory.c]);
+ Slot slot = this.e.activeContainer.a(this.e.inventory, this.e.inventory.c);
+
+ this.e.activeContainer.a();
+ this.e.am = false;
+
// CraftBukkit - Boolean flag
- if (!ItemStack.a(e.an.e(), packet15place.e) || always) {
- b(((Packet) (new Packet103(e.ap.f, slot.c, e.an.e()))));
+ if (!ItemStack.a(this.e.inventory.e(), packet15place.e) || always) {
+ this.b((Packet) (new Packet103SetSlot(this.e.activeContainer.f, slot.c, this.e.inventory.e())));
}
- d.e.B = false;
+
+ this.d.e.B = false;
}
- public void a(String s, Object aobj[]) {
- a.info((new StringBuilder()).append(e.aw).append(" lost connection: ").append(s).toString());
- d.f.a(((Packet) (new Packet3Chat((new StringBuilder()).append("\247e").append(e.aw).append(" left the game.").toString()))));
- d.f.c(e);
- c = true;
+ public void a(String s, Object[] aobject) {
+ a.info(this.e.name + " lost connection: " + s);
+ this.d.f.a((Packet) (new Packet3Chat("§e" + this.e.name + " left the game.")));
+ this.d.f.c(this.e);
+ this.c = true;
}
public void a(Packet packet) {
- a.warning((new StringBuilder()).append((((this).getClass()))).append(" wasn't prepared to deal with a ").append(((((packet)).getClass()))).toString());
- a("Protocol error, unexpected packet");
+ a.warning(this.getClass() + " wasn\'t prepared to deal with a " + packet.getClass());
+ this.a("Protocol error, unexpected packet");
}
public void b(Packet packet) {
- b.a(packet);
+ this.b.a(packet);
}
public void a(Packet16BlockItemSwitch packet16blockitemswitch) {
- e.an.c = packet16blockitemswitch.a;
+ this.e.inventory.c = packet16blockitemswitch.a;
}
public void a(Packet3Chat packet3chat) {
String s = packet3chat.a;
if (s.length() > 100) {
- a("Chat message too long");
- return;
- }
- s = s.trim();
- for (int l = 0; l < s.length(); l++) {
- if (FontAllowedCharacters.a.indexOf(((int) (s.charAt(l)))) < 0) {
- a("Illegal characters in chat");
- return;
- }
- }
-
- if (s.startsWith("/")) {
- c(s);
+ this.a("Chat message too long");
} else {
- // CraftBukkit start
- Player player = getPlayer();
- PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
- server.getPluginManager().callEvent(event);
- s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
- if (event.isCancelled()) {
- return;
+ s = s.trim();
+
+ for (int i = 0; i < s.length(); ++i) {
+ if (FontAllowedCharacters.a.indexOf(s.charAt(i)) < 0) {
+ this.a("Illegal characters in chat");
+ return;
+ }
}
- // CraftBukkit end
- a.info(s);
- d.f.a(((Packet) (new Packet3Chat(s))));
+ if (s.startsWith("/")) {
+ this.c(s);
+ } else {
+ // CraftBukkit start
+ Player player = getPlayer();
+ PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
+ server.getPluginManager().callEvent(event);
+ s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
+ a.info(s);
+ this.d.f.a((Packet) (new Packet3Chat(s)));
+ }
}
}
private void c(String s) {
// CraftBukkit start
CraftPlayer player = getPlayer();
- boolean targetPluginFound = server.dispatchCommand(player , s);
+ boolean targetPluginFound = server.dispatchCommand(player, s);
if (targetPluginFound) {
return;
}
-
+
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, player, s);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -557,167 +587,175 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
s = event.getMessage();
player = (CraftPlayer) event.getPlayer();
- EntityPlayerMP e = player.getHandle();
+ EntityPlayer e = player.getHandle();
// CraftBukkit stop
if (s.toLowerCase().startsWith("/me ")) {
- s = (new StringBuilder()).append("* ").append(e.aw).append(" ").append(s.substring(s.indexOf(" ")).trim()).toString();
+ s = "* " + this.e.name + " " + s.substring(s.indexOf(" ")).trim();
a.info(s);
- d.f.a(((Packet) (new Packet3Chat(s))));
+ this.d.f.a((Packet) (new Packet3Chat(s)));
} else if (s.toLowerCase().startsWith("/kill")) {
- e.a(((Entity) (null)), 1000);
+ this.e.a((Entity) null, 1000);
} else if (s.toLowerCase().startsWith("/tell ")) {
- String as[] = s.split(" ");
+ String[] astring = s.split(" ");
- if (as.length >= 3) {
+ if (astring.length >= 3) {
s = s.substring(s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim();
- s = (new StringBuilder()).append("\2477").append(e.aw).append(" whispers ").append(s).toString();
- a.info((new StringBuilder()).append(s).append(" to ").append(as[1]).toString());
- if (!d.f.a(as[1], ((Packet) (new Packet3Chat(s))))) {
- b(((Packet) (new Packet3Chat("\247cThere's no player by that name online."))));
+ s = "§7" + this.e.name + " whispers " + s;
+ a.info(s + " to " + astring[1]);
+ if (!this.d.f.a(astring[1], (Packet) (new Packet3Chat(s)))) {
+ this.b((Packet) (new Packet3Chat("§cThere\'s no player by that name online.")));
}
}
- } else if (d.f.g(e.aw)) {
- String s1 = s.substring(1);
-
- a.info((new StringBuilder()).append(e.aw).append(" issued server command: ").append(s1).toString());
- d.a(s1, ((ICommandListener) (this)));
} else {
- String s2 = s.substring(1);
+ String s1;
- a.info((new StringBuilder()).append(e.aw).append(" tried command: ").append(s2).toString());
+ if (this.d.f.g(this.e.name)) {
+ s1 = s.substring(1);
+ a.info(this.e.name + " issued server command: " + s1);
+ this.d.a(s1, (ICommandListener) this);
+ } else {
+ s1 = s.substring(1);
+ a.info(this.e.name + " tried command: " + s1);
+ }
}
}
public void a(Packet18ArmAnimation packet18armanimation) {
if (packet18armanimation.b == 1) {
+ // CraftBukkit start - Arm swing animation
Player player = getPlayer();
- // CraftBukkit: Arm swing animation
PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
server.getPluginManager().callEvent(event);
-
- e.K();
+ // CraftBukkit end
+
+ this.e.K();
}
}
- public void a(Packet19 packet19) {
- if (packet19.b == 1) {
- e.b(true);
- } else if (packet19.b == 2) {
- e.b(false);
+ public void a(Packet19EntityAction packet19entityaction) {
+ if (packet19entityaction.b == 1) {
+ this.e.b(true);
+ } else if (packet19entityaction.b == 2) {
+ this.e.b(false);
}
}
public void a(Packet255KickDisconnect packet255kickdisconnect) {
- b.a("disconnect.quitting", new Object[0]);
+ this.b.a("disconnect.quitting", new Object[0]);
}
public int b() {
- return b.d();
+ return this.b.d();
}
public void b(String s) {
- b(((Packet) (new Packet3Chat((new StringBuilder()).append("\2477").append(s).toString()))));
+ this.b((Packet) (new Packet3Chat("§7" + s)));
}
public String c() {
- return e.aw;
+ return this.e.name;
}
- public void a(Packet7 packet7) {
- Entity entity = d.e.a(packet7.b);
+ public void a(Packet7UseEntity packet7useentity) {
+ Entity entity = this.d.e.a(packet7useentity.b);
- if (entity != null && e.i(entity)) {
- if (packet7.c == 0) {
- e.g(entity);
- } else if (packet7.c == 1) {
- e.h(entity);
+ if (entity != null && this.e.i(entity)) {
+ if (packet7useentity.c == 0) {
+ this.e.g(entity);
+ } else if (packet7useentity.c == 1) {
+ this.e.h(entity);
}
}
}
- public void a(Packet9 packet9) {
- if (e.aZ > 0) {
- return;
- } else {
- e = d.f.d(e);
+ public void a(Packet9Respawn packet9respawn) {
+ if (this.e.health <= 0) {
+ this.e = this.d.f.d(this.e);
+
+ // CraftBukkit start
CraftPlayer player = getPlayer();
- player.setHandle(e); // CraftBukkit
- return;
+ player.setHandle(e);
+ // CraftBukkit end
}
}
- public void a(Packet101 packet101) {
- e.N();
+ public void a(Packet101CloseWindow packet101closewindow) {
+ this.e.N();
}
- public void a(Packet102 packet102) {
- if (e.ap.f == packet102.a && e.ap.c(((EntityPlayer) (e)))) {
- ItemStack itemstack = e.ap.a(packet102.b, packet102.c, ((EntityPlayer) (e)));
+ public void a(Packet102WindowClick packet102windowclick) {
+ if (this.e.activeContainer.f == packet102windowclick.a && this.e.activeContainer.c(this.e)) {
+ ItemStack itemstack = this.e.activeContainer.a(packet102windowclick.b, packet102windowclick.c, this.e);
- if (ItemStack.a(packet102.e, itemstack)) {
- e.a.b(((Packet) (new Packet106(packet102.a, packet102.d, true))));
- e.am = true;
- e.ap.a();
- e.M();
- e.am = false;
+ if (ItemStack.a(packet102windowclick.e, itemstack)) {
+ this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true)));
+ this.e.am = true;
+ this.e.activeContainer.a();
+ this.e.M();
+ this.e.am = false;
} else {
- k.put(((Integer.valueOf(e.ap.f))), ((Short.valueOf(packet102.d))));
- e.a.b(((Packet) (new Packet106(packet102.a, packet102.d, false))));
- e.ap.a(((EntityPlayer) (e)), false);
+ this.k.put(Integer.valueOf(this.e.activeContainer.f), Short.valueOf(packet102windowclick.d));
+ this.e.a.b((Packet) (new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false)));
+ this.e.activeContainer.a(this.e, false);
ArrayList arraylist = new ArrayList();
- for (int l = 0; l < e.ap.e.size(); l++) {
- ((List) (arraylist)).add(((((Slot) e.ap.e.get(l)).c())));
+ for (int i = 0; i < this.e.activeContainer.e.size(); ++i) {
+ arraylist.add(((Slot) this.e.activeContainer.e.get(i)).c());
}
- e.a(e.ap, ((List) (arraylist)));
+ this.e.a(this.e.activeContainer, arraylist);
}
}
}
- public void a(Packet106 packet106) {
- Short short1 = (Short) k.get(((Integer.valueOf(e.ap.f))));
+ public void a(Packet106Transaction packet106transaction) {
+ Short oshort = (Short) this.k.get(Integer.valueOf(this.e.activeContainer.f));
- if (short1 != null && packet106.b == short1.shortValue() && e.ap.f == packet106.a && !e.ap.c(((EntityPlayer) (e)))) {
- e.ap.a(((EntityPlayer) (e)), true);
+ if (oshort != null && packet106transaction.b == oshort.shortValue() && this.e.activeContainer.f == packet106transaction.a && !this.e.activeContainer.c(this.e)) {
+ this.e.activeContainer.a(this.e, true);
}
}
- public void a(Packet130 packet130) {
- if (d.e.f(packet130.a, packet130.b, packet130.c)) {
- TileEntity tileentity = d.e.m(packet130.a, packet130.b, packet130.c);
+ public void a(Packet130UpdateSign packet130updatesign) {
+ if (this.d.e.f(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c)) {
+ TileEntity tileentity = this.d.e.getTileEntity(packet130updatesign.a, packet130updatesign.b, packet130updatesign.c);
+
+ int i;
+ int j;
- for (int l = 0; l < 4; l++) {
+ for (i = 0; i < 4; ++i) {
boolean flag = true;
- if (packet130.d[l].length() > 15) {
+ if (packet130updatesign.d[i].length() > 15) {
flag = false;
} else {
- for (int k1 = 0; k1 < packet130.d[l].length(); k1++) {
- if (FontAllowedCharacters.a.indexOf(((int) (packet130.d[l].charAt(k1)))) < 0) {
+ for (j = 0; j < packet130updatesign.d[i].length(); ++j) {
+ if (FontAllowedCharacters.a.indexOf(packet130updatesign.d[i].charAt(j)) < 0) {
flag = false;
}
}
}
+
if (!flag) {
- packet130.d[l] = "!?";
+ packet130updatesign.d[i] = "!?";
}
}
if (tileentity instanceof TileEntitySign) {
- int i1 = packet130.a;
- int j1 = packet130.b;
- int l1 = packet130.c;
+ i = packet130updatesign.a;
+ int k = packet130updatesign.b;
+
+ j = packet130updatesign.c;
TileEntitySign tileentitysign = (TileEntitySign) tileentity;
- for (int i2 = 0; i2 < 4; i2++) {
- tileentitysign.e[i2] = packet130.d[i2];
+ for (int l = 0; l < 4; ++l) {
+ tileentitysign.e[l] = packet130updatesign.d[l];
}
tileentitysign.d();
- d.e.g(i1, j1, l1);
+ this.d.e.g(i, k, j);
}
}
}
diff --git a/src/main/java/net/minecraft/server/PropertyManager.java b/src/main/java/net/minecraft/server/PropertyManager.java
index 9e548214..4c741537 100644
--- a/src/main/java/net/minecraft/server/PropertyManager.java
+++ b/src/main/java/net/minecraft/server/PropertyManager.java
@@ -1,6 +1,8 @@
package net.minecraft.server;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -10,26 +12,25 @@ import joptsimple.OptionSet; // CraftBukkit
public class PropertyManager {
public static Logger a = Logger.getLogger("Minecraft");
- private Properties b;
+ private Properties b = new Properties();
private File c;
- public PropertyManager(File file) {
- b = new Properties();
- c = file;
- if (file.exists()) {
+ public PropertyManager(File file1) {
+ this.c = file1;
+ if (file1.exists()) {
try {
- b.load(((java.io.InputStream) (new FileInputStream(file))));
+ this.b.load(new FileInputStream(file1));
} catch (Exception exception) {
- a.log(Level.WARNING, (new StringBuilder()).append("Failed to load ").append(((file))).toString(), ((Throwable) (exception)));
- a();
+ a.log(Level.WARNING, "Failed to load " + file1, exception);
+ this.a();
}
} else {
- a.log(Level.WARNING, (new StringBuilder()).append(((file))).append(" does not exist").toString());
- a();
+ a.log(Level.WARNING, file1 + " does not exist");
+ this.a();
}
}
- // Craftbukkit start
+ // CraftBukkit start
private OptionSet options = null;
public PropertyManager(final OptionSet options) {
@@ -45,45 +46,48 @@ public class PropertyManager {
return value;
}
- // Craftbukkit end
+ // CraftBukkit end
public void a() {
a.log(Level.INFO, "Generating new properties file");
- b();
+ this.b();
}
public void b() {
try {
- b.store(((java.io.OutputStream) (new FileOutputStream(c))), "Minecraft server properties");
+ this.b.store(new FileOutputStream(this.c), "Minecraft server properties");
} catch (Exception exception) {
- a.log(Level.WARNING, (new StringBuilder()).append("Failed to save ").append(((c))).toString(), ((Throwable) (exception)));
- a();
+ a.log(Level.WARNING, "Failed to save " + this.c, exception);
+ this.a();
}
}
public String a(String s, String s1) {
- if (!b.containsKey(((s)))) {
- b.setProperty(s, getOverride(s, s1)); // Craftbukkit
- b();
+ if (!this.b.containsKey(s)) {
+ this.b.setProperty(s, getOverride(s, s1)); // CraftBukkit
+ this.b();
}
- return getOverride(s, b.getProperty(s, s1)); // Craftbukkit
+
+ return getOverride(s, this.b.getProperty(s, s1)); // CraftBukkit
}
public int a(String s, int i) {
try {
- return getOverride(s, Integer.parseInt(a(s, String.valueOf(i)))); // Craftbukkit
+ return getOverride(s, Integer.parseInt(this.a(s, "" + i))); // CraftBukkit
} catch (Exception exception) {
- b.setProperty(s, getOverride(s, i).toString()); // Craftbukkit
+ i = getOverride(s, i); // CraftBukkit
+ this.b.setProperty(s, "" + i);
+ return i;
}
- return getOverride(s, i); // Craftbukkit
}
public boolean a(String s, boolean flag) {
try {
- return getOverride(s, Boolean.parseBoolean(a(s, String.valueOf(flag)))); // Craftbukkit
+ return getOverride(s, Boolean.parseBoolean(this.a(s, "" + flag))); // CraftBukkit
} catch (Exception exception) {
- b.setProperty(s, getOverride(s, flag).toString()); // Craftbukkit
+ flag = getOverride(s, flag); // CraftBukkit
+ this.b.setProperty(s, "" + flag);
+ return flag;
}
- return getOverride(s, flag); // Craftbukkit
}
}
diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
index 0cd6b62c..10de0923 100644
--- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java
+++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
@@ -1,7 +1,15 @@
package net.minecraft.server;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
// CraftBukkit start
@@ -16,100 +24,89 @@ import org.bukkit.event.player.PlayerLoginEvent;
public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft");
- public List b;
+ public List b = new ArrayList();
private MinecraftServer c;
private PlayerManager d;
private int e;
- private Set f;
- private Set g;
- private Set h;
+ private Set f = new HashSet();
+ private Set g = new HashSet();
+ private Set h = new HashSet();
private File i;
private File j;
private File k;
private PlayerNBTManager l;
- private CraftServer server; // CraftBukkit
-
public ServerConfigurationManager(MinecraftServer minecraftserver) {
- // CraftBukkit 2 lines!
- minecraftserver.server = new CraftServer(minecraftserver, this);
- server = minecraftserver.server;
-
- b = ((List) (new ArrayList()));
- f = ((Set) (new HashSet()));
- g = ((Set) (new HashSet()));
- h = ((Set) (new HashSet()));
- c = minecraftserver;
- i = minecraftserver.a("banned-players.txt");
- j = minecraftserver.a("banned-ips.txt");
- k = minecraftserver.a("ops.txt");
- d = new PlayerManager(minecraftserver);
- e = minecraftserver.d.a("max-players", 20);
- e();
- g();
- i();
- f();
- h();
- j();
+ this.c = minecraftserver;
+ this.i = minecraftserver.a("banned-players.txt");
+ this.j = minecraftserver.a("banned-ips.txt");
+ this.k = minecraftserver.a("ops.txt");
+ this.d = new PlayerManager(minecraftserver);
+ this.e = minecraftserver.d.a("max-players", 20);
+ this.e();
+ this.g();
+ this.i();
+ this.f();
+ this.h();
+ this.j();
}
public void a(WorldServer worldserver) {
- l = new PlayerNBTManager(new File(worldserver.t, "players"));
+ this.l = new PlayerNBTManager(new File(worldserver.t, "players"));
}
public int a() {
- return d.b();
+ return this.d.b();
}
- public void a(EntityPlayerMP entityplayermp) {
- b.add(((entityplayermp)));
- l.b(entityplayermp);
- c.e.A.d((int) entityplayermp.p >> 4, (int) entityplayermp.r >> 4);
- for (; c.e.a(((Entity) (entityplayermp)), entityplayermp.z).size() != 0; entityplayermp.a(entityplayermp.p, entityplayermp.q + 1.0D, entityplayermp.r)) {
- ;
+ public void a(EntityPlayer entityplayer) {
+ this.b.add(entityplayer);
+ this.l.b(entityplayer);
+ this.c.e.A.d((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
+
+ while (this.c.e.a(entityplayer, entityplayer.boundingBox).size() != 0) {
+ entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
}
- c.e.a(((Entity) (entityplayermp)));
- d.a(entityplayermp);
- // CraftBukkit
- server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayermp)));
+ this.c.e.a(entityplayer);
+ this.d.a(entityplayer);
}
- public void b(EntityPlayerMP entityplayermp) {
- d.c(entityplayermp);
+ public void b(EntityPlayer entityplayer) {
+ this.d.c(entityplayer);
}
- public void c(EntityPlayerMP entityplayermp) {
- l.a(entityplayermp);
- c.e.d(((Entity) (entityplayermp)));
- b.remove(((entityplayermp)));
- d.b(entityplayermp);
+ public void c(EntityPlayer entityplayer) {
+ this.l.a(entityplayer);
+ this.c.e.d(entityplayer);
+ this.b.remove(entityplayer);
+ this.d.b(entityplayer);
- // CraftBukkit
- server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayermp)));
+ // CraftBukkit start
+ server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayer))); // CraftBukkit
}
+ private CraftServer server;
+ // CraftBukkit end
- public EntityPlayerMP a(NetLoginHandler netloginhandler, String s, String s1) {
+ public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) {
// CraftBukkit start - note: this entire method needs to be changed
// 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
// depending on the outcome.
- EntityPlayerMP entity = new EntityPlayerMP(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
- Player player = (entity == null)?null:(Player)entity.getBukkitEntity();
+ EntityPlayer entity = new EntityPlayer(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
+ Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
- // CraftBukkit end
- String s2 = ((netloginhandler.b.b())).toString();
+ String s2 = netloginhandler.b.b().toString();
s2 = s2.substring(s2.indexOf("/") + 1);
s2 = s2.substring(0, s2.indexOf(":"));
- // CraftBukkit start
- if (f.contains(s.trim().toLowerCase())) {
+ if (this.f.contains(s.trim().toLowerCase())) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!");
- } else if (g.contains(s2)) {
+ } else if (this.g.contains(s2)) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!");
- } else if (b.size() >= e) {
+ } else if (this.b.size() >= this.e) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
}
@@ -118,201 +115,213 @@ public class ServerConfigurationManager {
netloginhandler.a(event.getKickMessage());
return null;
}
- // CraftBukkit end
- for (int i1 = 0; i1 < b.size(); i1++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
- if (entityplayermp.aw.equalsIgnoreCase(s)) {
- entityplayermp.a.a("You logged in from another location");
+ for (int i = 0; i < this.b.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
+
+ if (entityplayer.name.equalsIgnoreCase(s)) {
+ entityplayer.a.a("You logged in from another location");
}
}
- // CraftBukkit
- return entity;
+ return new EntityPlayer(this.c, this.c.e, s, new ItemInWorldManager(this.c.e));
+ // CraftBukkit end
}
- public EntityPlayerMP d(EntityPlayerMP entityplayermp) {
- c.k.a(entityplayermp);
- c.k.b(((Entity) (entityplayermp)));
- d.b(entityplayermp);
- b.remove(((entityplayermp)));
- c.e.e(((Entity) (entityplayermp)));
- EntityPlayerMP entityplayermp1 = new EntityPlayerMP(c, ((World) (c.e)), entityplayermp.aw, new ItemInWorldManager(((World) (c.e))));
-
- entityplayermp1.g = entityplayermp.g;
- entityplayermp1.a = entityplayermp.a;
- c.e.A.d((int) entityplayermp1.p >> 4, (int) entityplayermp1.r >> 4);
- for (; c.e.a(((Entity) (entityplayermp1)), entityplayermp1.z).size() != 0; entityplayermp1.a(entityplayermp1.p, entityplayermp1.q + 1.0D, entityplayermp1.r)) {
- ;
+ public EntityPlayer d(EntityPlayer entityplayer) {
+ this.c.k.a(entityplayer);
+ this.c.k.b(entityplayer);
+ this.d.b(entityplayer);
+ this.b.remove(entityplayer);
+ this.c.e.e(entityplayer);
+ EntityPlayer entityplayer1 = new EntityPlayer(this.c, this.c.e, entityplayer.name, new ItemInWorldManager(this.c.e));
+
+ entityplayer1.id = entityplayer.id;
+ entityplayer1.a = entityplayer.a;
+ this.c.e.A.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
+
+ while (this.c.e.a(entityplayer1, entityplayer1.boundingBox).size() != 0) {
+ entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
}
- entityplayermp1.a.b(((Packet) (new Packet9())));
- entityplayermp1.a.a(entityplayermp1.p, entityplayermp1.q, entityplayermp1.r, entityplayermp1.v, entityplayermp1.w);
- d.a(entityplayermp1);
- c.e.a(((Entity) (entityplayermp1)));
- b.add(((entityplayermp1)));
- entityplayermp1.l();
- return entityplayermp1;
+
+ entityplayer1.a.b((Packet) (new Packet9Respawn()));
+ entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
+ this.d.a(entityplayer1);
+ this.c.e.a(entityplayer1);
+ this.b.add(entityplayer1);
+ entityplayer1.l();
+ return entityplayer1;
}
public void b() {
- d.a();
+ this.d.a();
}
- public void a(int i1, int j1, int k1) {
- d.a(i1, j1, k1);
+ public void a(int i, int j, int k) {
+ this.d.a(i, j, k);
}
public void a(Packet packet) {
- for (int i1 = 0; i1 < b.size(); i1++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
+ for (int i = 0; i < this.b.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
- entityplayermp.a.b(packet);
+ entityplayer.a.b(packet);
}
}
public String c() {
String s = "";
- for (int i1 = 0; i1 < b.size(); i1++) {
- if (i1 > 0) {
- s = (new StringBuilder()).append(s).append(", ").toString();
+ for (int i = 0; i < this.b.size(); ++i) {
+ if (i > 0) {
+ s = s + ", ";
}
- s = (new StringBuilder()).append(s).append(((EntityPlayerMP) b.get(i1)).aw).toString();
+
+ s = s + ((EntityPlayer) this.b.get(i)).name;
}
return s;
}
public void a(String s) {
- f.add(((s.toLowerCase())));
- f();
+ this.f.add(s.toLowerCase());
+ this.f();
}
public void b(String s) {
- f.remove(((s.toLowerCase())));
- f();
+ this.f.remove(s.toLowerCase());
+ this.f();
}
private void e() {
try {
- f.clear();
- BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(i))));
+ this.f.clear();
+ BufferedReader bufferedreader = new BufferedReader(new FileReader(this.i));
+ String s = "";
- for (String s = ""; (s = bufferedreader.readLine()) != null;) {
- f.add(((s.trim().toLowerCase())));
+ while ((s = bufferedreader.readLine()) != null) {
+ this.f.add(s.trim().toLowerCase());
}
bufferedreader.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to load ban list: ").append(((exception))).toString());
+ a.warning("Failed to load ban list: " + exception);
}
}
private void f() {
try {
- PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(i, false))));
- String s;
+ PrintWriter printwriter = new PrintWriter(new FileWriter(this.i, false));
+ Iterator iterator = this.f.iterator();
- for (Iterator iterator = f.iterator(); iterator.hasNext(); printwriter.println(s)) {
- s = (String) iterator.next();
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
+
+ printwriter.println(s);
}
printwriter.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to save ban list: ").append(((exception))).toString());
+ a.warning("Failed to save ban list: " + exception);
}
}
public void c(String s) {
- g.add(((s.toLowerCase())));
- h();
+ this.g.add(s.toLowerCase());
+ this.h();
}
public void d(String s) {
- g.remove(((s.toLowerCase())));
- h();
+ this.g.remove(s.toLowerCase());
+ this.h();
}
private void g() {
try {
- g.clear();
- BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(j))));
+ this.g.clear();
+ BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j));
+ String s = "";
- for (String s = ""; (s = bufferedreader.readLine()) != null;) {
- g.add(((s.trim().toLowerCase())));
+ while ((s = bufferedreader.readLine()) != null) {
+ this.g.add(s.trim().toLowerCase());
}
bufferedreader.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString());
+ a.warning("Failed to load ip ban list: " + exception);
}
}
private void h() {
try {
- PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(j, false))));
- String s;
+ PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false));
+ Iterator iterator = this.g.iterator();
+
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
- for (Iterator iterator = g.iterator(); iterator.hasNext(); printwriter.println(s)) {
- s = (String) iterator.next();
+ printwriter.println(s);
}
printwriter.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString());
+ a.warning("Failed to save ip ban list: " + exception);
}
}
public void e(String s) {
- h.add(((s.toLowerCase())));
- j();
+ this.h.add(s.toLowerCase());
+ this.j();
}
public void f(String s) {
- h.remove(((s.toLowerCase())));
- j();
+ this.h.remove(s.toLowerCase());
+ this.j();
}
private void i() {
try {
- h.clear();
- BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(k))));
+ this.h.clear();
+ BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k));
+ String s = "";
- for (String s = ""; (s = bufferedreader.readLine()) != null;) {
- h.add(((s.trim().toLowerCase())));
+ while ((s = bufferedreader.readLine()) != null) {
+ this.h.add(s.trim().toLowerCase());
}
bufferedreader.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString());
+ a.warning("Failed to load ip ban list: " + exception);
}
}
private void j() {
try {
- PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(k, false))));
- String s;
+ PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false));
+ Iterator iterator = this.h.iterator();
+
+ while (iterator.hasNext()) {
+ String s = (String) iterator.next();
- for (Iterator iterator = h.iterator(); iterator.hasNext(); printwriter.println(s)) {
- s = (String) iterator.next();
+ printwriter.println(s);
}
printwriter.close();
} catch (Exception exception) {
- a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString());
+ a.warning("Failed to save ip ban list: " + exception);
}
}
public boolean g(String s) {
- return h.contains(((s.trim().toLowerCase())));
+ return this.h.contains(s.trim().toLowerCase());
}
- public EntityPlayerMP h(String s) {
- for (int i1 = 0; i1 < b.size(); i1++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
+ public EntityPlayer h(String s) {
+ for (int i = 0; i < this.b.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
- if (entityplayermp.aw.equalsIgnoreCase(s)) {
- return entityplayermp;
+ if (entityplayer.name.equalsIgnoreCase(s)) {
+ return entityplayer;
}
}
@@ -320,22 +329,22 @@ public class ServerConfigurationManager {
}
public void a(String s, String s1) {
- EntityPlayerMP entityplayermp = h(s);
+ EntityPlayer entityplayer = this.h(s);
- if (entityplayermp != null) {
- entityplayermp.a.b(((Packet) (new Packet3Chat(s1))));
+ if (entityplayer != null) {
+ entityplayer.a.b((Packet) (new Packet3Chat(s1)));
}
}
- public void a(double d1, double d2, double d3, double d4, Packet packet) {
- for (int i1 = 0; i1 < b.size(); i1++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
- double d5 = d1 - entityplayermp.p;
- double d6 = d2 - entityplayermp.q;
- double d7 = d3 - entityplayermp.r;
+ public void a(double d0, double d1, double d2, double d3, Packet packet) {
+ for (int i = 0; i < this.b.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
+ double d4 = d0 - entityplayer.locX;
+ double d5 = d1 - entityplayer.locY;
+ double d6 = d2 - entityplayer.locZ;
- if (d5 * d5 + d6 * d6 + d7 * d7 < d4 * d4) {
- entityplayermp.a.b(packet);
+ if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) {
+ entityplayer.a.b(packet);
}
}
}
@@ -343,20 +352,20 @@ public class ServerConfigurationManager {
public void i(String s) {
Packet3Chat packet3chat = new Packet3Chat(s);
- for (int i1 = 0; i1 < b.size(); i1++) {
- EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
+ for (int i = 0; i < this.b.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
- if (g(entityplayermp.aw)) {
- entityplayermp.a.b(((Packet) (packet3chat)));
+ if (this.g(entityplayer.name)) {
+ entityplayer.a.b((Packet) packet3chat);
}
}
}
public boolean a(String s, Packet packet) {
- EntityPlayerMP entityplayermp = h(s);
+ EntityPlayer entityplayer = this.h(s);
- if (entityplayermp != null) {
- entityplayermp.a.b(packet);
+ if (entityplayer != null) {
+ entityplayer.a.b(packet);
return true;
} else {
return false;
@@ -364,10 +373,10 @@ public class ServerConfigurationManager {
}
public void d() {
- for (int i1 = 0; i1 < b.size(); i1++) {
- l.a((EntityPlayerMP) b.get(i1));
+ for (int i = 0; i < this.b.size(); ++i) {
+ this.l.a((EntityPlayer) this.b.get(i));
}
}
- public void a(int i1, int j1, int k1, TileEntity tileentity) {}
+ public void a(int i, int j, int k, TileEntity tileentity) {}
}
diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java
index 738402e6..abec2db3 100644
--- a/src/main/java/net/minecraft/server/Slot.java
+++ b/src/main/java/net/minecraft/server/Slot.java
@@ -9,14 +9,14 @@ public class Slot {
public int e;
public Slot(IInventory iinventory, int i, int j, int k) {
- b = iinventory;
- a = i;
- d = j;
- e = k;
+ this.b = iinventory;
+ this.a = i;
+ this.d = j;
+ this.e = k;
}
public void b() {
- d();
+ this.d();
}
public boolean a(ItemStack itemstack) {
@@ -24,27 +24,27 @@ public class Slot {
}
public ItemStack c() {
- return b.a(a);
+ return this.b.a(this.a);
}
public void b(ItemStack itemstack) {
- b.a(a, itemstack);
- d();
+ this.b.a(this.a, itemstack);
+ this.d();
}
public void d() {
- b.d();
+ this.b.d();
}
public int a() {
- return b.c();
+ return this.b.c();
}
public ItemStack a(int i) {
- return b.b(a, i);
+ return this.b.b(this.a, i);
}
public boolean a(IInventory iinventory, int i) {
- return iinventory == b && i == a;
+ return iinventory == this.b && i == this.a;
}
}
diff --git a/src/main/java/net/minecraft/server/ThreadCommandReader.java b/src/main/java/net/minecraft/server/ThreadCommandReader.java
deleted file mode 100644
index ae357424..00000000
--- a/src/main/java/net/minecraft/server/ThreadCommandReader.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package net.minecraft.server;
-
-import java.io.*;
-
-public class ThreadCommandReader extends Thread {
-
- final MinecraftServer a; /* synthetic field */
-
- public ThreadCommandReader(MinecraftServer minecraftserver) {
- super();
- a = minecraftserver;
- }
-
- public void run() {
- BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new InputStreamReader(System.in))));
- String s = null;
-
- try {
- while (!a.g && MinecraftServer.a(a) && (s = bufferedreader.readLine()) != null) {
- a.a("#" + s, ((ICommandListener) (a)));
- }
- } catch (IOException ioexception) {
- ioexception.printStackTrace();
- }
- }
-}
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
index 098631e5..e3683ddc 100644
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
@@ -2,7 +2,7 @@ package net.minecraft.server;
public class TileEntityChest extends TileEntity implements IInventory {
- private ItemStack e[];
+ private ItemStack[] e = new ItemStack[36];
// CraftBukkit start
public ItemStack[] getContents() {
@@ -10,45 +10,46 @@ public class TileEntityChest extends TileEntity implements IInventory {
}
// CraftBukkit end
- public TileEntityChest() {
- e = new ItemStack[36];
- }
+ public TileEntityChest() {}
public int h_() {
return 27;
}
public ItemStack a(int i) {
- return e[i];
+ return this.e[i];
}
public ItemStack b(int i, int j) {
- if (e[i] != null) {
- if (e[i].a <= j) {
- ItemStack itemstack = e[i];
+ if (this.e[i] != null) {
+ ItemStack itemstack;
- e[i] = null;
- d();
+ if (this.e[i].count <= j) {
+ itemstack = this.e[i];
+ this.e[i] = null;
+ this.d();
return itemstack;
- }
- ItemStack itemstack1 = e[i].a(j);
+ } else {
+ itemstack = this.e[i].a(j);
+ if (this.e[i].count == 0) {
+ this.e[i] = null;
+ }
- if (e[i].a == 0) {
- e[i] = null;
+ this.d();
+ return itemstack;
}
- d();
- return itemstack1;
} else {
return null;
}
}
public void a(int i, ItemStack itemstack) {
- e[i] = itemstack;
- if (itemstack != null && itemstack.a > c()) {
- itemstack.a = c();
+ this.e[i] = itemstack;
+ if (itemstack != null && itemstack.count > this.c()) {
+ itemstack.count = this.c();
}
- d();
+
+ this.d();
}
public String b() {
@@ -59,13 +60,14 @@ public class TileEntityChest extends TileEntity implements IInventory {
super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Items");
- e = new ItemStack[h_()];
- for (int i = 0; i < nbttaglist.b(); i++) {
+ this.e = new ItemStack[this.h_()];
+
+ for (int i = 0; i < nbttaglist.b(); ++i) {
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
- int j = nbttagcompound1.b("Slot") & 0xff;
+ int j = nbttagcompound1.b("Slot") & 255;
- if (j >= 0 && j < e.length) {
- e[j] = new ItemStack(nbttagcompound1);
+ if (j >= 0 && j < this.e.length) {
+ this.e[j] = new ItemStack(nbttagcompound1);
}
}
}
@@ -74,27 +76,24 @@ public class TileEntityChest extends TileEntity implements IInventory {
super.b(nbttagcompound);
NBTTagList nbttaglist = new NBTTagList();
- for (int i = 0; i < e.length; i++) {
- if (e[i] != null) {
+ for (int i = 0; i < this.e.length; ++i) {
+ if (this.e[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.a("Slot", (byte) i);
- e[i].a(nbttagcompound1);
- nbttaglist.a(((NBTBase) (nbttagcompound1)));
+ this.e[i].a(nbttagcompound1);
+ nbttaglist.a((NBTBase) nbttagcompound1);
}
}
- nbttagcompound.a("Items", ((NBTBase) (nbttaglist)));
+ nbttagcompound.a("Items", (NBTBase) nbttaglist);
}
public int c() {
return 64;
}
- public boolean a_(EntityPlayer entityplayer) {
- if (a.m(b, c, d) != this) {
- return false;
- }
- return entityplayer.d((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D) <= 64D;
+ public boolean a_(EntityHuman entityhuman) {
+ return this.a.getTileEntity(this.b, this.c, this.d) != this ? false : entityhuman.d((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D) <= 64.0D;
}
}
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
index 62e51c13..4111ae6f 100644
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
@@ -2,10 +2,10 @@ package net.minecraft.server;
public class TileEntityFurnace extends TileEntity implements IInventory {
- private ItemStack h[];
- public int e;
- public int f;
- public int g;
+ private ItemStack[] h = new ItemStack[3];
+ public int e = 0;
+ public int f = 0;
+ public int g = 0;
// CraftBukkit start
public ItemStack[] getContents() {
@@ -13,44 +13,41 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
}
// CraftBukkit end
- public TileEntityFurnace() {
- h = new ItemStack[3];
- e = 0;
- f = 0;
- g = 0;
- }
+ public TileEntityFurnace() {}
public int h_() {
- return h.length;
+ return this.h.length;
}
- public ItemStack a(int j) {
- return h[j];
+ public ItemStack a(int i) {
+ return this.h[i];
}
- public ItemStack b(int j, int k) {
- if (h[j] != null) {
- if (h[j].a <= k) {
- ItemStack itemstack = h[j];
+ public ItemStack b(int i, int j) {
+ if (this.h[i] != null) {
+ ItemStack itemstack;
- h[j] = null;
+ if (this.h[i].count <= j) {
+ itemstack = this.h[i];
+ this.h[i] = null;
return itemstack;
- }
- ItemStack itemstack1 = h[j].a(k);
+ } else {
+ itemstack = this.h[i].a(j);
+ if (this.h[i].count == 0) {
+ this.h[i] = null;
+ }
- if (h[j].a == 0) {
- h[j] = null;
+ return itemstack;
}
- return itemstack1;
} else {
return null;
}
}
- public void a(int j, ItemStack itemstack) {
- h[j] = itemstack;
- if (itemstack != null && itemstack.a > c()) {
- itemstack.a = c();
+ public void a(int i, ItemStack itemstack) {
+ this.h[i] = itemstack;
+ if (itemstack != null && itemstack.count > this.c()) {
+ itemstack.count = this.c();
}
}
@@ -62,38 +59,39 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
super.a(nbttagcompound);
NBTTagList nbttaglist = nbttagcompound.k("Items");
- h = new ItemStack[h_()];
- for (int j = 0; j < nbttaglist.b(); j++) {
- NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(j);
- byte byte0 = nbttagcompound1.b("Slot");
+ this.h = new ItemStack[this.h_()];
+
+ for (int i = 0; i < nbttaglist.b(); ++i) {
+ NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i);
+ byte b0 = nbttagcompound1.b("Slot");
- if (byte0 >= 0 && byte0 < h.length) {
- h[byte0] = new ItemStack(nbttagcompound1);
+ if (b0 >= 0 && b0 < this.h.length) {
+ this.h[b0] = new ItemStack(nbttagcompound1);
}
}
- e = ((int) (nbttagcompound.c("BurnTime")));
- g = ((int) (nbttagcompound.c("CookTime")));
- f = a(h[1]);
+ this.e = nbttagcompound.c("BurnTime");
+ this.g = nbttagcompound.c("CookTime");
+ this.f = this.a(this.h[1]);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- nbttagcompound.a("BurnTime", (short) e);
- nbttagcompound.a("CookTime", (short) g);
+ nbttagcompound.a("BurnTime", (short) this.e);
+ nbttagcompound.a("CookTime", (short) this.g);
NBTTagList nbttaglist = new NBTTagList();
- for (int j = 0; j < h.length; j++) {
- if (h[j] != null) {
+ for (int i = 0; i < this.h.length; ++i) {
+ if (this.h[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- nbttagcompound1.a("Slot", (byte) j);
- h[j].a(nbttagcompound1);
- nbttaglist.a(((NBTBase) (nbttagcompound1)));
+ nbttagcompound1.a("Slot", (byte) i);
+ this.h[i].a(nbttagcompound1);
+ nbttaglist.a((NBTBase) nbttagcompound1);
}
}
- nbttagcompound.a("Items", ((NBTBase) (nbttaglist)));
+ nbttagcompound.a("Items", (NBTBase) nbttaglist);
}
public int c() {
@@ -101,109 +99,91 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
}
public boolean e() {
- return e > 0;
+ return this.e > 0;
}
public void f() {
- boolean flag = e > 0;
+ boolean flag = this.e > 0;
boolean flag1 = false;
- if (e > 0) {
- e--;
+ if (this.e > 0) {
+ --this.e;
}
- if (!a.z) {
- if (e == 0 && i()) {
- f = e = a(h[1]);
- if (e > 0) {
+
+ if (!this.a.isStatic) {
+ if (this.e == 0 && this.i()) {
+ this.f = this.e = this.a(this.h[1]);
+ if (this.e > 0) {
flag1 = true;
- if (h[1] != null) {
- h[1].a--;
- if (h[1].a == 0) {
- h[1] = null;
+ if (this.h[1] != null) {
+ --this.h[1].count;
+ if (this.h[1].count == 0) {
+ this.h[1] = null;
}
}
}
}
- if (e() && i()) {
- g++;
- if (g == 200) {
- g = 0;
- h();
+
+ if (this.e() && this.i()) {
+ ++this.g;
+ if (this.g == 200) {
+ this.g = 0;
+ this.h();
flag1 = true;
}
} else {
- g = 0;
+ this.g = 0;
}
- if (flag != (e > 0)) {
+
+ if (flag != this.e > 0) {
flag1 = true;
- BlockFurnace.a(e > 0, a, b, c, d);
+ BlockFurnace.a(this.e > 0, this.a, this.b, this.c, this.d);
}
}
+
if (flag1) {
- d();
+ this.d();
}
}
private boolean i() {
- if (h[0] == null) {
+ if (this.h[0] == null) {
return false;
- }
- ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba);
+ } else {
+ ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id);
- if (itemstack == null) {
- return false;
- }
- if (h[2] == null) {
- return true;
+ return itemstack == null ? false : (this.h[2] == null ? true : (!this.h[2].a(itemstack) ? false : (this.h[2].count < this.c() && this.h[2].count < this.h[2].b() ? true : this.h[2].count < itemstack.b())));
}
- if (!h[2].a(itemstack)) {
- return false;
- }
- if (h[2].a < c() && h[2].a < h[2].b()) {
- return true;
- }
- return h[2].a < itemstack.b();
}
public void h() {
- if (!i()) {
- return;
- }
- ItemStack itemstack = FurnaceRecipes.a().a(h[0].a().ba);
+ if (this.i()) {
+ ItemStack itemstack = FurnaceRecipes.a().a(this.h[0].a().id);
- if (h[2] == null) {
- h[2] = itemstack.j();
- } else if (h[2].c == itemstack.c) {
- h[2].a++;
- }
- h[0].a--;
- if (h[0].a <= 0) {
- h[0] = null;
+ if (this.h[2] == null) {
+ this.h[2] = itemstack.j();
+ } else if (this.h[2].id == itemstack.id) {
+ ++this.h[2].count;
+ }
+
+ --this.h[0].count;
+ if (this.h[0].count <= 0) {
+ this.h[0] = null;
+ }
}
}
private int a(ItemStack itemstack) {
if (itemstack == null) {
return 0;
- }
- int j = itemstack.a().ba;
+ } else {
+ int i = itemstack.a().id;
- if (j < 256 && Block.m[j].bt == Material.c) {
- return 300;
- }
- if (j == Item.B.ba) {
- return 100;
+ 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)));
}
- if (j == Item.k.ba) {
- return 1600;
- }
- return j != Item.aw.ba ? 0 : 20000;
}
- public boolean a_(EntityPlayer entityplayer) {
- if (a.m(b, c, d) != this) {
- return false;
- }
- return entityplayer.d((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D) <= 64D;
+ public boolean a_(EntityHuman entityhuman) {
+ return this.a.getTileEntity(this.b, this.c, this.d) != this ? false : entityhuman.d((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D) <= 64.0D;
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java
index b3c30623..52f8a302 100644
--- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java
+++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java
@@ -1,108 +1,102 @@
package net.minecraft.server;
-import java.util.List;
-import java.util.Random;
-
public class TileEntityMobSpawner extends TileEntity {
- public int e;
- public String h; // CraftBukkit -> public
+ public int e = -1;
+ public String h = "Pig"; // CraftBukkit private -> public
public double f;
- public double g;
+ public double g = 0.0D;
public TileEntityMobSpawner() {
- e = -1;
- g = 0.0D;
- h = "Pig";
- e = 20;
+ this.e = 20;
}
public void a(String s) {
- h = s;
+ this.h = s;
}
public boolean a() {
- return a.a((double) b + 0.5D, (double) c + 0.5D, (double) d + 0.5D, 16D) != null;
+ return this.a.a((double) this.b + 0.5D, (double) this.c + 0.5D, (double) this.d + 0.5D, 16.0D) != null;
}
public void f() {
- g = f;
- if (!a()) {
- return;
- }
- double d = (float) b + a.l.nextFloat();
- double d2 = (float) c + a.l.nextFloat();
- double d4 = (float) this.d + a.l.nextFloat();
-
- a.a("smoke", d, d2, d4, 0.0D, 0.0D, 0.0D);
- a.a("flame", d, d2, d4, 0.0D, 0.0D, 0.0D);
- for (f += 1000F / ((float) e + 200F); f > 360D;) {
- f -= 360D;
- g -= 360D;
- }
-
- if (e == -1) {
- b();
- }
- if (e > 0) {
- e--;
- return;
- }
- byte byte0 = 4;
+ this.g = this.f;
+ if (this.a()) {
+ double d0 = (double) ((float) this.b + this.a.l.nextFloat());
+ double d1 = (double) ((float) this.c + this.a.l.nextFloat());
+ double d2 = (double) ((float) this.d + this.a.l.nextFloat());
- for (int i = 0; i < byte0; i++) {
- EntityLiving entityliving = (EntityLiving) EntityList.a(h, a);
+ this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
+ this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
- if (entityliving == null) {
- return;
+ for (this.f += (double) (1000.0F / ((float) this.e + 200.0F)); this.f > 360.0D; this.g -= 360.0D) {
+ this.f -= 360.0D;
}
- int j = a.a(((entityliving)).getClass(), AxisAlignedBB.b(b, c, this.d, b + 1, c + 1, this.d + 1).b(8D, 4D, 8D)).size();
- if (j >= 6) {
- b();
- return;
- }
- if (entityliving == null) {
- continue;
+ if (this.e == -1) {
+ this.b();
}
- double d6 = (double) b + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
- double d7 = (c + a.l.nextInt(3)) - 1;
- double d8 = (double) this.d + (a.l.nextDouble() - a.l.nextDouble()) * 4D;
- entityliving.c(d6, d7, d8, a.l.nextFloat() * 360F, 0.0F);
- if (!entityliving.b()) {
- continue;
- }
- a.a(((Entity) (entityliving)));
- for (int k = 0; k < 20; k++) {
- double d1 = (double) b + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
- double d3 = (double) c + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
- double d5 = (double) this.d + 0.5D + ((double) a.l.nextFloat() - 0.5D) * 2D;
-
- a.a("smoke", d1, d3, d5, 0.0D, 0.0D, 0.0D);
- a.a("flame", d1, d3, d5, 0.0D, 0.0D, 0.0D);
+ if (this.e > 0) {
+ --this.e;
+ } else {
+ byte b0 = 4;
+
+ for (int i = 0; i < b0; ++i) {
+ EntityLiving entityliving = (EntityLiving) ((EntityLiving) EntityTypes.a(this.h, this.a));
+
+ if (entityliving == null) {
+ return;
+ }
+
+ int j = this.a.a(entityliving.getClass(), AxisAlignedBB.b((double) this.b, (double) this.c, (double) this.d, (double) (this.b + 1), (double) (this.c + 1), (double) (this.d + 1)).b(8.0D, 4.0D, 8.0D)).size();
+
+ if (j >= 6) {
+ this.b();
+ return;
+ }
+
+ if (entityliving != null) {
+ double d3 = (double) this.b + (this.a.l.nextDouble() - this.a.l.nextDouble()) * 4.0D;
+ double d4 = (double) (this.c + this.a.l.nextInt(3) - 1);
+ double d5 = (double) this.d + (this.a.l.nextDouble() - this.a.l.nextDouble()) * 4.0D;
+
+ entityliving.c(d3, d4, d5, this.a.l.nextFloat() * 360.0F, 0.0F);
+ if (entityliving.b()) {
+ this.a.a((Entity) entityliving);
+
+ for (int k = 0; k < 20; ++k) {
+ d0 = (double) this.b + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
+ d1 = (double) this.c + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
+ d2 = (double) this.d + 0.5D + ((double) this.a.l.nextFloat() - 0.5D) * 2.0D;
+ this.a.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
+ this.a.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
+ }
+
+ entityliving.R();
+ this.b();
+ }
+ }
+ }
+
+ super.f();
}
-
- entityliving.R();
- b();
}
-
- super.f();
}
private void b() {
- e = 200 + a.l.nextInt(600);
+ this.e = 200 + this.a.l.nextInt(600);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
- h = nbttagcompound.h("EntityId");
- e = ((short) (nbttagcompound.c("Delay")));
+ this.h = nbttagcompound.h("EntityId");
+ this.e = nbttagcompound.c("Delay");
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
- nbttagcompound.a("EntityId", h);
- nbttagcompound.a("Delay", (short) e);
+ nbttagcompound.a("EntityId", this.h);
+ nbttagcompound.a("Delay", (short) this.e);
}
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 06ceb23a..97316346 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1,7 +1,9 @@
package net.minecraft.server;
import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
@@ -15,29 +17,69 @@ import org.bukkit.event.block.BlockPhysicsEvent;
public class WorldServer extends World {
public ChunkProviderServer A;
- public boolean B;
+ public boolean B = false;
public boolean C;
private MinecraftServer D;
- private MCHashTable E;
+ private EntityList E = new EntityList();
- public WorldServer(MinecraftServer minecraftserver, File file, String s, int i) {
- super(file, s, (new Random()).nextLong(), WorldProvider.a(i));
- B = false;
- E = new MCHashTable();
- D = minecraftserver;
- world = new CraftWorld(this); // CraftBukkit
- server = minecraftserver.server; // CraftBukkit
+ public WorldServer(MinecraftServer minecraftserver, File file1, String s, int i) {
+ super(file1, s, (new Random()).nextLong(), WorldProvider.a(i));
+ this.D = minecraftserver;
+
+ // CraftBukkit start
+ world = new CraftWorld(this);
+ server = minecraftserver.server;
+ }
+
+ private final CraftWorld world;
+ private final CraftServer server;
+
+ @Override
+ public boolean d(int i1, int j1, int k1, int l1) {
+ boolean result = super.d(i1, j1, k1, l1);
+ if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
+ return result;
+ }
+
+ @Override
+ public boolean setTypeId(int i, int j, int k, int l) {
+ boolean result = super.setTypeId(i, j, k, l);
+ if ((result) && (world != null)) world.updateBlock(i, j, k);
+ return result;
+ }
+
+ @Override
+ public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) {
+ boolean result = super.setTypeIdAndData(i, j, k, l, i1);
+ if ((result) && (world != null)) world.updateBlock(i, j, k);
+ return result;
}
+ @Override
+ public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
+ super.setTileEntity(i, j, k, tileentity);
+ if (world != null) world.updateBlock(i, j, k);
+ }
+
+ public CraftWorld getWorld() {
+ return world;
+ }
+
+ public CraftServer getServer() {
+ return server;
+ }
+ // CraftBukkit end
+
public void f() {
super.f();
}
public void a(Entity entity, boolean flag) {
- if (!D.m && ((entity instanceof EntityAnimals) || (entity instanceof EntityWaterMob))) {
+ if (!this.D.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
entity.q();
}
- if (entity.j == null || !(entity.j instanceof EntityPlayer)) {
+
+ if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) {
super.a(entity, flag);
}
}
@@ -46,173 +88,124 @@ public class WorldServer extends World {
super.a(entity, flag);
}
- protected IChunkProvider a(File file) {
- A = new ChunkProviderServer(this, q.a(file), q.c());
- return ((IChunkProvider) (A));
+ protected IChunkProvider a(File file1) {
+ this.A = new ChunkProviderServer(this, this.q.a(file1), this.q.c());
+ return this.A;
}
public List d(int i, int j, int k, int l, int i1, int j1) {
ArrayList arraylist = new ArrayList();
- for (int k1 = 0; k1 < c.size(); k1++) {
- TileEntity tileentity = (TileEntity) c.get(k1);
+ for (int k1 = 0; k1 < this.c.size(); ++k1) {
+ TileEntity tileentity = (TileEntity) this.c.get(k1);
if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) {
- ((List) (arraylist)).add(((tileentity)));
+ arraylist.add(tileentity);
}
}
- return ((List) (arraylist));
+ return arraylist;
}
- public boolean a(EntityPlayer entityplayer, int i, int j, int k) {
- int l = (int) MathHelper.e(i - m);
- int i1 = (int) MathHelper.e(k - o);
+ public boolean a(EntityHuman entityhuman, int i, int j, int k) {
+ int l = (int) MathHelper.e((float) (i - this.spawnX));
+ int i1 = (int) MathHelper.e((float) (k - this.spawnZ));
if (l > i1) {
i1 = l;
}
- return i1 > 16 || D.f.g(entityplayer.aw);
+
+ return i1 > 16 || this.D.f.g(entityhuman.name);
}
protected void b(Entity entity) {
super.b(entity);
- E.a(entity.g, ((entity)));
+ this.E.a(entity.id, entity);
}
protected void c(Entity entity) {
super.c(entity);
- E.d(entity.g);
+ this.E.d(entity.id);
}
public Entity a(int i) {
- return (Entity) E.a(i);
+ return (Entity) this.E.a(i);
}
- public void a(Entity entity, byte byte0) {
- Packet38 packet38 = new Packet38(entity.g, byte0);
+ public void a(Entity entity, byte b0) {
+ Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0);
- D.k.b(entity, ((Packet) (packet38)));
+ this.D.k.b(entity, packet38entitystatus);
}
- public Explosion a(Entity entity, double d1, double d2, double d3, float f1, boolean flag) {
- Explosion explosion = super.a(entity, d1, d2, d3, f1, flag);
+ public Explosion a(Entity entity, double d0, double d1, double d2, float f, boolean flag) {
+ Explosion explosion = super.a(entity, d0, d1, d2, f, flag);
- D.f.a(d1, d2, d3, 64D, ((Packet) (new Packet60(d1, d2, d3, f1, explosion.g))));
+ this.D.f.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g));
return explosion;
}
public void c(int i, int j, int k, int l, int i1) {
super.c(i, j, k, l, i1);
- D.f.a(i, j, k, 64D, ((Packet) (new Packet54(i, j, k, l, i1))));
+ this.D.f.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1));
}
- // CraftBukkit start
- private final CraftWorld world;
- private final CraftServer server;
-
- @Override
- public boolean d(int i1, int j1, int k1, int l1) {
- boolean result = super.d(i1, j1, k1, l1);
- if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
- return result;
- }
-
- @Override
- public boolean b(int i1, int j1, int k1, int l1) {
- boolean result = super.b(i1, j1, k1, l1);
- if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
- return result;
- }
-
- @Override
- public boolean a(int i1, int j1, int k1, int l1, int i2) {
- boolean result = super.a(i1, j1, k1, l1, i2);
- if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
- return result;
- }
-
- @Override
- public void a(int i1, int j1, int k1, TileEntity tileentity) {
- super.a(i1, j1, k1, tileentity);
- if (world != null) world.updateBlock(i1, j1, k1);
- }
-
- public CraftWorld getWorld() {
- return world;
- }
-
- public CraftServer getServer() {
- return server;
- }
- // CraftBukkit end
-
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
// XXX: done because it calls private k()
@Override
- public void h(int i1, int j1, int k1, int l1) {
- l(i1 - 1, j1, k1, l1);
- l(i1 + 1, j1, k1, l1);
- l(i1, j1 - 1, k1, l1);
- l(i1, j1 + 1, k1, l1);
- l(i1, j1, k1 - 1, l1);
- l(i1, j1, k1 + 1, l1);
+ public void h(int i, int j, int k, int l) {
+ this.l(i - 1, j, k, l);
+ this.l(i + 1, j, k, l);
+ this.l(i, j - 1, k, l);
+ this.l(i, j + 1, k, l);
+ this.l(i, j, k - 1, l);
+ this.l(i, j, k + 1, l);
}
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
- private void l(int i1, int j1, int k1, int l1) {
- if (i || z) {
- return;
- }
- Block block = Block.m[a(i1, j1, k1)];
-
- if (block != null) {
- // CraftBukkit start
- if (world != null) {
- BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i1, j1, k1), l1);
- server.getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return;
+ private void l(int i, int j, int k, int l) {
+ if (!this.i && !this.isStatic) {
+ Block block = Block.byId[this.getTypeId(i, j, k)];
+
+ if (block != null) {
+ // CraftBukkit start
+ if (world != null) {
+ BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i, j, k), l);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
}
- }
- // CraftBukkit stop
+ // CraftBukkit stop
- block.b(this, i1, j1, k1, l1);
+ block.b(this, i, j, k, l);
+ }
}
}
// XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED!
@Override
- public boolean a(int i1, int j1, int k1, int l1, boolean flag) {
- int i2 = a(j1, k1, l1);
- Block block = Block.m[i2];
- Block block1 = Block.m[i1];
- AxisAlignedBB axisalignedbb = block1.d(this, j1, k1, l1);
+ public boolean a(int i, int j, int k, int l, boolean flag) {
+ int i1 = this.getTypeId(j, k, l);
+ Block block = Block.byId[i1];
+ Block block1 = Block.byId[i];
+ AxisAlignedBB axisalignedbb = block1.d(this, j, k, l);
if (flag) {
axisalignedbb = null;
}
- if (axisalignedbb != null && !a(axisalignedbb)) {
- return false;
- }
+
// Craftbukkit start - We dont want to allow the user to override the bounding box check
- boolean defaultReturn;
+ boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb) ? false : (block != Block.WATER && block != Block.STATIONARY_WATER && block != Block.LAVA && block != Block.STATIONARY_LAVA && block != Block.FIRE && block != Block.SNOW ? i > 0 && block == null && block1.a(this, j, k, l) : true);
- if (block == Block.A || block == Block.B || block == Block.C || block == Block.D || block == Block.ar || block == Block.aS) {
- defaultReturn = true;
- } else {
- defaultReturn = (i1 > 0) && (block == null) && (block1.a(this, j1, k1, l1));
+ if (!defaultReturn) {
+ return false;
}
- // Craftbukkit - If flag is true, it's natural, not user placement. Don't hook.
- if (!flag) {
- BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j1, k1, l1), i1, defaultReturn);
- server.getPluginManager().callEvent(event);
+ BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j, k, l), i1, defaultReturn);
+ server.getPluginManager().callEvent(event);
- return event.isBuildable();
- } else {
- return defaultReturn;
- }
+ return event.isBuildable();
// CraftBukkit end
}
}