From 5b2c774edc069f70d1fa9940d96bb0b8705bef7a Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Thu, 15 Sep 2011 01:23:52 +0100 Subject: [PATCH] Update for Minecraft 1.8 --- pom.xml | 2 +- src/main/java/net/minecraft/server/Block.java | 67 +- .../net/minecraft/server/BlockCactus.java | 4 +- .../net/minecraft/server/BlockDispenser.java | 194 ++-- .../java/net/minecraft/server/BlockDoor.java | 3 +- .../java/net/minecraft/server/BlockFire.java | 11 +- .../net/minecraft/server/BlockFlowing.java | 4 +- .../net/minecraft/server/BlockFurnace.java | 146 --- .../net/minecraft/server/BlockJukeBox.java | 70 -- .../net/minecraft/server/BlockLeaves.java | 4 +- .../net/minecraft/server/BlockMushroom.java | 99 +- .../net/minecraft/server/BlockPiston.java | 50 +- .../net/minecraft/server/BlockPortal.java | 4 +- .../minecraft/server/BlockPressurePlate.java | 6 +- .../net/minecraft/server/BlockPumpkin.java | 4 +- .../minecraft/server/BlockRedstoneTorch.java | 4 +- .../minecraft/server/BlockRedstoneWire.java | 6 +- .../java/net/minecraft/server/BlockSign.java | 2 +- .../java/net/minecraft/server/BlockSoil.java | 4 +- src/main/java/net/minecraft/server/Chunk.java | 559 +++++++--- .../minecraft/server/ChunkProviderServer.java | 26 +- .../server/ConsoleCommandHandler.java | 417 -------- .../net/minecraft/server/CraftingManager.java | 5 + .../java/net/minecraft/server/Entity.java | 314 +++--- .../net/minecraft/server/EntityArrow.java | 106 +- .../java/net/minecraft/server/EntityBoat.java | 32 +- .../java/net/minecraft/server/EntityCow.java | 36 +- .../net/minecraft/server/EntityCreature.java | 57 +- .../net/minecraft/server/EntityCreeper.java | 32 +- .../java/net/minecraft/server/EntityEgg.java | 25 +- .../net/minecraft/server/EntityFireball.java | 24 +- .../java/net/minecraft/server/EntityFish.java | 22 +- .../net/minecraft/server/EntityGhast.java | 33 +- .../net/minecraft/server/EntityHuman.java | 632 ++++++++---- .../java/net/minecraft/server/EntityItem.java | 25 +- .../net/minecraft/server/EntityLiving.java | 570 ++++++---- .../net/minecraft/server/EntityMinecart.java | 40 +- .../net/minecraft/server/EntityMonster.java | 72 +- .../net/minecraft/server/EntityPainting.java | 18 +- .../java/net/minecraft/server/EntityPig.java | 12 +- .../net/minecraft/server/EntityPigZombie.java | 36 +- .../net/minecraft/server/EntityPlayer.java | 236 +++-- .../net/minecraft/server/EntitySheep.java | 18 +- .../net/minecraft/server/EntitySkeleton.java | 49 +- .../net/minecraft/server/EntitySnowball.java | 22 +- .../net/minecraft/server/EntitySpider.java | 22 +- .../net/minecraft/server/EntitySquid.java | 92 +- .../net/minecraft/server/EntityTNTPrimed.java | 8 +- .../net/minecraft/server/EntityTracker.java | 4 +- .../minecraft/server/EntityTrackerEntry.java | 22 +- .../minecraft/server/EntityWeatherStorm.java | 4 +- .../java/net/minecraft/server/EntityWolf.java | 111 +- .../net/minecraft/server/EntityZombie.java | 24 +- .../java/net/minecraft/server/Explosion.java | 7 +- .../java/net/minecraft/server/IInventory.java | 6 +- .../server/InventoryCraftResult.java | 6 +- .../minecraft/server/InventoryCrafting.java | 6 +- .../minecraft/server/InventoryLargeChest.java | 22 +- .../net/minecraft/server/InventoryPlayer.java | 48 +- .../java/net/minecraft/server/ItemBed.java | 28 +- .../java/net/minecraft/server/ItemBlock.java | 146 +-- .../java/net/minecraft/server/ItemBucket.java | 12 + .../java/net/minecraft/server/ItemDoor.java | 141 +-- .../net/minecraft/server/ItemFishingRod.java | 6 +- .../minecraft/server/ItemFlintAndSteel.java | 58 +- .../java/net/minecraft/server/ItemHoe.java | 42 +- .../minecraft/server/ItemInWorldManager.java | 218 ++-- .../net/minecraft/server/ItemPainting.java | 36 +- .../net/minecraft/server/ItemRedstone.java | 32 +- .../java/net/minecraft/server/ItemReed.java | 9 +- .../java/net/minecraft/server/ItemSeeds.java | 4 +- .../java/net/minecraft/server/ItemSign.java | 8 +- .../java/net/minecraft/server/ItemStack.java | 40 +- .../net/minecraft/server/ItemWorldMap.java | 17 +- .../net/minecraft/server/MinecraftServer.java | 47 +- .../net/minecraft/server/NetLoginHandler.java | 40 +- .../minecraft/server/NetServerHandler.java | 145 ++- .../net/minecraft/server/NetworkManager.java | 14 +- .../java/net/minecraft/server/Packet.java | 23 +- .../net/minecraft/server/PlayerInstance.java | 4 +- .../minecraft/server/PortalTravelAgent.java | 26 +- .../server/SecondaryWorldServer.java | 4 +- .../server/ServerConfigurationManager.java | 82 +- src/main/java/net/minecraft/server/Slot.java | 8 +- .../net/minecraft/server/SpawnerCreature.java | 200 ++-- .../minecraft/server/ThreadLoginVerifier.java | 2 +- .../net/minecraft/server/TileEntityChest.java | 139 ++- .../minecraft/server/TileEntityDispenser.java | 10 +- .../minecraft/server/TileEntityFurnace.java | 12 +- .../server/TileEntityMobSpawner.java | 6 +- .../minecraft/server/TileEntityPiston.java | 70 +- .../net/minecraft/server/TileEntitySign.java | 8 +- src/main/java/net/minecraft/server/World.java | 970 ++++++++++-------- .../minecraft/server/WorldChunkManager.java | 121 --- .../java/net/minecraft/server/WorldData.java | 31 +- .../net/minecraft/server/WorldGenClay.java | 63 -- .../net/minecraft/server/WorldGenForest.java | 108 +- .../net/minecraft/server/WorldGenTaiga1.java | 114 +- .../net/minecraft/server/WorldGenTaiga2.java | 158 +-- .../net/minecraft/server/WorldGenTrees.java | 108 +- .../net/minecraft/server/WorldManager.java | 2 - .../net/minecraft/server/WorldServer.java | 34 +- .../org/bukkit/craftbukkit/CraftChunk.java | 14 +- .../org/bukkit/craftbukkit/CraftServer.java | 7 +- .../org/bukkit/craftbukkit/CraftWorld.java | 28 +- .../bukkit/craftbukkit/block/CraftBlock.java | 22 +- .../craftbukkit/entity/CraftLivingEntity.java | 18 +- 107 files changed, 4415 insertions(+), 3504 deletions(-) delete mode 100644 src/main/java/net/minecraft/server/BlockFurnace.java delete mode 100644 src/main/java/net/minecraft/server/BlockJukeBox.java delete mode 100644 src/main/java/net/minecraft/server/ConsoleCommandHandler.java delete mode 100644 src/main/java/net/minecraft/server/WorldChunkManager.java delete mode 100644 src/main/java/net/minecraft/server/WorldGenClay.java diff --git a/pom.xml b/pom.xml index 6b94dd1695..0a3967cc23 100644 --- a/pom.xml +++ b/pom.xml @@ -39,7 +39,7 @@ org.bukkit minecraft-server - 1.7.3 + 1.8 jar compile diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index 8183374e2e..517686d0f6 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -39,7 +39,7 @@ public class Block { public static final Block IRON_ORE = (new BlockOre(15, 33)).c(3.0F).b(5.0F).a(h).a("oreIron"); public static final Block COAL_ORE = (new BlockOre(16, 34)).c(3.0F).b(5.0F).a(h).a("oreCoal"); public static final Block LOG = (new BlockLog(17)).c(2.0F).a(e).a("log").g(); - public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).f(1).a(g).a("leaves").n().g(); + public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).f(1).a(g).a("leaves").g(); public static final Block SPONGE = (new BlockSponge(19)).c(0.6F).a(g).a("sponge"); public static final Block GLASS = (new BlockGlass(20, 49, Material.SHATTERABLE, false)).c(0.3F).a(j).a("glass"); public static final Block LAPIS_ORE = (new BlockOre(21, 160)).c(3.0F).b(5.0F).a(h).a("oreLapis"); @@ -72,7 +72,7 @@ public class Block { public static final Block MOSSY_COBBLESTONE = (new Block(48, 36, Material.STONE)).c(2.0F).b(10.0F).a(h).a("stoneMoss"); public static final Block OBSIDIAN = (new BlockObsidian(49, 37)).c(10.0F).b(2000.0F).a(h).a("obsidian"); public static final Block TORCH = (new BlockTorch(50, 80)).c(0.0F).a(0.9375F).a(e).a("torch").g(); - public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).a("fire").n().g(); + public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).a("fire").n(); public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(i).a("mobSpawner").n(); public static final Block WOOD_STAIRS = (new BlockStairs(53, WOOD)).a("stairsWood").g(); public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(e).a("chest").g(); @@ -81,7 +81,7 @@ public class Block { public static final Block DIAMOND_BLOCK = (new BlockOreBlock(57, 24)).c(5.0F).b(10.0F).a(i).a("blockDiamond"); public static final Block WORKBENCH = (new BlockWorkbench(58)).c(2.5F).a(e).a("workbench"); public static final Block CROPS = (new BlockCrops(59, 88)).c(0.0F).a(g).a("crops").n().g(); - public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).a("farmland"); + public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).a("farmland").g(); public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(h).a("furnace").g(); public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(h).a(0.875F).a("furnace").g(); public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(e).a("sign").n().g(); @@ -106,7 +106,7 @@ public class Block { public static final Block CLAY = (new BlockClay(82, 72)).c(0.6F).a(f).a("clay"); public static final Block SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(g).a("reeds").n(); public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(h).a("jukebox").g(); - public static final Block FENCE = (new BlockFence(85, 4)).c(2.0F).b(5.0F).a(e).a("fence").g(); + public static final Block FENCE = (new BlockFence(85, 4)).c(2.0F).b(5.0F).a(e).a("fence"); public static final Block PUMPKIN = (new BlockPumpkin(86, 102, false)).c(1.0F).a(e).a("pumpkin").g(); public static final Block NETHERRACK = (new BlockBloodStone(87, 103)).c(0.4F).a(h).a("hellrock"); public static final Block SOUL_SAND = (new BlockSlowSand(88, 104)).c(0.5F).a(l).a("hellsand"); @@ -118,12 +118,25 @@ public class Block { public static final Block DIODE_ON = (new BlockDiode(94, true)).c(0.0F).a(0.625F).a(e).a("diode").n().g(); public static final Block LOCKED_CHEST = (new BlockLockedChest(95)).c(0.0F).a(1.0F).a(e).a("lockedchest").a(true).g(); public static final Block TRAP_DOOR = (new BlockTrapdoor(96, Material.WOOD)).c(3.0F).a(e).a("trapdoor").n().g(); + public static final Block MONSTER_EGGS = (new BlockMonsterEggs(97)).c(0.75F); + public static final Block SMOOTH_BRICK = (new BlockSmoothBrick(98)).c(1.5F).b(10.0F).a(h).a("stonebricksmooth"); + public static final Block BIG_MUSHROOM_1 = (new BlockHugeMushroom(99, Material.WOOD, 142, 0)).c(0.2F).a(e).a("mushroom").g(); + public static final Block BIG_MUSHROOM_2 = (new BlockHugeMushroom(100, Material.WOOD, 142, 1)).c(0.2F).a(e).a("mushroom").g(); + public static final Block IRON_FENCE = (new BlockThin(101, 85, 85, Material.ORE)).c(5.0F).b(10.0F).a(i).a("fenceIron"); + public static final Block THIN_GLASS = (new BlockThin(102, 49, 148, Material.SHATTERABLE)).c(0.3F).a(j).a("thinGlass"); + public static final Block MELON = (new BlockMelon(103)).c(1.0F).a(e).a("melon"); + public static final Block PUMPKIN_STEM = (new BlockStem(104, PUMPKIN)).c(0.0F).a(e).a("pumpkinStem").g(); + public static final Block MELON_STEM = (new BlockStem(105, MELON)).c(0.0F).a(e).a("pumpkinStem").g(); + public static final Block VINE = (new BlockVine(106)).c(0.2F).a(g).a("vine").g(); + public static final Block FENCE_GATE = (new BlockFenceGate(107, 4)).c(2.0F).b(5.0F).a(e).a("fenceGate").g(); + public static final Block BRICK_STAIRS = (new BlockStairs(108, BRICK)).a("stairsBrick").g(); + public static final Block STONE_STAIRS = (new BlockStairs(109, SMOOTH_BRICK)).a("stairsStoneBrickSmooth").g(); public int textureId; public final int id; protected float strength; protected float durability; - protected boolean bq; - protected boolean br; + protected boolean bD; + protected boolean bE; public double minX; public double minY; public double minZ; @@ -131,16 +144,16 @@ public class Block { public double maxY; public double maxZ; public StepSound stepSound; - public float bz; + public float bM; public final Material material; public float frictionFactor; private String name; protected Block(int i, Material material) { - this.bq = true; - this.br = true; + this.bD = true; + this.bE = true; this.stepSound = d; - this.bz = 1.0F; + this.bM = 1.0F; this.frictionFactor = 0.6F; if (byId[i] != null) { throw new IllegalArgumentException("Slot " + i + " is already occupied by " + byId[i] + " when adding " + this); @@ -253,10 +266,10 @@ public class Block { } public boolean a(int i, boolean flag) { - return this.k_(); + return this.q_(); } - public boolean k_() { + public boolean q_() { return true; } @@ -270,7 +283,7 @@ public class Block { return 10; } - public void c(World world, int i, int j, int k) {} + public void a(World world, int i, int j, int k) {} public void remove(World world, int i, int j, int k) {} @@ -329,7 +342,7 @@ public class Block { } public MovingObjectPosition a(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { - this.a(world, i, j, k); + this.a((IBlockAccess) world, i, j, k); vec3d = vec3d.add((double) (-i), (double) (-j), (double) (-k)); vec3d1 = vec3d1.add((double) (-i), (double) (-j), (double) (-k)); Vec3D vec3d2 = vec3d.a(vec3d1, this.minX); @@ -365,27 +378,27 @@ public class Block { Vec3D vec3d8 = null; - if (vec3d2 != null && (vec3d8 == null || vec3d.a(vec3d2) < vec3d.a(vec3d8))) { + if (vec3d2 != null && (vec3d8 == null || vec3d.b(vec3d2) < vec3d.b(vec3d8))) { vec3d8 = vec3d2; } - if (vec3d3 != null && (vec3d8 == null || vec3d.a(vec3d3) < vec3d.a(vec3d8))) { + if (vec3d3 != null && (vec3d8 == null || vec3d.b(vec3d3) < vec3d.b(vec3d8))) { vec3d8 = vec3d3; } - if (vec3d4 != null && (vec3d8 == null || vec3d.a(vec3d4) < vec3d.a(vec3d8))) { + if (vec3d4 != null && (vec3d8 == null || vec3d.b(vec3d4) < vec3d.b(vec3d8))) { vec3d8 = vec3d4; } - if (vec3d5 != null && (vec3d8 == null || vec3d.a(vec3d5) < vec3d.a(vec3d8))) { + if (vec3d5 != null && (vec3d8 == null || vec3d.b(vec3d5) < vec3d.b(vec3d8))) { vec3d8 = vec3d5; } - if (vec3d6 != null && (vec3d8 == null || vec3d.a(vec3d6) < vec3d.a(vec3d8))) { + if (vec3d6 != null && (vec3d8 == null || vec3d.b(vec3d6) < vec3d.b(vec3d8))) { vec3d8 = vec3d6; } - if (vec3d7 != null && (vec3d8 == null || vec3d.a(vec3d7) < vec3d.a(vec3d8))) { + if (vec3d7 != null && (vec3d8 == null || vec3d.b(vec3d7) < vec3d.b(vec3d8))) { vec3d8 = vec3d7; } @@ -434,7 +447,7 @@ public class Block { return vec3d == null ? false : vec3d.a >= this.minX && vec3d.a <= this.maxX && vec3d.b >= this.minY && vec3d.b <= this.maxY; } - public void d(World world, int i, int j, int k) {} + public void a_(World world, int i, int j, int k) {} public boolean canPlace(World world, int i, int j, int k, int l) { return this.canPlace(world, i, j, k); @@ -476,6 +489,7 @@ public class Block { public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { entityhuman.a(StatisticList.C[this.id], 1); + entityhuman.b(0.025F); this.g(world, i, j, k, l); } @@ -501,24 +515,27 @@ public class Block { public void a(World world, int i, int j, int k, int l, int i1) {} public boolean m() { - return this.br; + return this.bE; } protected Block n() { - this.br = false; + this.bE = false; return this; } public int e() { - return this.material.j(); + return this.material.l(); } static { Item.byId[WOOL.id] = (new ItemCloth(WOOL.id - 256)).a("cloth"); - Item.byId[LOG.id] = (new ItemLog(LOG.id - 256)).a("log"); + Item.byId[LOG.id] = (new ItemLog(LOG.id - 256, LOG)).a("log"); + Item.byId[SMOOTH_BRICK.id] = (new ItemLog(SMOOTH_BRICK.id - 256, SMOOTH_BRICK)).a("stonebricksmooth"); Item.byId[STEP.id] = (new ItemStep(STEP.id - 256)).a("stoneSlab"); Item.byId[SAPLING.id] = (new ItemSapling(SAPLING.id - 256)).a("sapling"); Item.byId[LEAVES.id] = (new ItemLeaves(LEAVES.id - 256)).a("leaves"); + Item.byId[VINE.id] = new ItemColoredBlock(VINE.id - 256, false); + Item.byId[LONG_GRASS.id] = new ItemColoredBlock(LONG_GRASS.id - 256, true); Item.byId[PISTON.id] = new ItemPiston(PISTON.id - 256); Item.byId[PISTON_STICKY.id] = new ItemPiston(PISTON_STICKY.id - 256); diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java index d1800e634e..3ba77d171b 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java @@ -90,12 +90,12 @@ public class BlockCactus extends Block { world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - entity.damageEntity((Entity) null, event.getDamage()); + entity.damageEntity(DamageSource.g, event.getDamage()); } return; } // CraftBukkit end - entity.damageEntity((Entity) null, 1); + entity.damageEntity(DamageSource.g, 1); } } diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index 89975dd8d2..a30748cbad 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -25,8 +25,8 @@ public class BlockDispenser extends BlockContainer { return Block.DISPENSER.id; } - public void c(World world, int i, int j, int k) { - super.c(world, i, j, k); + public void a(World world, int i, int j, int k) { + super.a(world, i, j, k); this.g(world, i, j, k); } @@ -68,12 +68,15 @@ public class BlockDispenser extends BlockContainer { } else { TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - entityhuman.a(tileentitydispenser); + if (tileentitydispenser != null) { + entityhuman.a(tileentitydispenser); + } + return true; } } - // CraftBukkit - private -> public + // CraftBukkit - priv to public public void dispense(World world, int i, int j, int k, Random random) { int l = world.getData(i, j, k); byte b0 = 0; @@ -90,85 +93,88 @@ public class BlockDispenser extends BlockContainer { } TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - // CraftBukkit start - int dispenseSlot = tileentitydispenser.findDispenseSlot(); - ItemStack itemstack = null; - if (dispenseSlot > -1) { - itemstack = tileentitydispenser.getContents()[dispenseSlot]; - // Copy item stack, because we want it to have 1 item - itemstack = new ItemStack(itemstack.id, 1, itemstack.damage); - } - // CraftBukkit end - - double d0 = (double) i + (double) b0 * 0.6D + 0.5D; - double d1 = (double) j + 0.5D; - double d2 = (double) k + (double) b1 * 0.6D + 0.5D; - - if (itemstack == null) { - world.e(1001, i, j, k, 0); - } else { + if (tileentitydispenser != null) { // CraftBukkit start - double d3 = random.nextDouble() * 0.1D + 0.2D; - double motX = (double) b0 * d3; - double motY = 0.20000000298023224D; - double motZ = (double) b1 * d3; - motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; - motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; - motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; + int dispenseSlot = tileentitydispenser.findDispenseSlot(); + ItemStack itemstack = null; + if (dispenseSlot > -1) { + itemstack = tileentitydispenser.getContents()[dispenseSlot]; - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); - - BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ)); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; + // Copy item stack, because we want it to have 1 item + itemstack = new ItemStack(itemstack.id, 1, itemstack.damage); } - - // Actually remove the item - tileentitydispenser.splitStack(dispenseSlot, 1); - - motX = event.getVelocity().getX(); - motY = event.getVelocity().getY(); - motZ = event.getVelocity().getZ(); - - itemstack = new ItemStack(event.getItem().getTypeId(), event.getItem().getAmount(), event.getItem().getDurability()); // CraftBukkit end - if (itemstack.id == Item.ARROW.id) { - EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); + double d0 = (double) i + (double) b0 * 0.6D + 0.5D; + double d1 = (double) j + 0.5D; + double d2 = (double) k + (double) b1 * 0.6D + 0.5D; - entityarrow.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); - entityarrow.fromPlayer = true; - world.addEntity(entityarrow); - world.e(1002, i, j, k, 0); - } else if (itemstack.id == Item.EGG.id) { - EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); - - entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); - world.addEntity(entityegg); - world.e(1002, i, j, k, 0); - } else if (itemstack.id == Item.SNOW_BALL.id) { - EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); - - entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); - world.addEntity(entitysnowball); - world.e(1002, i, j, k, 0); + if (itemstack == null) { + world.e(1001, i, j, k, 0); } else { - EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); // CraftBukkit start - // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up - entityitem.motX = motX; - entityitem.motY = motY; - entityitem.motZ = motZ; - // CraftBukkit end - world.addEntity(entityitem); - world.e(1000, i, j, k, 0); - } + double d3 = random.nextDouble() * 0.1D + 0.2D; + double motX = (double) b0 * d3; + double motY = 0.20000000298023224D; + double motZ = (double) b1 * d3; + motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; + motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; + motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; - world.e(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); + org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ)); + world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + // Actually remove the item + tileentitydispenser.splitStack(dispenseSlot, 1); + + motX = event.getVelocity().getX(); + motY = event.getVelocity().getY(); + motZ = event.getVelocity().getZ(); + + itemstack = new ItemStack(event.getItem().getTypeId(), event.getItem().getAmount(), event.getItem().getDurability()); + // CraftBukkit end + + if (itemstack.id == Item.ARROW.id) { + EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); + + entityarrow.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); + entityarrow.fromPlayer = true; + world.addEntity(entityarrow); + world.e(1002, i, j, k, 0); + } else if (itemstack.id == Item.EGG.id) { + EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); + + entityegg.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); + world.addEntity(entityegg); + world.e(1002, i, j, k, 0); + } else if (itemstack.id == Item.SNOW_BALL.id) { + EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); + + entitysnowball.a((double) b0, 0.10000000149011612D, (double) b1, 1.1F, 6.0F); + world.addEntity(entitysnowball); + world.e(1002, i, j, k, 0); + } else { + EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); + // CraftBukkit start + // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up + entityitem.motX = motX; + entityitem.motY = motY; + entityitem.motZ = motZ; + // CraftBukkit end + world.addEntity(entityitem); + world.e(1000, i, j, k, 0); + } + + world.e(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); + } } } @@ -188,7 +194,7 @@ public class BlockDispenser extends BlockContainer { } } - protected TileEntity a_() { + public TileEntity a_() { return new TileEntityDispenser(); } @@ -215,29 +221,31 @@ public class BlockDispenser extends BlockContainer { public void remove(World world, int i, int j, int k) { TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); - for (int l = 0; l < tileentitydispenser.getSize(); ++l) { - ItemStack itemstack = tileentitydispenser.getItem(l); + if (tileentitydispenser != null) { + for (int l = 0; l < tileentitydispenser.getSize(); ++l) { + ItemStack itemstack = tileentitydispenser.getItem(l); - 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; + 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; - while (itemstack.count > 0) { - int i1 = this.a.nextInt(21) + 10; + while (itemstack.count > 0) { + int i1 = this.a.nextInt(21) + 10; - if (i1 > itemstack.count) { - i1 = itemstack.count; + 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.getData())); + 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.addEntity(entityitem); } - - 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.getData())); - 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.addEntity(entityitem); } } } diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 1308051e03..27f47e8536 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -198,7 +198,8 @@ public class BlockDoor extends Block { } public boolean canPlace(World world, int i, int j, int k) { - return j >= 127 ? false : world.e(i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k); + world.getClass(); + return j >= 128 - 1 ? false : world.e(i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k); } public static boolean e(int i) { diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java index 35e43955fe..ad4bb04b34 100644 --- a/src/main/java/net/minecraft/server/BlockFire.java +++ b/src/main/java/net/minecraft/server/BlockFire.java @@ -30,6 +30,7 @@ public class BlockFire extends Block { this.a(Block.TNT.id, 15, 100); this.a(Block.LONG_GRASS.id, 60, 100); this.a(Block.WOOL.id, 30, 60); + this.a(Block.VINE.id, 15, 100); } private void a(int i, int j, int k) { @@ -64,7 +65,7 @@ public class BlockFire extends Block { world.setTypeId(i, j, k, 0); } - if (!flag && world.v() && (world.s(i, j, k) || world.s(i - 1, j, k) || world.s(i + 1, j, k) || world.s(i, j, k - 1) || world.s(i, j, k + 1))) { + if (!flag && world.u() && (world.s(i, j, k) || world.s(i - 1, j, k) || world.s(i + 1, j, k) || world.s(i, j, k - 1) || world.s(i, j, k + 1))) { world.setTypeId(i, j, k, 0); } else { int l = world.getData(i, j, k); @@ -111,7 +112,7 @@ public class BlockFire extends Block { if (i2 > 0) { int j2 = (i2 + 40) / (l + 30); - if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.v() || !world.s(i1, k1, j1)) && !world.s(i1 - 1, k1, k) && !world.s(i1 + 1, k1, j1) && !world.s(i1, k1, j1 - 1) && !world.s(i1, k1, j1 + 1)) { + if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.u() || !world.s(i1, k1, j1)) && !world.s(i1 - 1, k1, k) && !world.s(i1 + 1, k1, j1) && !world.s(i1, k1, j1 - 1) && !world.s(i1, k1, j1 + 1)) { int k2 = l + random.nextInt(5) / 4; if (k2 > 15) { @@ -205,7 +206,7 @@ public class BlockFire extends Block { } } - public boolean k_() { + public boolean q_() { return false; } @@ -229,8 +230,8 @@ public class BlockFire extends Block { } } - public void c(World world, int i, int j, int k) { - if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.a_(world, i, j, k)) { + public void a(World world, int i, int j, int k) { + if (world.getTypeId(i, j - 1, k) != Block.OBSIDIAN.id || !Block.PORTAL.b_(world, i, j, k)) { if (!world.e(i, j - 1, k) && !this.g(world, i, j, k)) { world.setTypeId(i, j, k, 0); } else { diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index 52ba8de16c..aaae7bc162 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -292,8 +292,8 @@ public class BlockFlowing extends BlockFluids { return material == this.material ? false : (material == Material.LAVA ? false : !this.k(world, i, j, k)); } - public void c(World world, int i, int j, int k) { - super.c(world, i, j, k); + public void a(World world, int i, int j, int k) { + super.a(world, i, j, k); if (world.getTypeId(i, j, k) == this.id) { world.c(i, j, k, this.id, this.c()); } diff --git a/src/main/java/net/minecraft/server/BlockFurnace.java b/src/main/java/net/minecraft/server/BlockFurnace.java deleted file mode 100644 index ab9f6bd960..0000000000 --- a/src/main/java/net/minecraft/server/BlockFurnace.java +++ /dev/null @@ -1,146 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockFurnace extends BlockContainer { - - private Random a = new Random(); - private final boolean b; - private static boolean c = false; - - protected BlockFurnace(int i, boolean flag) { - super(i, Material.STONE); - this.b = flag; - this.textureId = 45; - } - - public int a(int i, Random random) { - return Block.FURNACE.id; - } - - public void c(World world, int i, int j, int k) { - super.c(world, i, j, k); - this.g(world, i, j, k); - } - - private void g(World world, int i, int j, int k) { - if (!world.isStatic) { - 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]) { - b0 = 3; - } - - if (Block.o[i1] && !Block.o[l]) { - b0 = 2; - } - - if (Block.o[j1] && !Block.o[k1]) { - b0 = 5; - } - - if (Block.o[k1] && !Block.o[j1]) { - b0 = 4; - } - - world.setData(i, j, k, b0); - } - } - - public int a(int i) { - return i == 1 ? this.textureId + 17 : (i == 0 ? this.textureId + 17 : (i == 3 ? this.textureId - 1 : this.textureId)); - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { - if (world.isStatic) { - return true; - } else { - TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k); - - entityhuman.a(tileentityfurnace); - return true; - } - } - - public static void a(boolean flag, World world, int i, int j, int k) { - int l = world.getData(i, j, k); - TileEntity tileentity = world.getTileEntity(i, j, k); - if (tileentity == null) return; // CraftBukkit - - c = true; - if (flag) { - world.setTypeId(i, j, k, Block.BURNING_FURNACE.id); - } else { - world.setTypeId(i, j, k, Block.FURNACE.id); - } - - c = false; - world.setData(i, j, k, l); - tileentity.j(); - world.setTileEntity(i, j, k, tileentity); - } - - protected TileEntity a_() { - return new TileEntityFurnace(); - } - - public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) { - int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 0.5D) & 3; - - if (l == 0) { - world.setData(i, j, k, 2); - } - - if (l == 1) { - world.setData(i, j, k, 5); - } - - if (l == 2) { - world.setData(i, j, k, 3); - } - - if (l == 3) { - world.setData(i, j, k, 4); - } - } - - public void remove(World world, int i, int j, int k) { - if (!c) { - TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.getTileEntity(i, j, k); - - if (tileentityfurnace == null) return; // CraftBukkit - for (int l = 0; l < tileentityfurnace.getSize(); ++l) { - ItemStack itemstack = tileentityfurnace.getItem(l); - - 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; - - while (itemstack.count > 0) { - int i1 = this.a.nextInt(21) + 10; - - if (i1 > itemstack.count) { - i1 = itemstack.count; - } - - itemstack.count -= i1; - EntityItem entityitem = new EntityItem(world, (double) ((float) i + f), (double) ((float) j + f1), (double) ((float) k + f2), new ItemStack(itemstack.id, i1, itemstack.getData())); - 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.addEntity(entityitem); - } - } - } - } - - super.remove(world, i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/BlockJukeBox.java b/src/main/java/net/minecraft/server/BlockJukeBox.java deleted file mode 100644 index 67f857a469..0000000000 --- a/src/main/java/net/minecraft/server/BlockJukeBox.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.minecraft.server; - -public class BlockJukeBox extends BlockContainer { - - protected BlockJukeBox(int i, int j) { - super(i, j, Material.WOOD); - } - - public int a(int i) { - return this.textureId + (i == 1 ? 1 : 0); - } - - public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) { - if (world.getData(i, j, k) == 0) { - return false; - } else { - this.b_(world, i, j, k); - return true; - } - } - - public void f(World world, int i, int j, int k, int l) { - if (!world.isStatic) { - TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k); - - tileentityrecordplayer.a = l; - tileentityrecordplayer.update(); - world.setData(i, j, k, 1); - } - } - - public void b_(World world, int i, int j, int k) { - if (!world.isStatic) { - TileEntityRecordPlayer tileentityrecordplayer = (TileEntityRecordPlayer) world.getTileEntity(i, j, k); - if (tileentityrecordplayer == null) return; // CraftBukkit - int l = tileentityrecordplayer.a; - - if (l != 0) { - world.e(1005, i, j, k, 0); - world.a((String) null, i, j, k); - tileentityrecordplayer.a = 0; - tileentityrecordplayer.update(); - world.setData(i, j, k, 0); - float f = 0.7F; - double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D; - double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(l, 1, 0)); - - entityitem.pickupDelay = 10; - world.addEntity(entityitem); - } - } - } - - public void remove(World world, int i, int j, int k) { - this.b_(world, i, j, k); - super.remove(world, i, j, k); - } - - public void dropNaturally(World world, int i, int j, int k, int l, float f) { - if (!world.isStatic) { - super.dropNaturally(world, i, j, k, l, f); - } - } - - protected TileEntity a_() { - return new TileEntityRecordPlayer(); - } -} diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java index a06725625e..2c035124c3 100644 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ b/src/main/java/net/minecraft/server/BlockLeaves.java @@ -40,7 +40,7 @@ public class BlockLeaves extends BlockLeavesBase { if (!world.isStatic) { int l = world.getData(i, j, k); - if ((l & 8) != 0) { + if ((l & 8) != 0 && (l & 4) == 0) { byte b0 = 4; int i1 = b0 + 1; byte b1 = 32; @@ -139,7 +139,7 @@ public class BlockLeaves extends BlockLeavesBase { } public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (!world.isStatic && entityhuman.G() != null && entityhuman.G().id == Item.SHEARS.id) { + if (!world.isStatic && entityhuman.K() != null && entityhuman.K().id == Item.SHEARS.id) { entityhuman.a(StatisticList.C[this.id], 1); this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3)); } else { diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index c179ae22d0..aae8a13dea 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -1,8 +1,7 @@ package net.minecraft.server; import java.util.Random; - -import org.bukkit.event.block.BlockSpreadEvent; // CraftBukkit +import org.bukkit.event.block.BlockSpreadEvent; public class BlockMushroom extends BlockFlower { @@ -16,29 +15,54 @@ public class BlockMushroom extends BlockFlower { public void a(World world, int i, int j, int k, Random random) { if (random.nextInt(100) == 0) { - int l = i + random.nextInt(3) - 1; - int i1 = j + random.nextInt(2) - random.nextInt(2); - int j1 = k + random.nextInt(3) - 1; + byte b0 = 4; + int l = 5; - if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) { - int k1 = i + (random.nextInt(3) - 1); + int i1; + int j1; + int k1; - k1 = k + (random.nextInt(3) - 1); - if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - org.bukkit.block.BlockState blockState = bworld.getBlockAt(l, i1, j1).getState(); - blockState.setTypeId(this.id); - - BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); - world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - blockState.update(true); + for (i1 = i - b0; i1 <= i + b0; ++i1) { + for (j1 = k - b0; j1 <= k + b0; ++j1) { + for (k1 = j - 1; k1 <= j + 1; ++k1) { + if (world.getTypeId(i1, k1, j1) == this.id) { + --l; + if (l <= 0) { + return; + } + } } - // CraftBukkit end } } + + i1 = i + random.nextInt(3) - 1; + j1 = j + random.nextInt(2) - random.nextInt(2); + k1 = k + random.nextInt(3) - 1; + + for (int l1 = 0; l1 < 4; ++l1) { + if (world.isEmpty(i1, j1, k1) && this.f(world, i1, j1, k1)) { + i = i1; + j = j1; + k = k1; + } + + i1 = i + random.nextInt(3) - 1; + j1 = j + random.nextInt(2) - random.nextInt(2); + k1 = k + random.nextInt(3) - 1; + } + + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState(); + blockState.setTypeId(this.id); + + BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); + world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + blockState.update(true); + } + // CraftBukkit end } } @@ -47,6 +71,39 @@ public class BlockMushroom extends BlockFlower { } public boolean f(World world, int i, int j, int k) { - return j >= 0 && j < 128 ? world.k(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)) : false; + if (j >= 0) { + world.getClass(); + if (j < 128) { + return world.k(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)); + } + } + + return false; + } + + public boolean b(World world, int i, int j, int k, Random random) { + int l = world.getTypeId(i, j - 1, k); + + if (l != Block.DIRT.id && l != Block.GRASS.id) { + return false; + } else { + int i1 = world.getData(i, j, k); + + world.setRawTypeId(i, j, k, 0); + WorldGenHugeMushroom worldgenhugemushroom = null; + + if (this.id == Block.BROWN_MUSHROOM.id) { + worldgenhugemushroom = new WorldGenHugeMushroom(0); + } else if (this.id == Block.RED_MUSHROOM.id) { + worldgenhugemushroom = new WorldGenHugeMushroom(1); + } + + if (worldgenhugemushroom != null && worldgenhugemushroom.a(world, random, i, j, k)) { + return true; + } else { + world.setRawTypeIdAndData(i, j, k, this.id, i1); + return false; + } + } } } diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java index 1c27571a79..a6423ed895 100644 --- a/src/main/java/net/minecraft/server/BlockPiston.java +++ b/src/main/java/net/minecraft/server/BlockPiston.java @@ -48,7 +48,7 @@ public class BlockPiston extends Block { } } - public void c(World world, int i, int j, int k) { + public void a(World world, int i, int j, int k) { if (!world.isStatic && world.getTileEntity(i, j, k) == null) { this.g(world, i, j, k); } @@ -110,7 +110,7 @@ public class BlockPiston extends Block { TileEntity tileentity = world.getTileEntity(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1]); if (tileentity != null && tileentity instanceof TileEntityPiston) { - ((TileEntityPiston) tileentity).k(); + ((TileEntityPiston) tileentity).e(); } world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, i1); @@ -130,9 +130,9 @@ public class BlockPiston extends Block { TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1; if (tileentitypiston.d() == i1 && tileentitypiston.c()) { - tileentitypiston.k(); + tileentitypiston.e(); i2 = tileentitypiston.a(); - j2 = tileentitypiston.e(); + j2 = tileentitypiston.j(); flag = true; } } @@ -296,6 +296,48 @@ public class BlockPiston extends Block { } } + private static int H(World world, int i, int j, int k, int l) { + int i1 = i + PistonBlockTextures.b[l]; + int j1 = j + PistonBlockTextures.c[l]; + int k1 = k + PistonBlockTextures.d[l]; + int l1 = 0; + + while (true) { + if (l1 < 13) { + if (j1 > 0) { + world.getClass(); + if (j1 < 128 - 1) { + int i2 = world.getTypeId(i1, j1, k1); + + if (i2 != 0) { + if (!a(i2, world, i1, j1, k1, true)) { + return -1; // CraftBukkit + } + + if (Block.byId[i2].e() != 1) { + if (l1 == 12) { + return -1; // CraftBukkit + } + + i1 += PistonBlockTextures.b[l]; + j1 += PistonBlockTextures.c[l]; + k1 += PistonBlockTextures.d[l]; + ++l1; + continue; + } + } + + return l1; // CraftBukkit + } + } + + return -1; // CraftBukkit + } + + return l1; // CraftBukkit + } + } + private boolean i(World world, int i, int j, int k, int l) { int i1 = i + PistonBlockTextures.b[l]; int j1 = j + PistonBlockTextures.c[l]; diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java index f9ab850c1e..ba88a26cc9 100644 --- a/src/main/java/net/minecraft/server/BlockPortal.java +++ b/src/main/java/net/minecraft/server/BlockPortal.java @@ -40,7 +40,7 @@ public class BlockPortal extends BlockBreakable { return false; } - public boolean a_(World world, int i, int j, int k) { + public boolean b_(World world, int i, int j, int k) { byte b0 = 0; byte b1 = 0; @@ -166,7 +166,7 @@ public class BlockPortal extends BlockBreakable { world.getServer().getPluginManager().callEvent(event); // CraftBukkit end - entity.P(); + entity.T(); } } } diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java index f9daa00fa6..e0cf2fe591 100644 --- a/src/main/java/net/minecraft/server/BlockPressurePlate.java +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -39,15 +39,15 @@ public class BlockPressurePlate extends Block { } public boolean canPlace(World world, int i, int j, int k) { - return world.e(i, j - 1, k); + return world.e(i, j - 1, k) || world.getTypeId(i, j - 1, k) == Block.FENCE.id; } - public void c(World world, int i, int j, int k) {} + public void a(World world, int i, int j, int k) {} public void doPhysics(World world, int i, int j, int k, int l) { boolean flag = false; - if (!world.e(i, j - 1, k)) { + if (!world.e(i, j - 1, k) && world.getTypeId(i, j - 1, k) != Block.FENCE.id) { flag = true; } diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java index acb280c545..420bc11ba5 100644 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -33,8 +33,8 @@ public class BlockPumpkin extends Block { return i == 1 ? this.textureId : (i == 0 ? this.textureId : (i == 3 ? this.textureId + 1 + 16 : this.textureId + 16)); } - public void c(World world, int i, int j, int k) { - super.c(world, i, j, k); + public void a(World world, int i, int j, int k) { + super.a(world, i, j, k); } public boolean canPlace(World world, int i, int j, int k) { diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java index b744679d26..847e64c52b 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java @@ -46,9 +46,9 @@ public class BlockRedstoneTorch extends BlockTorch { return 2; } - public void c(World world, int i, int j, int k) { + public void a(World world, int i, int j, int k) { if (world.getData(i, j, k) == 0) { - super.c(world, i, j, k); + super.a(world, i, j, k); } if (this.isOn) { diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java index af50818a88..b57b6378bf 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java @@ -191,8 +191,8 @@ public class BlockRedstoneWire extends Block { } } - public void c(World world, int i, int j, int k) { - super.c(world, i, j, k); + public void a(World world, int i, int j, int k) { + super.a(world, i, j, k); if (!world.isStatic) { this.g(world, i, j, k); world.applyPhysics(i, j + 1, k, this.id); @@ -351,7 +351,7 @@ public class BlockRedstoneWire extends Block { } else { int j1 = iblockaccess.getData(i, j, k); - return l == BedBlockTextures.b[j1 & 3]; + return l == Direction.e[j1 & 3]; } } } diff --git a/src/main/java/net/minecraft/server/BlockSign.java b/src/main/java/net/minecraft/server/BlockSign.java index f47462c184..7a2e8fb020 100644 --- a/src/main/java/net/minecraft/server/BlockSign.java +++ b/src/main/java/net/minecraft/server/BlockSign.java @@ -60,7 +60,7 @@ public class BlockSign extends BlockContainer { return false; } - protected TileEntity a_() { + public TileEntity a_() { try { return (TileEntity) this.a.newInstance(); } catch (Exception exception) { diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index 6e700ad515..54509332f1 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -74,7 +74,9 @@ public class BlockSoil extends Block { for (int l = i - b0; l <= i + b0; ++l) { for (int i1 = k - b0; i1 <= k + b0; ++i1) { - if (world.getTypeId(l, j + 1, i1) == Block.CROPS.id) { + int j1 = world.getTypeId(l, j + 1, i1); + + if (j1 == Block.CROPS.id || j1 == Block.MELON_STEM.id || j1 == Block.PUMPKIN_STEM.id) { return true; } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index e44b937892..f490df3d46 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -1,6 +1,7 @@ package net.minecraft.server; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -11,30 +12,37 @@ public class Chunk { public static boolean a; public byte[] b; - public boolean c; + public int[] c; + public boolean[] d; + public boolean e; public World world; - public NibbleArray e; - public NibbleArray f; public NibbleArray g; + public NibbleArray h; + public NibbleArray i; public byte[] heightMap; - public int i; + public int k; public final int x; public final int z; public Map tileEntities; public List[] entitySlices; public boolean done; - public boolean o; - public boolean p; public boolean q; - public long r; + public boolean r; + public boolean s; + public long t; + boolean u; public Chunk(World world, int i, int j) { + this.c = new int[256]; + this.d = new boolean[256]; this.tileEntities = new HashMap(); - this.entitySlices = new List[8]; this.done = false; - this.o = false; this.q = false; - this.r = 0L; + this.s = false; + this.t = 0L; + this.u = false; + world.getClass(); + this.entitySlices = new List[128 / 16]; this.world = world; this.x = i; this.z = j; @@ -44,6 +52,8 @@ public class Chunk { this.entitySlices[k] = new ArrayList(); } + Arrays.fill(this.c, -999); + // CraftBukkit start org.bukkit.craftbukkit.CraftWorld cworld = this.world.getWorld(); this.bukkitChunk = (cworld == null) ? null : cworld.popPreservedChunk(i, j); @@ -58,9 +68,14 @@ public class Chunk { public Chunk(World world, byte[] abyte, int i, int j) { this(world, i, j); this.b = abyte; - this.e = new NibbleArray(abyte.length); - this.f = new NibbleArray(abyte.length); - this.g = new NibbleArray(abyte.length); + + int k = abyte.length; + + // Craftbukkit start - FIX THE DECOMPILER! + this.g = new NibbleArray(k, 7); + this.h = new NibbleArray(k, 7); + this.i = new NibbleArray(k, 7); + // Craftbukkit end } public boolean a(int i, int j) { @@ -74,18 +89,25 @@ public class Chunk { public void a() {} public void initLighting() { - int i = 127; + this.world.getClass(); + int i = 128 - 1; int j; int k; for (j = 0; j < 16; ++j) { for (k = 0; k < 16; ++k) { - int l = 127; + this.world.getClass(); + int l = 128 - 1; - int i1; + this.world.getClass(); + int i1 = j << 11; - for (i1 = j << 11 | k << 7; l > 0 && Block.q[this.b[i1 + l - 1] & 255] == 0; --l) { + this.world.getClass(); + + int j1; + + for (j1 = i1 | k << 7; l > 0 && Block.q[this.b[j1 + l - 1] & 255] == 0; --l) { ; } @@ -95,54 +117,105 @@ public class Chunk { } if (!this.world.worldProvider.e) { - int j1 = 15; - int k1 = 127; + int k1 = 15; + + this.world.getClass(); + int l1 = 128 - 1; do { - j1 -= Block.q[this.b[i1 + k1] & 255]; - if (j1 > 0) { - this.f.a(j, k1, k, j1); + k1 -= Block.q[this.b[j1 + l1] & 255]; + if (k1 > 0) { + this.h.a(j, l1, k, k1); } - --k1; - } while (k1 > 0 && j1 > 0); + --l1; + } while (l1 > 0 && k1 > 0); } } } - this.i = i; + this.k = i; for (j = 0; j < 16; ++j) { for (k = 0; k < 16; ++k) { - this.c(j, k); + this.d(j, k); } } - this.o = true; + this.q = true; } public void loadNOP() {} - private void c(int i, int j) { - int k = this.b(i, j); - int l = this.x * 16 + i; - int i1 = this.z * 16 + j; + private void d(int i, int j) { + this.d[i + j * 16] = true; + } - this.f(l - 1, i1, k); - this.f(l + 1, i1, k); - this.f(l, i1 - 1, k); - this.f(l, i1 + 1, k); + private void i() { + World j0000 = this.world; + int j0001 = this.x * 16 + 8; + + this.world.getClass(); + if (j0000.areChunksLoaded(j0001, 128 / 2, this.z * 16 + 8, 16)) { + for (int j = 0; j < 16; ++j) { + for (int k = 0; k < 16; ++k) { + if (this.d[j + k * 16]) { + this.d[j + k * 16] = false; + int l = this.b(j, k); + int i1 = this.x * 16 + j; + int j1 = this.z * 16 + k; + int k1 = this.world.getHighestBlockYAt(i1 - 1, j1); + int l1 = this.world.getHighestBlockYAt(i1 + 1, j1); + int i2 = this.world.getHighestBlockYAt(i1, j1 - 1); + int j2 = this.world.getHighestBlockYAt(i1, j1 + 1); + + if (l1 < k1) { + k1 = l1; + } + + if (i2 < k1) { + k1 = i2; + } + + if (j2 < k1) { + k1 = j2; + } + + this.u = true; + this.f(i1, j1, k1); + this.u = true; + this.f(i1 - 1, j1, l); + this.f(i1 + 1, j1, l); + this.f(i1, j1 - 1, l); + this.f(i1, j1 + 1, l); + } + } + } + } } private void f(int i, int j, int k) { int l = this.world.getHighestBlockYAt(i, j); if (l > k) { - this.world.a(EnumSkyBlock.SKY, i, k, j, i, l, j); - this.o = true; + this.d(i, j, k, l + 1); } else if (l < k) { - this.world.a(EnumSkyBlock.SKY, i, l, j, i, k, j); - this.o = true; + this.d(i, j, l, k + 1); + } + } + + private void d(int i, int j, int k, int l) { + if (l > k) { + World world = this.world; + + this.world.getClass(); + if (world.areChunksLoaded(i, 128 / 2, j, 16)) { + for (int i1 = k; i1 < l; ++i1) { + this.world.b(EnumSkyBlock.SKY, i, i1, j); + } + + this.q = true; + } } } @@ -154,52 +227,52 @@ public class Chunk { i1 = j; } - for (int j1 = i << 11 | k << 7; i1 > 0 && Block.q[this.b[j1 + i1 - 1] & 255] == 0; --i1) { + this.world.getClass(); + int j1 = i << 11; + + this.world.getClass(); + + for (int k1 = j1 | k << 7; i1 > 0 && Block.q[this.b[k1 + i1 - 1] & 255] == 0; --i1) { ; } if (i1 != l) { this.world.g(i, k, i1, l); this.heightMap[k << 4 | i] = (byte) i1; - int k1; int l1; int i2; + int j2; - if (i1 < this.i) { - this.i = i1; + if (i1 < this.k) { + this.k = i1; } else { - k1 = 127; + this.world.getClass(); + l1 = 128 - 1; - for (l1 = 0; l1 < 16; ++l1) { - for (i2 = 0; i2 < 16; ++i2) { - if ((this.heightMap[i2 << 4 | l1] & 255) < k1) { - k1 = this.heightMap[i2 << 4 | l1] & 255; + for (i2 = 0; i2 < 16; ++i2) { + for (j2 = 0; j2 < 16; ++j2) { + if ((this.heightMap[j2 << 4 | i2] & 255) < l1) { + l1 = this.heightMap[j2 << 4 | i2] & 255; } } } - this.i = k1; + this.k = l1; } - k1 = this.x * 16 + i; - l1 = this.z * 16 + k; + l1 = this.x * 16 + i; + i2 = this.z * 16 + k; if (i1 < l) { - for (i2 = i1; i2 < l; ++i2) { - this.f.a(i, i2, k, 15); + for (j2 = i1; j2 < l; ++j2) { + this.h.a(i, j2, k, 15); } } else { - this.world.a(EnumSkyBlock.SKY, k1, l, l1, k1, i1, l1); - - for (i2 = l; i2 < i1; ++i2) { - this.f.a(i, i2, k, 0); + for (j2 = l; j2 < i1; ++j2) { + this.h.a(i, j2, k, 0); } } - i2 = 15; - - int j2; - - for (j2 = i1; i1 > 0 && i2 > 0; this.f.a(i, i1, k, i2)) { + for (j2 = 15; i1 > 0 && j2 > 0; this.h.a(i, i1, k, j2)) { --i1; int k2 = Block.q[this.getTypeId(i, i1, k)]; @@ -207,141 +280,237 @@ public class Chunk { k2 = 1; } - i2 -= k2; - if (i2 < 0) { - i2 = 0; + j2 -= k2; + if (j2 < 0) { + j2 = 0; } } - while (i1 > 0 && Block.q[this.getTypeId(i, i1 - 1, k)] == 0) { - --i1; + byte b0 = this.heightMap[k << 4 | i]; + int l2 = l; + int i3 = b0; + + if (b0 < l) { + l2 = b0; + i3 = l; } - if (i1 != j2) { - this.world.a(EnumSkyBlock.SKY, k1 - 1, i1, l1 - 1, k1 + 1, j2, l1 + 1); - } - - this.o = true; + this.d(l1 - 1, i2, l2, i3); + this.d(l1 + 1, i2, l2, i3); + this.d(l1, i2 - 1, l2, i3); + this.d(l1, i2 + 1, l2, i3); + this.d(l1, i2, l2, i3); + this.q = true; } } public int getTypeId(int i, int j, int k) { - return this.b[i << 11 | k << 7 | j] & 255; + byte[] abyte = this.b; + + this.world.getClass(); + int l = i << 11; + + this.world.getClass(); + return abyte[l | k << 7 | j] & 255; } public boolean a(int i, int j, int k, int l, int i1) { byte b0 = (byte) l; - int j1 = this.heightMap[k << 4 | i] & 255; - int k1 = this.b[i << 11 | k << 7 | j] & 255; + int j1 = k << 4 | i; - if (k1 == l && this.e.a(i, j, k) == i1) { + if (j >= this.c[j1] - 1) { + this.c[j1] = -999; + } + + int k1 = this.heightMap[k << 4 | i] & 255; + byte[] j2000 = this.b; + + this.world.getClass(); + int j2001 = i << 11; + + this.world.getClass(); + int i2 = j2000[j2001 | k << 7 | j] & 255; + + if (i2 == l && this.g.a(i, j, k) == i1) { return false; } else { - int l1 = this.x * 16 + i; - int i2 = this.z * 16 + k; + int j2 = this.x * 16 + i; + int k2 = this.z * 16 + k; - this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255); - if (k1 != 0 && !this.world.isStatic) { - Block.byId[k1].remove(this.world, l1, j, i2); + j2000 = this.b; + this.world.getClass(); + j2001 = i << 11; + this.world.getClass(); + j2000[j2001 | k << 7 | j] = (byte) (b0 & 255); + if (i2 != 0 && !this.world.isStatic) { + Block.byId[i2].remove(this.world, j2, j, k2); } - this.e.a(i, j, k, i1); + this.g.a(i, j, k, i1); if (!this.world.worldProvider.e) { if (Block.q[b0 & 255] != 0) { - if (j >= j1) { + if (j >= k1) { this.g(i, j + 1, k); } - } else if (j == j1 - 1) { + } else if (j == k1 - 1) { this.g(i, j, k); } - this.world.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2); + this.world.a(EnumSkyBlock.SKY, j2, j, k2, j2, j, k2); } - this.world.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2); - this.c(i, k); - this.e.a(i, j, k, i1); + this.world.a(EnumSkyBlock.BLOCK, j2, j, k2, j2, j, k2); + this.d(i, k); + this.g.a(i, j, k, i1); + TileEntity tileentity; + if (l != 0) { - Block.byId[l].c(this.world, l1, j, i2); + if (!this.world.isStatic) { + Block.byId[l].a(this.world, j2, j, k2); + } + + if (Block.byId[l] instanceof BlockContainer) { + tileentity = this.d(i, j, k); + if (tileentity == null) { + tileentity = ((BlockContainer) Block.byId[l]).a_(); + this.world.setTileEntity(i, j, k, tileentity); + } + + if (tileentity != null) { + tileentity.g(); + } + } + } else if (i2 > 0 && Block.byId[i2] instanceof BlockContainer) { + tileentity = this.d(i, j, k); + if (tileentity != null) { + tileentity.g(); + } } - this.o = true; + this.q = true; return true; } } public boolean a(int i, int j, int k, int l) { byte b0 = (byte) l; - int i1 = this.heightMap[k << 4 | i] & 255; - int j1 = this.b[i << 11 | k << 7 | j] & 255; + int i1 = k << 4 | i; - if (j1 == l) { + if (j >= this.c[i1] - 1) { + this.c[i1] = -999; + } + + int j1 = this.heightMap[i1] & 255; + byte[] j2000 = this.b; + + this.world.getClass(); + int j2001 = i << 11; + + this.world.getClass(); + int l1 = j2000[j2001 | k << 7 | j] & 255; + + if (l1 == l) { return false; } else { - int k1 = this.x * 16 + i; - int l1 = this.z * 16 + k; + int i2 = this.x * 16 + i; + int j2 = this.z * 16 + k; - this.b[i << 11 | k << 7 | j] = (byte) (b0 & 255); - if (j1 != 0) { - Block.byId[j1].remove(this.world, k1, j, l1); + j2000 = this.b; + this.world.getClass(); + j2001 = i << 11; + this.world.getClass(); + j2000[j2001 | k << 7 | j] = (byte) (b0 & 255); + if (l1 != 0) { + Block.byId[l1].remove(this.world, i2, j, j2); } - this.e.a(i, j, k, 0); + this.g.a(i, j, k, 0); if (Block.q[b0 & 255] != 0) { - if (j >= i1) { + if (j >= j1) { this.g(i, j + 1, k); } - } else if (j == i1 - 1) { + } else if (j == j1 - 1) { this.g(i, j, k); } - this.world.a(EnumSkyBlock.SKY, k1, j, l1, k1, j, l1); - this.world.a(EnumSkyBlock.BLOCK, k1, j, l1, k1, j, l1); - this.c(i, k); - if (l != 0 && !this.world.isStatic) { - Block.byId[l].c(this.world, k1, j, l1); + this.world.a(EnumSkyBlock.SKY, i2, j, j2, i2, j, j2); + this.world.a(EnumSkyBlock.BLOCK, i2, j, j2, i2, j, j2); + this.d(i, k); + TileEntity tileentity; + + if (l != 0) { + if (!this.world.isStatic) { + Block.byId[l].a(this.world, i2, j, j2); + } + + if (l > 0 && Block.byId[l] instanceof BlockContainer) { + tileentity = this.d(i, j, k); + if (tileentity == null) { + tileentity = ((BlockContainer) Block.byId[l]).a_(); + this.world.setTileEntity(i, j, k, tileentity); + } + + if (tileentity != null) { + tileentity.g(); + } + } + } else if (l1 > 0 && Block.byId[l1] instanceof BlockContainer) { + tileentity = this.d(i, j, k); + if (tileentity != null) { + tileentity.g(); + } } - this.o = true; + this.q = true; return true; } } public int getData(int i, int j, int k) { - return this.e.a(i, j, k); + return this.g.a(i, j, k); } public void b(int i, int j, int k, int l) { - this.o = true; - this.e.a(i, j, k, l); + this.q = true; + this.g.a(i, j, k, l); + int i1 = this.getTypeId(i, j, k); + + if (i1 > 0 && Block.byId[i1] instanceof BlockContainer) { + TileEntity tileentity = this.d(i, j, k); + + if (tileentity != null) { + tileentity.g(); + tileentity.n = l; + } + } } public int a(EnumSkyBlock enumskyblock, int i, int j, int k) { - return enumskyblock == EnumSkyBlock.SKY ? this.f.a(i, j, k) : (enumskyblock == EnumSkyBlock.BLOCK ? this.g.a(i, j, k) : 0); + return enumskyblock == EnumSkyBlock.SKY ? this.h.a(i, j, k) : (enumskyblock == EnumSkyBlock.BLOCK ? this.i.a(i, j, k) : 0); } public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - this.o = true; + this.q = true; if (enumskyblock == EnumSkyBlock.SKY) { - this.f.a(i, j, k, l); + this.h.a(i, j, k, l); } else { if (enumskyblock != EnumSkyBlock.BLOCK) { return; } - this.g.a(i, j, k, l); + this.i.a(i, j, k, l); } } public int c(int i, int j, int k, int l) { - int i1 = this.f.a(i, j, k); + int i1 = this.h.a(i, j, k); if (i1 > 0) { a = true; } i1 -= l; - int j1 = this.g.a(i, j, k); + int j1 = this.i.a(i, j, k); if (j1 > i1) { i1 = j1; @@ -351,7 +520,7 @@ public class Chunk { } public void a(Entity entity) { - this.q = true; + this.s = true; int i = MathHelper.floor(entity.locX / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D); @@ -372,15 +541,15 @@ public class Chunk { k = this.entitySlices.length - 1; } - entity.bG = true; - entity.bH = this.x; - entity.bI = k; - entity.bJ = this.z; + entity.bV = true; + entity.bW = this.x; + entity.bX = k; + entity.bY = this.z; this.entitySlices[k].add(entity); } public void b(Entity entity) { - this.a(entity, entity.bI); + this.a(entity, entity.bX); } public void a(Entity entity, int i) { @@ -410,13 +579,15 @@ public class Chunk { return null; } - BlockContainer blockcontainer = (BlockContainer) Block.byId[l]; + if (tileentity == null) { + tileentity = ((BlockContainer) Block.byId[l]).a_(); + this.world.setTileEntity(this.x * 16 + i, j, this.z * 16 + k, tileentity); + } - blockcontainer.c(this.world, this.x * 16 + i, j, this.z * 16 + k); tileentity = (TileEntity) this.tileEntities.get(chunkposition); } - if (tileentity != null && tileentity.g()) { + if (tileentity != null && tileentity.m()) { this.tileEntities.remove(chunkposition); return null; } else { @@ -430,8 +601,8 @@ public class Chunk { int k = tileentity.z - this.z * 16; this.a(i, j, k, tileentity); - if (this.c) { - this.world.c.add(tileentity); + if (this.e) { + this.world.h.add(tileentity); } } @@ -443,7 +614,7 @@ public class Chunk { tileentity.y = j; tileentity.z = this.z * 16 + k; if (this.getTypeId(i, j, k) != 0 && Block.byId[this.getTypeId(i, j, k)] instanceof BlockContainer) { - tileentity.j(); + tileentity.n(); this.tileEntities.put(chunkposition, tileentity); } else { System.out.println("Attempted to place a tile entity where there was no entity tile!"); @@ -453,17 +624,17 @@ public class Chunk { public void e(int i, int j, int k) { ChunkPosition chunkposition = new ChunkPosition(i, j, k); - if (this.c) { + if (this.e) { TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition); if (tileentity != null) { - tileentity.h(); + tileentity.i(); } } } public void addEntities() { - this.c = true; + this.e = true; this.world.a(this.tileEntities.values()); for (int i = 0; i < this.entitySlices.length; ++i) { @@ -472,13 +643,13 @@ public class Chunk { } public void removeEntities() { - this.c = false; + this.e = false; Iterator iterator = this.tileEntities.values().iterator(); while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); - world.markForRemoval(tileentity); // Craftbukkit + this.world.a(tileentity); } for (int i = 0; i < this.entitySlices.length; ++i) { @@ -502,7 +673,7 @@ public class Chunk { } public void f() { - this.o = true; + this.q = true; } public void a(Entity entity, AxisAlignedBB axisalignedbb, List list) { @@ -556,18 +727,18 @@ public class Chunk { } public boolean a(boolean flag) { - if (this.p) { + if (this.r) { return false; } else { if (flag) { - if (this.q && this.world.getTime() != this.r) { + if (this.s && this.world.getTime() != this.t) { return true; } - } else if (this.q && this.world.getTime() >= this.r + 600L) { + } else if (this.s && this.world.getTime() >= this.t + 600L) { return true; } - return this.o; + return this.q; } } @@ -579,52 +750,65 @@ public class Chunk { if (l1 * i2 * j2 == this.b.length) { System.arraycopy(this.b, 0, abyte, k1, this.b.length); k1 += this.b.length; - System.arraycopy(this.e.a, 0, abyte, k1, this.e.a.length); - k1 += this.e.a.length; System.arraycopy(this.g.a, 0, abyte, k1, this.g.a.length); k1 += this.g.a.length; - System.arraycopy(this.f.a, 0, abyte, k1, this.f.a.length); - k1 += this.f.a.length; + System.arraycopy(this.i.a, 0, abyte, k1, this.i.a.length); + k1 += this.i.a.length; + System.arraycopy(this.h.a, 0, abyte, k1, this.h.a.length); + k1 += this.h.a.length; return k1; } else { int k2; int l2; int i3; int j3; + int k3; for (k2 = i; k2 < l; ++k2) { - for (l2 = k; l2 < j1; ++l2) { - i3 = k2 << 11 | l2 << 7 | j; - j3 = i1 - j; - System.arraycopy(this.b, i3, abyte, k1, j3); - k1 += j3; + for (i3 = k; i3 < j1; ++i3) { + this.world.getClass(); + l2 = k2 << 11; + this.world.getClass(); + j3 = l2 | i3 << 7 | j; + k3 = i1 - j; + System.arraycopy(this.b, j3, abyte, k1, k3); + k1 += k3; } } for (k2 = i; k2 < l; ++k2) { - for (l2 = k; l2 < j1; ++l2) { - i3 = (k2 << 11 | l2 << 7 | j) >> 1; - j3 = (i1 - j) / 2; - System.arraycopy(this.e.a, i3, abyte, k1, j3); - k1 += j3; + for (i3 = k; i3 < j1; ++i3) { + this.world.getClass(); + l2 = k2 << 11; + this.world.getClass(); + j3 = (l2 | i3 << 7 | j) >> 1; + k3 = (i1 - j) / 2; + System.arraycopy(this.g.a, j3, abyte, k1, k3); + k1 += k3; } } for (k2 = i; k2 < l; ++k2) { - for (l2 = k; l2 < j1; ++l2) { - i3 = (k2 << 11 | l2 << 7 | j) >> 1; - j3 = (i1 - j) / 2; - System.arraycopy(this.g.a, i3, abyte, k1, j3); - k1 += j3; + for (i3 = k; i3 < j1; ++i3) { + this.world.getClass(); + l2 = k2 << 11; + this.world.getClass(); + j3 = (l2 | i3 << 7 | j) >> 1; + k3 = (i1 - j) / 2; + System.arraycopy(this.i.a, j3, abyte, k1, k3); + k1 += k3; } } for (k2 = i; k2 < l; ++k2) { - for (l2 = k; l2 < j1; ++l2) { - i3 = (k2 << 11 | l2 << 7 | j) >> 1; - j3 = (i1 - j) / 2; - System.arraycopy(this.f.a, i3, abyte, k1, j3); - k1 += j3; + for (i3 = k; i3 < j1; ++i3) { + this.world.getClass(); + l2 = k2 << 11; + this.world.getClass(); + j3 = (l2 | i3 << 7 | j) >> 1; + k3 = (i1 - j) / 2; + System.arraycopy(this.h.a, j3, abyte, k1, k3); + k1 += k3; } } @@ -636,11 +820,56 @@ public class Chunk { return new Random(this.world.getSeed() + (long) (this.x * this.x * 4987142) + (long) (this.x * 5947611) + (long) (this.z * this.z) * 4392871L + (long) (this.z * 389711) ^ i); } - public boolean isEmpty() { - return false; + public void g() { + BlockRegister.a(this.b); + } + + public void a(IChunkProvider ichunkprovider, IChunkProvider ichunkprovider1, int i, int j) { + if (!this.done && ichunkprovider.isChunkLoaded(i + 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { + ichunkprovider.getChunkAt(ichunkprovider1, i, j); + } + + if (ichunkprovider.isChunkLoaded(i - 1, j) && !ichunkprovider.getOrCreateChunk(i - 1, j).done && ichunkprovider.isChunkLoaded(i - 1, j + 1) && ichunkprovider.isChunkLoaded(i, j + 1) && ichunkprovider.isChunkLoaded(i - 1, j + 1)) { + ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j); + } + + if (ichunkprovider.isChunkLoaded(i, j - 1) && !ichunkprovider.getOrCreateChunk(i, j - 1).done && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j - 1) && ichunkprovider.isChunkLoaded(i + 1, j)) { + ichunkprovider.getChunkAt(ichunkprovider1, i, j - 1); + } + + if (ichunkprovider.isChunkLoaded(i - 1, j - 1) && !ichunkprovider.getOrCreateChunk(i - 1, j - 1).done && ichunkprovider.isChunkLoaded(i, j - 1) && ichunkprovider.isChunkLoaded(i - 1, j)) { + ichunkprovider.getChunkAt(ichunkprovider1, i - 1, j - 1); + } + } + + public int c(int i, int j) { + int k = i | j << 4; + int l = this.c[k]; + + if (l == -999) { + this.world.getClass(); + int i1 = 128 - 1; + + l = -1; + + while (i1 > 0 && l == -1) { + int j1 = this.getTypeId(i, i1, j); + Material material = j1 == 0 ? Material.AIR : Block.byId[j1].material; + + if (!material.isSolid() && !material.isLiquid()) { + --i1; + } else { + l = i1 + 1; + } + } + + this.c[k] = l; + } + + return l; } public void h() { - BlockRegister.a(this.b); + this.i(); } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 0b232fd13e..6fd568cba2 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -2,10 +2,8 @@ package net.minecraft.server; import java.io.IOException; 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 @@ -91,21 +89,7 @@ public class ChunkProviderServer implements IChunkProvider { } // CraftBukkit end - if (!chunk.done && this.isChunkLoaded(i + 1, j + 1) && this.isChunkLoaded(i, j + 1) && this.isChunkLoaded(i + 1, j)) { - this.getChunkAt(this, i, j); - } - - if (this.isChunkLoaded(i - 1, j) && !this.getOrCreateChunk(i - 1, j).done && this.isChunkLoaded(i - 1, j + 1) && this.isChunkLoaded(i, j + 1) && this.isChunkLoaded(i - 1, j)) { - this.getChunkAt(this, i - 1, j); - } - - if (this.isChunkLoaded(i, j - 1) && !this.getOrCreateChunk(i, j - 1).done && this.isChunkLoaded(i + 1, j - 1) && this.isChunkLoaded(i, j - 1) && this.isChunkLoaded(i + 1, j)) { - this.getChunkAt(this, i, j - 1); - } - - if (this.isChunkLoaded(i - 1, j - 1) && !this.getOrCreateChunk(i - 1, j - 1).done && this.isChunkLoaded(i - 1, j - 1) && this.isChunkLoaded(i, j - 1) && this.isChunkLoaded(i - 1, j)) { - this.getChunkAt(this, i - 1, j - 1); - } + chunk.a(this, this, i, j); } return chunk; @@ -136,7 +120,7 @@ public class ChunkProviderServer implements IChunkProvider { Chunk chunk = this.e.a(this.world, i, j); if (chunk != null) { - chunk.r = this.world.getTime(); + chunk.t = this.world.getTime(); } return chunk; @@ -160,7 +144,7 @@ public class ChunkProviderServer implements IChunkProvider { public void saveChunk(Chunk chunk) { // CraftBukkit - private -> public if (this.e != null) { try { - chunk.r = this.world.getTime(); + chunk.t = this.world.getTime(); this.e.a(this.world, chunk); } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception ioexception.printStackTrace(); @@ -205,13 +189,13 @@ public class ChunkProviderServer implements IChunkProvider { for (int j = 0; j < this.chunkList.size(); ++j) { Chunk chunk = (Chunk) this.chunkList.get(j); - if (flag && !chunk.p) { + if (flag && !chunk.r) { this.saveChunkNOP(chunk); } if (chunk.a(flag)) { this.saveChunk(chunk); - chunk.o = false; + chunk.q = false; ++i; if (i == 24 && !flag) { return false; diff --git a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java b/src/main/java/net/minecraft/server/ConsoleCommandHandler.java deleted file mode 100644 index ea6338a962..0000000000 --- a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java +++ /dev/null @@ -1,417 +0,0 @@ -package net.minecraft.server; - -import java.util.Iterator; -import java.util.Set; -import java.util.logging.Logger; - -// CraftBukkit start -import org.bukkit.craftbukkit.command.ServerCommandListener; -import org.bukkit.craftbukkit.entity.CraftPlayer; -// CraftBukkit end - -public class ConsoleCommandHandler { - - private static Logger a = Logger.getLogger("Minecraft"); - private MinecraftServer server; - private ICommandListener listener; // CraftBukkit - - public ConsoleCommandHandler(MinecraftServer minecraftserver) { - this.server = minecraftserver; - } - - // Craftbukkit start - private boolean hasPermission(ICommandListener listener, String perm) { - if (listener instanceof ServerCommandListener) { - ServerCommandListener serv = (ServerCommandListener)listener; - return serv.getSender().hasPermission(perm); - } else if (listener instanceof NetServerHandler) { - NetServerHandler net = (NetServerHandler)listener; - return net.getPlayer().hasPermission(perm); - } else if ((listener instanceof ServerGUI) || (listener instanceof MinecraftServer)) { - return server.console.hasPermission(perm); - } - - return false; - } - - private boolean checkPermission(ICommandListener listener, String command) { - if (hasPermission(listener, "bukkit.command." + command)) { - return true; - } else { - listener.sendMessage("I'm sorry, Dave, but I cannot let you do that."); - return false; - } - } - // Craftbukkit end - - public boolean handle(ServerCommand servercommand) { // CraftBukkit - returns boolean - String s = servercommand.command; - ICommandListener icommandlistener = servercommand.b; - String s1 = icommandlistener.getName(); - this.listener = icommandlistener; // CraftBukkit - ServerConfigurationManager serverconfigurationmanager = this.server.serverConfigurationManager; - - if (!s.toLowerCase().startsWith("help") && !s.toLowerCase().startsWith("?")) { - if (s.toLowerCase().startsWith("list")) { - if (!checkPermission(listener, "list")) return true; // Craftbukkit - icommandlistener.sendMessage("Connected players: " + serverconfigurationmanager.c()); - } else if (s.toLowerCase().startsWith("stop")) { - if (!checkPermission(listener, "stop")) return true; // Craftbukkit - this.print(s1, "Stopping the server.."); - this.server.a(); - } else { - int i; - WorldServer worldserver; - - if (s.toLowerCase().startsWith("save-all")) { - if (!checkPermission(listener, "save.perform")) return true; // Craftbukkit - this.print(s1, "Forcing save.."); - if (serverconfigurationmanager != null) { - serverconfigurationmanager.savePlayers(); - } - - // CraftBukkit start - for (i = 0; i < this.server.worlds.size(); ++i) { - worldserver = this.server.worlds.get(i); - boolean save = worldserver.canSave; - worldserver.canSave = false; - worldserver.save(true, (IProgressUpdate) null); - worldserver.canSave = save; - } - // CraftBukkit end - - this.print(s1, "Save complete."); - } else if (s.toLowerCase().startsWith("save-off")) { - if (!checkPermission(listener, "save.disable")) return true; // Craftbukkit - this.print(s1, "Disabling level saving.."); - - for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit - worldserver = this.server.worlds.get(i); // CraftBukkit - worldserver.canSave = true; - } - } else if (s.toLowerCase().startsWith("save-on")) { - if (!checkPermission(listener, "save.enable")) return true; // Craftbukkit - this.print(s1, "Enabling level saving.."); - - for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit - worldserver = this.server.worlds.get(i); // CraftBukkit - worldserver.canSave = false; - } - } else { - String s2; - - if (s.toLowerCase().startsWith("op ")) { - if (!checkPermission(listener, "op.give")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.e(s2); - this.print(s1, "Opping " + s2); - serverconfigurationmanager.a(s2, "\u00A7eYou are now op!"); - } else if (s.toLowerCase().startsWith("deop ")) { - if (!checkPermission(listener, "op.take")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.f(s2); - serverconfigurationmanager.a(s2, "\u00A7eYou are no longer op!"); - this.print(s1, "De-opping " + s2); - } else if (s.toLowerCase().startsWith("ban-ip ")) { - if (!checkPermission(listener, "ban.ip")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.c(s2); - this.print(s1, "Banning ip " + s2); - } else if (s.toLowerCase().startsWith("pardon-ip ")) { - if (!checkPermission(listener, "unban.ip")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.d(s2); - this.print(s1, "Pardoning ip " + s2); - } else { - EntityPlayer entityplayer; - - if (s.toLowerCase().startsWith("ban ")) { - if (!checkPermission(listener, "ban.player")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.a(s2); - this.print(s1, "Banning " + s2); - entityplayer = serverconfigurationmanager.i(s2); - if (entityplayer != null) { - entityplayer.netServerHandler.disconnect("Banned by admin"); - } - } else if (s.toLowerCase().startsWith("pardon ")) { - if (!checkPermission(listener, "unban.player")) return true; // Craftbukkit - s2 = s.substring(s.indexOf(" ")).trim(); - serverconfigurationmanager.b(s2); - this.print(s1, "Pardoning " + s2); - } else { - int j; - - if (s.toLowerCase().startsWith("kick ")) { - if (!checkPermission(listener, "kick")) return true; // Craftbukkit - // CraftBukkit start - Add kick message compatibility - String[] parts = s.split(" "); - s2 = parts.length >= 2 ? parts[1] : ""; - // CraftBukkit end - entityplayer = null; - - for (j = 0; j < serverconfigurationmanager.players.size(); ++j) { - EntityPlayer entityplayer1 = (EntityPlayer) serverconfigurationmanager.players.get(j); - - if (entityplayer1.name.equalsIgnoreCase(s2)) { - entityplayer = entityplayer1; - } - } - - if (entityplayer != null) { - entityplayer.netServerHandler.disconnect("Kicked by admin"); - this.print(s1, "Kicking " + entityplayer.name); - } else { - icommandlistener.sendMessage("Can\'t find user " + s2 + ". No kick."); - } - } else { - EntityPlayer entityplayer2; - String[] astring; - - if (s.toLowerCase().startsWith("tp ")) { - if (!checkPermission(listener, "teleport")) return true; // Craftbukkit - astring = s.split(" "); - if (astring.length == 3) { - entityplayer = serverconfigurationmanager.i(astring[1]); - entityplayer2 = serverconfigurationmanager.i(astring[2]); - if (entityplayer == null) { - icommandlistener.sendMessage("Can\'t find user " + astring[1] + ". No tp."); - } else if (entityplayer2 == null) { - icommandlistener.sendMessage("Can\'t find user " + astring[2] + ". No tp."); - } else if (entityplayer.dimension != entityplayer2.dimension) { - icommandlistener.sendMessage("User " + astring[1] + " and " + astring[2] + " are in different dimensions. No tp."); - } else { - entityplayer.netServerHandler.a(entityplayer2.locX, entityplayer2.locY, entityplayer2.locZ, entityplayer2.yaw, entityplayer2.pitch); - this.print(s1, "Teleporting " + astring[1] + " to " + astring[2] + "."); - } - } else { - icommandlistener.sendMessage("Syntax error, please provice a source and a target."); - } - } else { - String s3; - int k; - - if (s.toLowerCase().startsWith("give ")) { - if (!checkPermission(listener, "give")) return true; // Craftbukkit - astring = s.split(" "); - if (astring.length != 3 && astring.length != 4) { - return true; // CraftBukkit - } - - s3 = astring[1]; - entityplayer2 = serverconfigurationmanager.i(s3); - if (entityplayer2 != null) { - try { - k = Integer.parseInt(astring[2]); - if (Item.byId[k] != null) { - this.print(s1, "Giving " + entityplayer2.name + " some " + k); - int l = 1; - - if (astring.length > 3) { - l = this.a(astring[3], 1); - } - - if (l < 1) { - l = 1; - } - - if (l > 64) { - l = 64; - } - - entityplayer2.b(new ItemStack(k, l, 0)); - } else { - icommandlistener.sendMessage("There\'s no item with id " + k); - } - } catch (NumberFormatException numberformatexception) { - icommandlistener.sendMessage("There\'s no item with id " + astring[2]); - } - } else { - icommandlistener.sendMessage("Can\'t find user " + s3); - } - } else if (s.toLowerCase().startsWith("time ")) { - astring = s.split(" "); - if (astring.length != 3) { - return true; // CraftBukkit - } - - s3 = astring[1]; - - try { - j = Integer.parseInt(astring[2]); - WorldServer worldserver1; - - if ("add".equalsIgnoreCase(s3)) { - if (!checkPermission(listener, "time.add")) return true; // Craftbukkit - for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit - worldserver1 = this.server.worlds.get(k); // CraftBukkit - worldserver1.setTimeAndFixTicklists(worldserver1.getTime() + (long) j); - } - - this.print(s1, "Added " + j + " to time"); - } else if ("set".equalsIgnoreCase(s3)) { - if (!checkPermission(listener, "time.set")) return true; // Craftbukkit - for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit - worldserver1 = this.server.worlds.get(k); // CraftBukkit - worldserver1.setTimeAndFixTicklists((long) j); - } - - this.print(s1, "Set time to " + j); - } else { - icommandlistener.sendMessage("Unknown method, use either \"add\" or \"set\""); - } - } catch (NumberFormatException numberformatexception1) { - icommandlistener.sendMessage("Unable to convert time value, " + astring[2]); - } - } else if (s.toLowerCase().startsWith("say ")) { - if (!checkPermission(listener, "say")) return true; // Craftbukkit - s = s.substring(s.indexOf(" ")).trim(); - a.info("[" + s1 + "] " + s); - serverconfigurationmanager.sendAll(new Packet3Chat("\u00A7d[Server] " + s)); - } else if (s.toLowerCase().startsWith("tell ")) { - if (!checkPermission(listener, "tell")) return true; // Craftbukkit - 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 = "\u00A77" + s1 + " whispers " + s; - a.info(s); - if (!serverconfigurationmanager.a(astring[1], (Packet) (new Packet3Chat(s)))) { - icommandlistener.sendMessage("There\'s no player by that name online."); - } - } - } else if (s.toLowerCase().startsWith("whitelist ")) { - this.a(s1, s, icommandlistener); - } else { - icommandlistener.sendMessage("Unknown console command. Type \"help\" for help."); // CraftBukkit - return false; // CraftBukkit - } - } - } - } - } - } - } - } else { - if (!checkPermission(listener, "help")) return true; // Craftbukkit - this.a(icommandlistener); - } - - return true; // CraftBukkit - } - - private void a(String s, String s1, ICommandListener icommandlistener) { - String[] astring = s1.split(" "); - this.listener = icommandlistener; // CraftBukkit - - if (astring.length >= 2) { - String s2 = astring[1].toLowerCase(); - - if ("on".equals(s2)) { - if (!checkPermission(listener, "whitelist.enable")) return; // Craftbukkit - this.print(s, "Turned on white-listing"); - this.server.propertyManager.b("white-list", true); - } else if ("off".equals(s2)) { - if (!checkPermission(listener, "whitelist.disable")) return; // Craftbukkit - this.print(s, "Turned off white-listing"); - this.server.propertyManager.b("white-list", false); - } else if ("list".equals(s2)) { - if (!checkPermission(listener, "whitelist.list")) return; // Craftbukkit - Set set = this.server.serverConfigurationManager.e(); - String s3 = ""; - - String s4; - - for (Iterator iterator = set.iterator(); iterator.hasNext(); s3 = s3 + s4 + " ") { - s4 = (String) iterator.next(); - } - - icommandlistener.sendMessage("White-listed players: " + s3); - } else { - String s5; - - if ("add".equals(s2) && astring.length == 3) { - if (!checkPermission(listener, "whitelist.add")) return; // Craftbukkit - s5 = astring[2].toLowerCase(); - this.server.serverConfigurationManager.k(s5); - this.print(s, "Added " + s5 + " to white-list"); - } else if ("remove".equals(s2) && astring.length == 3) { - if (!checkPermission(listener, "whitelist.remove")) return; // Craftbukkit - s5 = astring[2].toLowerCase(); - this.server.serverConfigurationManager.l(s5); - this.print(s, "Removed " + s5 + " from white-list"); - } else if ("reload".equals(s2)) { - if (!checkPermission(listener, "whitelist.reload")) return; // Craftbukkit - this.server.serverConfigurationManager.f(); - this.print(s, "Reloaded white-list from file"); - } - } - } - } - - private void a(ICommandListener icommandlistener) { - icommandlistener.sendMessage("To run the server without a gui, start it like this:"); - icommandlistener.sendMessage(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui"); - icommandlistener.sendMessage("Console commands:"); - icommandlistener.sendMessage(" help or ? shows this message"); - icommandlistener.sendMessage(" kick removes a player from the server"); - icommandlistener.sendMessage(" ban bans a player from the server"); - icommandlistener.sendMessage(" pardon pardons a banned player so that they can connect again"); - icommandlistener.sendMessage(" ban-ip bans an IP address from the server"); - icommandlistener.sendMessage(" pardon-ip pardons a banned IP address so that they can connect again"); - icommandlistener.sendMessage(" op turns a player into an op"); - icommandlistener.sendMessage(" deop removes op status from a player"); - icommandlistener.sendMessage(" tp moves one player to the same location as another player"); - icommandlistener.sendMessage(" give [num] gives a player a resource"); - icommandlistener.sendMessage(" tell sends a private message to a player"); - icommandlistener.sendMessage(" stop gracefully stops the server"); - icommandlistener.sendMessage(" save-all forces a server-wide level save"); - icommandlistener.sendMessage(" save-off disables terrain saving (useful for backup scripts)"); - icommandlistener.sendMessage(" save-on re-enables terrain saving"); - icommandlistener.sendMessage(" list lists all currently connected players"); - icommandlistener.sendMessage(" say broadcasts a message to all players"); - icommandlistener.sendMessage(" time adds to or sets the world time (0-24000)"); - } - - private void print(String s, String s1) { - String s2 = s + ": " + s1; - - // CraftBukkit start - this.listener.sendMessage(s1); - this.informOps("\u00A77(" + s2 + ")"); - if (this.listener instanceof MinecraftServer) { - return; // Already logged so don't call a.info() - } - // CraftBukkit end - a.info(s2); - } - - // CraftBukkit start - private void informOps(String msg) { - Packet3Chat packet3chat = new Packet3Chat(msg); - EntityPlayer sender = null; - if (this.listener instanceof ServerCommandListener) { - org.bukkit.command.CommandSender commandSender = ((ServerCommandListener) this.listener).getSender(); - if (commandSender instanceof CraftPlayer) { - sender = ((CraftPlayer) commandSender).getHandle(); - } - } - java.util.List players = this.server.serverConfigurationManager.players; - for (int i = 0; i < players.size(); ++i) { - EntityPlayer entityPlayer = (EntityPlayer) players.get(i); - if (sender != entityPlayer && this.server.serverConfigurationManager.isOp(entityPlayer.name)) { - entityPlayer.netServerHandler.sendPacket(packet3chat); - } - } - } - // CraftBukkit end - - private int a(String s, int i) { - try { - return Integer.parseInt(s); - } catch (NumberFormatException numberformatexception) { - return i; - } - } -} diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index 78ca3c4feb..7a01145f73 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -25,6 +25,7 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Item.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Item.SUGAR_CANE}); this.registerShapedRecipe(new ItemStack(Item.BOOK, 1), new Object[] { "#", "#", "#", Character.valueOf('#'), Item.PAPER}); this.registerShapedRecipe(new ItemStack(Block.FENCE, 2), new Object[] { "###", "###", Character.valueOf('#'), Item.STICK}); + this.registerShapedRecipe(new ItemStack(Block.FENCE_GATE, 1), new Object[] { "#W#", "#W#", Character.valueOf('#'), Item.STICK, Character.valueOf('W'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Block.JUKEBOX, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.DIAMOND}); this.registerShapedRecipe(new ItemStack(Block.NOTE_BLOCK, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.REDSTONE}); this.registerShapedRecipe(new ItemStack(Block.BOOKSHELF, 1), new Object[] { "###", "XXX", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.BOOK}); @@ -38,6 +39,8 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Block.STEP, 3, 0), new Object[] { "###", Character.valueOf('#'), Block.STONE}); this.registerShapedRecipe(new ItemStack(Block.STEP, 3, 1), new Object[] { "###", Character.valueOf('#'), Block.SANDSTONE}); this.registerShapedRecipe(new ItemStack(Block.STEP, 3, 2), new Object[] { "###", Character.valueOf('#'), Block.WOOD}); + this.registerShapedRecipe(new ItemStack(Block.STEP, 3, 4), new Object[] { "###", Character.valueOf('#'), Block.BRICK}); + this.registerShapedRecipe(new ItemStack(Block.STEP, 3, 5), new Object[] { "###", Character.valueOf('#'), Block.SMOOTH_BRICK}); this.registerShapedRecipe(new ItemStack(Block.LADDER, 2), new Object[] { "# #", "###", "# #", Character.valueOf('#'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Item.WOOD_DOOR, 1), new Object[] { "##", "##", "##", Character.valueOf('#'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Block.TRAP_DOOR, 2), new Object[] { "###", "###", Character.valueOf('#'), Block.WOOD}); @@ -64,6 +67,8 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Block.WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Item.FISHING_ROD, 1), new Object[] { " #", " #X", "# X", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.STRING}); this.registerShapedRecipe(new ItemStack(Block.COBBLESTONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.COBBLESTONE}); + this.registerShapedRecipe(new ItemStack(Block.BRICK_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.BRICK}); + this.registerShapedRecipe(new ItemStack(Block.STONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.SMOOTH_BRICK}); this.registerShapedRecipe(new ItemStack(Item.PAINTING, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Block.WOOL}); this.registerShapedRecipe(new ItemStack(Item.GOLDEN_APPLE, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.GOLD_BLOCK, Character.valueOf('X'), Item.APPLE}); this.registerShapedRecipe(new ItemStack(Block.LEVER, 1), new Object[] { "X", "#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.STICK}); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 37dc9f8f74..7b71ac5491 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -8,7 +8,6 @@ import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.block.BlockFace; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Projectile; import org.bukkit.entity.Vehicle; import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; import org.bukkit.event.vehicle.VehicleExitEvent; @@ -17,15 +16,14 @@ import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit end public abstract class Entity { private static int entityCount = 0; public int id; - public double aH; - public boolean aI; + public double aX; + public boolean aY; public Entity passenger; public Entity vehicle; public World world; @@ -45,81 +43,80 @@ public abstract class Entity { public final AxisAlignedBB boundingBox; public boolean onGround; public boolean positionChanged; - public boolean bc; - public boolean bd; + public boolean bs; + public boolean bt; public boolean velocityChanged; - public boolean bf; - public boolean bg; + protected boolean bv; + public boolean bw; public boolean dead; public float height; public float length; public float width; - public float bl; - public float bm; + public float bB; + public float bC; public float fallDistance; // CraftBukkit - private -> public private int b; - public double bo; - public double bp; - public double bq; - public float br; - public float bs; - public boolean bt; - public float bu; + public double bE; + public double bF; + public double bG; + public float bH; + public float bI; + public boolean bJ; + public float bK; protected Random random; public int ticksLived; public int maxFireTicks; public int fireTicks; public int maxAirTicks; // CraftBukkit - protected - >public - protected boolean bA; + protected boolean bQ; public int noDamageTicks; public int airTicks; private boolean justCreated; protected boolean fireProof; protected DataWatcher datawatcher; - public float bF; private double d; private double e; - public boolean bG; - public int bH; - public int bI; - public int bJ; - public boolean bK; + public boolean bV; + public int bW; + public int bX; + public int bY; + public boolean bZ; + public boolean ca; public UUID uniqueId = UUID.randomUUID(); // CraftBukkit public Entity(World world) { this.id = entityCount++; - this.aH = 1.0D; - this.aI = false; + this.aX = 1.0D; + this.aY = false; this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); this.onGround = false; - this.bd = false; + this.bt = false; this.velocityChanged = false; - this.bg = true; + this.bw = true; this.dead = false; this.height = 0.0F; this.length = 0.6F; this.width = 1.8F; - this.bl = 0.0F; - this.bm = 0.0F; + this.bB = 0.0F; + this.bC = 0.0F; this.fallDistance = 0.0F; this.b = 1; - this.br = 0.0F; - this.bs = 0.0F; - this.bt = false; - this.bu = 0.0F; + this.bH = 0.0F; + this.bI = 0.0F; + this.bJ = false; + this.bK = 0.0F; this.random = new Random(); this.ticksLived = 0; this.maxFireTicks = 1; this.fireTicks = 0; this.maxAirTicks = 300; - this.bA = false; + this.bQ = false; this.noDamageTicks = 0; this.airTicks = 300; this.justCreated = true; this.fireProof = false; this.datawatcher = new DataWatcher(); - this.bF = 0.0F; - this.bG = false; + this.bV = false; this.world = world; this.setPosition(0.0D, 0.0D, 0.0D); this.datawatcher.a(0, Byte.valueOf((byte) 0)); @@ -128,7 +125,7 @@ public abstract class Entity { protected abstract void b(); - public DataWatcher aa() { + public DataWatcher al() { return this.datawatcher; } @@ -188,27 +185,41 @@ public abstract class Entity { float f = this.length / 2.0F; float f1 = this.width; - this.boundingBox.c(d0 - (double) f, d1 - (double) this.height + (double) this.br, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.br + (double) f1, d2 + (double) f); + this.boundingBox.c(d0 - (double) f, d1 - (double) this.height + (double) this.bH, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.bH + (double) f1, d2 + (double) f); } - public void m_() { - this.R(); + public void s_() { + this.aa(); } - public void R() { + public void aa() { if (this.vehicle != null && this.vehicle.dead) { this.vehicle = null; } ++this.ticksLived; - this.bl = this.bm; + this.bB = this.bC; this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; this.lastPitch = this.pitch; this.lastYaw = this.yaw; + int i; + + if (this.at()) { + int j = MathHelper.floor(this.locX); + int k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); + + i = MathHelper.floor(this.locZ); + int l = this.world.getTypeId(j, k, i); + + if (l > 0) { + this.world.a("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.length, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.length, -this.motX * 4.0D, 1.5D, -this.motZ * 4.0D); + } + } + if (this.f_()) { - if (!this.bA && !this.justCreated) { + if (!this.bQ && !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) { @@ -218,28 +229,27 @@ public abstract class Entity { this.world.makeSound(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); float f1 = (float) MathHelper.floor(this.boundingBox.b); - int i; float f2; float f3; 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); + f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + this.world.a("bubble", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); } 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); + f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length; + this.world.a("splash", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); } } this.fallDistance = 0.0F; - this.bA = true; + this.bQ = true; this.fireTicks = 0; } else { - this.bA = false; + this.bQ = false; } if (this.world.isStatic) { @@ -258,10 +268,10 @@ public abstract class Entity { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.b, event.getDamage()); } } else { - this.damageEntity((Entity) null, 1); + this.damageEntity(DamageSource.b, 1); } // CraftBukkit end } @@ -270,12 +280,12 @@ public abstract class Entity { } } - if (this.ae()) { - this.ab(); + if (this.ap()) { + this.am(); } if (this.locY < -64.0D) { - this.Y(); + this.ah(); } if (!this.world.isStatic) { @@ -286,7 +296,7 @@ public abstract class Entity { this.justCreated = false; } - protected void ab() { + protected void am() { if (!this.fireProof) { // CraftBukkit start - TODO: this event spams! if (this instanceof EntityLiving) { @@ -300,7 +310,7 @@ public abstract class Entity { server.getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.c, event.getDamage()); } if (this.fireTicks <= 0) { @@ -319,12 +329,12 @@ public abstract class Entity { } // CraftBukkit end - this.damageEntity((Entity) null, 4); + this.damageEntity(DamageSource.c, 4); this.fireTicks = 600; } } - protected void Y() { + protected void ah() { this.die(); } @@ -336,18 +346,18 @@ public abstract class Entity { } public void move(double d0, double d1, double d2) { - if (this.bt) { + if (this.bJ) { 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.br; + this.locY = this.boundingBox.b + (double) this.height - (double) this.bH; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; } else { - this.br *= 0.4F; + this.bH *= 0.4F; double d3 = this.locX; double d4 = this.locZ; - if (this.bf) { - this.bf = false; + if (this.bv) { + this.bv = false; d0 *= 0.25D; d1 *= 0.05000000074505806D; d2 *= 0.25D; @@ -393,7 +403,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.bg && d6 != d1) { + if (!this.bw && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -408,7 +418,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.bg && d5 != d0) { + if (!this.bw && d5 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -419,7 +429,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.bg && d7 != d2) { + if (!this.bw && d7 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -429,13 +439,13 @@ public abstract class Entity { double d10; int k; - if (this.bs > 0.0F && flag1 && (flag || this.br < 0.05F) && (d5 != d0 || d7 != d2)) { + if (this.bI > 0.0F && flag1 && (flag || this.bH < 0.05F) && (d5 != d0 || d7 != d2)) { d9 = d0; d10 = d1; double d11 = d2; d0 = d5; - d1 = (double) this.bs; + d1 = (double) this.bI; d2 = d7; AxisAlignedBB axisalignedbb1 = this.boundingBox.clone(); @@ -447,7 +457,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.bg && d6 != d1) { + if (!this.bw && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -458,7 +468,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.bg && d5 != d0) { + if (!this.bw && d5 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -469,18 +479,18 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.bg && d7 != d2) { + if (!this.bw && d7 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } - if (!this.bg && d6 != d1) { + if (!this.bw && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } else { - d1 = (double) (-this.bs); + d1 = (double) (-this.bI); for (k = 0; k < list.size(); ++k) { d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); @@ -498,18 +508,18 @@ public abstract class Entity { double d12 = this.boundingBox.b - (double) ((int) this.boundingBox.b); if (d12 > 0.0D) { - this.br = (float) ((double) this.br + d12 + 0.01D); + this.bH = (float) ((double) this.bH + d12 + 0.01D); } } } this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; - this.locY = this.boundingBox.b + (double) this.height - (double) this.br; + this.locY = this.boundingBox.b + (double) this.height - (double) this.bH; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; this.positionChanged = d5 != d0 || d7 != d2; - this.bc = d6 != d1; + this.bs = d6 != d1; this.onGround = d6 != d1 && d6 < 0.0D; - this.bd = this.positionChanged || this.bc; + this.bt = this.positionChanged || this.bs; this.a(d1, this.onGround); if (d5 != d0) { this.motX = 0.0D; @@ -549,8 +559,8 @@ public abstract class Entity { } // CraftBukkit end - if (this.n() && !flag && this.vehicle == null) { - this.bm = (float) ((double) this.bm + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); + if (this.e_() && !flag && this.vehicle == null) { + this.bC = (float) ((double) this.bC + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); l = MathHelper.floor(this.locX); i1 = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); j1 = MathHelper.floor(this.locZ); @@ -559,8 +569,8 @@ public abstract class Entity { k = this.world.getTypeId(l, i1 - 1, j1); } - if (this.bm > (float) this.b && k > 0) { - ++this.b; + if (this.bC > (float) this.b && k > 0) { + this.b = (int) this.bC + 1; StepSound stepsound = Block.byId[k].stepSound; if (this.world.getTypeId(l, i1 + 1, j1) == Block.SNOW.id) { @@ -595,7 +605,7 @@ public abstract class Entity { } } - boolean flag2 = this.ac(); + boolean flag2 = this.an(); if (this.world.d(this.boundingBox.shrink(0.0010D, 0.0010D, 0.0010D))) { this.burn(1); @@ -625,7 +635,7 @@ public abstract class Entity { } } - protected boolean n() { + protected boolean e_() { return true; } @@ -640,7 +650,7 @@ public abstract class Entity { } } - public AxisAlignedBB e_() { + public AxisAlignedBB f() { return null; } @@ -658,7 +668,7 @@ public abstract class Entity { i = event.getDamage(); } // CraftBukkit end - this.damageEntity((Entity) null, i); + this.damageEntity(DamageSource.a, i); } } @@ -668,12 +678,12 @@ public abstract class Entity { } } - public boolean ac() { - return this.bA || this.world.s(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + public boolean an() { + return this.bQ || this.world.s(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); } - public boolean ad() { - return this.bA; + public boolean ao() { + return this.bQ; } public boolean f_() { @@ -701,7 +711,7 @@ public abstract class Entity { return 0.0F; } - public boolean ae() { + public boolean ap() { return this.world.a(this.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA); } @@ -724,22 +734,19 @@ public abstract class Entity { } } - public float c(float f) { + public float a_(float f) { int i = MathHelper.floor(this.locX); - double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; - int j = MathHelper.floor(this.locY - (double) this.height + d0); - int k = MathHelper.floor(this.locZ); + int j = MathHelper.floor(this.locZ); + World world = this.world; - if (this.world.a(MathHelper.floor(this.boundingBox.a), MathHelper.floor(this.boundingBox.b), MathHelper.floor(this.boundingBox.c), MathHelper.floor(this.boundingBox.d), MathHelper.floor(this.boundingBox.e), MathHelper.floor(this.boundingBox.f))) { - float f1 = this.world.n(i, j, k); + this.world.getClass(); + if (world.isLoaded(i, 128 / 2, j)) { + double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; + int k = MathHelper.floor(this.locY - (double) this.height + d0); - if (f1 < this.bF) { - f1 = this.bF; - } - - return f1; + return this.world.m(i, k, j); } else { - return this.bF; + return 0.0F; } } @@ -760,7 +767,7 @@ public abstract class Entity { this.lastZ = this.locZ = d2; this.lastYaw = this.yaw = f; this.lastPitch = this.pitch = f1; - this.br = 0.0F; + this.bH = 0.0F; double d3 = (double) (this.lastYaw - f); if (d3 < -180.0D) { @@ -776,15 +783,15 @@ public abstract class Entity { } public void setPositionRotation(double d0, double d1, double d2, float f, float f1) { - this.bo = this.lastX = this.locX = d0; - this.bp = this.lastY = this.locY = d1 + (double) this.height; - this.bq = this.lastZ = this.locZ = d2; + this.bE = this.lastX = this.locX = d0; + this.bF = this.lastY = this.locY = d1 + (double) this.height; + this.bG = this.lastZ = this.locZ = d2; this.yaw = f; this.pitch = f1; this.setPosition(this.locX, this.locY, this.locZ); } - public float f(Entity entity) { + public float g(Entity entity) { float f = (float) (this.locX - entity.locX); float f1 = (float) (this.locY - entity.locY); float f2 = (float) (this.locZ - entity.locZ); @@ -808,7 +815,7 @@ public abstract class Entity { return (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); } - public double g(Entity entity) { + public double h(Entity entity) { double d0 = this.locX - entity.locX; double d1 = this.locY - entity.locY; double d2 = this.locZ - entity.locZ; @@ -816,7 +823,7 @@ public abstract class Entity { return d0 * d0 + d1 * d1 + d2 * d2; } - public void b(EntityHuman entityhuman) {} + public void a_(EntityHuman entityhuman) {} public void collide(Entity entity) { if (entity.passenger != this && entity.vehicle != this) { @@ -838,8 +845,8 @@ public abstract class Entity { d1 *= d3; d0 *= 0.05000000074505806D; d1 *= 0.05000000074505806D; - d0 *= (double) (1.0F - this.bu); - d1 *= (double) (1.0F - this.bu); + d0 *= (double) (1.0F - this.bK); + d1 *= (double) (1.0F - this.bK); this.b(-d0, 0.0D, -d1); entity.b(d0, 0.0D, d1); } @@ -850,29 +857,30 @@ public abstract class Entity { this.motX += d0; this.motY += d1; this.motZ += d2; + this.ca = true; } - protected void af() { + protected void aq() { this.velocityChanged = true; } - public boolean damageEntity(Entity entity, int i) { - this.af(); + public boolean damageEntity(DamageSource damagesource, int i) { + this.aq(); return false; } - public boolean l_() { + public boolean r_() { return false; } - public boolean d_() { + public boolean g() { return false; } - public void c(Entity entity, int i) {} + public void b(Entity entity, int i) {} public boolean c(NBTTagCompound nbttagcompound) { - String s = this.ag(); + String s = this.ar(); if (!this.dead && s != null) { nbttagcompound.setString("id", s); @@ -884,7 +892,7 @@ public abstract class Entity { } public void d(NBTTagCompound nbttagcompound) { - nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY + (double) this.br, this.locZ})); + nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY + (double) this.bH, this.locZ})); nbttagcompound.a("Motion", (NBTBase) this.a(new double[] { this.motX, this.motY, this.motZ})); // CraftBukkit start - checking for NaN pitch/yaw and resetting to zero @@ -934,9 +942,9 @@ public abstract class Entity { } // CraftBukkit end */ - this.lastX = this.bo = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; - this.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; - this.lastZ = this.bq = this.locZ = ((NBTTagDouble) nbttaglist.a(2)).a; + this.lastX = this.bE = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; + this.lastY = this.bF = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; + this.lastZ = this.bG = 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.g("FallDistance"); @@ -997,7 +1005,7 @@ public abstract class Entity { // CraftBukkit end } - protected final String ag() { + protected final String ar() { return EntityTypes.b(this); } @@ -1049,11 +1057,11 @@ public abstract class Entity { return entityitem; } - public boolean T() { + public boolean ac() { return !this.dead; } - public boolean K() { + public boolean O() { for (int i = 0; i < 8; ++i) { float f = ((float) ((i >> 0) % 2) - 0.5F) * this.length * 0.9F; float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F; @@ -1070,24 +1078,24 @@ public abstract class Entity { return false; } - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { return false; } - public AxisAlignedBB a_(Entity entity) { + public AxisAlignedBB b(Entity entity) { return null; } - public void E() { + public void I() { if (this.vehicle.dead) { this.vehicle = null; } else { this.motX = 0.0D; this.motY = 0.0D; this.motZ = 0.0D; - this.m_(); + this.s_(); if (this.vehicle != null) { - this.vehicle.f(); + this.vehicle.g_(); 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) { @@ -1134,15 +1142,15 @@ public abstract class Entity { } } - public void f() { - this.passenger.setPosition(this.locX, this.locY + this.m() + this.passenger.I(), this.locZ); + public void g_() { + this.passenger.setPosition(this.locX, this.locY + this.n() + this.passenger.M(), this.locZ); } - public double I() { + public double M() { return (double) this.height; } - public double m() { + public double n() { return (double) this.width * 0.75D; } @@ -1206,25 +1214,37 @@ public abstract class Entity { } } - public Vec3D Z() { + public Vec3D ai() { return null; } - public void P() {} + public void T() {} public ItemStack[] getEquipment() { return null; } public boolean isSneaking() { - return this.d(1); + return this.e(1); } public void setSneak(boolean flag) { this.a(1, flag); } - protected boolean d(int i) { + public boolean at() { + return this.e(3); + } + + public void g(boolean flag) { + this.a(3, flag); + } + + public void h(boolean flag) { + this.a(4, flag); + } + + protected boolean e(int i) { return (this.datawatcher.a(0) & 1 << i) != 0; } @@ -1335,4 +1355,18 @@ public abstract class Entity { return false; } + + public void q() { + this.bv = true; + } + + public String Y() { + String s = EntityTypes.b(this); + + if (s == null) { + s = "generic"; + } + + return StatisticCollector.a("entity." + s + ".name"); + } } diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 3e31abd8d1..09a4b18139 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -13,17 +13,18 @@ import org.bukkit.event.player.PlayerPickupItemEvent; public class EntityArrow extends Entity { - private int d = -1; private int e = -1; private int f = -1; - private int g = 0; + private int g = -1; private int h = 0; + private int i = 0; private boolean inGround = false; public boolean fromPlayer = false; public int shake = 0; - public EntityLiving shooter; - private int j; - private int k = 0; + public Entity shooter; + private int k; + private int l = 0; + public boolean d = false; public EntityArrow(World world) { super(world); @@ -37,7 +38,7 @@ public class EntityArrow extends Entity { this.height = 0.0F; } - public EntityArrow(World world, EntityLiving entityliving) { + public EntityArrow(World world, EntityLiving entityliving, float f) { super(world); this.shooter = entityliving; this.fromPlayer = entityliving instanceof EntityHuman; @@ -51,7 +52,7 @@ public class EntityArrow extends Entity { this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F)); this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F)); this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F)); - this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); + this.a(this.motX, this.motY, this.motZ, f * 1.5F, 1.0F); } protected void b() {} @@ -75,11 +76,11 @@ public class EntityArrow extends Entity { 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.j = 0; + this.k = 0; } - public void m_() { - super.m_(); + public void s_() { + super.s_(); if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) { float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); @@ -87,11 +88,11 @@ public class EntityArrow extends Entity { this.lastPitch = this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D); } - int i = this.world.getTypeId(this.d, this.e, this.f); + int i = this.world.getTypeId(this.e, this.f, this.g); if (i > 0) { - Block.byId[i].a(this.world, this.d, this.e, this.f); - AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.d, this.e, this.f); + Block.byId[i].a((IBlockAccess) this.world, this.e, this.f, this.g); + AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.e, this.f, this.g); if (axisalignedbb != null && axisalignedbb.a(Vec3D.create(this.locX, this.locY, this.locZ))) { this.inGround = true; @@ -103,12 +104,12 @@ public class EntityArrow extends Entity { } if (this.inGround) { - i = this.world.getTypeId(this.d, this.e, this.f); - int j = this.world.getData(this.d, this.e, this.f); + i = this.world.getTypeId(this.e, this.f, this.g); + int j = this.world.getData(this.e, this.f, this.g); - if (i == this.g && j == this.h) { - ++this.j; - if (this.j == 1200) { + if (i == this.h && j == this.i) { + ++this.k; + if (this.k == 1200) { this.die(); } } else { @@ -116,11 +117,11 @@ public class EntityArrow extends Entity { 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.j = 0; this.k = 0; + this.l = 0; } } else { - ++this.k; + ++this.l; Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ); Vec3D vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true); @@ -135,18 +136,19 @@ public class EntityArrow extends Entity { 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; + int k; float f1; - for (int k = 0; k < list.size(); ++k) { + for (k = 0; k < list.size(); ++k) { Entity entity1 = (Entity) list.get(k); - if (entity1.l_() && (entity1 != this.shooter || this.k >= 5)) { + if (entity1.r_() && (entity1 != this.shooter || this.l >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.boundingBox.b((double) f1, (double) f1, (double) f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); if (movingobjectposition1 != null) { - double d1 = vec3d.a(movingobjectposition1.f); + double d1 = vec3d.b(movingobjectposition1.f); if (d1 < d0 || d0 == 0.0D) { entity = entity1; @@ -168,6 +170,13 @@ public class EntityArrow extends Entity { this.world.getServer().getPluginManager().callEvent(phe); // CraftBukkit end if (movingobjectposition.entity != null) { + f2 = MathHelper.a(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); + int l = (int) Math.ceil((double) f2 * 2.0D); + + if (this.d) { + l = l * 3 / 2 + 1; + } + // CraftBukkit start boolean stick; if (entity instanceof EntityLiving) { @@ -187,10 +196,10 @@ public class EntityArrow extends Entity { stick = !projectile.doesBounce(); } else { // this function returns if the arrow should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this, event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(this.shooter, 4); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this.shooter), 4); } if (stick) { // CraftBukkit end @@ -202,14 +211,14 @@ public class EntityArrow extends Entity { this.motZ *= -0.10000000149011612D; this.yaw += 180.0F; this.lastYaw += 180.0F; - this.k = 0; + this.l = 0; } } else { - this.d = movingobjectposition.b; - this.e = movingobjectposition.c; - this.f = movingobjectposition.d; - this.g = this.world.getTypeId(this.d, this.e, this.f); - this.h = this.world.getData(this.d, this.e, this.f); + this.e = movingobjectposition.b; + this.f = movingobjectposition.c; + this.g = movingobjectposition.d; + this.h = this.world.getTypeId(this.e, this.f, this.g); + this.i = this.world.getData(this.e, this.f, this.g); 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)); @@ -220,6 +229,13 @@ public class EntityArrow extends Entity { this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.shake = 7; + this.d = false; + } + } + + if (this.d) { + for (k = 0; k < 4; ++k) { + this.world.a("crit", this.locX + this.motX * (double) k / 4.0D, this.locY + this.motY * (double) k / 4.0D, this.locZ + this.motZ * (double) k / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ); } } @@ -249,9 +265,9 @@ public class EntityArrow extends Entity { this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; float f3 = 0.99F; - f1 = 0.03F; - if (this.ad()) { - for (int l = 0; l < 4; ++l) { + f1 = 0.05F; + if (this.ao()) { + for (int i1 = 0; i1 < 4; ++i1) { 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); @@ -269,28 +285,28 @@ public class EntityArrow extends Entity { } public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("xTile", (short) this.d); - nbttagcompound.a("yTile", (short) this.e); - nbttagcompound.a("zTile", (short) this.f); - nbttagcompound.a("inTile", (byte) this.g); - nbttagcompound.a("inData", (byte) this.h); + nbttagcompound.a("xTile", (short) this.e); + nbttagcompound.a("yTile", (short) this.f); + nbttagcompound.a("zTile", (short) this.g); + nbttagcompound.a("inTile", (byte) this.h); + nbttagcompound.a("inData", (byte) this.i); nbttagcompound.a("shake", (byte) this.shake); nbttagcompound.a("inGround", (byte) (this.inGround ? 1 : 0)); nbttagcompound.a("player", this.fromPlayer); } public void a(NBTTagCompound nbttagcompound) { - this.d = nbttagcompound.d("xTile"); - this.e = nbttagcompound.d("yTile"); - this.f = nbttagcompound.d("zTile"); - this.g = nbttagcompound.c("inTile") & 255; - this.h = nbttagcompound.c("inData") & 255; + this.e = nbttagcompound.d("xTile"); + this.f = nbttagcompound.d("yTile"); + this.g = nbttagcompound.d("zTile"); + this.h = nbttagcompound.c("inTile") & 255; + this.i = nbttagcompound.c("inData") & 255; this.shake = nbttagcompound.c("shake") & 255; this.inGround = nbttagcompound.c("inGround") == 1; this.fromPlayer = nbttagcompound.m("player"); } - public void b(EntityHuman entityhuman) { + public void a_(EntityHuman entityhuman) { if (!this.world.isStatic) { // CraftBukkit start ItemStack itemstack = new ItemStack(Item.ARROW, 1); diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index c090d6e67d..7773ad7e6b 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -49,26 +49,26 @@ public class EntityBoat extends Entity { this.damage = 0; this.b = 0; this.c = 1; - this.aI = true; + this.aY = true; this.b(1.5F, 0.6F); this.height = this.width / 2.0F; } - protected boolean n() { + protected boolean e_() { return false; } protected void b() {} - public AxisAlignedBB a_(Entity entity) { + public AxisAlignedBB b(Entity entity) { return entity.boundingBox; } - public AxisAlignedBB e_() { + public AxisAlignedBB f() { return this.boundingBox; } - public boolean d_() { + public boolean g() { return true; } @@ -85,15 +85,15 @@ public class EntityBoat extends Entity { this.world.getServer().getPluginManager().callEvent(new VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit } - public double m() { + public double n() { return (double) this.width * 0.0D - 0.30000001192092896D; } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { if (!this.world.isStatic && !this.dead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity attacker = (entity == null) ? null : entity.getBukkitEntity(); + org.bukkit.entity.Entity attacker = (damagesource.a() == null) ? null : damagesource.a().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, i); this.world.getServer().getPluginManager().callEvent(event); @@ -107,7 +107,7 @@ public class EntityBoat extends Entity { this.c = -this.c; this.b = 10; this.damage += i * 10; - this.af(); + this.aq(); if (this.damage > 40) { // CraftBukkit start @@ -143,11 +143,11 @@ public class EntityBoat extends Entity { } } - public boolean l_() { + public boolean r_() { return !this.dead; } - public void m_() { + public void s_() { // CraftBukkit start double prevX = this.locX; double prevY = this.locY; @@ -156,7 +156,7 @@ public class EntityBoat extends Entity { float prevPitch = this.pitch; // CraftBukkit end - super.m_(); + super.s_(); if (this.b > 0) { --this.b; } @@ -358,7 +358,7 @@ public class EntityBoat extends Entity { for (l = 0; l < list.size(); ++l) { Entity entity = (Entity) list.get(l); - if (entity != this.passenger && entity.d_() && entity instanceof EntityBoat) { + if (entity != this.passenger && entity.g() && entity instanceof EntityBoat) { entity.collide(this); } } @@ -381,12 +381,12 @@ public class EntityBoat extends Entity { } } - public void f() { + public void g_() { if (this.passenger != null) { double d0 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; double d1 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D) * 0.4D; - this.passenger.setPosition(this.locX + d0, this.locY + this.m() + this.passenger.I(), this.locZ + d1); + this.passenger.setPosition(this.locX + d0, this.locY + this.n() + this.passenger.M(), this.locZ + d1); } } @@ -394,7 +394,7 @@ public class EntityBoat extends Entity { protected void a(NBTTagCompound nbttagcompound) {} - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) { return true; } else { diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index 3694ab7b6b..772c8fb16f 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -23,27 +23,47 @@ public class EntityCow extends EntityAnimal { super.a(nbttagcompound); } - protected String g() { - return "mob.cow"; - } - protected String h() { - return "mob.cowhurt"; + return "mob.cow"; } protected String i() { return "mob.cowhurt"; } - protected float k() { + protected String j() { + return "mob.cowhurt"; + } + + protected float l() { return 0.4F; } - protected int j() { + protected int k() { return Item.LEATHER.id; } - public boolean a(EntityHuman entityhuman) { + protected void a(boolean flag) { + int i = this.random.nextInt(3); + + int j; + + for (j = 0; j < i; ++j) { + this.b(Item.LEATHER.id, 1); + } + + i = this.random.nextInt(3) + 1; + + for (j = 0; j < i; ++j) { + if (this.fireTicks > 0) { + this.b(Item.COOKED_BEEF.id, 1); + } else { + this.b(Item.RAW_BEEF.id, 1); + } + } + } + + public boolean b(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (itemstack != null && itemstack.id == Item.BUCKET.id) { diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index 58f98396fe..605a852d43 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -6,22 +6,27 @@ import org.bukkit.craftbukkit.TrigMath; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end -public class EntityCreature extends EntityLiving { +public abstract class EntityCreature extends EntityLiving { public PathEntity pathEntity; // CraftBukkit - public public Entity target; // CraftBukkit - public protected boolean e = false; + protected int f = 0; public EntityCreature(World world) { super(world); } - protected boolean w() { + protected boolean v() { return false; } protected void c_() { - this.e = this.w(); + if (this.f > 0) { + --this.f; + } + + this.e = this.v(); float f = 16.0F; if (this.target == null) { @@ -44,7 +49,7 @@ public class EntityCreature extends EntityLiving { if (this.target != null) { this.pathEntity = this.world.findPath(this, this.target, f); } - } else if (!this.target.T()) { + } else if (!this.target.ac()) { // CraftBukkit start EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED); this.world.getServer().getPluginManager().callEvent(event); @@ -58,9 +63,9 @@ public class EntityCreature extends EntityLiving { } // CraftBukkit end } else { - float f1 = this.target.f(this); + float f1 = this.target.g(this); - if (this.e(this.target)) { + if (this.f(this.target)) { this.a(this.target, f1); } else { this.b(this.target, f1); @@ -69,13 +74,13 @@ public class EntityCreature extends EntityLiving { if (!this.e && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) { this.pathEntity = this.world.findPath(this, this.target, f); - } else if (!this.e && (this.pathEntity == null && this.random.nextInt(80) == 0 || this.random.nextInt(80) == 0)) { - this.B(); + } else if (!this.e && (this.pathEntity == null && this.random.nextInt(80) == 0 || this.f > 0 || this.random.nextInt(80) == 0)) { + this.A(); } int i = MathHelper.floor(this.boundingBox.b + 0.5D); - boolean flag = this.ad(); - boolean flag1 = this.ae(); + boolean flag = this.ao(); + boolean flag1 = this.ap(); this.pitch = 0.0F; if (this.pathEntity != null && this.random.nextInt(100) != 0) { @@ -92,7 +97,7 @@ public class EntityCreature extends EntityLiving { } } - this.aC = false; + this.aS = false; if (vec3d != null) { double d1 = vec3d.a - this.locX; double d2 = vec3d.c - this.locZ; @@ -101,7 +106,7 @@ public class EntityCreature extends EntityLiving { float f2 = (float) (TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; float f3 = f2 - this.yaw; - for (this.aA = this.aE; f3 < -180.0F; f3 += 360.0F) { + for (this.aQ = this.aU; f3 < -180.0F; f3 += 360.0F) { ; } @@ -125,12 +130,12 @@ public class EntityCreature extends EntityLiving { this.yaw = (float) (Math.atan2(d5, d4) * 180.0D / 3.1415927410125732D) - 90.0F; f3 = (f4 - this.yaw + 90.0F) * 3.1415927F / 180.0F; - this.az = -MathHelper.sin(f3) * this.aA * 1.0F; - this.aA = MathHelper.cos(f3) * this.aA * 1.0F; + this.aP = -MathHelper.sin(f3) * this.aQ * 1.0F; + this.aQ = MathHelper.cos(f3) * this.aQ * 1.0F; } if (d3 > 0.0D) { - this.aC = true; + this.aS = true; } } @@ -138,12 +143,12 @@ public class EntityCreature extends EntityLiving { this.a(this.target, 30.0F, 30.0F); } - if (this.positionChanged && !this.C()) { - this.aC = true; + if (this.positionChanged && !this.B()) { + this.aS = true; } if (this.random.nextFloat() < 0.8F && (flag || flag1)) { - this.aC = true; + this.aS = true; } } else { super.c_(); @@ -151,7 +156,7 @@ public class EntityCreature extends EntityLiving { } } - protected void B() { + protected void A() { boolean flag = false; int i = -1; int j = -1; @@ -198,7 +203,7 @@ public class EntityCreature extends EntityLiving { return super.d() && this.a(i, j, k) >= 0.0F; } - public boolean C() { + public boolean B() { return this.pathEntity != null; } @@ -206,11 +211,21 @@ public class EntityCreature extends EntityLiving { this.pathEntity = pathentity; } - public Entity F() { + public Entity C() { return this.target; } public void setTarget(Entity entity) { this.target = entity; } + + protected float D() { + float f = super.D(); + + if (this.f > 0) { + f *= 2.0F; + } + + return f; + } } diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 31743fe16e..b31231a0a3 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -37,7 +37,7 @@ public class EntityCreeper extends EntityMonster { protected void b(Entity entity, float f) { if (!this.world.isStatic) { if (this.fuseTicks > 0) { - this.e(-1); + this.b(-1); --this.fuseTicks; if (this.fuseTicks < 0) { this.fuseTicks = 0; @@ -46,10 +46,10 @@ public class EntityCreeper extends EntityMonster { } } - public void m_() { + public void s_() { this.b = this.fuseTicks; if (this.world.isStatic) { - int i = this.x(); + int i = this.w(); if (i > 0 && this.fuseTicks == 0) { this.world.makeSound(this, "random.fuse", 1.0F, 0.5F); @@ -65,9 +65,9 @@ public class EntityCreeper extends EntityMonster { } } - super.m_(); + super.s_(); if (this.target == null && this.fuseTicks > 0) { - this.e(-1); + this.b(-1); --this.fuseTicks; if (this.fuseTicks < 0) { this.fuseTicks = 0; @@ -75,27 +75,27 @@ public class EntityCreeper extends EntityMonster { } } - protected String h() { + protected String i() { return "mob.creeper"; } - protected String i() { + protected String j() { return "mob.creeperdeath"; } - public void die(Entity entity) { - super.die(entity); - if (entity instanceof EntitySkeleton) { + public void die(DamageSource damagesource) { + super.die(damagesource); + if (damagesource.a() instanceof EntitySkeleton) { this.b(Item.GOLD_RECORD.id + this.random.nextInt(2), 1); } } protected void a(Entity entity, float f) { if (!this.world.isStatic) { - int i = this.x(); + int i = this.w(); if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) { - this.e(-1); + this.b(-1); --this.fuseTicks; if (this.fuseTicks < 0) { this.fuseTicks = 0; @@ -105,7 +105,7 @@ public class EntityCreeper extends EntityMonster { this.world.makeSound(this, "random.fuse", 1.0F, 0.5F); } - this.e(1); + this.b(1); ++this.fuseTicks; if (this.fuseTicks >= 30) { // CraftBukkit start @@ -132,15 +132,15 @@ public class EntityCreeper extends EntityMonster { return this.datawatcher.a(17) == 1; } - protected int j() { + protected int k() { return Item.SULPHUR.id; } - private int x() { + private int w() { return this.datawatcher.a(16); } - private void e(int i) { + private void b(int i) { this.datawatcher.watch(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 50441dbb94..4a0dbf1b23 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -79,11 +79,11 @@ public class EntityEgg extends Entity { this.h = 0; } - public void m_() { - this.bo = this.locX; - this.bp = this.locY; - this.bq = this.locZ; - super.m_(); + public void s_() { + this.bE = this.locX; + this.bF = this.locY; + this.bG = this.locZ; + super.s_(); if (this.a > 0) { --this.a; } @@ -128,13 +128,13 @@ public class EntityEgg extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.l_() && (entity1 != this.thrower || this.i >= 5)) { + if (entity1.r_() && (entity1 != this.thrower || this.i >= 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) { - double d1 = vec3d.a(movingobjectposition1.f); + double d1 = vec3d.b(movingobjectposition1.f); if (d1 < d0 || d0 == 0.0D) { entity = entity1; @@ -168,10 +168,10 @@ public class EntityEgg extends Entity { stick = !projectile.doesBounce(); } else { // this function returns if the egg should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this, event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(this.thrower, 0); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this.thrower), 0); } if (stick) { @@ -244,9 +244,6 @@ public class EntityEgg extends Entity { case WOLF: entity = new EntityWolf(this.world); break; - case MONSTER: - entity = new EntityMonster(this.world); - break; default: entity = new EntityChicken(this.world); break; @@ -297,7 +294,7 @@ public class EntityEgg extends Entity { float f2 = 0.99F; float f3 = 0.03F; - if (this.ad()) { + if (this.ao()) { for (int i1 = 0; i1 < 4; ++i1) { float f4 = 0.25F; @@ -332,7 +329,7 @@ public class EntityEgg extends Entity { this.f = nbttagcompound.c("inGround") == 1; } - public void b(EntityHuman entityhuman) { + public void a_(EntityHuman entityhuman) { if (this.f && this.thrower == entityhuman && this.a <= 0 && entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) { this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, 1); diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 7b7335b839..e65d2c3370 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -61,8 +61,8 @@ public class EntityFireball extends Entity { this.e = d2 / d3 * 0.1D; } - public void m_() { - super.m_(); + public void s_() { + super.s_(); this.fireTicks = 10; if (this.a > 0) { --this.a; @@ -107,13 +107,13 @@ public class EntityFireball extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.l_() && (entity1 != this.shooter || this.l >= 25)) { + if (entity1.r_() && (entity1 != this.shooter || this.l >= 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) { - double d1 = vec3d.a(movingobjectposition1.f); + double d1 = vec3d.b(movingobjectposition1.f); if (d1 < d0 || d0 == 0.0D) { entity = entity1; @@ -150,10 +150,10 @@ public class EntityFireball extends Entity { stick = !projectile.doesBounce(); } else { // this function returns if the fireball should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this, event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(this.shooter, 0); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this.shooter), 0); } if (stick) { ; @@ -200,7 +200,7 @@ public class EntityFireball extends Entity { this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; float f2 = 0.95F; - if (this.ad()) { + if (this.ao()) { for (int k = 0; k < 4; ++k) { float f3 = 0.25F; @@ -238,14 +238,14 @@ public class EntityFireball extends Entity { this.j = nbttagcompound.c("inGround") == 1; } - public boolean l_() { + public boolean r_() { return true; } - public boolean damageEntity(Entity entity, int i) { - this.af(); - if (entity != null) { - Vec3D vec3d = entity.Z(); + public boolean damageEntity(DamageSource damagesource, int i) { + this.aq(); + if (damagesource.a() != null) { + Vec3D vec3d = damagesource.a().ai(); if (vec3d != null) { this.motX = vec3d.a; diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java index ff63566d86..65b7d2be69 100644 --- a/src/main/java/net/minecraft/server/EntityFish.java +++ b/src/main/java/net/minecraft/server/EntityFish.java @@ -32,12 +32,12 @@ public class EntityFish extends Entity { public EntityFish(World world) { super(world); this.b(0.25F, 0.25F); - this.bK = true; + this.bZ = true; } public EntityFish(World world, EntityHuman entityhuman) { super(world); - this.bK = true; + this.bZ = true; this.owner = entityhuman; this.owner.hookedFish = this; this.b(0.25F, 0.25F); @@ -79,8 +79,8 @@ public class EntityFish extends Entity { this.i = 0; } - public void m_() { - super.m_(); + public void s_() { + super.s_(); if (this.l > 0) { double d0 = this.locX + (this.m - this.locX) / (double) this.l; double d1 = this.locY + (this.n - this.locY) / (double) this.l; @@ -103,9 +103,9 @@ public class EntityFish extends Entity { this.c(this.yaw, this.pitch); } else { if (!this.world.isStatic) { - ItemStack itemstack = this.owner.G(); + ItemStack itemstack = this.owner.K(); - if (this.owner.dead || !this.owner.T() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.g(this.owner) > 1024.0D) { + if (this.owner.dead || !this.owner.ac() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.h(this.owner) > 1024.0D) { this.die(); this.owner.hookedFish = null; return; @@ -168,13 +168,13 @@ public class EntityFish extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.l_() && (entity1 != this.owner || this.j >= 5)) { + if (entity1.r_() && (entity1 != this.owner || this.j >= 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); + d5 = vec3d.b(movingobjectposition1.f); if (d5 < d4 || d4 == 0.0D) { entity = entity1; d4 = d5; @@ -204,10 +204,10 @@ public class EntityFish extends Entity { stick = !projectile.doesBounce(); } else { // this function returns if the fish should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this, event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.a((Entity) this, this), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(this.owner, 0); + stick = movingobjectposition.entity.damageEntity(DamageSource.a((Entity) this, this.owner), 0); } if (!stick) { // CraftBukkit end @@ -333,7 +333,7 @@ public class EntityFish extends Entity { this.h = nbttagcompound.c("inGround") == 1; } - public int h() { + public int i() { byte b0 = 0; if (this.c != null) { diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index cd428f4556..62d8baf31c 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -21,6 +21,7 @@ public class EntityGhast extends EntityFlying implements IMonster { this.texture = "/mob/ghast.png"; this.b(4.0F, 4.0F); this.fireProof = true; + this.ax = 5; } protected void b() { @@ -28,8 +29,8 @@ public class EntityGhast extends EntityFlying implements IMonster { this.datawatcher.a(16, Byte.valueOf((byte) 0)); } - public void m_() { - super.m_(); + public void s_() { + super.s_(); byte b0 = this.datawatcher.a(16); this.texture = b0 == 1 ? "/mob/ghast_fire.png" : "/mob/ghast.png"; @@ -40,7 +41,7 @@ public class EntityGhast extends EntityFlying implements IMonster { this.die(); } - this.U(); + this.ad(); this.e = this.f; double d0 = this.b - this.locX; double d1 = this.c - this.locY; @@ -104,23 +105,23 @@ public class EntityGhast extends EntityFlying implements IMonster { double d4 = 64.0D; - if (this.target != null && this.target.g(this) < d4 * d4) { + if (this.target != null && this.target.h(this) < d4 * d4) { double d5 = this.target.locX - this.locX; double d6 = this.target.boundingBox.b + (double) (this.target.width / 2.0F) - (this.locY + (double) (this.width / 2.0F)); double d7 = this.target.locZ - this.locZ; - this.K = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; - if (this.e(this.target)) { + this.U = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; + if (this.f(this.target)) { if (this.f == 10) { - this.world.makeSound(this, "mob.ghast.charge", this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, "mob.ghast.charge", this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } ++this.f; if (this.f == 20) { - this.world.makeSound(this, "mob.ghast.fireball", this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, "mob.ghast.fireball", this.l(), (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.b(1.0F); + Vec3D vec3d = this.c(1.0F); entityfireball.locX = this.locX + vec3d.a * d8; entityfireball.locY = this.locY + (double) (this.width / 2.0F) + 0.5D; @@ -132,7 +133,7 @@ public class EntityGhast extends EntityFlying implements IMonster { --this.f; } } else { - this.K = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; + this.U = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; if (this.f > 0) { --this.f; } @@ -164,23 +165,23 @@ public class EntityGhast extends EntityFlying implements IMonster { return true; } - protected String g() { + protected String h() { return "mob.ghast.moan"; } - protected String h() { + protected String i() { return "mob.ghast.scream"; } - protected String i() { + protected String j() { return "mob.ghast.death"; } - protected int j() { + protected int k() { return Item.SULPHUR.id; } - protected float k() { + protected float l() { return 10.0F; } @@ -188,7 +189,7 @@ public class EntityGhast extends EntityFlying implements IMonster { return this.random.nextInt(20) == 0 && super.d() && this.world.spawnMonsters > 0; } - public int l() { + public int m() { return 1; } } diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index a57fbf7714..a5a7fec3e2 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -22,35 +22,46 @@ public abstract class EntityHuman extends EntityLiving { public InventoryPlayer inventory = new InventoryPlayer(this); public Container defaultContainer; public Container activeContainer; - public byte l = 0; - public int m = 0; - public float n; - public float o; - public boolean p = false; - public int q = 0; + protected FoodMetaData m = new FoodMetaData(); + protected int n = 0; + public byte o = 0; + public int p = 0; + public float q; + public float r; + public boolean s = false; + public int t = 0; public String name; public int dimension; - public double t; - public double u; - public double v; - public double w; + public int w = 0; public double x; public double y; + public double z; + public double A; + public double B; + public double C; // CraftBukkit start public boolean sleeping; public boolean fauxSleeping; public String spawnWorld = ""; + public int sleepTicks; // CraftBukkit end - public ChunkCoordinates A; - public int sleepTicks; // CraftBukkit - private -> public - public float B; - public float C; + public ChunkCoordinates E; + public float F; + public float G; private ChunkCoordinates b; private ChunkCoordinates c; - public int D = 20; - protected boolean E = false; - public float F; - private int d = 0; + public int H = 20; + protected boolean I = false; + public float J; + public PlayerAbilities K = new PlayerAbilities(); + public int exp; + public int expLevel; + public int expTotal; + private ItemStack d; + private int e; + protected float O = 0.1F; + protected float P = 0.02F; + private int f = 0; public EntityFish hookedFish = null; public EntityHuman(World world) { @@ -62,8 +73,8 @@ public abstract class EntityHuman extends EntityLiving { this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F); this.health = 20; - this.U = "humanoid"; - this.T = 180.0F; + this.ae = "humanoid"; + this.ad = 180.0F; this.maxFireTicks = 20; this.texture = "/mob/char.png"; } @@ -71,9 +82,54 @@ public abstract class EntityHuman extends EntityLiving { protected void b() { super.b(); this.datawatcher.a(16, Byte.valueOf((byte) 0)); + this.datawatcher.a(17, Byte.valueOf((byte) 0)); } - public void m_() { + public boolean o_() { + return this.d != null; + } + + public void E() { + if (this.d != null) { + this.d.a(this.world, this, this.e); + } + + this.F(); + } + + public void F() { + this.d = null; + this.e = 0; + if (!this.world.isStatic) { + this.h(false); + } + } + + public boolean G() { + return this.o_() && Item.byId[this.d.id].b(this.d) == EnumAnimation.c; + } + + public void s_() { + if (this.d != null) { + ItemStack itemstack = this.inventory.getItemInHand(); + + if (itemstack != this.d) { + this.F(); + } else { + if (this.e <= 25 && this.e % 4 == 0) { + this.b(itemstack, 5); + } + + if (--this.e == 0 && !this.world.isStatic) { + this.C(); + } + } + } + + if (this.w > 0) { + --this.w; + } + if (this.isSleeping()) { ++this.sleepTicks; if (this.sleepTicks > 100) { @@ -81,7 +137,7 @@ public abstract class EntityHuman extends EntityLiving { } if (!this.world.isStatic) { - if (!this.o()) { + if (!this.w()) { this.a(true, true, false); } else if (this.world.d()) { this.a(false, true, true); @@ -94,95 +150,162 @@ public abstract class EntityHuman extends EntityLiving { } } - super.m_(); + super.s_(); if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.b(this)) { - this.y(); + this.x(); this.activeContainer = this.defaultContainer; } - this.t = this.w; - this.u = this.x; - this.v = this.y; - double d0 = this.locX - this.w; - double d1 = this.locY - this.x; - double d2 = this.locZ - this.y; + if (this.K.b) { + for (int i = 0; i < 8; ++i) { + ; + } + } + + if (this.fireTicks > 0 && this.K.a) { + this.fireTicks = 0; + } + + this.x = this.A; + this.y = this.B; + this.z = this.C; + double d0 = this.locX - this.A; + double d1 = this.locY - this.B; + double d2 = this.locZ - this.C; double d3 = 10.0D; if (d0 > d3) { - this.t = this.w = this.locX; + this.x = this.A = this.locX; } if (d2 > d3) { - this.v = this.y = this.locZ; + this.z = this.C = this.locZ; } if (d1 > d3) { - this.u = this.x = this.locY; + this.y = this.B = this.locY; } if (d0 < -d3) { - this.t = this.w = this.locX; + this.x = this.A = this.locX; } if (d2 < -d3) { - this.v = this.y = this.locZ; + this.z = this.C = this.locZ; } if (d1 < -d3) { - this.u = this.x = this.locY; + this.y = this.B = this.locY; } - this.w += d0 * 0.25D; - this.y += d2 * 0.25D; - this.x += d1 * 0.25D; + this.A += d0 * 0.25D; + this.C += d2 * 0.25D; + this.B += d1 * 0.25D; this.a(StatisticList.k, 1); if (this.vehicle == null) { this.c = null; } + + if (!this.world.isStatic) { + this.m.a(this); + } } - protected boolean D() { + protected void b(ItemStack itemstack, int i) { + if (itemstack.m() == EnumAnimation.b) { + for (int j = 0; j < i; ++j) { + Vec3D vec3d = Vec3D.create(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + + vec3d.a(-this.pitch * 3.1415927F / 180.0F); + vec3d.b(-this.yaw * 3.1415927F / 180.0F); + Vec3D vec3d1 = Vec3D.create(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D); + + vec3d1.a(-this.pitch * 3.1415927F / 180.0F); + vec3d1.b(-this.yaw * 3.1415927F / 180.0F); + vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.t(), this.locZ); + this.world.a("iconcrack_" + itemstack.getItem().id, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); + } + + this.world.makeSound(this, "mob.eat", 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + } + } + + protected void C() { + if (this.d != null) { + this.b(this.d, 16); + int i = this.d.count; + ItemStack itemstack = this.d.b(this.world, this); + + if (itemstack != this.d || itemstack != null && itemstack.count != i) { + this.inventory.items[this.inventory.itemInHandIndex] = itemstack; + if (itemstack.count == 0) { + this.inventory.items[this.inventory.itemInHandIndex] = null; + } + } + + this.F(); + } + } + + protected boolean H() { return this.health <= 0 || this.isSleeping(); } - protected void y() { + protected void x() { this.activeContainer = this.defaultContainer; } - public void E() { + public void I() { double d0 = this.locX; double d1 = this.locY; double d2 = this.locZ; - super.E(); - this.n = this.o; - this.o = 0.0F; - this.i(this.locX - d0, this.locY - d1, this.locZ - d2); + super.I(); + this.q = this.r; + this.r = 0.0F; + this.h(this.locX - d0, this.locY - d1, this.locZ - d2); + } + + private int o() { + return this.a(MobEffectList.e) ? 6 - (1 + this.b(MobEffectList.e).c()) * 1 : (this.a(MobEffectList.f) ? 6 + (1 + this.b(MobEffectList.f).c()) * 2 : 6); } protected void c_() { - if (this.p) { - ++this.q; - if (this.q >= 8) { - this.q = 0; - this.p = false; + int i = this.o(); + + if (this.s) { + ++this.t; + if (this.t >= i) { + this.t = 0; + this.s = false; } } else { - this.q = 0; + this.t = 0; } - this.aa = (float) this.q / 8.0F; + this.am = (float) this.t / (float) i; } - public void v() { - // CraftBukkit - spawnMonsters -> allowMonsters - if (!this.world.allowMonsters && this.health < 20 && this.ticksLived % 20 * 12 == 0) { - this.b(1, RegainReason.REGEN); + public void s() { + if (this.n > 0) { + --this.n; + } + + // CraftBukkit - spawnMonsters -> allowMonsters + if (!this.world.allowMonsters && this.health < 20 && this.ticksLived % 20 * 12 == 0) { + this.c(1, RegainReason.REGEN); + } + + this.inventory.h(); + this.q = this.r; + super.s(); + this.aj = this.O; + this.ak = this.P; + if (this.at()) { + this.aj = (float) ((double) this.aj + (double) this.O * 0.3D); + this.ak = (float) ((double) this.ak + (double) this.P * 0.3D); } - this.inventory.f(); - this.n = this.o; - super.v(); float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); // CraftBukkit - Math -> TrigMath float f1 = (float) TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F; @@ -199,8 +322,8 @@ public abstract class EntityHuman extends EntityLiving { f1 = 0.0F; } - this.o += (f - this.o) * 0.4F; - this.aj += (f1 - this.aj) * 0.8F; + this.r += (f - this.r) * 0.4F; + this.av += (f1 - this.av) * 0.8F; if (this.health > 0) { List list = this.world.b((Entity) this, this.boundingBox.b(1.0D, 0.0D, 1.0D)); @@ -209,19 +332,19 @@ public abstract class EntityHuman extends EntityLiving { Entity entity = (Entity) list.get(i); if (!entity.dead) { - this.i(entity); + this.j(entity); } } } } } - private void i(Entity entity) { - entity.b(this); + private void j(Entity entity) { + entity.a_(this); } - public void die(Entity entity) { - super.die(entity); + public void die(DamageSource damagesource) { + super.die(damagesource); this.b(0.2F, 0.2F); this.setPosition(this.locX, this.locY, this.locZ); this.motY = 0.10000000149011612D; @@ -229,10 +352,10 @@ public abstract class EntityHuman extends EntityLiving { this.a(new ItemStack(Item.APPLE, 1), true); } - this.inventory.h(); - if (entity != null) { - this.motX = (double) (-MathHelper.cos((this.af + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - this.motZ = (double) (-MathHelper.sin((this.af + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.inventory.j(); + if (damagesource != null) { + this.motX = (double) (-MathHelper.cos((this.ar + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motZ = (double) (-MathHelper.sin((this.ar + this.yaw) * 3.1415927F / 180.0F) * 0.1F); } else { this.motX = this.motZ = 0.0D; } @@ -241,8 +364,8 @@ public abstract class EntityHuman extends EntityLiving { this.a(StatisticList.y, 1); } - public void c(Entity entity, int i) { - this.m += i; + public void b(Entity entity, int i) { + this.p += i; if (entity instanceof EntityHuman) { this.a(StatisticList.A, 1); } else { @@ -250,7 +373,7 @@ public abstract class EntityHuman extends EntityLiving { } } - public void F() { + public void J() { this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, 1), false); } @@ -319,6 +442,14 @@ public abstract class EntityHuman extends EntityLiving { f /= 5.0F; } + if (this.a(MobEffectList.e)) { + f *= 1.0F + (float) (this.b(MobEffectList.e).c() + 1) * 0.2F; + } + + if (this.a(MobEffectList.f)) { + f *= 1.0F - (float) (this.b(MobEffectList.f).c() + 1) * 0.2F; + } + return f; } @@ -334,8 +465,11 @@ public abstract class EntityHuman extends EntityLiving { this.dimension = nbttagcompound.e("Dimension"); this.sleeping = nbttagcompound.m("Sleeping"); this.sleepTicks = nbttagcompound.d("SleepTimer"); + this.exp = nbttagcompound.e("Xp"); + this.expLevel = nbttagcompound.e("XpLevel"); + this.expTotal = nbttagcompound.e("XpTotal"); if (this.sleeping) { - this.A = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + this.E = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); this.a(true, true, false); } @@ -349,6 +483,8 @@ public abstract class EntityHuman extends EntityLiving { if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { this.b = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ")); } + + this.m.a(nbttagcompound); } public void b(NBTTagCompound nbttagcompound) { @@ -357,12 +493,16 @@ public abstract class EntityHuman extends EntityLiving { nbttagcompound.a("Dimension", this.dimension); nbttagcompound.a("Sleeping", this.sleeping); nbttagcompound.a("SleepTimer", (short) this.sleepTicks); + nbttagcompound.a("Xp", this.exp); + nbttagcompound.a("XpLevel", this.expLevel); + nbttagcompound.a("XpTotal", this.expTotal); if (this.b != null) { nbttagcompound.a("SpawnX", this.b.x); nbttagcompound.a("SpawnY", this.b.y); nbttagcompound.a("SpawnZ", this.b.z); - nbttagcompound.setString("SpawnWorld", this.spawnWorld); // CraftBukkit } + + this.m.b(nbttagcompound); } public void a(IInventory iinventory) {} @@ -375,72 +515,78 @@ public abstract class EntityHuman extends EntityLiving { return 0.12F; } - protected void s() { + protected void m_() { this.height = 1.62F; } - public boolean damageEntity(Entity entity, int i) { - this.ay = 0; - if (this.health <= 0) { + public boolean damageEntity(DamageSource damagesource, int i) { + if (this.K.a && !damagesource.d()) { return false; } else { - if (this.isSleeping() && !this.world.isStatic) { - this.a(true, true, false); - } - - if (entity instanceof EntityMonster || entity instanceof EntityArrow) { - if (this.world.spawnMonsters == 0) { - i = 0; - } - - if (this.world.spawnMonsters == 1) { - i = i / 3 + 1; - } - - if (this.world.spawnMonsters == 3) { - i = i * 3 / 2; - } - } - - if (i == 0) { + this.aO = 0; + if (this.health <= 0) { return false; } else { - Object object = entity; - - if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { - object = ((EntityArrow) entity).shooter; + if (this.isSleeping() && !this.world.isStatic) { + this.a(true, true, false); } - if (object instanceof EntityLiving) { - // CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters - // also damage the player in this way. For example, EntitySlime. + Entity entity = damagesource.a(); - // We handle projectiles in their individual classes! - if (!(entity.getBukkitEntity() instanceof Projectile)) { - org.bukkit.entity.Entity damager = ((Entity) object).getBukkitEntity(); - org.bukkit.entity.Entity damagee = this.getBukkitEntity(); - - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled() || event.getDamage() == 0) { - return false; - } - - i = event.getDamage(); + if (entity instanceof EntityMonster || entity instanceof EntityArrow) { + if (this.world.spawnMonsters == 0) { + i = 0; } - // CraftBukkit end - this.a((EntityLiving) object, false); + if (this.world.spawnMonsters == 1) { + i = i / 3 + 1; + } + + if (this.world.spawnMonsters == 3) { + i = i * 3 / 2; + } } - this.a(StatisticList.x, i); - return super.damageEntity(entity, i); + if (i == 0) { + return false; + } else { + Entity entity1 = entity; + + if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { + entity1 = ((EntityArrow) entity).shooter; + } + + if (entity1 instanceof EntityLiving) { + // CraftBukkit start - this is here instead of EntityMonster because EntityLiving(s) that aren't monsters + // also damage the player in this way. For example, EntitySlime. + + // We handle projectiles in their individual classes! + if (!(entity.getBukkitEntity() instanceof Projectile)) { + org.bukkit.entity.Entity damager = ((Entity) entity1).getBukkitEntity(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, i); + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled() || event.getDamage() == 0) { + return false; + } + + i = event.getDamage(); + } + // CraftBukkit end + + this.a((EntityLiving) entity1, false); + } + + this.a(StatisticList.x, i); + return super.damageEntity(damagesource, i); + } } } } - protected boolean j_() { + protected boolean n_() { return false; } @@ -454,7 +600,7 @@ public abstract class EntityHuman extends EntityLiving { } } - if (!(entityliving instanceof EntityHuman) || this.j_()) { + if (!(entityliving instanceof EntityHuman) || this.n_()) { List list = this.world.a(EntityWolf.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D)); Iterator iterator = list.iterator(); @@ -462,7 +608,7 @@ public abstract class EntityHuman extends EntityLiving { Entity entity = (Entity) iterator.next(); EntityWolf entitywolf1 = (EntityWolf) entity; - if (entitywolf1.isTamed() && entitywolf1.F() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { + if (entitywolf1.isTamed() && entitywolf1.C() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { // CraftBukkit start org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entityliving.getBukkitEntity(); @@ -487,14 +633,22 @@ public abstract class EntityHuman extends EntityLiving { } } - protected void c(int i) { - int j = 25 - this.inventory.g(); - int k = i * j + this.d; + protected void b(DamageSource damagesource, int i) { + if (!damagesource.b() && this.G()) { + i = 1 + i >> 1; + } - this.inventory.c(i); - i = k / 25; - this.d = k % 25; - super.c(i); + if (!damagesource.b()) { + int j = 25 - this.inventory.i(); + int k = i * j + this.f; + + this.inventory.d(i); + i = k / 25; + this.f = k % 25; + } + + this.b(damagesource.c()); + super.b(damagesource, i); } public void a(TileEntityFurnace tileentityfurnace) {} @@ -504,43 +658,47 @@ public abstract class EntityHuman extends EntityLiving { public void a(TileEntitySign tileentitysign) {} public void c(Entity entity) { - if (!entity.a(this)) { - ItemStack itemstack = this.G(); + if (!entity.b(this)) { + ItemStack itemstack = this.K(); if (itemstack != null && entity instanceof EntityLiving) { itemstack.a((EntityLiving) entity); // CraftBukkit - bypass infinite items; <= 0 -> == 0 if (itemstack.count == 0) { itemstack.a(this); - this.H(); + this.L(); } } } } - public ItemStack G() { + public ItemStack K() { return this.inventory.getItemInHand(); } - public void H() { + public void L() { this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); } - public double I() { + public double M() { return (double) (this.height - 0.5F); } - public void w() { - this.q = -1; - this.p = true; + public void v() { + if (!this.s || this.t >= this.o() / 2 || this.t < 0) { + this.t = -1; + this.s = true; + } } public void d(Entity entity) { int i = this.inventory.a(entity); if (i > 0) { - if (this.motY < 0.0D) { - ++i; + boolean flag = this.motY < 0.0D && !this.onGround && !this.p() && !this.ao(); + + if (flag) { + i = i * 3 / 2 + 1; } // CraftBukkit start - Don't call the event when the entity is human since it will be called with damageEntity @@ -559,33 +717,52 @@ public abstract class EntityHuman extends EntityLiving { } // CraftBukkit end + boolean flag1 = entity.damageEntity(DamageSource.b(this), i); + // CraftBukkit start - Return when the damage fails so that the item will not lose durability - if (!entity.damageEntity(this, i)) { + if (!flag1) { return; } // CraftBukkit end - ItemStack itemstack = this.G(); + if (flag1) { + if (this.at()) { + entity.b((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * 1.0F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * 1.0F)); + this.motX *= 0.6D; + this.motZ *= 0.6D; + this.g(false); + } + + if (flag) { + this.e(entity); + } + } + + ItemStack itemstack = this.K(); if (itemstack != null && entity instanceof EntityLiving) { itemstack.a((EntityLiving) entity, this); // CraftBukkit - bypass infinite items; <= 0 -> == 0 if (itemstack.count == 0) { itemstack.a(this); - this.H(); + this.L(); } } if (entity instanceof EntityLiving) { - if (entity.T()) { + if (entity.ac()) { this.a((EntityLiving) entity, true); } this.a(StatisticList.w, i); } + + this.b(0.3F); } } + public void e(Entity entity) {} + public void a(ItemStack itemstack) {} public void die() { @@ -596,13 +773,13 @@ public abstract class EntityHuman extends EntityLiving { } } - public boolean K() { - return !this.sleeping && super.K(); + public boolean O() { + return !this.sleeping && super.O(); } public EnumBedError a(int i, int j, int k) { if (!this.world.isStatic) { - if (this.isSleeping() || !this.T()) { + if (this.isSleeping() || !this.ac()) { return EnumBedError.OTHER_PROBLEM; } @@ -658,7 +835,7 @@ public abstract class EntityHuman extends EntityLiving { f = 0.9F; } - this.e(i1); + this.b(i1); this.setPosition((double) ((float) i + f), (double) ((float) j + 0.9375F), (double) ((float) k + f1)); } else { this.setPosition((double) ((float) i + 0.5F), (double) ((float) j + 0.9375F), (double) ((float) k + 0.5F)); @@ -666,7 +843,7 @@ public abstract class EntityHuman extends EntityLiving { this.sleeping = true; this.sleepTicks = 0; - this.A = new ChunkCoordinates(i, j, k); + this.E = new ChunkCoordinates(i, j, k); this.motX = this.motZ = this.motY = 0.0D; if (!this.world.isStatic) { this.world.everyoneSleeping(); @@ -675,32 +852,32 @@ public abstract class EntityHuman extends EntityLiving { return EnumBedError.OK; } - private void e(int i) { - this.B = 0.0F; - this.C = 0.0F; + private void b(int i) { + this.F = 0.0F; + this.G = 0.0F; switch (i) { case 0: - this.C = -1.8F; + this.G = -1.8F; break; case 1: - this.B = 1.8F; + this.F = 1.8F; break; case 2: - this.C = 1.8F; + this.G = 1.8F; break; case 3: - this.B = -1.8F; + this.F = -1.8F; } } public void a(boolean flag, boolean flag1, boolean flag2) { this.b(0.6F, 1.8F); - this.s(); - ChunkCoordinates chunkcoordinates = this.A; - ChunkCoordinates chunkcoordinates1 = this.A; + this.m_(); + ChunkCoordinates chunkcoordinates = this.E; + ChunkCoordinates chunkcoordinates1 = this.E; if (chunkcoordinates != null && this.world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) == Block.BED.id) { BlockBed.a(this.world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, false); @@ -740,16 +917,16 @@ public abstract class EntityHuman extends EntityLiving { } if (flag2) { - this.a(this.A); + this.a(this.E); } } - private boolean o() { - return this.world.getTypeId(this.A.x, this.A.y, this.A.z) == Block.BED.id; + private boolean w() { + return this.world.getTypeId(this.E.x, this.E.y, this.E.z) == Block.BED.id; } public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) { - IChunkProvider ichunkprovider = world.o(); + IChunkProvider ichunkprovider = world.n(); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); @@ -793,9 +970,14 @@ public abstract class EntityHuman extends EntityLiving { public void a(Statistic statistic, int i) {} - protected void O() { - super.O(); + protected void S() { + super.S(); this.a(StatisticList.u, 1); + if (this.at()) { + this.b(0.8F); + } else { + this.b(0.2F); + } } public void a(float f, float f1) { @@ -803,11 +985,22 @@ public abstract class EntityHuman extends EntityLiving { double d1 = this.locY; double d2 = this.locZ; - super.a(f, f1); - this.h(this.locX - d0, this.locY - d1, this.locZ - d2); + if (this.K.b) { + double d3 = this.motY; + float f2 = this.ak; + + this.ak = 0.05F; + super.a(f, f1); + this.motY = d3 * 0.6D; + this.ak = f2; + } else { + super.a(f, f1); + } + + this.a(this.locX - d0, this.locY - d1, this.locZ - d2); } - private void h(double d0, double d1, double d2) { + public void a(double d0, double d1, double d2) { if (this.vehicle == null) { int i; @@ -815,11 +1008,13 @@ public abstract class EntityHuman extends EntityLiving { i = Math.round(MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.a(StatisticList.q, i); + this.b(0.015F * (float) i * 0.01F); } - } else if (this.ad()) { + } else if (this.ao()) { i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F); if (i > 0) { this.a(StatisticList.m, i); + this.b(0.015F * (float) i * 0.01F); } } else if (this.p()) { if (d1 > 0.0D) { @@ -829,6 +1024,11 @@ public abstract class EntityHuman extends EntityLiving { i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F); if (i > 0) { this.a(StatisticList.l, i); + if (this.at()) { + this.b(0.099999994F * (float) i * 0.01F); + } else { + this.b(0.01F * (float) i * 0.01F); + } } } else { i = Math.round(MathHelper.a(d0 * d0 + d2 * d2) * 100.0F); @@ -839,7 +1039,7 @@ public abstract class EntityHuman extends EntityLiving { } } - private void i(double d0, double d1, double d2) { + private void h(double d0, double d1, double d2) { if (this.vehicle != null) { int i = Math.round(MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); @@ -849,7 +1049,7 @@ public abstract class EntityHuman extends EntityLiving { if (this.c == null) { this.c = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); } else if (this.c.a(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) >= 1000.0D) { - this.a(AchievementList.q, 1); + this.a((Statistic) AchievementList.q, 1); } } else if (this.vehicle instanceof EntityBoat) { this.a(StatisticList.s, i); @@ -861,11 +1061,13 @@ public abstract class EntityHuman extends EntityLiving { } protected void a(float f) { - if (f >= 2.0F) { - this.a(StatisticList.n, (int) Math.round((double) f * 100.0D)); - } + if (!this.K.c) { + if (f >= 2.0F) { + this.a(StatisticList.n, (int) Math.round((double) f * 100.0D)); + } - super.a(f); + super.a(f); + } } public void a(EntityLiving entityliving) { @@ -874,11 +1076,75 @@ public abstract class EntityHuman extends EntityLiving { } } - public void P() { - if (this.D > 0) { - this.D = 10; + public void T() { + if (this.H > 0) { + this.H = 10; } else { - this.E = true; + this.I = true; } } + + public void d(int i) { + this.exp += i; + this.expTotal += i; + + while (this.exp >= this.U()) { + this.exp -= this.U(); + this.y(); + } + } + + public int U() { + return (this.expLevel + 1) * 10; + } + + private void y() { + ++this.expLevel; + } + + public void b(float f) { + if (!this.K.a) { + if (!this.world.isStatic) { + this.m.a(f); + } + } + } + + public FoodMetaData V() { + return this.m; + } + + public boolean c(boolean flag) { + return (flag || this.m.b()) && !this.K.a; + } + + public boolean W() { + return this.health > 0 && this.health < 20; + } + + public void a(ItemStack itemstack, int i) { + if (itemstack != this.d) { + this.d = itemstack; + this.e = i; + if (!this.world.isStatic) { + this.h(true); + } + } + } + + public boolean c(int i, int j, int k) { + return true; + } + + protected int a(EntityHuman entityhuman) { + return this.expTotal >> 1; + } + + protected boolean X() { + return true; + } + + public String Y() { + return this.name; + } } diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index d8558b6743..1d99c44dd9 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -29,7 +29,7 @@ public class EntityItem extends Entity { this.motZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); } - protected boolean n() { + protected boolean e_() { return false; } @@ -41,8 +41,8 @@ public class EntityItem extends Entity { protected void b() {} - public void m_() { - super.m_(); + public void s_() { + super.s_(); // CraftBukkit start int currentTick = (int) (System.currentTimeMillis() / 50); this.pickupDelay -= (currentTick - this.lastTick); @@ -92,11 +92,11 @@ public class EntityItem extends Entity { } protected void burn(int i) { - this.damageEntity((Entity) null, i); + this.damageEntity(DamageSource.a, i); } - public boolean damageEntity(Entity entity, int i) { - this.af(); + public boolean damageEntity(DamageSource damagesource, int i) { + this.aq(); this.f -= i; if (this.f <= 0) { this.die(); @@ -108,7 +108,7 @@ public class EntityItem extends Entity { public void b(NBTTagCompound nbttagcompound) { nbttagcompound.a("Health", (short) ((byte) this.f)); nbttagcompound.a("Age", (short) this.b); - nbttagcompound.a("Item", this.itemStack.a(new NBTTagCompound())); + nbttagcompound.a("Item", this.itemStack.b(new NBTTagCompound())); } public void a(NBTTagCompound nbttagcompound) { @@ -116,10 +116,13 @@ public class EntityItem extends Entity { this.b = nbttagcompound.d("Age"); NBTTagCompound nbttagcompound1 = nbttagcompound.k("Item"); - this.itemStack = new ItemStack(nbttagcompound1); + this.itemStack = ItemStack.a(nbttagcompound1); + if (this.itemStack == null) { + this.die(); + } } - public void b(EntityHuman entityhuman) { + public void a_(EntityHuman entityhuman) { if (!this.world.isStatic) { int i = this.itemStack.count; @@ -158,4 +161,8 @@ public class EntityItem extends Entity { } } } + + public String Y() { + return StatisticCollector.a("item." + this.itemStack.k()); + } } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 1ea01a1d66..9d839020c2 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1,5 +1,8 @@ package net.minecraft.server; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; // CraftBukkit start @@ -15,80 +18,88 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; public abstract class EntityLiving extends Entity { public int maxNoDamageTicks = 20; - public float I; - public float J; - public float K = 0.0F; - public float L = 0.0F; - protected float M; - protected float N; - protected float O; - protected float P; - protected boolean Q = true; + public float S; + public float T; + public float U = 0.0F; + public float V = 0.0F; + protected float W; + protected float X; + protected float Y; + protected float Z; + protected boolean aa = true; protected String texture = "/mob/char.png"; - protected boolean S = true; - protected float T = 0.0F; - protected String U = null; - protected float V = 1.0F; - protected int W = 0; - protected float X = 0.0F; - public boolean Y = false; - public float Z; - public float aa; + protected boolean ac = true; + protected float ad = 0.0F; + protected String ae = null; + protected float af = 1.0F; + protected int ag = 0; + protected float ah = 0.0F; + public boolean ai = false; + public float aj = 0.1F; + public float ak = 0.02F; + public float al; + public float am; public int health = 10; - public int ac; + public int ao; private int a; public int hurtTicks; - public int ae; - public float af = 0.0F; + public int aq; + public float ar = 0.0F; public int deathTicks = 0; public int attackTicks = 0; - public float ai; - public float aj; - protected boolean ak = false; - public int al = -1; - public float am = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); - public float an; - public float ao; - public float ap; - protected int aq; - protected double ar; - protected double as; - protected double at; - protected double au; - protected double av; - float aw = 0.0F; + public float au; + public float av; + protected boolean aw = false; + protected int ax; + public int ay = -1; + public float az = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); + public float aA; + public float aB; + public float aC; + private EntityHuman b = null; + private int c = 0; + public int aD = 0; + public int aE = 0; + protected HashMap aF = new HashMap(); + protected int aG; + protected double aH; + protected double aI; + protected double aJ; + protected double aK; + protected double aL; + float aM = 0.0F; public int lastDamage = 0; // CraftBukkit - protected -> public - protected int ay = 0; - protected float az; - protected float aA; - protected float aB; - protected boolean aC = false; - protected float aD = 0.0F; - protected float aE = 0.7F; - private Entity b; - protected int aF = 0; + protected int aO = 0; + protected float aP; + protected float aQ; + protected float aR; + protected boolean aS = false; + protected float aT = 0.0F; + protected float aU = 0.7F; + private Entity d; + protected int aV = 0; public EntityLiving(World world) { super(world); - this.aI = true; - this.J = (float) (Math.random() + 1.0D) * 0.01F; + this.aY = true; + this.T = (float) (Math.random() + 1.0D) * 0.01F; this.setPosition(this.locX, this.locY, this.locZ); - this.I = (float) Math.random() * 12398.0F; + this.S = (float) Math.random() * 12398.0F; this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); - this.bs = 0.5F; + this.bI = 0.5F; } protected void b() {} - public boolean e(Entity entity) { + public boolean f(Entity entity) { return this.world.a(Vec3D.create(this.locX, this.locY + (double) this.t(), this.locZ), Vec3D.create(entity.locX, entity.locY + (double) entity.t(), entity.locZ)) == null; } - public boolean l_() { + public boolean r_() { return !this.dead; } - public boolean d_() { + public boolean g() { return !this.dead; } @@ -100,29 +111,29 @@ public abstract class EntityLiving extends Entity { return 80; } - public void Q() { - String s = this.g(); + public void Z() { + String s = this.h(); if (s != null) { - this.world.makeSound(this, s, this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, s, this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } } - public void R() { - this.Z = this.aa; - super.R(); + public void aa() { + this.al = this.am; + super.aa(); if (this.random.nextInt(1000) < this.a++) { this.a = -this.e(); - this.Q(); + this.Z(); } - if (this.T() && this.K()) { + if (this.ac() && this.O()) { // CraftBukkit start EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.SUFFOCATION, 1); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.d, event.getDamage()); } // CraftBukkit end } @@ -133,7 +144,7 @@ public abstract class EntityLiving extends Entity { int i; - if (this.T() && this.a(Material.WATER) && !this.b_()) { + if (this.ac() && this.a(Material.WATER) && !this.b_() && !this.aF.containsKey(Integer.valueOf(MobEffectList.o.H))) { --this.airTicks; if (this.airTicks == -20) { this.airTicks = 0; @@ -151,7 +162,7 @@ public abstract class EntityLiving extends Entity { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled() && event.getDamage() != 0) { - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.e, event.getDamage()); } // CraftBukkit end } @@ -161,7 +172,7 @@ public abstract class EntityLiving extends Entity { this.airTicks = this.maxAirTicks; } - this.ai = this.aj; + this.au = this.av; if (this.attackTicks > 0) { --this.attackTicks; } @@ -177,7 +188,18 @@ public abstract class EntityLiving extends Entity { if (this.health <= 0) { ++this.deathTicks; if (this.deathTicks > 20) { - this.X(); + if (this.c > 0 || this.X()) { + i = this.a(this.b); + + while (i > 0) { + int j = EntityExperienceOrb.b(i); + + i -= j; + this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); + } + } + + this.ag(); this.die(); for (i = 0; i < 20; ++i) { @@ -190,13 +212,28 @@ public abstract class EntityLiving extends Entity { } } - this.P = this.O; - this.L = this.K; + if (this.c > 0) { + --this.c; + } else { + this.b = null; + } + + this.aj(); + this.Z = this.Y; + this.V = this.U; this.lastYaw = this.yaw; this.lastPitch = this.pitch; } - public void S() { + protected int a(EntityHuman entityhuman) { + return this.ax; + } + + protected boolean X() { + return false; + } + + public void ab() { for (int i = 0; i < 20; ++i) { double d0 = this.random.nextGaussian() * 0.02D; double d1 = this.random.nextGaussian() * 0.02D; @@ -207,22 +244,33 @@ public abstract class EntityLiving extends Entity { } } - public void E() { - super.E(); - this.M = this.N; - this.N = 0.0F; + public void I() { + super.I(); + this.W = this.X; + this.X = 0.0F; } - public void m_() { - super.m_(); - this.v(); + public void s_() { + super.s_(); + if (this.aD > 0) { + if (this.aE <= 0) { + this.aE = 60; + } + + --this.aE; + if (this.aE <= 0) { + --this.aD; + } + } + + this.s(); double d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f = MathHelper.a(d0 * d0 + d1 * d1); - float f1 = this.K; + float f1 = this.U; float f2 = 0.0F; - this.M = this.N; + this.W = this.X; float f3 = 0.0F; if (f > 0.05F) { @@ -232,7 +280,7 @@ public abstract class EntityLiving extends Entity { f1 = (float) TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; } - if (this.aa > 0.0F) { + if (this.am > 0.0F) { f1 = this.yaw; } @@ -240,11 +288,11 @@ public abstract class EntityLiving extends Entity { f3 = 0.0F; } - this.N += (f3 - this.N) * 0.3F; + this.X += (f3 - this.X) * 0.3F; float f4; - for (f4 = f1 - this.K; f4 < -180.0F; f4 += 360.0F) { + for (f4 = f1 - this.U; f4 < -180.0F; f4 += 360.0F) { ; } @@ -252,11 +300,11 @@ public abstract class EntityLiving extends Entity { f4 -= 360.0F; } - this.K += f4 * 0.3F; + this.U += f4 * 0.3F; float f5; - for (f5 = this.yaw - this.K; f5 < -180.0F; f5 += 360.0F) { + for (f5 = this.yaw - this.U; f5 < -180.0F; f5 += 360.0F) { ; } @@ -274,9 +322,9 @@ public abstract class EntityLiving extends Entity { f5 = 75.0F; } - this.K = this.yaw - f5; + this.U = this.yaw - f5; if (f5 * f5 > 2500.0F) { - this.K += f5 * 0.2F; + this.U += f5 * 0.2F; } if (flag) { @@ -291,12 +339,12 @@ public abstract class EntityLiving extends Entity { this.lastYaw += 360.0F; } - while (this.K - this.L < -180.0F) { - this.L -= 360.0F; + while (this.U - this.V < -180.0F) { + this.V -= 360.0F; } - while (this.K - this.L >= 180.0F) { - this.L += 360.0F; + while (this.U - this.V >= 180.0F) { + this.V += 360.0F; } while (this.pitch - this.lastPitch < -180.0F) { @@ -307,7 +355,7 @@ public abstract class EntityLiving extends Entity { this.lastPitch += 360.0F; } - this.O += f2; + this.Y += f2; } protected void b(float f, float f1) { @@ -315,11 +363,11 @@ public abstract class EntityLiving extends Entity { } // CraftBukkit start - delegate so we can handle providing a reason for health being regained - public void b(int i) { - b(i, RegainReason.CUSTOM); + public void c(int i) { + c(i, RegainReason.CUSTOM); } - public void b(int i, RegainReason regainReason) { + public void c(int i, RegainReason regainReason) { if (this.health > 0) { EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason); this.world.getServer().getPluginManager().callEvent(event); @@ -336,15 +384,15 @@ public abstract class EntityLiving extends Entity { } } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { if (this.world.isStatic) { return false; } else { - this.ay = 0; + this.aO = 0; if (this.health <= 0) { return false; } else { - this.ao = 1.5F; + this.aB = 1.5F; boolean flag = true; if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { @@ -352,21 +400,37 @@ public abstract class EntityLiving extends Entity { return false; } - this.c(i - this.lastDamage); + this.b(damagesource, i - this.lastDamage); this.lastDamage = i; flag = false; } else { this.lastDamage = i; - this.ac = this.health; + this.ao = this.health; this.noDamageTicks = this.maxNoDamageTicks; - this.c(i); - this.hurtTicks = this.ae = 10; + this.b(damagesource, i); + this.hurtTicks = this.aq = 10; + } + + this.ar = 0.0F; + Entity entity = damagesource.a(); + + if (entity != null) { + if (entity instanceof EntityHuman) { + this.c = 60; + this.b = (EntityHuman) entity; + } else if (entity instanceof EntityWolf) { + EntityWolf entitywolf = (EntityWolf) entity; + + if (entitywolf.isTamed()) { + this.c = 60; + this.b = null; + } + } } - this.af = 0.0F; if (flag) { this.world.a(this, (byte) 2); - this.af(); + this.aq(); if (entity != null) { double d0 = entity.locX - this.locX; @@ -376,21 +440,21 @@ public abstract class EntityLiving extends Entity { d0 = (Math.random() - Math.random()) * 0.01D; } - this.af = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; + this.ar = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; this.a(entity, i, d0, d1); } else { - this.af = (float) ((int) (Math.random() * 2.0D) * 180); + this.ar = (float) ((int) (Math.random() * 2.0D) * 180); } } if (this.health <= 0) { if (flag) { - this.world.makeSound(this, this.i(), this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, this.j(), this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } - this.die(entity); + this.die(damagesource); } else if (flag) { - this.world.makeSound(this, this.h(), this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, this.i(), this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } return true; @@ -398,27 +462,28 @@ public abstract class EntityLiving extends Entity { } } - protected void c(int i) { + protected void b(DamageSource damagesource, int i) { this.health -= i; } - protected float k() { + protected float l() { return 1.0F; } - protected String g() { - return null; - } - protected String h() { - return "random.hurt"; + return null; } protected String i() { return "random.hurt"; } + protected String j() { + return "random.hurt"; + } + public void a(Entity entity, int i, double d0, double d1) { + this.ca = true; float f = MathHelper.a(d0 * d0 + d1 * d1); float f1 = 0.4F; @@ -433,25 +498,27 @@ public abstract class EntityLiving extends Entity { } } - public void die(Entity entity) { - if (this.W >= 0 && entity != null) { - entity.c(this, this.W); + public void die(DamageSource damagesource) { + Entity entity = damagesource.a(); + + if (this.ag >= 0 && entity != null) { + entity.b(this, this.ag); } if (entity != null) { entity.a(this); } - this.ak = true; + this.aw = true; if (!this.world.isStatic) { - this.q(); + this.a(this.c > 0); } this.world.a(this, (byte) 3); } - protected void q() { - int i = this.j(); + protected void a(boolean flag) { + int i = this.k(); // CraftBukkit start - whole method List loot = new java.util.ArrayList(); @@ -472,7 +539,7 @@ public abstract class EntityLiving extends Entity { // CraftBukkit end } - protected int j() { + protected int k() { return 0; } @@ -486,7 +553,7 @@ public abstract class EntityLiving extends Entity { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled() && event.getDamage() != 0) { - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.h, event.getDamage()); } // CraftBukkit end @@ -503,7 +570,7 @@ public abstract class EntityLiving extends Entity { public void a(float f, float f1) { double d0; - if (this.ad()) { + if (this.ao()) { d0 = this.locY; this.a(f, f1, 0.02F); this.move(this.motX, this.motY, this.motZ); @@ -514,7 +581,7 @@ public abstract class EntityLiving extends Entity { if (this.positionChanged && this.d(this.motX, this.motY + 0.6000000238418579D - this.locY + d0, this.motZ)) { this.motY = 0.30000001192092896D; } - } else if (this.ae()) { + } else if (this.ap()) { d0 = this.locY; this.a(f, f1, 0.02F); this.move(this.motX, this.motY, this.motZ); @@ -538,8 +605,9 @@ public abstract class EntityLiving extends Entity { } float f3 = 0.16277136F / (f2 * f2 * f2); + float f4 = this.onGround ? this.aj * f3 : this.ak; - this.a(f, f1, this.onGround ? 0.1F * f3 : 0.02F); + this.a(f, f1, f4); f2 = 0.91F; if (this.onGround) { f2 = 0.54600006F; @@ -551,22 +619,22 @@ public abstract class EntityLiving extends Entity { } if (this.p()) { - float f4 = 0.15F; + float f5 = 0.15F; - if (this.motX < (double) (-f4)) { - this.motX = (double) (-f4); + if (this.motX < (double) (-f5)) { + this.motX = (double) (-f5); } - if (this.motX > (double) f4) { - this.motX = (double) f4; + if (this.motX > (double) f5) { + this.motX = (double) f5; } - if (this.motZ < (double) (-f4)) { - this.motZ = (double) (-f4); + if (this.motZ < (double) (-f5)) { + this.motZ = (double) (-f5); } - if (this.motZ > (double) f4) { - this.motZ = (double) f4; + if (this.motZ > (double) f5) { + this.motZ = (double) f5; } this.fallDistance = 0.0F; @@ -590,17 +658,17 @@ public abstract class EntityLiving extends Entity { this.motZ *= (double) f2; } - this.an = this.ao; + this.aA = this.aB; d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; - float f5 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F; + float f6 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F; - if (f5 > 1.0F) { - f5 = 1.0F; + if (f6 > 1.0F) { + f6 = 1.0F; } - this.ao += (f5 - this.ao) * 0.4F; - this.ap += this.ao; + this.aB += (f6 - this.aB) * 0.4F; + this.aC += this.aB; } public boolean p() { @@ -616,6 +684,22 @@ public abstract class EntityLiving extends Entity { nbttagcompound.a("HurtTime", (short) this.hurtTicks); nbttagcompound.a("DeathTime", (short) this.deathTicks); nbttagcompound.a("AttackTime", (short) this.attackTicks); + if (!this.aF.isEmpty()) { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.aF.values().iterator(); + + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + nbttagcompound1.a("Id", (byte) mobeffect.a()); + nbttagcompound1.a("Amplifier", (byte) mobeffect.c()); + nbttagcompound1.a("Duration", mobeffect.b()); + nbttaglist.a((NBTBase) nbttagcompound1); + } + + nbttagcompound.a("ActiveEffects", (NBTBase) nbttaglist); + } } public void a(NBTTagCompound nbttagcompound) { @@ -627,9 +711,21 @@ public abstract class EntityLiving extends Entity { this.hurtTicks = nbttagcompound.d("HurtTime"); this.deathTicks = nbttagcompound.d("DeathTime"); this.attackTicks = nbttagcompound.d("AttackTime"); + if (nbttagcompound.hasKey("ActiveEffects")) { + NBTTagList nbttaglist = nbttagcompound.l("ActiveEffects"); + + for (int i = 0; i < nbttaglist.c(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); + byte b0 = nbttagcompound1.c("Id"); + byte b1 = nbttagcompound1.c("Amplifier"); + int j = nbttagcompound1.e("Duration"); + + this.aF.put(Integer.valueOf(b0), new MobEffect(b0, j, b1)); + } + } } - public boolean T() { + public boolean ac() { return !this.dead && this.health > 0; } @@ -637,15 +733,15 @@ public abstract class EntityLiving extends Entity { return false; } - public void v() { - if (this.aq > 0) { - double d0 = this.locX + (this.ar - this.locX) / (double) this.aq; - double d1 = this.locY + (this.as - this.locY) / (double) this.aq; - double d2 = this.locZ + (this.at - this.locZ) / (double) this.aq; + public void s() { + if (this.aG > 0) { + double d0 = this.locX + (this.aH - this.locX) / (double) this.aG; + double d1 = this.locY + (this.aI - this.locY) / (double) this.aG; + double d2 = this.locZ + (this.aJ - this.locZ) / (double) this.aG; double d3; - for (d3 = this.au - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) { + for (d3 = this.aK - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) { ; } @@ -653,9 +749,9 @@ public abstract class EntityLiving extends Entity { d3 -= 360.0D; } - this.yaw = (float) ((double) this.yaw + d3 / (double) this.aq); - this.pitch = (float) ((double) this.pitch + (this.av - (double) this.pitch) / (double) this.aq); - --this.aq; + this.yaw = (float) ((double) this.yaw + d3 / (double) this.aG); + this.pitch = (float) ((double) this.pitch + (this.aL - (double) this.pitch) / (double) this.aG); + --this.aG; this.setPosition(d0, d1, d2); this.c(this.yaw, this.pitch); List list = this.world.getEntities(this, this.boundingBox.shrink(0.03125D, 0.0D, 0.03125D)); @@ -676,61 +772,77 @@ public abstract class EntityLiving extends Entity { } } - if (this.D()) { - this.aC = false; - this.az = 0.0F; - this.aA = 0.0F; - this.aB = 0.0F; - } else if (!this.Y) { + if (this.H()) { + this.aS = false; + this.aP = 0.0F; + this.aQ = 0.0F; + this.aR = 0.0F; + } else if (!this.ai) { this.c_(); } - boolean flag = this.ad(); - boolean flag1 = this.ae(); + boolean flag = this.ao(); + boolean flag1 = this.ap(); - if (this.aC) { + if (this.aS) { if (flag) { this.motY += 0.03999999910593033D; } else if (flag1) { this.motY += 0.03999999910593033D; } else if (this.onGround) { - this.O(); + this.S(); } } - this.az *= 0.98F; - this.aA *= 0.98F; - this.aB *= 0.9F; - this.a(this.az, this.aA); + this.aP *= 0.98F; + this.aQ *= 0.98F; + this.aR *= 0.9F; + float f = this.aj; + + this.aj *= this.D(); + this.a(this.aP, this.aQ); + this.aj = f; List list1 = this.world.b((Entity) this, this.boundingBox.b(0.20000000298023224D, 0.0D, 0.20000000298023224D)); if (list1 != null && list1.size() > 0) { for (int j = 0; j < list1.size(); ++j) { Entity entity = (Entity) list1.get(j); - if (entity.d_()) { + if (entity.g()) { entity.collide(this); } } } } - protected boolean D() { + protected boolean H() { return this.health <= 0; } - protected void O() { - this.motY = 0.41999998688697815D; + public boolean G() { + return false; } - protected boolean h_() { + protected void S() { + this.motY = 0.41999998688697815D; + if (this.at()) { + float f = this.yaw * 0.017453292F; + + this.motX -= (double) (MathHelper.sin(f) * 0.2F); + this.motZ += (double) (MathHelper.cos(f) * 0.2F); + } + + this.ca = true; + } + + protected boolean d_() { return true; } - protected void U() { + protected void ad() { EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - if (this.h_() && entityhuman != null) { + if (this.d_() && entityhuman != null) { double d0 = entityhuman.locX - this.locX; double d1 = entityhuman.locY - this.locY; double d2 = entityhuman.locZ - this.locZ; @@ -740,9 +852,9 @@ public abstract class EntityLiving extends Entity { this.die(); } - if (this.ay > 600 && this.random.nextInt(800) == 0) { + if (this.aO > 600 && this.random.nextInt(800) == 0) { if (d3 < 1024.0D) { - this.ay = 0; + this.aO = 0; } else { this.die(); } @@ -751,43 +863,43 @@ public abstract class EntityLiving extends Entity { } protected void c_() { - ++this.ay; + ++this.aO; EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - this.U(); - this.az = 0.0F; - this.aA = 0.0F; + this.ad(); + this.aP = 0.0F; + this.aQ = 0.0F; float f = 8.0F; if (this.random.nextFloat() < 0.02F) { entityhuman = this.world.findNearbyPlayer(this, (double) f); if (entityhuman != null) { - this.b = entityhuman; - this.aF = 10 + this.random.nextInt(20); + this.d = entityhuman; + this.aV = 10 + this.random.nextInt(20); } else { - this.aB = (this.random.nextFloat() - 0.5F) * 20.0F; + this.aR = (this.random.nextFloat() - 0.5F) * 20.0F; } } - if (this.b != null) { - this.a(this.b, 10.0F, (float) this.u()); - if (this.aF-- <= 0 || this.b.dead || this.b.g(this) > (double) (f * f)) { - this.b = null; + if (this.d != null) { + this.a(this.d, 10.0F, (float) this.u()); + if (this.aV-- <= 0 || this.d.dead || this.d.h(this) > (double) (f * f)) { + this.d = null; } } else { if (this.random.nextFloat() < 0.05F) { - this.aB = (this.random.nextFloat() - 0.5F) * 20.0F; + this.aR = (this.random.nextFloat() - 0.5F) * 20.0F; } - this.yaw += this.aB; - this.pitch = this.aD; + this.yaw += this.aR; + this.pitch = this.aT; } - boolean flag = this.ad(); - boolean flag1 = this.ae(); + boolean flag = this.ao(); + boolean flag1 = this.ap(); if (flag || flag1) { - this.aC = this.random.nextFloat() < 0.8F; + this.aS = this.random.nextFloat() < 0.8F; } } @@ -816,12 +928,12 @@ public abstract class EntityLiving extends Entity { this.yaw = this.b(this.yaw, f2, f); } - public boolean V() { - return this.b != null; + public boolean ae() { + return this.d != null; } - public Entity W() { - return this.b; + public Entity af() { + return this.d; } private float b(float f, float f1, float f2) { @@ -846,13 +958,13 @@ public abstract class EntityLiving extends Entity { return f + f3; } - public void X() {} + public void ag() {} public boolean d() { return this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox); } - protected void Y() { + protected void ah() { // CraftBukkit start EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.VOID, 4); this.world.getServer().getPluginManager().callEvent(event); @@ -861,15 +973,15 @@ public abstract class EntityLiving extends Entity { return; } - this.damageEntity((Entity) null, event.getDamage()); + this.damageEntity(DamageSource.i, event.getDamage()); // CraftBukkit end } - public Vec3D Z() { - return this.b(1.0F); + public Vec3D ai() { + return this.c(1.0F); } - public Vec3D b(float f) { + public Vec3D c(float f) { float f1; float f2; float f3; @@ -893,11 +1005,67 @@ public abstract class EntityLiving extends Entity { } } - public int l() { + public int m() { return 4; } public boolean isSleeping() { return false; } + + protected void aj() { + Iterator iterator = this.aF.keySet().iterator(); + + while (iterator.hasNext()) { + Integer integer = (Integer) iterator.next(); + MobEffect mobeffect = (MobEffect) this.aF.get(integer); + + if (!mobeffect.a(this) && !this.world.isStatic) { + iterator.remove(); + this.c(mobeffect); + } + } + } + + public Collection ak() { + return this.aF.values(); + } + + public boolean a(MobEffectList mobeffectlist) { + return this.aF.containsKey(Integer.valueOf(mobeffectlist.H)); + } + + public MobEffect b(MobEffectList mobeffectlist) { + return (MobEffect) this.aF.get(Integer.valueOf(mobeffectlist.H)); + } + + public void d(MobEffect mobeffect) { + if (this.aF.containsKey(Integer.valueOf(mobeffect.a()))) { + ((MobEffect) this.aF.get(Integer.valueOf(mobeffect.a()))).a(mobeffect); + this.b((MobEffect) this.aF.get(Integer.valueOf(mobeffect.a()))); + } else { + this.aF.put(Integer.valueOf(mobeffect.a()), mobeffect); + this.a(mobeffect); + } + } + + protected void a(MobEffect mobeffect) {} + + protected void b(MobEffect mobeffect) {} + + protected void c(MobEffect mobeffect) {} + + protected float D() { + float f = 1.0F; + + if (this.a(MobEffectList.c)) { + f *= 1.0F + 0.2F * (float) (this.b(MobEffectList.c).c() + 1); + } + + if (this.a(MobEffectList.d)) { + f *= 1.0F - 0.15F * (float) (this.b(MobEffectList.d).c() + 1); + } + + return f; + } } diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 60e1bdf01a..9ad729a51b 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -55,26 +55,26 @@ public class EntityMinecart extends Entity implements IInventory { this.b = 0; this.c = 1; this.i = false; - this.aI = true; + this.aY = true; this.b(0.98F, 0.7F); this.height = this.width / 2.0F; } - protected boolean n() { + protected boolean e_() { return false; } protected void b() {} - public AxisAlignedBB a_(Entity entity) { + public AxisAlignedBB b(Entity entity) { return entity.boundingBox; } - public AxisAlignedBB e_() { + public AxisAlignedBB f() { return null; } - public boolean d_() { + public boolean g() { return true; } @@ -92,15 +92,15 @@ public class EntityMinecart extends Entity implements IInventory { this.world.getServer().getPluginManager().callEvent(new VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit } - public double m() { + public double n() { return (double) this.width * 0.0D - 0.30000001192092896D; } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { if (!this.world.isStatic && !this.dead) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); - org.bukkit.entity.Entity passenger = (entity == null) ? null : entity.getBukkitEntity(); + org.bukkit.entity.Entity passenger = (damagesource.a() == null) ? null : damagesource.a().getBukkitEntity(); VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, i); this.world.getServer().getPluginManager().callEvent(event); @@ -114,7 +114,7 @@ public class EntityMinecart extends Entity implements IInventory { this.c = -this.c; this.b = 10; - this.af(); + this.aq(); this.damage += i * 10; if (this.damage > 40) { if (this.passenger != null) { @@ -175,7 +175,7 @@ public class EntityMinecart extends Entity implements IInventory { } } - public boolean l_() { + public boolean r_() { return !this.dead; } @@ -571,7 +571,7 @@ public class EntityMinecart extends Entity implements IInventory { for (int l1 = 0; l1 < list.size(); ++l1) { Entity entity = (Entity) list.get(l1); - if (entity != this.passenger && entity.d_() && entity instanceof EntityMinecart) { + if (entity != this.passenger && entity.g() && entity instanceof EntityMinecart) { entity.collide(this); } } @@ -673,7 +673,7 @@ public class EntityMinecart extends Entity implements IInventory { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.a("Slot", (byte) i); - this.items[i].a(nbttagcompound1); + this.items[i].b(nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1); } } @@ -698,7 +698,7 @@ public class EntityMinecart extends Entity implements IInventory { int j = nbttagcompound1.c("Slot") & 255; if (j >= 0 && j < this.items.length) { - this.items[j] = new ItemStack(nbttagcompound1); + this.items[j] = ItemStack.a(nbttagcompound1); } } } @@ -749,8 +749,8 @@ public class EntityMinecart extends Entity implements IInventory { d1 *= d3; d0 *= 0.10000000149011612D; d1 *= 0.10000000149011612D; - d0 *= (double) (1.0F - this.bu); - d1 *= (double) (1.0F - this.bu); + d0 *= (double) (1.0F - this.bK); + d1 *= (double) (1.0F - this.bK); d0 *= 0.5D; d1 *= 0.5D; if (entity instanceof EntityMinecart) { @@ -843,7 +843,7 @@ public class EntityMinecart extends Entity implements IInventory { public void update() {} - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { if (this.type == 0) { if (this.passenger != null && this.passenger instanceof EntityHuman && this.passenger != entityhuman) { return true; @@ -885,7 +885,11 @@ public class EntityMinecart extends Entity implements IInventory { return true; } - public boolean a_(EntityHuman entityhuman) { - return this.dead ? false : entityhuman.g(this) <= 64.0D; + public boolean a(EntityHuman entityhuman) { + return this.dead ? false : entityhuman.h(this) <= 64.0D; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java index abe59e9497..c805fd7a69 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -7,27 +7,28 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end -public class EntityMonster extends EntityCreature implements IMonster { +public abstract class EntityMonster extends EntityCreature implements IMonster { protected int damage = 2; public EntityMonster(World world) { super(world); this.health = 20; + this.ax = 5; } - public void v() { - float f = this.c(1.0F); + public void s() { + float f = this.a_(1.0F); if (f > 0.5F) { - this.ay += 2; + this.aO += 2; } - super.v(); + super.s(); } - public void m_() { - super.m_(); + public void s_() { + super.s_(); if (!this.world.isStatic && this.world.spawnMonsters == 0) { this.die(); } @@ -36,11 +37,13 @@ public class EntityMonster extends EntityCreature implements IMonster { protected Entity findTarget() { EntityHuman entityhuman = this.world.findNearbyPlayer(this, 16.0D); - return entityhuman != null && this.e(entityhuman) ? entityhuman : null; + return entityhuman != null && this.f(entityhuman) ? entityhuman : null; } - public boolean damageEntity(Entity entity, int i) { - if (super.damageEntity(entity, i)) { + public boolean damageEntity(DamageSource damagesource, int i) { + if (super.damageEntity(damagesource, i)) { + Entity entity = damagesource.a(); + if (this.passenger != entity && this.vehicle != entity) { if (entity != this) { // CraftBukkit start @@ -68,31 +71,36 @@ public class EntityMonster extends EntityCreature implements IMonster { } } + protected boolean c(Entity entity) { + // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for lastDamage EntityMonster + // to damage another EntityMonster, and we want to catch those events. + // This does not fire events for slime attacks, av they're not lastDamage EntityMonster. + if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) { + org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); + + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return entity.damageEntity(DamageSource.a(this), event.getDamage()); + } + + return false; + } + // CraftBukkit end + + return entity.damageEntity(DamageSource.a((EntityLiving) this), this.damage); + } + protected void a(Entity entity, float f) { if (this.attackTicks <= 0 && f < 2.0F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) { this.attackTicks = 20; - // CraftBukkit start - this is still duplicated here and EntityHuman because it's possible for lastDamage EntityMonster - // to damage another EntityMonster, and we want to catch those events. - // This does not fire events for slime attacks, av they're not lastDamage EntityMonster. - if (entity instanceof EntityLiving && !(entity instanceof EntityHuman)) { - org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); - - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - entity.damageEntity(this, event.getDamage()); - } - return; - } - // CraftBukkit end - - entity.damageEntity(this, this.damage); + this.c(entity); } } protected float a(int i, int j, int k) { - return 0.5F - this.world.n(i, j, k); + return 0.5F - this.world.m(i, j, k); } public void b(NBTTagCompound nbttagcompound) { @@ -113,12 +121,12 @@ public class EntityMonster extends EntityCreature implements IMonster { } else { int l = this.world.getLightLevel(i, j, k); - if (this.world.u()) { - int i1 = this.world.f; + if (this.world.t()) { + int i1 = this.world.k; - this.world.f = 10; + this.world.k = 10; l = this.world.getLightLevel(i, j, k); - this.world.f = i1; + this.world.k = i1; } return l <= this.random.nextInt(8) && super.d(); diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java index 40d28bae54..6271393be3 100644 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ b/src/main/java/net/minecraft/server/EntityPainting.java @@ -39,7 +39,7 @@ public class EntityPainting extends Entity { this.e = enumart; this.b(l); - if (this.h()) { + if (this.i()) { arraylist.add(enumart); } } @@ -117,10 +117,10 @@ public class EntityPainting extends Entity { return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); } - public void m_() { + public void s_() { if (this.f++ == 100 && !this.world.isStatic) { this.f = 0; - if (!this.h()) { + if (!this.i()) { // CraftBukkit start PaintingBreakByWorldEvent event = new PaintingBreakByWorldEvent((org.bukkit.entity.Painting) this.getBukkitEntity()); this.world.getServer().getPluginManager().callEvent(event); @@ -136,7 +136,7 @@ public class EntityPainting extends Entity { } } - public boolean h() { + public boolean i() { if (this.world.getEntities(this, this.boundingBox).size() > 0) { return false; } else { @@ -194,14 +194,14 @@ public class EntityPainting extends Entity { } } - public boolean l_() { + public boolean r_() { return true; } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { if (!this.dead && !this.world.isStatic) { // CraftBukkit start - PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((org.bukkit.entity.Painting) this.getBukkitEntity(), entity == null ? null : entity.getBukkitEntity()); + PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((org.bukkit.entity.Painting) this.getBukkitEntity(), damagesource.a() == null ? null : damagesource.a().getBukkitEntity()); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -210,7 +210,7 @@ public class EntityPainting extends Entity { // CraftBukkit end this.die(); - this.af(); + this.aq(); this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); } @@ -249,7 +249,7 @@ public class EntityPainting extends Entity { this.b(this.a); } - public void a(double d0, double d1, double d2) { + public void a_(double d0, double d1, double d2) { if (!this.world.isStatic && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { this.die(); this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index 10f4d8aa4d..c38d5a74f8 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -27,19 +27,19 @@ public class EntityPig extends EntityAnimal { this.setSaddle(nbttagcompound.m("Saddle")); } - protected String g() { - return "mob.pig"; - } - protected String h() { return "mob.pig"; } protected String i() { + return "mob.pig"; + } + + protected String j() { return "mob.pigdeath"; } - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { entityhuman.mount(this); return true; @@ -48,7 +48,7 @@ public class EntityPig extends EntityAnimal { } } - protected int j() { + protected int k() { return this.fireTicks > 0 ? Item.GRILLED_PORK.id : Item.PORK.id; } diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 1e3b524689..d5ebce0570 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -11,23 +11,23 @@ public class EntityPigZombie extends EntityZombie { public int angerLevel = 0; // CraftBukkit - private -> public private int soundDelay = 0; - private static final ItemStack f = new ItemStack(Item.GOLD_SWORD, 1); + private static final ItemStack g = new ItemStack(Item.GOLD_SWORD, 1); public EntityPigZombie(World world) { super(world); this.texture = "/mob/pigzombie.png"; - this.aE = 0.5F; + this.aU = 0.5F; this.damage = 5; this.fireProof = true; } - public void m_() { - this.aE = this.target != null ? 0.95F : 0.5F; + public void s_() { + this.aU = this.target != null ? 0.95F : 0.5F; if (this.soundDelay > 0 && --this.soundDelay == 0) { - this.world.makeSound(this, "mob.zombiepig.zpigangry", this.k() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); + this.world.makeSound(this, "mob.zombiepig.zpigangry", this.l() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); } - super.m_(); + super.s_(); } public boolean d() { @@ -48,11 +48,13 @@ public class EntityPigZombie extends EntityZombie { return this.angerLevel == 0 ? null : super.findTarget(); } - public void v() { - super.v(); + public void s() { + super.s(); } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { + Entity entity = damagesource.a(); + if (entity instanceof EntityHuman) { List list = this.world.b((Entity) this, this.boundingBox.b(32.0D, 32.0D, 32.0D)); @@ -62,17 +64,17 @@ public class EntityPigZombie extends EntityZombie { if (entity1 instanceof EntityPigZombie) { EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; - entitypigzombie.d(entity); + entitypigzombie.e(entity); } } - this.d(entity); + this.e(entity); } - return super.damageEntity(entity, i); + return super.damageEntity(damagesource, i); } - private void d(Entity entity) { + private void e(Entity entity) { // CraftBukkit start org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity(); @@ -95,19 +97,19 @@ public class EntityPigZombie extends EntityZombie { this.soundDelay = this.random.nextInt(40); } - protected String g() { + protected String h() { return "mob.zombiepig.zpig"; } - protected String h() { + protected String i() { return "mob.zombiepig.zpighurt"; } - protected String i() { + protected String j() { return "mob.zombiepig.zpigdeath"; } - protected int j() { + protected int k() { 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 c7fa3a1842..c227c6b127 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -23,11 +23,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public double e; public List chunkCoordIntPairQueue = new LinkedList(); public Set playerChunkCoordIntPairs = new HashSet(); - private int bL = -99999999; - private int bM = 60; - private ItemStack[] bN = new ItemStack[] { null, null, null, null, null}; - private int bO = 0; + private int cb = -99999999; + private int cc = -99999999; + private boolean cd = true; + private int ce = -99999999; + private int cf = 60; + private ItemStack[] cg = new ItemStack[] { null, null, null, null, null}; + private int ch = 0; public boolean h; + public int i; public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) { super(world); @@ -46,7 +50,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); this.b = minecraftserver; - this.bs = 0.0F; + this.bI = 0.0F; this.name = s; this.height = 0.0F; @@ -58,6 +62,18 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public org.bukkit.Location compassTarget; // CraftBukkit end + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + if (nbttagcompound.hasKey("playerGameType")) { + this.itemInWorldManager.a(nbttagcompound.e("playerGameType")); + } + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.a("playerGameType", this.itemInWorldManager.a()); + } + public void spawnIn(World world) { super.spawnIn(world); // CraftBukkit - world fallback code, either respawn location or global spawn @@ -89,10 +105,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public ItemStack[] getEquipment() { - return this.bN; + return this.cg; } - protected void s() { + protected void m_() { this.height = 0.0F; } @@ -100,26 +116,27 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return 1.62F; } - public void m_() { - this.itemInWorldManager.a(); - --this.bM; + public void s_() { + this.itemInWorldManager.c(); + --this.cf; this.activeContainer.a(); for (int i = 0; i < 5; ++i) { - ItemStack itemstack = this.c_(i); + ItemStack itemstack = this.b(i); - if (itemstack != this.bN[i]) { + if (itemstack != this.cg[i]) { this.b.getTracker(this.dimension).a(this, new Packet5EntityEquipment(this.id, i, itemstack)); - this.bN[i] = itemstack; + this.cg[i] = itemstack; } } } - public ItemStack c_(int i) { + public ItemStack b(int i) { return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; } - public void die(Entity entity) { + public void die(DamageSource damagesource) { + this.b.serverConfigurationManager.sendAll(new Packet3Chat(damagesource.a((EntityHuman) this))); // CraftBukkit start java.util.List loot = new java.util.ArrayList(); @@ -158,12 +175,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting { // CraftBukkit end } - public boolean damageEntity(Entity entity, int i) { - if (this.bM > 0) { + public boolean damageEntity(DamageSource damagesource, int i) { + if (this.cf > 0) { return false; } else { // CraftBukkit - this.b.pvpMode -> this.world.pvpMode - if (!this.world.pvpMode) { + if (!this.world.pvpMode && damagesource instanceof EntityDamageSource) { + Entity entity = damagesource.a(); + if (entity instanceof EntityHuman) { return false; } @@ -177,26 +196,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - return super.damageEntity(entity, i); + return super.damageEntity(damagesource, i); } } - protected boolean j_() { + protected boolean n_() { return this.b.pvpMode; } - public void b(int i) { - super.b(i, RegainReason.EATING); + public void c(int i) { + super.c(i, RegainReason.EATING); } - public void a(boolean flag) { - super.m_(); + public void b(boolean flag) { + super.s_(); for (int i = 0; i < this.inventory.getSize(); ++i) { ItemStack itemstack = this.inventory.getItem(i); - if (itemstack != null && Item.byId[itemstack.id].b() && this.netServerHandler.b() <= 2) { - Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).b(itemstack, this.world, this); + if (itemstack != null && Item.byId[itemstack.id].i_() && this.netServerHandler.b() <= 2) { + Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this); if (packet != null) { this.netServerHandler.sendPacket(packet); @@ -218,58 +237,82 @@ public class EntityPlayer extends EntityHuman implements ICrafting { WorldServer worldserver = this.b.getWorldServer(this.dimension); this.chunkCoordIntPairQueue.remove(chunkcoordintpair); - this.netServerHandler.sendPacket(new Packet51MapChunk(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, 16, 128, 16, worldserver)); - List list = worldserver.getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 128, chunkcoordintpair.z * 16 + 16); + NetServerHandler netserverhandler = this.netServerHandler; - for (int j = 0; j < list.size(); ++j) { - this.a((TileEntity) list.get(j)); + int j = chunkcoordintpair.x * 16; + int k = chunkcoordintpair.z * 16; + + worldserver.getClass(); + Packet51MapChunk packet51mapchunk = new Packet51MapChunk(j, 0, k, 16, 128, 16, worldserver); + + netserverhandler.sendPacket(packet51mapchunk); + int l = chunkcoordintpair.x * 16; + + j = chunkcoordintpair.z * 16; + int i1 = chunkcoordintpair.x * 16 + 16; + + worldserver.getClass(); + List list = worldserver.getTileEntities(l, 0, j, i1, 128, chunkcoordintpair.z * 16 + 16); + + for (int j1 = 0; j1 < list.size(); ++j1) { + this.a((TileEntity) list.get(j1)); } } } } - if (this.E) { + if (this.I) { //if (this.b.propertyManager.getBoolean("allow-nether", true)) { // CraftBukkit if (this.activeContainer != this.defaultContainer) { - this.y(); + this.x(); } if (this.vehicle != null) { this.mount(this.vehicle); } else { - this.F += 0.0125F; - if (this.F >= 1.0F) { - this.F = 1.0F; - this.D = 10; + this.J += 0.0125F; + if (this.J >= 1.0F) { + this.J = 1.0F; + this.H = 10; this.b.serverConfigurationManager.f(this); + this.ce = -1; + this.cb = -1; + this.cc = -1; } } - this.E = false; + this.I = false; //} // CraftBukkit } else { - if (this.F > 0.0F) { - this.F -= 0.05F; + if (this.J > 0.0F) { + this.J -= 0.05F; } - if (this.F < 0.0F) { - this.F = 0.0F; + if (this.J < 0.0F) { + this.J = 0.0F; } } - if (this.D > 0) { - --this.D; + if (this.H > 0) { + --this.H; } - if (this.health != this.bL) { - this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.health)); - this.bL = this.health; + if (this.health != this.cb || this.cc != this.m.a() || this.m.c() == 0.0F != this.cd) { + this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.health, this.m.a(), this.m.c())); + this.cb = this.health; + this.cc = this.m.a(); + this.cd = this.m.c() == 0.0F; + } + + if (this.expTotal != this.ce) { + this.ce = this.expTotal; + this.netServerHandler.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel)); } } private void a(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.f(); + Packet packet = tileentity.l(); if (packet != null) { this.netServerHandler.sendPacket(packet); @@ -277,10 +320,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void v() { - super.v(); - } - public void receive(Entity entity, int i) { if (!entity.dead) { EntityTracker entitytracker = this.b.getTracker(this.dimension); @@ -292,23 +331,27 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (entity instanceof EntityArrow) { entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); } + + if (entity instanceof EntityExperienceOrb) { + entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); + } } super.receive(entity, i); this.activeContainer.a(); } - public void w() { - if (!this.p) { - this.q = -1; - this.p = true; + public void v() { + if (!this.s) { + this.t = -1; + this.s = true; EntityTracker entitytracker = this.b.getTracker(this.dimension); entitytracker.a(this, new Packet18ArmAnimation(this, 1)); } } - public void x() {} + public void w() {} public EnumBedError a(int i, int j, int k) { EnumBedError enumbederror = super.a(i, j, k); @@ -360,39 +403,39 @@ public class EntityPlayer extends EntityHuman implements ICrafting { super.a(d0, flag); } - private void ai() { - this.bO = this.bO % 100 + 1; + private void au() { + this.ch = this.ch % 100 + 1; } public void b(int i, int j, int k) { - this.ai(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bO, 1, "Crafting", 9)); + this.au(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 1, "Crafting", 9)); this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k); - this.activeContainer.windowId = this.bO; + this.activeContainer.windowId = this.ch; this.activeContainer.a((ICrafting) this); } public void a(IInventory iinventory) { - this.ai(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bO, 0, iinventory.getName(), iinventory.getSize())); + this.au(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 0, iinventory.getName(), iinventory.getSize())); this.activeContainer = new ContainerChest(this.inventory, iinventory); - this.activeContainer.windowId = this.bO; + this.activeContainer.windowId = this.ch; this.activeContainer.a((ICrafting) this); } public void a(TileEntityFurnace tileentityfurnace) { - this.ai(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bO, 2, tileentityfurnace.getName(), tileentityfurnace.getSize())); + this.au(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 2, tileentityfurnace.getName(), tileentityfurnace.getSize())); this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace); - this.activeContainer.windowId = this.bO; + this.activeContainer.windowId = this.ch; this.activeContainer.a((ICrafting) this); } public void a(TileEntityDispenser tileentitydispenser) { - this.ai(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.bO, 3, tileentitydispenser.getName(), tileentitydispenser.getSize())); + this.au(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 3, tileentitydispenser.getName(), tileentitydispenser.getSize())); this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser); - this.activeContainer.windowId = this.bO; + this.activeContainer.windowId = this.ch; this.activeContainer.a((ICrafting) this); } @@ -410,7 +453,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void a(Container container, List list) { this.netServerHandler.sendPacket(new Packet104WindowItems(container.windowId, list)); - this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.j())); + this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.l())); } public void a(Container container, int i, int j) { @@ -419,26 +462,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void a(ItemStack itemstack) {} - public void y() { + public void x() { this.netServerHandler.sendPacket(new Packet101CloseWindow(this.activeContainer.windowId)); - this.A(); + this.z(); } - public void z() { + public void y() { if (!this.h) { - this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.j())); + this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.l())); } } - public void A() { + public void z() { this.activeContainer.a((EntityHuman) this); this.activeContainer = this.defaultContainer; } public void a(float f, float f1, boolean flag, boolean flag1, float f2, float f3) { - this.az = f; - this.aA = f1; - this.aC = flag; + this.aP = f; + this.aQ = f1; + this.aS = flag; this.setSneak(flag1); this.pitch = f2; this.yaw = f3; @@ -457,7 +500,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void B() { + public void A() { if (this.vehicle != null) { this.mount(this.vehicle); } @@ -471,8 +514,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void C() { - this.bL = -99999999; + public void B() { + this.cb = -99999999; } public void a(String s) { @@ -482,6 +525,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.netServerHandler.sendPacket(new Packet3Chat(s1)); } + protected void C() { + this.netServerHandler.sendPacket(new Packet38EntityStatus(this.id, (byte) 9)); + super.C(); + } + + public void a(ItemStack itemstack, int i) { + super.a(itemstack, i); + if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().b(itemstack) == EnumAnimation.b) { + EntityTracker entitytracker = this.b.getTracker(this.dimension); + + entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(this, 5)); + } + } + + protected void a(MobEffect mobeffect) { + super.a(mobeffect); + this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect)); + } + + protected void b(MobEffect mobeffect) { + super.b(mobeffect); + this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect)); + } + + protected void c(MobEffect mobeffect) { + super.c(mobeffect); + this.netServerHandler.sendPacket(new Packet42RemoveMobEffect(this.id, mobeffect)); + } + // CraftBukkit start public long timeOffset = 0; public boolean relativeTime = true; diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index cb2e3f1661..f619288e24 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -17,11 +17,7 @@ public class EntitySheep extends EntityAnimal { this.datawatcher.a(16, new Byte((byte) 0)); } - public boolean damageEntity(Entity entity, int i) { - return super.damageEntity(entity, i); - } - - protected void q() { + protected void a(boolean flag) { // CraftBukkit start - whole method java.util.List loot = new java.util.ArrayList(); @@ -41,11 +37,11 @@ public class EntitySheep extends EntityAnimal { // CraftBukkit end } - protected int j() { + protected int k() { return Block.WOOL.id; } - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared()) { @@ -80,10 +76,6 @@ public class EntitySheep extends EntityAnimal { this.setColor(nbttagcompound.c("Color")); } - protected String g() { - return "mob.sheep"; - } - protected String h() { return "mob.sheep"; } @@ -92,6 +84,10 @@ public class EntitySheep extends EntityAnimal { return "mob.sheep"; } + protected String j() { + return "mob.sheep"; + } + public int getColor() { return this.datawatcher.a(16) & 15; } diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index 51246f92d7..21b56ad9ed 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -14,21 +14,38 @@ public class EntitySkeleton extends EntityMonster { this.texture = "/mob/skeleton.png"; } - protected String g() { - return "mob.skeleton"; - } - protected String h() { - return "mob.skeletonhurt"; + return "mob.skeleton"; } protected String i() { return "mob.skeletonhurt"; } - public void v() { - if (this.world.d()) { - float f = this.c(1.0F); + protected String j() { + return "mob.skeletonhurt"; + } + + public boolean a(DamageSource damagesource, int i) { + return super.damageEntity(damagesource, i); + } + + public void a(DamageSource damagesource) { + super.die(damagesource); + if (damagesource.e() instanceof EntityArrow && damagesource.a() instanceof EntityHuman) { + EntityHuman entityhuman = (EntityHuman) damagesource.a(); + double d0 = entityhuman.locX - this.locX; + double d1 = entityhuman.locZ - this.locZ; + + if (d0 * d0 + d1 * d1 >= 2500.0D) { + entityhuman.a((Statistic) AchievementList.v); + } + } + } + + public void s() { + if (this.world.d() && !this.world.isStatic) { + float f = this.a_(1.0F); if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { // CraftBukkit start @@ -42,7 +59,7 @@ public class EntitySkeleton extends EntityMonster { } } - super.v(); + super.s(); } protected void a(Entity entity, float f) { @@ -51,16 +68,14 @@ public class EntitySkeleton extends EntityMonster { double d1 = entity.locZ - this.locZ; if (this.attackTicks == 0) { - EntityArrow entityarrow = new EntityArrow(this.world, this); - - ++entityarrow.locY; - double d2 = entity.locY + (double) entity.t() - 0.20000000298023224D - entityarrow.locY; + EntityArrow entityarrow = new EntityArrow(this.world, this, 1.0F); + double d2 = entity.locY + (double) entity.t() - 0.699999988079071D - entityarrow.locY; float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F; this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F)); this.world.addEntity(entityarrow); - entityarrow.a(d0, d2 + (double) f1, d1, 0.6F, 12.0F); - this.attackTicks = 30; + entityarrow.a(d0, d2 + (double) f1, d1, 1.6F, 12.0F); + this.attackTicks = 60; } this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; @@ -76,11 +91,11 @@ public class EntitySkeleton extends EntityMonster { super.a(nbttagcompound); } - protected int j() { + protected int k() { return Item.ARROW.id; } - protected void q() { + protected void a(boolean flag) { // CraftBukkit start - whole method java.util.List loot = new java.util.ArrayList(); diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index d89221a8eb..ffec1f3aab 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -77,11 +77,11 @@ public class EntitySnowball extends Entity { this.h = 0; } - public void m_() { - this.bo = this.locX; - this.bp = this.locY; - this.bq = this.locZ; - super.m_(); + public void s_() { + this.bE = this.locX; + this.bF = this.locY; + this.bG = this.locZ; + super.s_(); if (this.a > 0) { --this.a; } @@ -126,13 +126,13 @@ public class EntitySnowball extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.l_() && (entity1 != this.shooter || this.i >= 5)) { + if (entity1.r_() && (entity1 != this.shooter || this.i >= 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) { - double d1 = vec3d.a(movingobjectposition1.f); + double d1 = vec3d.b(movingobjectposition1.f); if (d1 < d0 || d0 == 0.0D) { entity = entity1; @@ -167,10 +167,10 @@ public class EntitySnowball extends Entity { stick = !projectile.doesBounce(); } else { // this function returns if the snowball should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(this, event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(this.shooter, 0); + stick = movingobjectposition.entity.damageEntity(DamageSource.a(this, this.shooter), 0); } if (stick) { ; @@ -213,7 +213,7 @@ public class EntitySnowball extends Entity { float f2 = 0.99F; float f3 = 0.03F; - if (this.ad()) { + if (this.ao()) { for (int l = 0; l < 4; ++l) { float f4 = 0.25F; @@ -248,7 +248,7 @@ public class EntitySnowball extends Entity { this.f = nbttagcompound.c("inGround") == 1; } - public void b(EntityHuman entityhuman) { + public void a_(EntityHuman entityhuman) { if (this.f && this.shooter == entityhuman && this.a <= 0 && entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) { this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, 1); diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index b1e77d3afe..1bccda26f6 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -11,19 +11,19 @@ public class EntitySpider extends EntityMonster { super(world); this.texture = "/mob/spider.png"; this.b(1.4F, 0.9F); - this.aE = 0.8F; + this.aU = 0.8F; } - public double m() { + public double n() { return (double) this.width * 0.75D - 0.5D; } - protected boolean n() { + protected boolean e_() { return false; } protected Entity findTarget() { - float f = this.c(1.0F); + float f = this.a_(1.0F); if (f < 0.5F) { double d0 = 16.0D; @@ -34,20 +34,20 @@ public class EntitySpider extends EntityMonster { } } - protected String g() { - return "mob.spider"; - } - protected String h() { return "mob.spider"; } protected String i() { + return "mob.spider"; + } + + protected String j() { return "mob.spiderdeath"; } protected void a(Entity entity, float f) { - float f1 = this.c(1.0F); + float f1 = this.a_(1.0F); if (f1 > 0.5F && this.random.nextInt(100) == 0) { // CraftBukkit start @@ -88,11 +88,13 @@ public class EntitySpider extends EntityMonster { super.a(nbttagcompound); } - protected int j() { + protected int k() { return Item.STRING.id; } public boolean p() { return this.positionChanged; } + + public void q() {} } diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java index f19f960346..d9eed62b9f 100644 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ b/src/main/java/net/minecraft/server/EntitySquid.java @@ -7,23 +7,23 @@ 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 g = 0.0F; public float h = 0.0F; public float i = 0.0F; public float j = 0.0F; - private float k = 0.0F; + public float k = 0.0F; private float l = 0.0F; private float m = 0.0F; private float n = 0.0F; private float o = 0.0F; private float p = 0.0F; + private float q = 0.0F; public EntitySquid(World world) { super(world); this.texture = "/mob/squid.png"; this.b(0.95F, 0.95F); - this.l = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; + this.m = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } public void b(NBTTagCompound nbttagcompound) { @@ -34,10 +34,6 @@ public class EntitySquid extends EntityWaterAnimal { super.a(nbttagcompound); } - protected String g() { - return null; - } - protected String h() { return null; } @@ -46,15 +42,19 @@ public class EntitySquid extends EntityWaterAnimal { return null; } - protected float k() { + protected String j() { + return null; + } + + protected float l() { return 0.4F; } - protected int j() { + protected int k() { return 0; } - protected void q() { + protected void a(boolean flag) { // CraftBukkit start - whole method java.util.List loot = new java.util.ArrayList(); @@ -75,60 +75,60 @@ public class EntitySquid extends EntityWaterAnimal { // CraftBukkit end } - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { return false; } - public boolean ad() { + public boolean ao() { return this.world.a(this.boundingBox.b(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this); } - public void v() { - super.v(); + public void s() { + super.s(); this.b = this.a; - this.f = this.c; - this.h = this.g; - this.j = this.i; - this.g += this.l; - if (this.g > 6.2831855F) { - this.g -= 6.2831855F; + this.g = this.c; + this.i = this.h; + this.k = this.j; + this.h += this.m; + if (this.h > 6.2831855F) { + this.h -= 6.2831855F; if (this.random.nextInt(10) == 0) { - this.l = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; + this.m = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } } - if (this.ad()) { + if (this.ao()) { float f; - if (this.g < 3.1415927F) { - f = this.g / 3.1415927F; - this.i = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F; + if (this.h < 3.1415927F) { + f = this.h / 3.1415927F; + this.j = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F; if ((double) f > 0.75D) { - this.k = 1.0F; - this.m = 1.0F; + this.l = 1.0F; + this.n = 1.0F; } else { - this.m *= 0.8F; + this.n *= 0.8F; } } else { - this.i = 0.0F; - this.k *= 0.9F; - this.m *= 0.99F; + this.j = 0.0F; + this.l *= 0.9F; + this.n *= 0.99F; } - if (!this.Y) { - this.motX = (double) (this.n * this.k); - this.motY = (double) (this.o * this.k); - this.motZ = (double) (this.p * this.k); + if (!this.ai) { + this.motX = (double) (this.o * this.l); + this.motY = (double) (this.p * this.l); + this.motZ = (double) (this.q * this.l); } f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); - this.K += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.K) * 0.1F; - this.yaw = this.K; - this.c += 3.1415927F * this.m * 1.5F; + this.U += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.U) * 0.1F; + this.yaw = this.U; + this.c += 3.1415927F * this.n * 1.5F; this.a += (-((float) Math.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.a) * 0.1F; } else { - this.i = MathHelper.abs(MathHelper.sin(this.g)) * 3.1415927F * 0.25F; - if (!this.Y) { + this.j = MathHelper.abs(MathHelper.sin(this.h)) * 3.1415927F * 0.25F; + if (!this.ai) { this.motX = 0.0D; this.motY -= 0.08D; this.motY *= 0.9800000190734863D; @@ -144,14 +144,14 @@ public class EntitySquid extends EntityWaterAnimal { } protected void c_() { - if (this.random.nextInt(50) == 0 || !this.bA || this.n == 0.0F && this.o == 0.0F && this.p == 0.0F) { + if (this.random.nextInt(50) == 0 || !this.bQ || this.o == 0.0F && this.p == 0.0F && this.q == 0.0F) { float f = this.random.nextFloat() * 3.1415927F * 2.0F; - this.n = MathHelper.cos(f) * 0.2F; - this.o = -0.1F + this.random.nextFloat() * 0.2F; - this.p = MathHelper.sin(f) * 0.2F; + this.o = MathHelper.cos(f) * 0.2F; + this.p = -0.1F + this.random.nextFloat() * 0.2F; + this.q = MathHelper.sin(f) * 0.2F; } - this.U(); + this.ad(); } -} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java index 1140cd4109..66a8451fcd 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -16,7 +16,7 @@ public class EntityTNTPrimed extends Entity { public EntityTNTPrimed(World world) { super(world); this.fuseTicks = 0; - this.aI = true; + this.aY = true; this.b(0.98F, 0.98F); this.height = this.width / 2.0F; } @@ -37,15 +37,15 @@ public class EntityTNTPrimed extends Entity { protected void b() {} - protected boolean n() { + protected boolean e_() { return false; } - public boolean l_() { + public boolean r_() { return !this.dead; } - public void m_() { + public void s_() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java index db1bcc745a..ee5e9986dc 100644 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ b/src/main/java/net/minecraft/server/EntityTracker.java @@ -52,13 +52,15 @@ public class EntityTracker { } else if (entity instanceof EntitySquid) { this.a(entity, 160, 3, true); } else if (entity instanceof IAnimal) { - this.a(entity, 160, 3); + this.a(entity, 160, 3, true); } else if (entity instanceof EntityTNTPrimed) { this.a(entity, 160, 10, true); } else if (entity instanceof EntityFallingSand) { this.a(entity, 160, 20, true); } else if (entity instanceof EntityPainting) { this.a(entity, 160, Integer.MAX_VALUE, false); + } else if (entity instanceof EntityExperienceOrb) { + this.a(entity, 160, 20, true); } } diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index 2019835838..4368f16d36 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -60,7 +60,7 @@ public class EntityTrackerEntry { } ++this.t; - if (++this.l % this.c == 0) { + if (++this.l % this.c == 0 || this.tracker.ca) { int i = MathHelper.floor(this.tracker.locX * 32.0D); int j = MathHelper.floor(this.tracker.locY * 32.0D); int k = MathHelper.floor(this.tracker.locZ * 32.0D); @@ -108,7 +108,7 @@ public class EntityTrackerEntry { this.a((Packet) object); } - DataWatcher datawatcher = this.tracker.aa(); + DataWatcher datawatcher = this.tracker.al(); if (datawatcher.a()) { this.b((Packet) (new Packet40EntityMetadata(this.tracker.id, datawatcher))); @@ -126,6 +126,7 @@ public class EntityTrackerEntry { } } + this.tracker.ca = false; if (this.tracker.velocityChanged) { // CraftBukkit start - create PlayerVelocity event boolean cancelled = false; @@ -208,6 +209,17 @@ public class EntityTrackerEntry { entityplayer.netServerHandler.sendPacket(new Packet17(this.tracker, 0, MathHelper.floor(this.tracker.locX), MathHelper.floor(this.tracker.locY), MathHelper.floor(this.tracker.locZ))); } } + + if (this.tracker instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving) this.tracker; + Iterator iterator = entityliving.ak().iterator(); + + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + + entityplayer.netServerHandler.sendPacket(new Packet41MobEffect(this.tracker.id, mobeffect)); + } + } } } else if (this.trackedPlayers.contains(entityplayer)) { this.trackedPlayers.remove(entityplayer); @@ -262,9 +274,9 @@ public class EntityTrackerEntry { } else if (this.tracker instanceof EntityFish) { return new Packet23VehicleSpawn(this.tracker, 90); } else if (this.tracker instanceof EntityArrow) { - EntityLiving entityliving = ((EntityArrow) this.tracker).shooter; + Entity entity = ((EntityArrow) this.tracker).shooter; - return new Packet23VehicleSpawn(this.tracker, 60, entityliving != null ? entityliving.id : this.tracker.id); + return new Packet23VehicleSpawn(this.tracker, 60, entity != null ? entity.id : this.tracker.id); } else if (this.tracker instanceof EntitySnowball) { return new Packet23VehicleSpawn(this.tracker, 61); } else if (this.tracker instanceof EntityFireball) { @@ -297,6 +309,8 @@ public class EntityTrackerEntry { if (this.tracker instanceof EntityPainting) { return new Packet25EntityPainting((EntityPainting) this.tracker); + } else if (this.tracker instanceof EntityExperienceOrb) { + return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker); } else { throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!"); } diff --git a/src/main/java/net/minecraft/server/EntityWeatherStorm.java b/src/main/java/net/minecraft/server/EntityWeatherStorm.java index 18e52d9146..de745542d3 100644 --- a/src/main/java/net/minecraft/server/EntityWeatherStorm.java +++ b/src/main/java/net/minecraft/server/EntityWeatherStorm.java @@ -72,8 +72,8 @@ public class EntityWeatherStorm extends EntityWeather { } } - public void m_() { - super.m_(); + public void s_() { + super.s_(); if (this.lifeTicks == 2) { this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F); diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index 61ae30a810..1c4d6c7b1a 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -17,16 +17,16 @@ public class EntityWolf extends EntityAnimal { private boolean a = false; private float b; private float c; - private boolean f; private boolean g; - private float h; + private boolean h; private float i; + private float j; public EntityWolf(World world) { super(world); this.texture = "/mob/wolf.png"; this.b(0.8F, 0.8F); - this.aE = 1.1F; + this.aU = 1.1F; this.health = 8; } @@ -37,7 +37,7 @@ public class EntityWolf extends EntityAnimal { this.datawatcher.a(18, new Integer(this.health)); } - protected boolean n() { + protected boolean e_() { return false; } @@ -64,45 +64,45 @@ public class EntityWolf extends EntityAnimal { } } - protected boolean h_() { + protected boolean d_() { return !this.isTamed(); } - protected String g() { + protected String h() { return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.b(18) < 10 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark"); } - protected String h() { + protected String i() { return "mob.wolf.hurt"; } - protected String i() { + protected String j() { return "mob.wolf.death"; } - protected float k() { + protected float l() { return 0.4F; } - protected int j() { + protected int k() { return -1; } protected void c_() { super.c_(); - if (!this.e && !this.C() && this.isTamed() && this.vehicle == null) { + if (!this.e && !this.B() && this.isTamed() && this.vehicle == null) { EntityHuman entityhuman = this.world.a(this.getOwnerName()); if (entityhuman != null) { - float f = entityhuman.f(this); + float f = entityhuman.g(this); if (f > 5.0F) { this.c(entityhuman, f); } - } else if (!this.ad()) { + } else if (!this.ao()) { this.setSitting(true); } - } else if (this.target == null && !this.C() && !this.isTamed() && this.world.random.nextInt(100) == 0) { + } else if (this.target == null && !this.B() && !this.isTamed() && this.world.random.nextInt(100) == 0) { List list = this.world.a(EntitySheep.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D)); if (!list.isEmpty()) { @@ -120,7 +120,7 @@ public class EntityWolf extends EntityAnimal { } } - if (this.ad()) { + if (this.ao()) { this.setSitting(false); } @@ -129,11 +129,11 @@ public class EntityWolf extends EntityAnimal { } } - public void v() { - super.v(); + public void s() { + super.s(); this.a = false; - if (this.V() && !this.C() && !this.isAngry()) { - Entity entity = this.W(); + if (this.ae() && !this.B() && !this.isAngry()) { + Entity entity = this.af(); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; @@ -143,22 +143,22 @@ public class EntityWolf extends EntityAnimal { if (!this.isTamed() && itemstack.id == Item.BONE.id) { this.a = true; } else if (this.isTamed() && Item.byId[itemstack.id] instanceof ItemFood) { - this.a = ((ItemFood) Item.byId[itemstack.id]).l(); + this.a = ((ItemFood) Item.byId[itemstack.id]).m(); } } } } - if (!this.Y && this.f && !this.g && !this.C() && this.onGround) { - this.g = true; - this.h = 0.0F; + if (!this.ai && this.g && !this.h && !this.B() && this.onGround) { + this.h = true; this.i = 0.0F; + this.j = 0.0F; this.world.a(this, (byte) 8); } } - public void m_() { - super.m_(); + public void s_() { + super.s_(); this.c = this.b; if (this.a) { this.b += (1.0F - this.b) * 0.4F; @@ -167,31 +167,31 @@ public class EntityWolf extends EntityAnimal { } if (this.a) { - this.aF = 10; + this.aV = 10; } - if (this.ac()) { - this.f = true; - this.g = false; - this.h = 0.0F; + if (this.an()) { + this.g = true; + this.h = false; this.i = 0.0F; - } else if ((this.f || this.g) && this.g) { - if (this.h == 0.0F) { - this.world.makeSound(this, "mob.wolf.shake", this.k(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.j = 0.0F; + } else if ((this.g || this.h) && this.h) { + if (this.i == 0.0F) { + this.world.makeSound(this, "mob.wolf.shake", this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } - this.i = this.h; - this.h += 0.05F; - if (this.i >= 2.0F) { - this.f = false; + this.j = this.i; + this.i += 0.05F; + if (this.j >= 2.0F) { this.g = false; + this.h = false; + this.j = 0.0F; this.i = 0.0F; - this.h = 0.0F; } - if (this.h > 0.4F) { + if (this.i > 0.4F) { float f = (float) this.boundingBox.b; - int i = (int) (MathHelper.sin((this.h - 0.4F) * 3.1415927F) * 7.0F); + int i = (int) (MathHelper.sin((this.i - 0.4F) * 3.1415927F) * 7.0F); for (int j = 0; j < i; ++j) { float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.length * 0.5F; @@ -232,17 +232,19 @@ public class EntityWolf extends EntityAnimal { } } - protected boolean w() { - return this.isSitting() || this.g; + protected boolean v() { + return this.isSitting() || this.h; } - public boolean damageEntity(Entity entity, int i) { + public boolean damageEntity(DamageSource damagesource, int i) { + Entity entity = damagesource.a(); + this.setSitting(false); if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { i = (i + 1) / 2; } - if (!super.damageEntity((Entity) entity, i)) { + if (!super.damageEntity(damagesource, i)) { return false; } else { if (!this.isTamed() && !this.isAngry()) { @@ -302,7 +304,7 @@ public class EntityWolf extends EntityAnimal { return true; } - this.target = (Entity) entity; + this.target = entity; } return true; @@ -343,11 +345,11 @@ public class EntityWolf extends EntityAnimal { } // CraftBukkit end - entity.damageEntity(this, b0); + entity.damageEntity(DamageSource.a((EntityLiving) this), b0); } } - public boolean a(EntityHuman entityhuman) { + public boolean b(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (!this.isTamed()) { @@ -366,10 +368,10 @@ public class EntityWolf extends EntityAnimal { this.setSitting(true); this.health = 20; this.setOwnerName(entityhuman.name); - this.a(true); + this.b(true); this.world.a(this, (byte) 7); } else { - this.a(false); + this.b(false); this.world.a(this, (byte) 6); } } @@ -380,13 +382,14 @@ public class EntityWolf extends EntityAnimal { if (itemstack != null && Item.byId[itemstack.id] instanceof ItemFood) { ItemFood itemfood = (ItemFood) Item.byId[itemstack.id]; - if (itemfood.l() && this.datawatcher.b(18) < 20) { + if (itemfood.m() && this.datawatcher.b(18) < 20) { --itemstack.count; + this.c(((ItemFood) Item.PORK).k(), RegainReason.EATING); // Craftbukkit + if (itemstack.count <= 0) { entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); } - this.b(((ItemFood) Item.PORK).k(), RegainReason.EATING); return true; } } @@ -394,7 +397,7 @@ public class EntityWolf extends EntityAnimal { if (entityhuman.name.equalsIgnoreCase(this.getOwnerName())) { if (!this.world.isStatic) { this.setSitting(!this.isSitting()); - this.aC = false; + this.aS = false; this.setPathEntity((PathEntity) null); } @@ -405,7 +408,7 @@ public class EntityWolf extends EntityAnimal { return false; } - void a(boolean flag) { + void b(boolean flag) { String s = "heart"; if (!flag) { @@ -421,7 +424,7 @@ public class EntityWolf extends EntityAnimal { } } - public int l() { + public int m() { return 8; } diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index f5c276d5aa..92eb6d85ad 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -7,13 +7,13 @@ public class EntityZombie extends EntityMonster { public EntityZombie(World world) { super(world); this.texture = "/mob/zombie.png"; - this.aE = 0.5F; + this.aU = 0.5F; this.damage = 5; } - public void v() { - if (this.world.d()) { - float f = this.c(1.0F); + public void s() { + if (this.world.d() && !this.world.isStatic) { + float f = this.a_(1.0F); if (f > 0.5F && this.world.isChunkLoaded(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { // CraftBukkit start @@ -27,22 +27,22 @@ public class EntityZombie extends EntityMonster { } } - super.v(); - } - - protected String g() { - return "mob.zombie"; + super.s(); } protected String h() { - return "mob.zombiehurt"; + return "mob.zombie"; } protected String i() { + return "mob.zombiehurt"; + } + + protected String j() { return "mob.zombiedeath"; } - protected int j() { - return Item.FEATHER.id; + protected int k() { + return Item.ROTTEN_FLESH.id; } } diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index 0903af4ae9..fe61a0288d 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -130,7 +130,7 @@ public class Explosion { server.getPluginManager().callEvent(event); if (!event.isCancelled()) { - entity.damageEntity(this.source, event.getDamage()); + entity.damageEntity(DamageSource.k, event.getDamage()); entity.motX += d0 * d10; entity.motY += d1 * d10; entity.motZ += d2 * d10; @@ -140,7 +140,7 @@ public class Explosion { server.getPluginManager().callEvent(event); if (!event.isCancelled()) { - entity.damageEntity(this.source, event.getDamage()); + entity.damageEntity(DamageSource.k, event.getDamage()); entity.motX += d0 * d10; entity.motY += d1 * d10; @@ -173,6 +173,7 @@ public class Explosion { public void a(boolean flag) { this.world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F); + this.world.a("hugeexplosion", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); ArrayList arraylist = new ArrayList(); arraylist.addAll(this.blocks); @@ -234,7 +235,7 @@ public class Explosion { // CraftBukkit Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield()); this.world.setTypeId(j, k, l, 0); - Block.byId[i1].d(this.world, j, k, l); + Block.byId[i1].a_(this.world, j, k, l); } } } diff --git a/src/main/java/net/minecraft/server/IInventory.java b/src/main/java/net/minecraft/server/IInventory.java index bb6ce82f0c..80a84b4d20 100644 --- a/src/main/java/net/minecraft/server/IInventory.java +++ b/src/main/java/net/minecraft/server/IInventory.java @@ -16,7 +16,11 @@ public interface IInventory { void update(); - boolean a_(EntityHuman entityhuman); + boolean a(EntityHuman entityhuman); + + void e(); + + void t_(); 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 2d0964f967..b506567701 100644 --- a/src/main/java/net/minecraft/server/InventoryCraftResult.java +++ b/src/main/java/net/minecraft/server/InventoryCraftResult.java @@ -45,7 +45,11 @@ public class InventoryCraftResult implements IInventory { public void update() {} - public boolean a_(EntityHuman entityhuman) { + public boolean a(EntityHuman entityhuman) { return true; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/InventoryCrafting.java b/src/main/java/net/minecraft/server/InventoryCrafting.java index 9151b8bf3a..a64f65a5bb 100644 --- a/src/main/java/net/minecraft/server/InventoryCrafting.java +++ b/src/main/java/net/minecraft/server/InventoryCrafting.java @@ -76,7 +76,11 @@ public class InventoryCrafting implements IInventory { public void update() {} - public boolean a_(EntityHuman entityhuman) { + public boolean a(EntityHuman entityhuman) { return true; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/InventoryLargeChest.java b/src/main/java/net/minecraft/server/InventoryLargeChest.java index 15dcdd8aa8..023f2751cc 100644 --- a/src/main/java/net/minecraft/server/InventoryLargeChest.java +++ b/src/main/java/net/minecraft/server/InventoryLargeChest.java @@ -18,6 +18,14 @@ public class InventoryLargeChest implements IInventory { public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) { this.a = s; + if (iinventory == null) { + iinventory = iinventory1; + } + + if (iinventory1 == null) { + iinventory1 = iinventory; + } + this.b = iinventory; this.c = iinventory1; } @@ -55,7 +63,17 @@ public class InventoryLargeChest implements IInventory { this.c.update(); } - public boolean a_(EntityHuman entityhuman) { - return this.b.a_(entityhuman) && this.c.a_(entityhuman); + public boolean a(EntityHuman entityhuman) { + return this.b.a(entityhuman) && this.c.a(entityhuman); + } + + public void e() { + this.b.e(); + this.c.e(); + } + + public void t_() { + this.b.t_(); + this.c.t_(); } } diff --git a/src/main/java/net/minecraft/server/InventoryPlayer.java b/src/main/java/net/minecraft/server/InventoryPlayer.java index f25e699b27..fecaa40dee 100644 --- a/src/main/java/net/minecraft/server/InventoryPlayer.java +++ b/src/main/java/net/minecraft/server/InventoryPlayer.java @@ -27,11 +27,11 @@ public class InventoryPlayer implements IInventory { return this.itemInHandIndex < 9 && this.itemInHandIndex >= 0 ? this.items[this.itemInHandIndex] : null; } - public static int e() { + public static int g() { return 9; } - private int d(int i) { + private int e(int i) { for (int j = 0; j < this.items.length; ++j) { if (this.items[j] != null && this.items[j].id == i) { return j; @@ -67,7 +67,7 @@ public class InventoryPlayer implements IInventory { } // CraftBukkit end - private int k() { + private int m() { for (int i = 0; i < this.items.length; ++i) { if (this.items[i] == null) { return i; @@ -83,7 +83,7 @@ public class InventoryPlayer implements IInventory { int k = this.firstPartial(itemstack); if (k < 0) { - k = this.k(); + k = this.m(); } if (k < 0) { @@ -114,7 +114,7 @@ public class InventoryPlayer implements IInventory { } } - public void f() { + public void h() { for (int i = 0; i < this.items.length; ++i) { if (this.items[i] != null) { this.items[i].a(this.d.world, this.d, i, this.itemInHandIndex == i); @@ -123,7 +123,7 @@ public class InventoryPlayer implements IInventory { } public boolean b(int i) { - int j = this.d(i); + int j = this.e(i); if (j < 0) { return false; @@ -136,11 +136,17 @@ public class InventoryPlayer implements IInventory { } } + public boolean c(int i) { + int j = this.e(i); + + return j >= 0; + } + public boolean pickup(ItemStack itemstack) { int i; if (itemstack.f()) { - i = this.k(); + i = this.m(); if (i >= 0) { this.items[i] = ItemStack.b(itemstack); this.items[i].b = 5; @@ -216,7 +222,7 @@ public class InventoryPlayer implements IInventory { if (this.items[i] != null) { nbttagcompound = new NBTTagCompound(); nbttagcompound.a("Slot", (byte) i); - this.items[i].a(nbttagcompound); + this.items[i].b(nbttagcompound); nbttaglist.a((NBTBase) nbttagcompound); } } @@ -225,7 +231,7 @@ public class InventoryPlayer implements IInventory { if (this.armor[i] != null) { nbttagcompound = new NBTTagCompound(); nbttagcompound.a("Slot", (byte) (i + 100)); - this.armor[i].a(nbttagcompound); + this.armor[i].b(nbttagcompound); nbttaglist.a((NBTBase) nbttagcompound); } } @@ -240,9 +246,9 @@ public class InventoryPlayer implements IInventory { for (int i = 0; i < nbttaglist.c(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i); int j = nbttagcompound.c("Slot") & 255; - ItemStack itemstack = new ItemStack(nbttagcompound); + ItemStack itemstack = ItemStack.a(nbttagcompound); - if (itemstack.getItem() != null) { + if (itemstack != null) { if (j >= 0 && j < this.items.length) { this.items[j] = itemstack; } @@ -284,7 +290,7 @@ public class InventoryPlayer implements IInventory { } public boolean b(Block block) { - if (block.material.i()) { + if (block.material.k()) { return true; } else { ItemStack itemstack = this.getItem(this.itemInHandIndex); @@ -293,7 +299,7 @@ public class InventoryPlayer implements IInventory { } } - public int g() { + public int i() { int i = 0; int j = 0; int k = 0; @@ -306,7 +312,7 @@ public class InventoryPlayer implements IInventory { j += k1; k += i1; - int l1 = ((ItemArmor) this.armor[l].getItem()).bl; + int l1 = ((ItemArmor) this.armor[l].getItem()).bu; i += l1; } @@ -319,7 +325,7 @@ public class InventoryPlayer implements IInventory { } } - public void c(int i) { + public void d(int i) { for (int j = 0; j < this.armor.length; ++j) { if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) { this.armor[j].damage(i, this.d); @@ -331,7 +337,7 @@ public class InventoryPlayer implements IInventory { } } - public void h() { + public void j() { int i; for (i = 0; i < this.items.length; ++i) { @@ -358,12 +364,12 @@ public class InventoryPlayer implements IInventory { this.d.a(itemstack); } - public ItemStack j() { + public ItemStack l() { return this.f; } - public boolean a_(EntityHuman entityhuman) { - return this.d.dead ? false : entityhuman.g(this.d) <= 64.0D; + public boolean a(EntityHuman entityhuman) { + return this.d.dead ? false : entityhuman.h(this.d) <= 64.0D; } public boolean c(ItemStack itemstack) { @@ -383,4 +389,8 @@ public class InventoryPlayer implements IInventory { return false; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index 5d19b7d53a..f78467c01f 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -40,23 +40,27 @@ public class ItemBed extends Item { b0 = 1; } - if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.e(i, j - 1, k) && world.e(i + b0, j - 1, k + b1)) { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + if (entityhuman.c(i, j, k) && entityhuman.c(i + b0, j, k + b1)) { + if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.e(i, j - 1, k) && world.e(i + b0, j - 1, k + b1)) { + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - world.setTypeIdAndData(i, j, k, blockbed.id, i1); + world.setTypeIdAndData(i, j, k, blockbed.id, i1); - // CraftBukkit start - bed - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed); + // CraftBukkit start - bed + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, blockbed); - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; + } + // CraftBukkit end + + world.setTypeIdAndData(i + b0, j, k + b1, blockbed.id, i1 + 8); + --itemstack.count; + return true; + } else { return false; } - // CraftBukkit end - - world.setTypeIdAndData(i + b0, j, k + b1, blockbed.id, i1 + 8); - --itemstack.count; - return true; } else { return false; } diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 3425366655..c0598a2d9f 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -16,12 +16,17 @@ public class ItemBlock extends Item { this.b(Block.byId[i + 256].a(2)); } + public int a() { + return this.id; + } + public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + int i1 = world.getTypeId(i, j, k); - if (world.getTypeId(i, j, k) == Block.SNOW.id) { + if (i1 == Block.SNOW.id) { l = 0; - } else { + } else if (i1 != Block.VINE.id) { if (l == 0) { --j; } @@ -49,75 +54,84 @@ public class ItemBlock extends Item { if (itemstack.count == 0) { return false; - } else if (j == 127 && Block.byId[this.id].material.isBuildable()) { + } else if (!entityhuman.c(i, j, k)) { return false; - } else if (world.a(this.id, i, j, k, false, l)) { - Block block = Block.byId[this.id]; - - // CraftBukkit start - This executes the placement of the block - CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); - - // There are like 30 combinations you can mix and match steps and double steps - // of different materials, so there are a lot of different cases of what - // would happen if you place x step onto another y step, so let's just keep - // track of the entire state - CraftBlockState blockStateBelow = null; - // Toggles whether the normal or the block below is used for the place event - boolean eventUseBlockBelow = false; - if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) - && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { - blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); - // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block - eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; - } - - /** - * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) - * - * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to - * hook between the 'placement' and the informing to 'world' so we can - * sanely undo this. - * - * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to - * replace this with. - */ - if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); - - if (event.isCancelled() || !event.canBuild()) { - if (blockStateBelow != null) { // Used for steps - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); - world.setTypeIdAndData(i, j - 1, k, blockStateBelow.getTypeId(), blockStateBelow.getRawData()); - - } else { - - if (this.id == Block.ICE.id) { - // Ice will explode if we set straight to 0 - world.setTypeId(i, j, k, 20); - } - - world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); - } - return true; - - } - world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) - - // CraftBukkit end - - Block.byId[this.id].postPlace(world, i, j, k, l); - Block.byId[this.id].postPlace(world, i, j, k, entityhuman); - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); - --itemstack.count; - } - - return true; } else { - return false; + world.getClass(); + if (j == 128 - 1 && Block.byId[this.id].material.isBuildable()) { + return false; + } else if (world.a(this.id, i, j, k, false, l)) { + Block block = Block.byId[this.id]; + + // CraftBukkit start - This executes the placement of the block + CraftBlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); + + // There are like 30 combinations you can mix and match steps and double steps + // of different materials, so there are a lot of different cases of what + // would happen if you place x step onto another y step, so let's just keep + // track of the entire state + CraftBlockState blockStateBelow = null; + // Toggles whether the normal or the block below is used for the place event + boolean eventUseBlockBelow = false; + if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) + && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) { + blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); + // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block + eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; + } + + /** + * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) + * + * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to + * hook between the 'placement' and the informing to 'world' so we can + * sanely undo this. + * + * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to + * replace this with. + */ + if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, eventUseBlockBelow ? blockStateBelow : replacedBlockState, clickedX, clickedY, clickedZ, block); + + if (event.isCancelled() || !event.canBuild()) { + if (blockStateBelow != null) { // Used for steps + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); + world.setTypeIdAndData(i, j - 1, k, blockStateBelow.getTypeId(), blockStateBelow.getRawData()); + + } else { + + if (this.id == Block.ICE.id) { + // Ice will explode if we set straight to 0 + world.setTypeId(i, j, k, 20); + } + + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); + } + return true; + + } + world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) + + // CraftBukkit end + + Block.byId[this.id].postPlace(world, i, j, k, l); + Block.byId[this.id].postPlace(world, i, j, k, entityhuman); + world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); + --itemstack.count; + } + + return true; + } else { + return false; + } } } - public String a() { + public String a(ItemStack itemstack) { + return Block.byId[this.id].l(); + } + + public String b() { return Block.byId[this.id].l(); } } diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index e1c2866ad6..6cb74b929b 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -49,6 +49,10 @@ public class ItemBucket extends Item { } if (this.a == 0) { + if (!entityhuman.c(i, j, k)) { + return itemstack; + } + if (world.getMaterial(i, j, k) == Material.WATER && world.getData(i, j, k) == 0) { // CraftBukkit start PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, i, j, k, -1, itemstack, Item.WATER_BUCKET); @@ -121,6 +125,10 @@ public class ItemBucket extends Item { ++i; } + if (!entityhuman.c(i, j, k)) { + return itemstack; + } + if (world.isEmpty(i, j, k) || !world.getMaterial(i, j, k).isBuildable()) { // CraftBukkit start PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clickedX, clickedY, clickedZ, movingobjectposition.face, itemstack); @@ -140,6 +148,10 @@ public class ItemBucket extends Item { world.setTypeIdAndData(i, j, k, this.a, 0); } + if (entityhuman.K.d) { + return itemstack; + } + // CraftBukkit start CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index 5e9d921b94..7e772b80f4 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -20,8 +20,6 @@ public class ItemDoor extends Item { if (l != 1) { return false; } else { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit - ++j; Block block; @@ -31,70 +29,87 @@ public class ItemDoor extends Item { block = Block.IRON_DOOR_BLOCK; } - if (!block.canPlace(world, i, j, k)) { - return false; - } else { - int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; - byte b0 = 0; - byte b1 = 0; - - if (i1 == 0) { - b1 = 1; - } - - if (i1 == 1) { - b0 = -1; - } - - if (i1 == 2) { - b1 = -1; - } - - if (i1 == 3) { - b0 = 1; - } - - int j1 = (world.e(i - b0, j, k - b1) ? 1 : 0) + (world.e(i - b0, j + 1, k - b1) ? 1 : 0); - int k1 = (world.e(i + b0, j, k + b1) ? 1 : 0) + (world.e(i + b0, j + 1, k + b1) ? 1 : 0); - boolean flag = world.getTypeId(i - b0, j, k - b1) == block.id || world.getTypeId(i - b0, j + 1, k - b1) == block.id; - boolean flag1 = world.getTypeId(i + b0, j, k + b1) == block.id || world.getTypeId(i + b0, j + 1, k + b1) == block.id; - boolean flag2 = false; - - if (flag && !flag1) { - flag2 = true; - } else if (k1 > j1) { - flag2 = true; - } - - if (flag2) { - i1 = i1 - 1 & 3; - i1 += 4; - } - - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - - world.suppressPhysics = true; - world.setTypeIdAndData(i, j, k, block.id, i1); - - // CraftBukkit start - bed - world.suppressPhysics = false; - world.applyPhysics(i, j, k, Block.REDSTONE_WIRE.id); - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, block); - - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + if (entityhuman.c(i, j, k) && entityhuman.c(i, j + 1, k)) { + if (!block.canPlace(world, i, j, k)) { return false; - } + } else { + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; - world.suppressPhysics = true; - // CraftBukkit end - world.setTypeIdAndData(i, j + 1, k, block.id, i1 + 8); - world.suppressPhysics = false; - // world.applyPhysics(i, j, k, block.id); // CraftBukkit - moved up - world.applyPhysics(i, j + 1, k, Block.REDSTONE_WIRE.id); - --itemstack.count; - return true; + // CraftBukkit start + if (a(world, i, j, k, i1, block, entityhuman)) { + --itemstack.count; + return true; + } else { + return false; + } + // CraftBukkit end + } + } else { + return false; } } } + + // Craftbukkit - void -> boolean + entityhuman argument + public static boolean a(World world, int i, int j, int k, int l, Block block, EntityHuman entityhuman) { + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + byte b0 = 0; + byte b1 = 0; + + if (l == 0) { + b1 = 1; + } + + if (l == 1) { + b0 = -1; + } + + if (l == 2) { + b1 = -1; + } + + if (l == 3) { + b0 = 1; + } + + int i1 = (world.e(i - b0, j, k - b1) ? 1 : 0) + (world.e(i - b0, j + 1, k - b1) ? 1 : 0); + int j1 = (world.e(i + b0, j, k + b1) ? 1 : 0) + (world.e(i + b0, j + 1, k + b1) ? 1 : 0); + boolean flag = world.getTypeId(i - b0, j, k - b1) == block.id || world.getTypeId(i - b0, j + 1, k - b1) == block.id; + boolean flag1 = world.getTypeId(i + b0, j, k + b1) == block.id || world.getTypeId(i + b0, j + 1, k + b1) == block.id; + boolean flag2 = false; + + if (flag && !flag1) { + flag2 = true; + } else if (j1 > i1) { + flag2 = true; + } + + if (flag2) { + l = l - 1 & 3; + l += 4; + } + + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + + world.suppressPhysics = true; + world.setTypeIdAndData(i, j, k, block.id, l); + // CraftBukkit start - bed + world.suppressPhysics = false; + world.applyPhysics(i, j, k, Block.REDSTONE_WIRE.id); + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, block); + + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; + } + + world.suppressPhysics = true; + // CraftBukkit end + world.setTypeIdAndData(i, j + 1, k, block.id, l + 8); + world.suppressPhysics = false; + // world.applyPhysics(i, j, k, block.id); // CraftBukkit - moved up + world.applyPhysics(i, j + 1, k, block.id); + + return true; // CraftBukkit + } } diff --git a/src/main/java/net/minecraft/server/ItemFishingRod.java b/src/main/java/net/minecraft/server/ItemFishingRod.java index 9bcf2e2f0d..c913be6e17 100644 --- a/src/main/java/net/minecraft/server/ItemFishingRod.java +++ b/src/main/java/net/minecraft/server/ItemFishingRod.java @@ -12,10 +12,10 @@ public class ItemFishingRod extends Item { public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { if (entityhuman.hookedFish != null) { - int i = entityhuman.hookedFish.h(); + int i = entityhuman.hookedFish.i(); itemstack.damage(i, entityhuman); - entityhuman.w(); + entityhuman.v(); } else { // CraftBukkit start PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null,PlayerFishEvent.State.FISHING); @@ -30,7 +30,7 @@ public class ItemFishingRod extends Item { world.addEntity(new EntityFish(world, entityhuman)); } - entityhuman.w(); + entityhuman.v(); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 97cfddaac1..56646bbb17 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -43,38 +43,42 @@ public class ItemFlintAndSteel extends Item { ++i; } - int i1 = world.getTypeId(i, j, k); + if (!entityhuman.c(i, j, k)) { + return false; + } else { + int i1 = world.getTypeId(i, j, k); - if (i1 == 0) { - // CraftBukkit start - store the clicked block - org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); - Player thePlayer = (Player) entityhuman.getBukkitEntity(); + if (i1 == 0) { + // CraftBukkit start - store the clicked block + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); + Player thePlayer = (Player) entityhuman.getBukkitEntity(); - BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, thePlayer); - world.getServer().getPluginManager().callEvent(eventIgnite); + BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, thePlayer); + world.getServer().getPluginManager().callEvent(eventIgnite); - if (eventIgnite.isCancelled()) { - itemstack.damage(1, entityhuman); - return false; + if (eventIgnite.isCancelled()) { + itemstack.damage(1, entityhuman); + return false; + } + + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); + // CraftBukkit end + + world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); + world.setTypeId(i, j, k, Block.FIRE.id); + + // CraftBukkit start + BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); + + if (placeEvent.isCancelled() || !placeEvent.canBuild()) { + placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); + return false; + } + // CraftBukkit end } - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); - // CraftBukkit end - - world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); - world.setTypeId(i, j, k, Block.FIRE.id); - - // CraftBukkit start - BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); - - if (placeEvent.isCancelled() || !placeEvent.canBuild()) { - placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); - return false; - } - // CraftBukkit end + itemstack.damage(1, entityhuman); + return true; } - - itemstack.damage(1, entityhuman); - return true; } } diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index 0885451607..318fcd75fc 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -15,33 +15,37 @@ public class ItemHoe extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - int i1 = world.getTypeId(i, j, k); - int j1 = world.getTypeId(i, j + 1, k); - - if ((l == 0 || j1 != 0 || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) { + if (!entityhuman.c(i, j, k)) { return false; } else { - Block block = Block.SOIL; + int i1 = world.getTypeId(i, j, k); + int j1 = world.getTypeId(i, j + 1, k); - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); - if (world.isStatic) { - return true; + if ((l == 0 || j1 != 0 || i1 != Block.GRASS.id) && i1 != Block.DIRT.id) { + return false; } else { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + Block block = Block.SOIL; - world.setTypeId(i, j, k, block.id); + world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); + if (world.isStatic) { + return true; + } else { + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - // CraftBukkit start - Hoes - blockface -1 for 'SELF' - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); + world.setTypeId(i, j, k, block.id); - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeId(blockState.getTypeId()); - return false; + // CraftBukkit start - Hoes - blockface -1 for 'SELF' + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); + + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeId(blockState.getTypeId()); + return false; + } + // CraftBukkit end + + itemstack.damage(1, entityhuman); + return true; } - // CraftBukkit end - - itemstack.damage(1, entityhuman); - return true; } } } diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 7e5df2145f..fef0758667 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -11,104 +11,139 @@ import org.bukkit.event.player.PlayerInteractEvent; public class ItemInWorldManager { - private WorldServer world; + public World world; public EntityHuman player; - private float c = 0.0F; + private int c = -1; + private float d = 0.0F; private int lastDigTick; - private int e; private int f; private int g; + private int h; private int currentTick; - private boolean i; - private int j; + private boolean j; private int k; private int l; private int m; + private int n; - public ItemInWorldManager(WorldServer worldserver) { - this.world = worldserver; + public ItemInWorldManager(World world) { + this.world = world; } - public void a() { + public void a(int i) { + this.c = i; + if (i == 0) { + this.player.K.c = false; + this.player.K.b = false; + this.player.K.d = false; + this.player.K.a = false; + } else { + this.player.K.c = true; + this.player.K.d = true; + this.player.K.a = true; + } + } + + public int a() { + return this.c; + } + + public boolean b() { + return this.c == 1; + } + + public void b(int i) { + if (this.c == -1) { + this.c = i; + } + + this.a(this.c); + } + + public void c() { this.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - if (this.i) { - int i = this.currentTick - this.m; - int j = this.world.getTypeId(this.j, this.k, this.l); + if (this.j) { + int i = this.currentTick - this.n; + int j = this.world.getTypeId(this.k, this.l, this.m); if (j != 0) { Block block = Block.byId[j]; float f = block.getDamage(this.player) * (float) (i + 1); if (f >= 1.0F) { - this.i = false; - this.c(this.j, this.k, this.l); + this.j = false; + this.c(this.k, this.l, this.m); } } else { - this.i = false; + this.j = false; } } } public void dig(int i, int j, int k, int l) { // this.world.douseFire((EntityHuman) null, i, j, k, l); // CraftBukkit - moved down - this.lastDigTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - int i1 = this.world.getTypeId(i, j, k); - - // CraftBukkit start - // Swings at air do *NOT* exist. - if (i1 <= 0) { - return; - } - - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand()); - - if (event.useInteractedBlock() == Event.Result.DENY) { - // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. - if (i1 == Block.WOODEN_DOOR.id) { - // For some reason *BOTH* the bottom/top part have to be marked updated. - boolean bottom = (this.world.getData(i, j, k) & 8) == 0; - ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); - ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.world)); - } else if (i1 == Block.TRAP_DOOR.id) { - ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); - } - } else { - Block.byId[i1].b(this.world, i, j, k, this.player); - // Allow fire punching to be blocked - this.world.douseFire((EntityHuman) null, i, j, k, l); - } - - // Handle hitting a block - float toolDamage = Block.byId[i1].getDamage(this.player); - if (event.useItemInHand() == Event.Result.DENY) { - // If we 'insta destroyed' then the client needs to be informed. - if (toolDamage > 1.0f) { - ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); - } - return; - } - BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), toolDamage >= 1.0f); - - if (blockEvent.isCancelled()) { - return; - } - - if (blockEvent.getInstaBreak()) { - toolDamage = 2.0f; - } - - if (toolDamage >= 1.0F) { - // CraftBukkit end + if (this.b()) { this.c(i, j, k); } else { - this.e = i; - this.f = j; - this.g = k; + this.lastDigTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit + int i1 = this.world.getTypeId(i, j, k); + + // CraftBukkit start + // Swings at air do *NOT* exist. + if (i1 <= 0) { + return; + } + + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand()); + + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + if (i1 == Block.WOODEN_DOOR.id) { + // For some reason *BOTH* the bottom/top part have to be marked updated. + boolean bottom = (this.world.getData(i, j, k) & 8) == 0; + ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); + ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j + (bottom ? 1 : -1), k, this.world)); + } else if (i1 == Block.TRAP_DOOR.id) { + ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); + } + } else { + Block.byId[i1].b(this.world, i, j, k, this.player); + // Allow fire punching to be blocked + this.world.douseFire((EntityHuman) null, i, j, k, l); + } + + // Handle hitting a block + float toolDamage = Block.byId[i1].getDamage(this.player); + if (event.useItemInHand() == Event.Result.DENY) { + // If we 'insta destroyed' then the client needs to be informed. + if (toolDamage > 1.0f) { + ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); + } + return; + } + BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), toolDamage >= 1.0f); + + if (blockEvent.isCancelled()) { + return; + } + + if (blockEvent.getInstaBreak()) { + toolDamage = 2.0f; + } + + if (toolDamage >= 1.0F) { + // CraftBukkit end + this.c(i, j, k); + } else { + this.f = i; + this.g = j; + this.h = k; + } } } public void a(int i, int j, int k) { - if (i == this.e && j == this.f && k == this.g) { + if (i == this.f && j == this.g && k == this.h) { this.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit int l = this.currentTick - this.lastDigTick; int i1 = this.world.getTypeId(i, j, k); @@ -119,12 +154,12 @@ public class ItemInWorldManager { if (f >= 0.7F) { this.c(i, j, k); - } else if (!this.i) { - this.i = true; - this.j = i; - this.k = j; - this.l = k; - this.m = this.lastDigTick; + } else if (!this.j) { + this.j = true; + this.k = i; + this.l = j; + this.m = k; + this.n = this.lastDigTick; } } // CraftBukkit start - force blockreset to client @@ -133,7 +168,7 @@ public class ItemInWorldManager { // CraftBukkit end } - this.c = 0.0F; + this.d = 0.0F; } public boolean b(int i, int j, int k) { @@ -167,19 +202,23 @@ public class ItemInWorldManager { this.world.a(this.player, 2001, i, j, k, l + this.world.getData(i, j, k) * 256); boolean flag = this.b(i, j, k); - ItemStack itemstack = this.player.G(); - if (itemstack != null) { - itemstack.a(l, i, j, k, this.player); - if (itemstack.count == 0) { - itemstack.a(this.player); - this.player.H(); - } - } - - if (flag && this.player.b(Block.byId[l])) { - Block.byId[l].a(this.world, this.player, i, j, k, i1); + if (this.b()) { ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); + } else { + ItemStack itemstack = this.player.K(); + + if (itemstack != null) { + itemstack.a(l, i, j, k, this.player); + if (itemstack.count == 0) { + itemstack.a(this.player); + this.player.L(); + } + } + + if (flag && this.player.b(Block.byId[l])) { + Block.byId[l].a(this.world, this.player, i, j, k, i1); + } } return flag; @@ -187,12 +226,18 @@ public class ItemInWorldManager { public boolean useItem(EntityHuman entityhuman, World world, ItemStack itemstack) { int i = itemstack.count; + int j = itemstack.getData(); ItemStack itemstack1 = itemstack.a(world, entityhuman); if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i)) { return false; } else { entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = itemstack1; + if (this.b()) { + itemstack1.count = i; + itemstack1.b(j); + } + if (itemstack1.count == 0) { entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null; } @@ -201,6 +246,7 @@ public class ItemInWorldManager { } } + // TODO: Review this code, it changed in 1.8 but I'm not sure if we need to update or not public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, int i, int j, int k, int l) { int i1 = world.getTypeId(i, j, k); @@ -231,4 +277,8 @@ public class ItemInWorldManager { return result; // CraftBukkit end } + + public void a(WorldServer worldserver) { + this.world = worldserver; + } } diff --git a/src/main/java/net/minecraft/server/ItemPainting.java b/src/main/java/net/minecraft/server/ItemPainting.java index 9ec87d0ebb..5985a6b4d6 100644 --- a/src/main/java/net/minecraft/server/ItemPainting.java +++ b/src/main/java/net/minecraft/server/ItemPainting.java @@ -32,30 +32,34 @@ public class ItemPainting extends Item { b0 = 3; } - EntityPainting entitypainting = new EntityPainting(world, i, j, k, b0); + if (!entityhuman.c(i, j, k)) { + return false; + } else { + EntityPainting entitypainting = new EntityPainting(world, i, j, k, b0); - if (entitypainting.h()) { - if (!world.isStatic) { - // CraftBukkit start - Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); + if (entitypainting.i()) { + if (!world.isStatic) { + // CraftBukkit start + Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); - org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.BlockFace blockFace = CraftBlock.notchToBlockFace(l); + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); + org.bukkit.block.BlockFace blockFace = CraftBlock.notchToBlockFace(l); - PaintingPlaceEvent event = new PaintingPlaceEvent((org.bukkit.entity.Painting) entitypainting.getBukkitEntity(), who, blockClicked, blockFace); - world.getServer().getPluginManager().callEvent(event); + PaintingPlaceEvent event = new PaintingPlaceEvent((org.bukkit.entity.Painting) entitypainting.getBukkitEntity(), who, blockClicked, blockFace); + world.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return false; + if (event.isCancelled()) { + return false; + } + // CraftBukkit end + world.addEntity(entitypainting); } - // CraftBukkit end - world.addEntity(entitypainting); + + --itemstack.count; } - --itemstack.count; + return true; } - - return true; } } } diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index f50305bd13..7f22ce18c5 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -45,25 +45,29 @@ public class ItemRedstone extends Item { } } - if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { - CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + if (!entityhuman.c(i, j, k)) { + return false; + } else { + if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit - We update after the event + world.setRawTypeId(i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit - We update after the event - // CraftBukkit start - redstone - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); + // CraftBukkit start - redstone + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); - return false; + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; + } + + world.update( i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks. + // CraftBukkit end + + --itemstack.count; // CraftBukkit - ORDER MATTERS } - world.update( i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks. - // CraftBukkit end - - --itemstack.count; // CraftBukkit - ORDER MATTERS + return true; } - - return true; } } diff --git a/src/main/java/net/minecraft/server/ItemReed.java b/src/main/java/net/minecraft/server/ItemReed.java index 2cfeac84b4..cb4c69071c 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -17,10 +17,11 @@ public class ItemReed extends Item { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + int i1 = world.getTypeId(i, j, k); - if (world.getTypeId(i, j, k) == Block.SNOW.id) { + if (i1 == Block.SNOW.id) { l = 0; - } else { + } else if (i1 != Block.VINE.id) { if (l == 0) { --j; } @@ -46,7 +47,9 @@ public class ItemReed extends Item { } } - if (itemstack.count == 0) { + if (!entityhuman.c(i, j, k)) { + return false; + } else if (itemstack.count == 0) { return false; } else { if (world.a(this.id, i, j, k, false, l)) { diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java index a45fd6b92e..0fb19e917a 100644 --- a/src/main/java/net/minecraft/server/ItemSeeds.java +++ b/src/main/java/net/minecraft/server/ItemSeeds.java @@ -18,7 +18,7 @@ public class ItemSeeds extends Item { public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { if (l != 1) { return false; - } else { + } else if (entityhuman.c(i, j, k) && entityhuman.c(i, j + 1, k)) { int i1 = world.getTypeId(i, j, k); if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) { @@ -40,6 +40,8 @@ public class ItemSeeds extends Item { } else { return false; } + } else { + return false; } } } diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index def29a9981..7aeaaff6e4 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -41,13 +41,17 @@ public class ItemSign extends Item { ++i; } - if (!Block.SIGN_POST.canPlace(world, i, j, k)) { + if (!entityhuman.c(i, j, k)) { + return false; + } else if (!Block.SIGN_POST.canPlace(world, i, j, k)) { return false; } else { CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit if (l == 1) { - world.setTypeIdAndData(i, j, k, Block.SIGN_POST.id, MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15); + int i1 = MathHelper.floor((double) ((entityhuman.yaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; + + world.setTypeIdAndData(i, j, k, Block.SIGN_POST.id, i1); } else { world.setTypeIdAndData(i, j, k, Block.WALL_SIGN.id, l); } diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index 243b974fc6..64d53648ba 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -38,9 +38,15 @@ public final class ItemStack { this.damage = k; } - public ItemStack(NBTTagCompound nbttagcompound) { + public static ItemStack a(NBTTagCompound nbttagcompound) { + ItemStack itemstack = new ItemStack(); + + itemstack.c(nbttagcompound); + return itemstack.getItem() != null ? itemstack : null; + } + + private ItemStack() { this.count = 0; - this.b(nbttagcompound); } public ItemStack a(int i) { @@ -70,14 +76,18 @@ public final class ItemStack { return this.getItem().a(this, world, entityhuman); } - public NBTTagCompound a(NBTTagCompound nbttagcompound) { + public ItemStack b(World world, EntityHuman entityhuman) { + return this.getItem().b(this, world, entityhuman); + } + + public NBTTagCompound b(NBTTagCompound nbttagcompound) { 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) { + public void c(NBTTagCompound nbttagcompound) { this.id = nbttagcompound.d("id"); this.count = nbttagcompound.c("Count"); this.damage = nbttagcompound.d("Damage"); @@ -183,12 +193,16 @@ public final class ItemStack { return this.id == itemstack.id && this.damage == itemstack.damage; } + public String k() { + return Item.byId[this.id].a(this); + } + public static ItemStack b(ItemStack itemstack) { return itemstack == null ? null : itemstack.cloneItemStack(); } public String toString() { - return this.count + "x" + Item.byId[this.id].a() + "@" + this.damage; + return this.count + "x" + Item.byId[this.id].b() + "@" + this.damage; } public void a(World world, Entity entity, int i, boolean flag) { @@ -199,12 +213,24 @@ public final class ItemStack { Item.byId[this.id].a(this, world, entity, i, flag); } - public void b(World world, EntityHuman entityhuman) { + public void c(World world, EntityHuman entityhuman) { entityhuman.a(StatisticList.D[this.id], this.count); - Item.byId[this.id].c(this, world, entityhuman); + Item.byId[this.id].d(this, world, entityhuman); } public boolean c(ItemStack itemstack) { return this.id == itemstack.id && this.count == itemstack.count && this.damage == itemstack.damage; } + + public int l() { + return this.getItem().c(this); + } + + public EnumAnimation m() { + return this.getItem().b(this); + } + + public void a(World world, EntityHuman entityhuman, int i) { + this.getItem().a(this, world, entityhuman, i); + } } diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java index 9ec729c2e2..8e7ac20440 100644 --- a/src/main/java/net/minecraft/server/ItemWorldMap.java +++ b/src/main/java/net/minecraft/server/ItemWorldMap.java @@ -21,13 +21,13 @@ public class ItemWorldMap extends ItemWorldMapBase { String s = "map_" + itemstack.getData(); worldmap = new WorldMap(s); - worldmap.b = world.q().c(); - worldmap.c = world.q().e(); + worldmap.b = world.p().c(); + worldmap.c = world.p().e(); worldmap.e = 3; worldmap.map = (byte) world.worldProvider.dimension; worldmap.a(); world.a(s, (WorldMapBase) worldmap); - + // CraftBukkit start MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); Bukkit.getServer().getPluginManager().callEvent(event); @@ -72,7 +72,6 @@ public class ItemWorldMap extends ItemWorldMapBase { byte b2 = 0; int[] aint = new int[256]; Chunk chunk = world.getChunkAtWorldCoords(i3, j3); - if (chunk.isEmpty()) continue; // CraftBukkit int k3 = i3 & 15; int l3 = j3 & 15; int i4 = 0; @@ -106,7 +105,7 @@ public class ItemWorldMap extends ItemWorldMapBase { j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3); if (j5 == 0) { flag1 = false; - } else if (k4 > 0 && j5 > 0 && Block.byId[j5].material.C == MaterialMapColor.b) { + } else if (k4 > 0 && j5 > 0 && Block.byId[j5].material.D == MaterialMapColor.b) { flag1 = false; } @@ -164,7 +163,7 @@ public class ItemWorldMap extends ItemWorldMapBase { i5 = 0; if (j4 > 0) { - MaterialMapColor materialmapcolor = Block.byId[j4].material.C; + MaterialMapColor materialmapcolor = Block.byId[j4].material.D; if (materialmapcolor == MaterialMapColor.n) { d2 = (double) i4 * 0.1D + (double) (k1 + j2 & 1) * 0.2D; @@ -225,7 +224,7 @@ public class ItemWorldMap extends ItemWorldMapBase { } } - public void c(ItemStack itemstack, World world, EntityHuman entityhuman) { + public void d(ItemStack itemstack, World world, EntityHuman entityhuman) { itemstack.b(world.b("map")); String s = "map_" + itemstack.getData(); WorldMap worldmap = new WorldMap(s); @@ -234,11 +233,11 @@ public class ItemWorldMap extends ItemWorldMapBase { worldmap.b = MathHelper.floor(entityhuman.locX); worldmap.c = MathHelper.floor(entityhuman.locZ); worldmap.e = 3; - worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit + worldmap.map = (byte) world.worldProvider.dimension; worldmap.a(); } - public Packet b(ItemStack itemstack, World world, EntityHuman entityhuman) { + public Packet c(ItemStack itemstack, World world, EntityHuman entityhuman) { byte[] abyte = this.a(itemstack, world).a(itemstack, world, entityhuman); return abyte == null ? null : new Packet131((short) Item.MAP.id, (short) itemstack.getData(), abyte); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index c232801a62..9d4125d16f 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -46,13 +46,14 @@ public class MinecraftServer implements Runnable, ICommandListener { int ticks = 0; public String i; public int j; - private List r = new ArrayList(); - private List s = Collections.synchronizedList(new ArrayList()); + private List s = new ArrayList(); + private List t = Collections.synchronizedList(new ArrayList()); // public EntityTracker[] tracker = new EntityTracker[2]; // CraftBukkit - removed! public boolean onlineMode; public boolean spawnAnimals; public boolean pvpMode; public boolean allowFlight; + public String p; // CraftBukkit start public List worlds = new ArrayList(); @@ -90,7 +91,7 @@ public class MinecraftServer implements Runnable, ICommandListener { System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true)); // CraftBukkit end - log.info("Starting minecraft server version Beta 1.7.3"); + log.info("Starting minecraft server version Beta 1.8"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { log.warning("**** NOT ENOUGH RAM!"); log.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); @@ -104,6 +105,8 @@ public class MinecraftServer implements Runnable, ICommandListener { this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true); this.pvpMode = this.propertyManager.getBoolean("pvp", true); this.allowFlight = this.propertyManager.getBoolean("allow-flight", false); + this.p = this.propertyManager.getString("motd", "A Minecraft Server"); + this.p.replace('\u00a7', '$'); InetAddress inetaddress = null; if (s.length() > 0) { @@ -168,17 +171,24 @@ public class MinecraftServer implements Runnable, ICommandListener { convertable.convert(s, new ConvertProgressUpdater(this)); } - // CraftBukkit start - for (int j = 0; j < (this.propertyManager.getBoolean("allow-nether", true) ? 2 : 1); ++j) { + // CraftBukkit - removed world array + int j = this.propertyManager.getInt("gamemode", 0); + + j = WorldSettings.a(j); + log.info("Default game type: " + j); + + // CraftBukkit start (+ removed worldsettings and servernbtmanager) + for (int k = 0; k < (this.propertyManager.getBoolean("allow-nether", true) ? 2 : 1); ++k) { WorldServer world; - int dimension = j == 0 ? 0 : -1; + int dimension = k == 0 ? 0 : -1; String worldType = Environment.getEnvironment(dimension).toString().toLowerCase(); String name = (dimension == 0) ? s : s + "_" + worldType; ChunkGenerator gen = this.server.getGenerator(name); + WorldSettings settings = new WorldSettings(i, j, true); - if (j == 0) { - world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, i, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit + if (k == 0) { + world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, settings, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit } else { String dim = "DIM-1"; @@ -208,7 +218,7 @@ public class MinecraftServer implements Runnable, ICommandListener { } } - world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, i, this.worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit + world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, settings, this.worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit } if (gen != null) { @@ -219,8 +229,9 @@ public class MinecraftServer implements Runnable, ICommandListener { world.tracker = new EntityTracker(this, dimension); world.addIWorldAccess(new WorldManager(this, world)); - world.spawnMonsters = this.propertyManager.getBoolean("spawn-monsters", true) ? 1 : 0; + world.spawnMonsters = this.propertyManager.getInt("difficulty", 1); world.setSpawnFlags(this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals); + world.p().d(j); this.worlds.add(world); this.serverConfigurationManager.setPlayerFileData(this.worlds.toArray(new WorldServer[0])); } @@ -256,7 +267,7 @@ public class MinecraftServer implements Runnable, ICommandListener { worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + i1 >> 4, chunkcoordinates.z + j1 >> 4); - while (worldserver.doLighting() && this.isRunning) { + while (worldserver.v() && this.isRunning) { ; } } @@ -442,7 +453,7 @@ public class MinecraftServer implements Runnable, ICommandListener { worldserver.doTick(); - while (worldserver.doLighting()) { + while (worldserver.v()) { ; } @@ -459,8 +470,8 @@ public class MinecraftServer implements Runnable, ICommandListener { } // CraftBukkit end - for (j = 0; j < this.r.size(); ++j) { - ((IUpdatePlayerListBox) this.r.get(j)).a(); + for (j = 0; j < this.s.size(); ++j) { + ((IUpdatePlayerListBox) this.s.get(j)).a(); } try { @@ -471,12 +482,12 @@ public class MinecraftServer implements Runnable, ICommandListener { } public void issueCommand(String s, ICommandListener icommandlistener) { - this.s.add(new ServerCommand(s, icommandlistener)); + this.t.add(new ServerCommand(s, icommandlistener)); } public void b() { - while (this.s.size() > 0) { - ServerCommand servercommand = (ServerCommand) this.s.remove(0); + while (this.t.size() > 0) { + ServerCommand servercommand = (ServerCommand) this.t.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); @@ -490,7 +501,7 @@ public class MinecraftServer implements Runnable, ICommandListener { } public void a(IUpdatePlayerListBox iupdateplayerlistbox) { - this.r.add(iupdateplayerlistbox); + this.s.add(iupdateplayerlistbox); } public static void main(final OptionSet options) { // CraftBukkit - replaces main(String args[]) diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index 99e775b8bd..0b28759a70 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -1,6 +1,7 @@ package net.minecraft.server; import java.net.Socket; +import java.util.Iterator; import java.util.Random; import java.util.logging.Logger; @@ -63,8 +64,8 @@ public class NetLoginHandler extends NetHandler { public void a(Packet1Login packet1login) { this.g = packet1login.name; - if (packet1login.a != 14) { - if (packet1login.a > 14) { + if (packet1login.a != 17) { + if (packet1login.a > 17) { this.disconnect("Outdated server!"); } else { this.disconnect("Outdated client!"); @@ -85,12 +86,24 @@ public class NetLoginHandler extends NetHandler { this.server.serverConfigurationManager.b(entityplayer); // entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity // CraftBukkit - add world and location to 'logged in' message. + entityplayer.itemInWorldManager.a((WorldServer) entityplayer.world); a.info(this.b() + " logged in with entity id " + entityplayer.id + " at ([" + entityplayer.world.worldData.name + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); + + entityplayer.itemInWorldManager.b(worldserver.p().n()); NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); - netserverhandler.sendPacket(new Packet1Login("", entityplayer.id, worldserver.getSeed(), (byte) worldserver.worldProvider.dimension)); + int i = entityplayer.id; + long j = worldserver.getSeed(); + int k = entityplayer.itemInWorldManager.a(); + byte b0 = (byte) worldserver.worldProvider.dimension; + byte b1 = (byte) worldserver.spawnMonsters; + + worldserver.getClass(); + Packet1Login packet1login1 = new Packet1Login("", i, j, k, b0, b1, (byte) -128, (byte) this.server.serverConfigurationManager.h()); + + netserverhandler.sendPacket(packet1login1); netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); this.server.serverConfigurationManager.a(entityplayer, worldserver); // this.server.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - message moved to join event @@ -98,6 +111,14 @@ public class NetLoginHandler extends NetHandler { netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.server.networkListenThread.a(netserverhandler); netserverhandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // CraftBukkit - add support for player specific time + Iterator iterator = entityplayer.ak().iterator(); + + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + + netserverhandler.sendPacket(new Packet41MobEffect(entityplayer.id, mobeffect)); + } + entityplayer.syncInventory(); } @@ -109,6 +130,19 @@ public class NetLoginHandler extends NetHandler { this.c = true; } + public void a(Packet254GetInfo packet254getinfo) { + try { + String s = this.server.p + "\u00A7" + this.server.serverConfigurationManager.g() + "\u00A7" + this.server.serverConfigurationManager.h(); + + this.networkManager.queue(new Packet255KickDisconnect(s)); + this.networkManager.d(); + this.server.networkListenThread.a(this.networkManager.f()); + this.c = true; + } catch (Exception exception) { + exception.printStackTrace(); + } + } + public void a(Packet packet) { this.disconnect("Protocol error"); } diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index a824131191..0d7e9c40fd 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -1,8 +1,7 @@ package net.minecraft.server; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.Random; import java.util.logging.Logger; // CraftBukkit start @@ -41,13 +40,16 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public EntityPlayer player; // CraftBukkit - private -> public private int f; private int g; - private int h; - private boolean i; + private boolean h; + private int i; + private long j; + private static Random k = new Random(); + private long l; private double x; private double y; private double z; private boolean checkMovement = true; - private Map n = new HashMap(); + private EntityList q = new EntityList(); public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; @@ -85,10 +87,14 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // CraftBukkit end public void a() { - this.i = false; + this.h = false; + ++this.f; this.networkManager.b(); - if (this.f - this.g > 20) { - this.sendPacket(new Packet0KeepAlive()); + if ((long) this.f - this.l > 20L) { + this.l = (long) this.f; + this.j = System.nanoTime() / 1000000L; + this.i = k.nextInt(); + this.sendPacket(new Packet0KeepAlive(this.i)); } } @@ -107,7 +113,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { s = event.getReason(); // CraftBukkit end - this.player.B(); + this.player.A(); this.sendPacket(new Packet255KickDisconnect(s)); this.networkManager.d(); @@ -129,7 +135,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public void a(Packet10Flying packet10flying) { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - this.i = true; + this.h = true; double d0; if (!this.checkMovement) { @@ -214,7 +220,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { float f = this.player.yaw; float f1 = this.player.pitch; - this.player.vehicle.f(); + this.player.vehicle.g_(); d1 = this.player.locX; d2 = this.player.locY; d3 = this.player.locZ; @@ -232,7 +238,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } this.player.onGround = packet10flying.g; - this.player.a(true); + this.player.b(true); this.player.move(d5, 0.0D, d4); this.player.setLocation(d1, d2, d3, f, f1); this.player.motX = d5; @@ -242,7 +248,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } if (this.player.vehicle != null) { - this.player.vehicle.f(); + this.player.vehicle.g_(); } this.minecraftServer.serverConfigurationManager.d(this.player); @@ -254,7 +260,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } if (this.player.isSleeping()) { - this.player.a(true); + this.player.b(true); this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch); worldserver.playerJoinedWorld(this.player); return; @@ -296,8 +302,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { f3 = packet10flying.pitch; } - this.player.a(true); - this.player.br = 0.0F; + this.player.b(true); + this.player.bH = 0.0F; this.player.setLocation(this.x, this.y, this.z, f2, f3); if (!this.checkMovement) { return; @@ -308,7 +314,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { double d7 = d3 - this.player.locZ; double d8 = d4 * d4 + d6 * d6 + d7 * d7; - if (d8 > 200.0D && this.checkMovement) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports + if (d8 > 100.0D && this.checkMovement) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports a.warning(this.player.name + " moved too quickly!"); this.disconnect("You moved too quickly :( (Hacking?)"); return; @@ -317,7 +323,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener { float f4 = 0.0625F; boolean flag = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0; + if (this.player.onGround && !packet10flying.g && d6 > 0.0D) { + this.player.b(0.2F); + } + this.player.move(d4, d6, d7); + this.player.onGround = packet10flying.g; + this.player.a(d4, d6, d7); d4 = d1 - this.player.locX; d6 = d2 - this.player.locY; if (d6 > -0.5D || d6 < 0.5D) { @@ -328,7 +340,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { d8 = d4 * d4 + d6 * d6 + d7 * d7; boolean flag1 = false; - if (d8 > 0.0625D && !this.player.isSleeping()) { + if (d8 > 0.0625D && !this.player.isSleeping() && !this.player.itemInWorldManager.b()) { flag1 = true; a.warning(this.player.name + " moved wrongly!"); System.out.println("Got position " + d1 + ", " + d2 + ", " + d3); @@ -345,17 +357,17 @@ public class NetServerHandler extends NetHandler implements ICommandListener { AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().b((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D); - if (!this.minecraftServer.allowFlight && !worldserver.b(axisalignedbb)) { + if (!this.minecraftServer.allowFlight && !this.player.itemInWorldManager.b() && !worldserver.b(axisalignedbb)) { if (d6 >= -0.03125D) { - ++this.h; - if (this.h > 80) { + ++this.g; + if (this.g > 80) { a.warning(this.player.name + " was kicked for floating too long!"); this.disconnect("Flying is not enabled on this server"); return; } } } else { - this.h = 0; + this.g = 0; } this.player.onGround = packet10flying.g; @@ -419,6 +431,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); if (packet14blockdig.e == 4) { + this.player.J(); + } else if (packet14blockdig.e == 5) { // CraftBukkit start // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. if (this.lastDropTick != MinecraftServer.currentTick) { @@ -433,7 +447,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } // CraftBukkit end - this.player.F(); + this.player.E(); } else { boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit boolean flag1 = false; @@ -446,6 +460,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener { flag1 = true; } + if (this.player.itemInWorldManager.b()) { + flag1 = false; + } + int i = packet14blockdig.a; int j = packet14blockdig.b; int k = packet14blockdig.c; @@ -462,8 +480,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - int l = (int) MathHelper.abs((float) (i - chunkcoordinates.x)); - int i1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z)); + int l = MathHelper.a(i - chunkcoordinates.x); + int i1 = MathHelper.a(k - chunkcoordinates.z); if (l > i1) { i1 = l; @@ -474,7 +492,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (i1 < this.server.getSpawnRadius() && !flag) { this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver)); } else { - // CraftBukkit - add face argument this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face); } } else if (packet14blockdig.e == 2) { @@ -554,8 +571,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { int k = packet15place.c; int l = packet15place.face; ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); - int i1 = (int) MathHelper.abs((float) (i - chunkcoordinates.x)); - int j1 = (int) MathHelper.abs((float) (k - chunkcoordinates.z)); + int i1 = MathHelper.a(i - chunkcoordinates.x); + int j1 = MathHelper.a(k - chunkcoordinates.z); if (i1 > j1) { j1 = i1; @@ -604,17 +621,20 @@ public class NetServerHandler extends NetHandler implements ICommandListener { itemstack = this.player.inventory.getItemInHand(); if (itemstack != null && itemstack.count == 0) { this.player.inventory.items[this.player.inventory.itemInHandIndex] = null; + itemstack = null; } - this.player.h = true; - this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]); - Slot slot = this.player.activeContainer.a(this.player.inventory, this.player.inventory.itemInHandIndex); + if (itemstack == null || itemstack.l() == 0) { + this.player.h = true; + this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]); + Slot slot = this.player.activeContainer.a(this.player.inventory, this.player.inventory.itemInHandIndex); - this.player.activeContainer.a(); - this.player.h = false; - // CraftBukkit - if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) { - this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.a, this.player.inventory.getItemInHand())); + this.player.activeContainer.a(); + this.player.h = false; + // CraftBukkit | TODO CHECK IF NEEDED -- new if structure might not need 'always'. Kept it in for now, but may be able to remove in future + if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) { + this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.b, this.player.inventory.getItemInHand())); + } } worldserver.weirdIsOpCache = false; @@ -663,7 +683,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public void a(Packet16BlockItemSwitch packet16blockitemswitch) { if (this.player.dead) return; // CraftBukkit - if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex <= InventoryPlayer.e()) { + if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex <= InventoryPlayer.g()) { // CraftBukkit start PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex); this.server.getPluginManager().callEvent(event); @@ -749,7 +769,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { a.info(s); this.minecraftServer.serverConfigurationManager.sendAll(new Packet3Chat(s)); } else if (s.toLowerCase().startsWith("/kill")) { - this.player.damageEntity(this.player, 1000); // CraftBukkit - replace null entity with player entity; TODO: decide if we want damage with a null source to fire an event. + this.player.damageEntity(DamageSource.j, 1000); } else if (s.toLowerCase().startsWith("/tell ")) { String[] astring = s.split(" "); @@ -811,7 +831,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (event.isCancelled()) return; // CraftBukkit end - this.player.w(); + this.player.v(); } } @@ -833,6 +853,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.player.setSneak(true); } else if (packet19entityaction.animation == 2) { this.player.setSneak(false); + } else if (packet19entityaction.animation == 4) { + this.player.g(true); + } else if (packet19entityaction.animation == 5) { + this.player.g(false); } else if (packet19entityaction.animation == 3) { this.player.a(false, true, true); this.checkMovement = false; @@ -860,9 +884,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = worldserver.getEntity(packet7useentity.target); - ItemStack itemInHand = this.player.inventory.getItemInHand(); - if (entity != null && this.player.e(entity) && this.player.g(entity) < 36.0D) { + if (entity != null && this.player.f(entity) && this.player.h(entity) < 36.0D) { + ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit if (packet7useentity.c == 0) { // CraftBukkit start PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity()); @@ -900,7 +924,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { public void a(Packet101CloseWindow packet101closewindow) { if (this.player.dead) return; // CraftBukkit - this.player.A(); + this.player.z(); } public void a(Packet102WindowClick packet102windowclick) { @@ -913,10 +937,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true)); this.player.h = true; this.player.activeContainer.a(); - this.player.z(); + this.player.y(); this.player.h = false; } else { - this.n.put(Integer.valueOf(this.player.activeContainer.windowId), Short.valueOf(packet102windowclick.d)); + this.q.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d)); this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false)); this.player.activeContainer.a(this.player, false); ArrayList arraylist = new ArrayList(); @@ -930,10 +954,29 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } + public void a(Packet107SetCreativeSlot packet107setcreativeslot) { + if (this.player.itemInWorldManager.b()) { + boolean flag = packet107setcreativeslot.a >= 36 && packet107setcreativeslot.a < 36 + InventoryPlayer.g(); + boolean flag1 = packet107setcreativeslot.b >= -1 && packet107setcreativeslot.b < Item.byId.length && (packet107setcreativeslot.b < 0 || Item.byId[packet107setcreativeslot.b] != null); + boolean flag2 = packet107setcreativeslot.d >= 0 && packet107setcreativeslot.c >= 0 && packet107setcreativeslot.c <= 64; + + if (flag && flag1 && flag2) { + if (packet107setcreativeslot.b <= 0) { + this.player.defaultContainer.a(packet107setcreativeslot.a, (ItemStack) null); + } else { + this.player.defaultContainer.a(packet107setcreativeslot.a, new ItemStack(packet107setcreativeslot.b, packet107setcreativeslot.c, packet107setcreativeslot.d)); + } + + this.player.defaultContainer.a(this.player, true); + } else if (!flag && flag1 && flag2 && packet107setcreativeslot.a == -1 && packet107setcreativeslot.b > 0) { + this.player.b(new ItemStack(packet107setcreativeslot.b, packet107setcreativeslot.c, packet107setcreativeslot.d)); + } + } + } + public void a(Packet106Transaction packet106transaction) { if (this.player.dead) return; // CraftBukkit - - Short oshort = (Short) this.n.get(Integer.valueOf(this.player.activeContainer.windowId)); + Short oshort = (Short) this.q.a(this.player.activeContainer.windowId); if (oshort != null && packet106transaction.b == oshort.shortValue() && this.player.activeContainer.windowId == packet106transaction.a && !this.player.activeContainer.c(this.player)) { this.player.activeContainer.a(this.player, true); @@ -996,7 +1039,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { for (int l = 0; l < 4; ++l) { tileentitysign1.lines[l] = event.getLine(l); } - tileentitysign1.a(false); + tileentitysign1.isEditable = true; } // CraftBukkit end @@ -1006,6 +1049,14 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } + public void a(Packet0KeepAlive packet0keepalive) { + if (packet0keepalive.a == this.i) { + int i = (int) (System.nanoTime() / 1000000L - this.x); + + this.player.i = (this.player.i * 3 + i) / 4; + } + } + public boolean c() { return true; } diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 11cf7db87b..f7b56f7429 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -88,7 +88,7 @@ public class NetworkManager { } } - private boolean f() { + private boolean g() { boolean flag = false; try { @@ -142,7 +142,7 @@ public class NetworkManager { this.r.interrupt(); } - private boolean g() { + private boolean h() { boolean flag = false; try { @@ -218,7 +218,7 @@ public class NetworkManager { this.w = 0; } - int i = 100; + int i = 1000; while (!this.m.isEmpty() && i-- >= 0) { Packet packet = (Packet) this.m.remove(0); @@ -247,6 +247,10 @@ public class NetworkManager { return this.lowPriorityQueue.size(); } + public Socket f() { + return this.socket; + } + static boolean a(NetworkManager networkmanager) { return networkmanager.l; } @@ -256,11 +260,11 @@ public class NetworkManager { } static boolean c(NetworkManager networkmanager) { - return networkmanager.g(); + return networkmanager.h(); } static boolean d(NetworkManager networkmanager) { - return networkmanager.f(); + return networkmanager.g(); } static DataOutputStream e(NetworkManager networkmanager) { diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java index f83acc410e..06475164ba 100644 --- a/src/main/java/net/minecraft/server/Packet.java +++ b/src/main/java/net/minecraft/server/Packet.java @@ -11,24 +11,24 @@ import java.util.Set; public abstract class Packet { - private static Map a = new HashMap(); + private static EntityList a = new EntityList(); private static Map b = new HashMap(); private static Set c = new HashSet(); private static Set d = new HashSet(); public final long timestamp = System.currentTimeMillis(); public boolean k = false; - private static HashMap e; + private static EntityList e; private static int f; public Packet() {} static void a(int i, boolean flag, boolean flag1, Class oclass) { - if (a.containsKey(Integer.valueOf(i))) { + if (a.b(i)) { throw new IllegalArgumentException("Duplicate packet id:" + i); } else if (b.containsKey(oclass)) { throw new IllegalArgumentException("Duplicate packet class:" + oclass); } else { - a.put(Integer.valueOf(i), oclass); + a.a(i, oclass); b.put(oclass, Integer.valueOf(i)); if (flag) { c.add(Integer.valueOf(i)); @@ -42,7 +42,7 @@ public abstract class Packet { public static Packet a(int i) { try { - Class oclass = (Class) a.get(Integer.valueOf(i)); + Class oclass = (Class) a.a(i); return oclass == null ? null : (Packet) oclass.newInstance(); } catch (Exception exception) { @@ -94,11 +94,11 @@ public abstract class Packet { } // CraftBukkit end - PacketCounter packetcounter = (PacketCounter) e.get(Integer.valueOf(i)); + PacketCounter packetcounter = (PacketCounter) e.a(i); if (packetcounter == null) { packetcounter = new PacketCounter((EmptyClass1) null); - e.put(Integer.valueOf(i), packetcounter); + e.a(i, packetcounter); } packetcounter.a(packet.a()); @@ -180,6 +180,7 @@ public abstract class Packet { a(23, true, false, Packet23VehicleSpawn.class); a(24, true, false, Packet24MobSpawn.class); a(25, true, false, Packet25EntityPainting.class); + a(26, true, false, Packet26AddExpOrb.class); a(27, false, false, Packet27.class); // CraftBukkit - true -> false; disabled unused packet. TODO -- check if needed a(28, true, false, Packet28EntityVelocity.class); a(29, true, false, Packet29DestroyEntity.class); @@ -191,6 +192,9 @@ public abstract class Packet { a(38, true, false, Packet38EntityStatus.class); a(39, true, false, Packet39AttachEntity.class); a(40, true, false, Packet40EntityMetadata.class); + a(41, true, false, Packet41MobEffect.class); + a(42, true, false, Packet42RemoveMobEffect.class); + a(43, true, false, Packet43SetExperience.class); a(50, true, false, Packet50PreChunk.class); a(51, true, false, Packet51MapChunk.class); a(52, true, false, Packet52MultiBlockChange.class); @@ -207,11 +211,14 @@ public abstract class Packet { a(104, true, false, Packet104WindowItems.class); a(105, true, false, Packet105CraftProgressBar.class); a(106, true, true, Packet106Transaction.class); + a(107, true, true, Packet107SetCreativeSlot.class); a(130, true, true, Packet130UpdateSign.class); a(131, true, false, Packet131.class); a(200, true, false, Packet200Statistic.class); + a(201, true, false, Packet201PlayerInfo.class); + a(254, false, true, Packet254GetInfo.class); a(255, true, true, Packet255KickDisconnect.class); - e = new HashMap(); + e = new EntityList(); f = 0; } } diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index 3c7706d572..7bc2699046 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -52,7 +52,7 @@ class PlayerInstance { if (this.b.size() == 0) { long i = (long) this.chunkX + 2147483647L | (long) this.chunkZ + 2147483647L << 32; - PlayerManager.a(this.playerManager).b(i); + PlayerManager.a(this.playerManager).d(i); if (this.dirtyCount > 0) { PlayerManager.b(this.playerManager).remove(this); } @@ -182,7 +182,7 @@ class PlayerInstance { private void sendTileEntity(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.f(); + Packet packet = tileentity.l(); if (packet != null) { this.sendAll(packet); diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java index 90683d73e6..5d8c833c73 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -37,7 +37,9 @@ public class PortalTravelAgent { for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { double d3 = (double) k1 + 0.5D - entity.locZ; - for (int l1 = 127; l1 >= 0; --l1) { + world.getClass(); + + for (int l1 = 128 - 1; l1 >= 0; --l1) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { --l1; @@ -119,9 +121,10 @@ public class PortalTravelAgent { for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - entity.locZ; + world.getClass(); - label271: - for (l2 = 127; l2 >= 0; --l2) { + label274: + for (l2 = 128 - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -143,7 +146,7 @@ public class PortalTravelAgent { int l4 = j2 + (k3 - 1) * i3 - l3 * j3; if (j4 < 0 && !world.getMaterial(i4, k4, l4).isBuildable() || j4 >= 0 && !world.isEmpty(i4, k4, l4)) { - continue label271; + continue label274; } } } @@ -170,11 +173,12 @@ public class PortalTravelAgent { for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - entity.locZ; + world.getClass(); - label219: - for (l2 = 127; l2 >= 0; --l2) { + label222: + for (l2 = 128 - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { - while (world.isEmpty(i2, l2 - 1, j2)) { + while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; } @@ -188,7 +192,7 @@ public class PortalTravelAgent { i4 = l2 + k3; k4 = j2 + (l3 - 1) * i3; if (k3 < 0 && !world.getMaterial(j4, i4, k4).isBuildable() || k3 >= 0 && !world.isEmpty(j4, i4, k4)) { - continue label219; + continue label222; } } } @@ -275,8 +279,10 @@ public class PortalTravelAgent { i1 = 70; } - if (i1 > 118) { - i1 = 118; + world.getClass(); + if (i1 > 128 - 10) { + world.getClass(); + i1 = 128 - 10; } j5 = i1; diff --git a/src/main/java/net/minecraft/server/SecondaryWorldServer.java b/src/main/java/net/minecraft/server/SecondaryWorldServer.java index 1f6ff334ed..086ba36108 100644 --- a/src/main/java/net/minecraft/server/SecondaryWorldServer.java +++ b/src/main/java/net/minecraft/server/SecondaryWorldServer.java @@ -4,8 +4,8 @@ import org.bukkit.generator.ChunkGenerator; // CraftBukkit public class SecondaryWorldServer extends WorldServer { // CraftBukkit start - public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, WorldServer worldserver, org.bukkit.World.Environment env, ChunkGenerator gen) { - super(minecraftserver, idatamanager, s, i, j, env, gen); + public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, WorldSettings worldsettings, WorldServer worldserver, org.bukkit.World.Environment env, ChunkGenerator gen) { + super(minecraftserver, idatamanager, s, i, worldsettings, env, gen); // CraftBukkit end this.worldMaps = worldserver.worldMaps; } diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 981f058af3..39353b1d3e 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -43,6 +43,7 @@ public class ServerConfigurationManager { private File m; public PlayerFileData playerFileData; // CraftBukkit - private - >public public boolean o; // Craftbukkit - private -> public + private int p = 0; // CraftBukkit start private CraftServer cserver; @@ -63,19 +64,19 @@ public class ServerConfigurationManager { // CraftBukkit - removed playermanagers this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20); this.o = minecraftserver.propertyManager.getBoolean("white-list", false); - this.g(); this.i(); this.k(); this.m(); - this.h(); + this.o(); this.j(); this.l(); this.n(); + this.p(); } public void setPlayerFileData(WorldServer[] aworldserver) { if (this.playerFileData != null) return; // CraftBukkit - this.playerFileData = aworldserver[0].p().d(); + this.playerFileData = aworldserver[0].o().d(); } public void a(EntityPlayer entityplayer) { @@ -110,6 +111,7 @@ public class ServerConfigurationManager { } public void c(EntityPlayer entityplayer) { + this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, 1000)); this.players.add(entityplayer); WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); @@ -132,6 +134,12 @@ public class ServerConfigurationManager { worldserver.addEntity(entityplayer); this.getPlayerManager(entityplayer.dimension).addPlayer(entityplayer); + + for (int i = 0; i < this.players.size(); ++i) { + EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); + + entityplayer.netServerHandler.sendPacket(new Packet201PlayerInfo(entityplayer1.name, true, entityplayer1.i)); + } } public void d(EntityPlayer entityplayer) { @@ -150,6 +158,7 @@ public class ServerConfigurationManager { this.server.getWorldServer(entityplayer.dimension).kill(entityplayer); this.players.remove(entityplayer); this.getPlayerManager(entityplayer.dimension).removePlayer(entityplayer); + this.sendAll(new Packet201PlayerInfo(entityplayer.name, false, 9999)); return playerQuitEvent.getQuitMessage(); // CraftBukkit } @@ -224,7 +233,7 @@ public class ServerConfigurationManager { isBedSpawn = true; location = new Location(cworld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5); } else { - entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0)); + entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0, 0)); } } @@ -257,8 +266,7 @@ public class ServerConfigurationManager { // CraftBukkit start byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId()); - entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0))); - entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension)); + entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension, (byte)entityplayer1.world.spawnMonsters, entityplayer1.world.getSeed(), 128, entityplayer1.itemInWorldManager.a())); entityplayer1.spawnIn(worldserver); entityplayer1.dead = false; entityplayer1.netServerHandler.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch)); @@ -268,7 +276,7 @@ public class ServerConfigurationManager { worldserver.addEntity(entityplayer1); this.players.add(entityplayer1); this.updateClient(entityplayer1); // CraftBukkit - entityplayer1.x(); + entityplayer1.w(); return entityplayer1; } @@ -307,8 +315,18 @@ public class ServerConfigurationManager { } public void b() { + int i; + + if (this.p-- <= 0) { + for (i = 0; i < this.players.size(); ++i) { + EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); + + this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.i)); + } + } + // CraftBukkit start - for (int i = 0; i < this.server.worlds.size(); ++i) { + for (i = 0; i < this.server.worlds.size(); ++i) { this.server.worlds.get(i).manager.flush(); } // CraftBukkit end @@ -352,15 +370,15 @@ public class ServerConfigurationManager { public void a(String s) { this.banByName.add(s.toLowerCase()); - this.h(); + this.j(); } public void b(String s) { this.banByName.remove(s.toLowerCase()); - this.h(); + this.j(); } - private void g() { + private void i() { try { this.banByName.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j)); @@ -376,7 +394,7 @@ public class ServerConfigurationManager { } } - private void h() { + private void j() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false)); Iterator iterator = this.banByName.iterator(); @@ -395,15 +413,15 @@ public class ServerConfigurationManager { public void c(String s) { this.banByIP.add(s.toLowerCase()); - this.j(); + this.l(); } public void d(String s) { this.banByIP.remove(s.toLowerCase()); - this.j(); + this.l(); } - private void i() { + private void k() { try { this.banByIP.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k)); @@ -419,7 +437,7 @@ public class ServerConfigurationManager { } } - private void j() { + private void l() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false)); Iterator iterator = this.banByIP.iterator(); @@ -438,7 +456,7 @@ public class ServerConfigurationManager { public void e(String s) { this.h.add(s.toLowerCase()); - this.l(); + this.n(); // Craftbukkit start Player player = server.server.getPlayer(s); @@ -450,7 +468,7 @@ public class ServerConfigurationManager { public void f(String s) { this.h.remove(s.toLowerCase()); - this.l(); + this.n(); // Craftbukkit start Player player = server.server.getPlayer(s); @@ -460,7 +478,7 @@ public class ServerConfigurationManager { // Craftbukkit end } - private void k() { + private void m() { try { this.h.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.l)); @@ -477,7 +495,7 @@ public class ServerConfigurationManager { } } - private void l() { + private void n() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.l, false)); Iterator iterator = this.h.iterator(); @@ -495,7 +513,7 @@ public class ServerConfigurationManager { } } - private void m() { + private void o() { try { this.i.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.m)); @@ -511,7 +529,7 @@ public class ServerConfigurationManager { } } - private void n() { + private void p() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.m, false)); Iterator iterator = this.i.iterator(); @@ -610,12 +628,12 @@ public class ServerConfigurationManager { public void k(String s) { this.i.add(s); - this.n(); + this.p(); } public void l(String s) { this.i.remove(s); - this.n(); + this.p(); } public Set e() { @@ -623,18 +641,26 @@ public class ServerConfigurationManager { } public void f() { - this.m(); + this.o(); } public void a(EntityPlayer entityplayer, WorldServer worldserver) { entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(worldserver.getTime())); - if (worldserver.v()) { - entityplayer.netServerHandler.sendPacket(new Packet70Bed(1)); + if (worldserver.u()) { + entityplayer.netServerHandler.sendPacket(new Packet70Bed(1, 0)); } } public void updateClient(EntityPlayer entityplayer) { entityplayer.updateInventory(entityplayer.defaultContainer); - entityplayer.C(); + entityplayer.B(); + } + + public int g() { + return this.players.size(); + } + + public int h() { + return this.maxPlayers; } } diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java index 18cc6a5734..58849856f7 100644 --- a/src/main/java/net/minecraft/server/Slot.java +++ b/src/main/java/net/minecraft/server/Slot.java @@ -3,16 +3,16 @@ package net.minecraft.server; public class Slot { public final int index; // CraftBukkit - private -> public - public final IInventory inventory; // CraftBukkit - private -> public - public int a; + public final IInventory inventory; public int b; public int c; + public int d; public Slot(IInventory iinventory, int i, int j, int k) { this.inventory = iinventory; this.index = i; - this.b = j; - this.c = k; + this.c = j; + this.d = k; } public void a(ItemStack itemstack) { diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java index fda0a0909f..e74ca37c49 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -1,8 +1,10 @@ package net.minecraft.server; +import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Random; import java.util.Set; // CraftBukkit @@ -17,7 +19,10 @@ public final class SpawnerCreature { protected static ChunkPosition a(World world, int i, int j) { int k = i + world.random.nextInt(16); - int l = world.random.nextInt(128); + Random random = world.random; + + world.getClass(); + int l = random.nextInt(128); int i1 = j + world.random.nextInt(16); return new ChunkPosition(k, l, i1); @@ -58,58 +63,36 @@ public final class SpawnerCreature { if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * b.size() / 256) { Iterator iterator = b.iterator(); - label113: + label91: while (iterator.hasNext()) { ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); BiomeBase biomebase = world.getWorldChunkManager().a(chunkcoordintpair); List list = biomebase.a(enumcreaturetype); if (list != null && !list.isEmpty()) { - int k1 = 0; - - BiomeMeta biomemeta; - - for (Iterator iterator1 = list.iterator(); iterator1.hasNext(); k1 += biomemeta.b) { - biomemeta = (BiomeMeta) iterator1.next(); - } - - int l1 = world.random.nextInt(k1); - - biomemeta = (BiomeMeta) list.get(0); - Iterator iterator2 = list.iterator(); - - while (iterator2.hasNext()) { - BiomeMeta biomemeta1 = (BiomeMeta) iterator2.next(); - - l1 -= biomemeta1.b; - if (l1 < 0) { - biomemeta = biomemeta1; - break; - } - } - + BiomeMeta biomemeta = (BiomeMeta) WeightedRandom.a(world.random, (Collection) list); ChunkPosition chunkposition = a(world, chunkcoordintpair.x * 16, chunkcoordintpair.z * 16); - int i2 = chunkposition.x; - int j2 = chunkposition.y; - int k2 = chunkposition.z; + int k1 = chunkposition.x; + int l1 = chunkposition.y; + int i2 = chunkposition.z; - if (!world.e(i2, j2, k2) && world.getMaterial(i2, j2, k2) == enumcreaturetype.c()) { - int l2 = 0; + if (!world.e(k1, l1, i2) && world.getMaterial(k1, l1, i2) == enumcreaturetype.c()) { + int j2 = 0; - for (int i3 = 0; i3 < 3; ++i3) { + for (int k2 = 0; k2 < 3; ++k2) { + int l2 = k1; + int i3 = l1; int j3 = i2; - int k3 = j2; - int l3 = k2; byte b1 = 6; - for (int i4 = 0; i4 < 4; ++i4) { + for (int k3 = 0; k3 < 4; ++k3) { + l2 += world.random.nextInt(b1) - world.random.nextInt(b1); + i3 += world.random.nextInt(1) - world.random.nextInt(1); j3 += world.random.nextInt(b1) - world.random.nextInt(b1); - k3 += world.random.nextInt(1) - world.random.nextInt(1); - l3 += world.random.nextInt(b1) - world.random.nextInt(b1); - if (a(enumcreaturetype, world, j3, k3, l3)) { - float f = (float) j3 + 0.5F; - float f1 = (float) k3; - float f2 = (float) l3 + 0.5F; + if (a(enumcreaturetype, world, l2, i3, j3)) { + float f = (float) l2 + 0.5F; + float f1 = (float) i3; + float f2 = (float) j3 + 0.5F; if (world.a((double) f, (double) f1, (double) f2, 24.0D) == null) { float f3 = f - (float) chunkcoordinates.x; @@ -129,16 +112,16 @@ public final class SpawnerCreature { entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F); if (entityliving.d()) { - ++l2; + ++j2; // CraftBukkit - added a reason for spawning this creature world.addEntity(entityliving, SpawnReason.NATURAL); a(entityliving, world, f, f1, f2); - if (l2 >= entityliving.l()) { - continue label113; + if (j2 >= entityliving.m()) { + continue label91; } } - i += l2; + i += j2; } } } @@ -190,8 +173,12 @@ public final class SpawnerCreature { if (l < 1) { l = 1; - } else if (l > 128) { - l = 128; + } else { + world.getClass(); + if (l > 128) { + world.getClass(); + l = 128; + } } int i1 = world.random.nextInt(aclass.length); @@ -202,46 +189,54 @@ public final class SpawnerCreature { ; } - while (!a(EnumCreatureType.MONSTER, world, j, j1, k) && j1 < l + 16 && j1 < 128) { + while (!a(EnumCreatureType.MONSTER, world, j, j1, k) && j1 < l + 16) { + world.getClass(); + if (j1 >= 128) { + break; + } + ++j1; } - if (j1 < l + 16 && j1 < 128) { - float f = (float) j + 0.5F; - float f1 = (float) j1; - float f2 = (float) k + 0.5F; + if (j1 < l + 16) { + world.getClass(); + if (j1 < 128) { + float f = (float) j + 0.5F; + float f1 = (float) j1; + float f2 = (float) k + 0.5F; - EntityLiving entityliving; + EntityLiving entityliving; - try { - entityliving = (EntityLiving) aclass[i1].getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); - } catch (Exception exception) { - exception.printStackTrace(); - return flag; - } + try { + entityliving = (EntityLiving) aclass[i1].getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } catch (Exception exception) { + exception.printStackTrace(); + return flag; + } - entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F); - if (entityliving.d()) { - PathEntity pathentity = pathfinder.a(entityliving, entityhuman, 32.0F); + entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F); + if (entityliving.d()) { + PathEntity pathentity = pathfinder.a(entityliving, entityhuman, 32.0F); - if (pathentity != null && pathentity.a > 1) { - PathPoint pathpoint = pathentity.c(); + if (pathentity != null && pathentity.a > 1) { + PathPoint pathpoint = pathentity.c(); - if (Math.abs((double) pathpoint.a - entityhuman.locX) < 1.5D && Math.abs((double) pathpoint.c - entityhuman.locZ) < 1.5D && Math.abs((double) pathpoint.b - entityhuman.locY) < 1.5D) { - ChunkCoordinates chunkcoordinates = BlockBed.f(world, MathHelper.floor(entityhuman.locX), MathHelper.floor(entityhuman.locY), MathHelper.floor(entityhuman.locZ), 1); + if (Math.abs((double) pathpoint.a - entityhuman.locX) < 1.5D && Math.abs((double) pathpoint.c - entityhuman.locZ) < 1.5D && Math.abs((double) pathpoint.b - entityhuman.locY) < 1.5D) { + ChunkCoordinates chunkcoordinates = BlockBed.f(world, MathHelper.floor(entityhuman.locX), MathHelper.floor(entityhuman.locY), MathHelper.floor(entityhuman.locZ), 1); - if (chunkcoordinates == null) { - chunkcoordinates = new ChunkCoordinates(j, j1 + 1, k); + if (chunkcoordinates == null) { + chunkcoordinates = new ChunkCoordinates(j, j1 + 1, k); + } + + entityliving.setPositionRotation((double) ((float) chunkcoordinates.x + 0.5F), (double) chunkcoordinates.y, (double) ((float) chunkcoordinates.z + 0.5F), 0.0F, 0.0F); + // CraftBukkit - added a reason for spawning this creature + world.addEntity(entityliving, SpawnReason.BED); + a(entityliving, world, (float) chunkcoordinates.x + 0.5F, (float) chunkcoordinates.y, (float) chunkcoordinates.z + 0.5F); + entityhuman.a(true, false, false); + entityliving.Z(); + flag = true; + flag1 = true; } - - entityliving.setPositionRotation((double) ((float) chunkcoordinates.x + 0.5F), (double) chunkcoordinates.y, (double) ((float) chunkcoordinates.z + 0.5F), 0.0F, 0.0F); - // CraftBukkit - added a reason for spawning this creature - world.addEntity(entityliving, SpawnReason.BED); - a(entityliving, world, (float) chunkcoordinates.x + 0.5F, (float) chunkcoordinates.y, (float) chunkcoordinates.z + 0.5F); - entityhuman.a(true, false, false); - entityliving.Q(); - flag = true; - flag1 = true; } } } @@ -252,4 +247,55 @@ public final class SpawnerCreature { return flag; } -} \ No newline at end of file + + public static void a(World world, BiomeBase biomebase, int i, int j, int k, int l, Random random) { + List list = biomebase.a(EnumCreatureType.CREATURE); + + if (!list.isEmpty()) { + while (random.nextFloat() < biomebase.d()) { + BiomeMeta biomemeta = (BiomeMeta) WeightedRandom.a(world.random, (Collection) list); + int i1 = biomemeta.b + random.nextInt(1 + biomemeta.c - biomemeta.b); + int j1 = i + random.nextInt(k); + int k1 = j + random.nextInt(l); + int l1 = j1; + int i2 = k1; + + for (int j2 = 0; j2 < i1; ++j2) { + boolean flag = false; + + for (int k2 = 0; !flag && k2 < 4; ++k2) { + int l2 = world.f(j1, k1); + + if (a(EnumCreatureType.CREATURE, world, j1, l2, k1)) { + float f = (float) j1 + 0.5F; + float f1 = (float) l2; + float f2 = (float) k1 + 0.5F; + + EntityLiving entityliving; + + try { + entityliving = (EntityLiving) biomemeta.a.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } catch (Exception exception) { + exception.printStackTrace(); + continue; + } + + entityliving.setPositionRotation((double) f, (double) f1, (double) f2, random.nextFloat() * 360.0F, 0.0F); + // CraftBukkit - added a reason for spawning this creature + world.addEntity(entityliving, SpawnReason.NATURAL); + world.addEntity(entityliving); + a(entityliving, world, f, f1, f2); + flag = true; + } + + j1 += random.nextInt(5) - random.nextInt(5); + + for (k1 += random.nextInt(5) - random.nextInt(5); j1 < i || j1 >= i + k || k1 < j || k1 >= j + k; k1 = i2 + random.nextInt(5) - random.nextInt(5)) { + j1 = l1 + random.nextInt(5) - random.nextInt(5); + } + } + } + } + } + } +} diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java index 4d98e6adaf..e6e2d7e809 100644 --- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java +++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java @@ -30,7 +30,7 @@ class ThreadLoginVerifier extends Thread { public void run() { try { String s = NetLoginHandler.a(this.netLoginHandler); - URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(this.loginPacket.name, "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8")); + URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(this.loginPacket.name, "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8")); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); String s1 = bufferedreader.readLine(); diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java index dbf08c15f3..e5761b05c5 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -3,6 +3,15 @@ package net.minecraft.server; public class TileEntityChest extends TileEntity implements IInventory { private ItemStack[] items = new ItemStack[27]; // CraftBukkit + public boolean a = false; + public TileEntityChest b; + public TileEntityChest c; + public TileEntityChest d; + public TileEntityChest e; + public float f; + public float g; + public int h; + private int q; // CraftBukkit start public ItemStack[] getContents() { @@ -67,7 +76,7 @@ public class TileEntityChest extends TileEntity implements IInventory { int j = nbttagcompound1.c("Slot") & 255; if (j >= 0 && j < this.items.length) { - this.items[j] = new ItemStack(nbttagcompound1); + this.items[j] = ItemStack.a(nbttagcompound1); } } } @@ -81,7 +90,7 @@ public class TileEntityChest extends TileEntity implements IInventory { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.a("Slot", (byte) i); - this.items[i].a(nbttagcompound1); + this.items[i].b(nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1); } } @@ -93,7 +102,131 @@ public class TileEntityChest extends TileEntity implements IInventory { return 64; } - public boolean a_(EntityHuman entityhuman) { + public boolean a(EntityHuman entityhuman) { return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; } + + public void g() { + super.g(); + this.a = false; + } + + public void h() { + if (!this.a) { + this.a = true; + this.b = null; + this.c = null; + this.d = null; + this.e = null; + if (this.world.getTypeId(this.x - 1, this.y, this.z) == Block.CHEST.id) { + this.d = (TileEntityChest) this.world.getTileEntity(this.x - 1, this.y, this.z); + } + + if (this.world.getTypeId(this.x + 1, this.y, this.z) == Block.CHEST.id) { + this.c = (TileEntityChest) this.world.getTileEntity(this.x + 1, this.y, this.z); + } + + if (this.world.getTypeId(this.x, this.y, this.z - 1) == Block.CHEST.id) { + this.b = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z - 1); + } + + if (this.world.getTypeId(this.x, this.y, this.z + 1) == Block.CHEST.id) { + this.e = (TileEntityChest) this.world.getTileEntity(this.x, this.y, this.z + 1); + } + + if (this.b != null) { + this.b.g(); + } + + if (this.e != null) { + this.e.g(); + } + + if (this.c != null) { + this.c.g(); + } + + if (this.d != null) { + this.d.g(); + } + } + } + + public void h_() { + super.h_(); + this.h(); + if (++this.q % 20 * 4 == 0) { + this.world.playNote(this.x, this.y, this.z, 1, this.h); + } + + this.g = this.f; + float f = 0.1F; + double d0; + double d1; + + if (this.h > 0 && this.f == 0.0F && this.b == null && this.d == null) { + d0 = (double) this.x + 0.5D; + d1 = (double) this.z + 0.5D; + if (this.e != null) { + d1 += 0.5D; + } + + if (this.c != null) { + d0 += 0.5D; + } + + this.world.makeSound(d0, (double) this.y + 0.5D, d1, "random.door_open", 1.0F, this.world.random.nextFloat() * 0.1F + 0.9F); + } + + if (this.h == 0 && this.f > 0.0F || this.h > 0 && this.f < 1.0F) { + if (this.h > 0) { + this.f += f; + } else { + this.f -= f; + } + + if (this.f > 1.0F) { + this.f = 1.0F; + } + + if (this.f < 0.0F) { + this.f = 0.0F; + if (this.b == null && this.d == null) { + d0 = (double) this.x + 0.5D; + d1 = (double) this.z + 0.5D; + if (this.e != null) { + d1 += 0.5D; + } + + if (this.c != null) { + d0 += 0.5D; + } + + this.world.makeSound(d0, (double) this.y + 0.5D, d1, "random.door_close", 1.0F, this.world.random.nextFloat() * 0.1F + 0.9F); + } + } + } + } + + public void b(int i, int j) { + if (i == 1) { + this.h = j; + } + } + + public void e() { + ++this.h; + this.world.playNote(this.x, this.y, this.z, 1, this.h); + } + + public void t_() { + --this.h; + this.world.playNote(this.x, this.y, this.z, 1, this.h); + } + + public void i() { + this.g(); + this.h(); + super.i(); + } } diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java index 7a9aab7ad5..61ac3078c6 100644 --- a/src/main/java/net/minecraft/server/TileEntityDispenser.java +++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java @@ -97,7 +97,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory { int j = nbttagcompound1.c("Slot") & 255; if (j >= 0 && j < this.items.length) { - this.items[j] = new ItemStack(nbttagcompound1); + this.items[j] = ItemStack.a(nbttagcompound1); } } } @@ -111,7 +111,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.a("Slot", (byte) i); - this.items[i].a(nbttagcompound1); + this.items[i].b(nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1); } } @@ -123,7 +123,11 @@ public class TileEntityDispenser extends TileEntity implements IInventory { return 64; } - public boolean a_(EntityHuman entityhuman) { + public boolean a(EntityHuman entityhuman) { return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 1503cbdf87..3370aab541 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -73,7 +73,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { byte b0 = nbttagcompound1.c("Slot"); if (b0 >= 0 && b0 < this.items.length) { - this.items[b0] = new ItemStack(nbttagcompound1); + this.items[b0] = ItemStack.a(nbttagcompound1); } } @@ -93,7 +93,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.a("Slot", (byte) i); - this.items[i].a(nbttagcompound1); + this.items[i].b(nbttagcompound1); nbttaglist.a((NBTBase) nbttagcompound1); } } @@ -109,7 +109,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { return this.burnTime > 0; } - public void g_() { + public void h_() { boolean flag = this.burnTime > 0; boolean flag1 = false; @@ -242,7 +242,11 @@ public class TileEntityFurnace extends TileEntity implements IInventory { } } - public boolean a_(EntityHuman entityhuman) { + public boolean a(EntityHuman entityhuman) { return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; } + + public void e() {} + + public void t_() {} } diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java index 9de8f5b5d1..a7704187a8 100644 --- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java +++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java @@ -21,7 +21,7 @@ public class TileEntityMobSpawner extends TileEntity { return this.world.a((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D, 16.0D) != null; } - public void g_() { + public void h_() { this.c = this.b; if (this.a()) { double d0 = (double) ((float) this.x + this.world.random.nextFloat()); @@ -86,14 +86,14 @@ public class TileEntityMobSpawner extends TileEntity { this.world.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); } - entityliving.S(); + entityliving.ab(); this.c(); } } } } - super.g_(); + super.h_(); } } diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java index 15d885f3dd..cc8b12f011 100644 --- a/src/main/java/net/minecraft/server/TileEntityPiston.java +++ b/src/main/java/net/minecraft/server/TileEntityPiston.java @@ -9,11 +9,11 @@ public class TileEntityPiston extends TileEntity { private int a; private int b; private int c; - private boolean i; - private boolean j; - private float k; - private float l; - private static List m = new ArrayList(); + private boolean d; + private boolean e; + private float f; + private float g; + private static List h = new ArrayList(); public TileEntityPiston() {} @@ -21,20 +21,20 @@ public class TileEntityPiston extends TileEntity { this.a = i; this.b = j; this.c = k; - this.i = flag; - this.j = flag1; + this.d = flag; + this.e = flag1; } public int a() { return this.a; } - public int e() { + public int j() { return this.b; } public boolean c() { - return this.i; + return this.d; } public int d() { @@ -46,11 +46,11 @@ public class TileEntityPiston extends TileEntity { f = 1.0F; } - return this.l + (this.k - this.l) * f; + return this.g + (this.f - this.g) * f; } private void a(float f, float f1) { - if (!this.i) { + if (!this.d) { --f; } else { f = 1.0F - f; @@ -62,8 +62,8 @@ public class TileEntityPiston extends TileEntity { List list = this.world.b((Entity) null, axisalignedbb); if (!list.isEmpty()) { - m.addAll(list); - Iterator iterator = m.iterator(); + h.addAll(list); + Iterator iterator = h.iterator(); while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -71,41 +71,41 @@ public class TileEntityPiston extends TileEntity { entity.move((double) (f1 * (float) PistonBlockTextures.b[this.c]), (double) (f1 * (float) PistonBlockTextures.c[this.c]), (double) (f1 * (float) PistonBlockTextures.d[this.c])); } - m.clear(); + h.clear(); } } } - public void k() { - if (this.l < 1.0F) { - this.l = this.k = 1.0F; - this.world.o(this.x, this.y, this.z); - this.h(); + public void e() { + if (this.g < 1.0F) { + this.g = this.f = 1.0F; + this.world.n(this.x, this.y, this.z); + this.i(); if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) { this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b); } } } - public void g_() { - // CraftBukkit - if (this.world == null) return; - this.l = this.k; - if (this.l >= 1.0F) { + public void h_() { + if (this.world == null) return; // CraftBukkit + + this.g = this.f; + if (this.g >= 1.0F) { this.a(1.0F, 0.25F); - this.world.o(this.x, this.y, this.z); - this.h(); + this.world.n(this.x, this.y, this.z); + this.i(); if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) { this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b); } } else { - this.k += 0.5F; - if (this.k >= 1.0F) { - this.k = 1.0F; + this.f += 0.5F; + if (this.f >= 1.0F) { + this.f = 1.0F; } - if (this.i) { - this.a(this.k, this.k - this.l + 0.0625F); + if (this.d) { + this.a(this.f, this.f - this.g + 0.0625F); } } } @@ -115,8 +115,8 @@ public class TileEntityPiston extends TileEntity { this.a = nbttagcompound.e("blockId"); this.b = nbttagcompound.e("blockData"); this.c = nbttagcompound.e("facing"); - this.l = this.k = nbttagcompound.g("progress"); - this.i = nbttagcompound.m("extending"); + this.g = this.f = nbttagcompound.g("progress"); + this.d = nbttagcompound.m("extending"); } public void b(NBTTagCompound nbttagcompound) { @@ -124,7 +124,7 @@ public class TileEntityPiston extends TileEntity { nbttagcompound.a("blockId", this.a); nbttagcompound.a("blockData", this.b); nbttagcompound.a("facing", this.c); - nbttagcompound.a("progress", this.l); - nbttagcompound.a("extending", this.i); + nbttagcompound.a("progress", this.g); + nbttagcompound.a("extending", this.d); } } diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java index cfbf6a0b9a..2bc3f20222 100644 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ b/src/main/java/net/minecraft/server/TileEntitySign.java @@ -4,7 +4,7 @@ public class TileEntitySign extends TileEntity { public String[] lines = new String[] { "", "", "", ""}; public int b = -1; - private boolean isEditable = true; + public boolean isEditable = true; // CraftBukkit - priv to public public TileEntitySign() {} @@ -28,7 +28,7 @@ public class TileEntitySign extends TileEntity { } } - public Packet f() { + public Packet l() { String[] astring = new String[4]; for (int i = 0; i < 4; ++i) { @@ -47,8 +47,4 @@ public class TileEntitySign extends TileEntity { public boolean a() { return this.isEditable; } - - public void a(boolean flag) { - this.isEditable = flag; - } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index f317fd2282..a4e39fcaae 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -31,50 +31,57 @@ import org.bukkit.block.BlockState; public class World implements IBlockAccess { - public boolean a = false; - private List C = new ArrayList(); + public final int a = 7; + public final int b = 11; + public final int c = 128; + public final int d = 127; + public final int e = 63; + public boolean f = false; public List entityList = new ArrayList(); - private List D = new ArrayList(); - private TreeSet E = new TreeSet(); - private Set F = new HashSet(); - public List c = new ArrayList(); - private List G = new ArrayList(); + private List M = new ArrayList(); + private TreeSet N = new TreeSet(); + private Set O = new HashSet(); + public List h = new ArrayList(); + private List P = new ArrayList(); + private List Q = new ArrayList(); public List players = new ArrayList(); - public List e = new ArrayList(); - private long H = 16777215L; - public int f = 0; - protected int g = (new Random()).nextInt(); - protected final int h = 1013904223; - protected float i; - protected float j; - protected float k; - protected float l; - protected int m = 0; - public int n = 0; + public List j = new ArrayList(); + private long R = 16777215L; + public int k = 0; + protected int l = (new Random()).nextInt(); + protected final int m = 1013904223; + protected float n; + protected float o; + protected float p; + protected float q; + protected int r = 0; + public int s = 0; public boolean suppressPhysics = false; - private long I = System.currentTimeMillis(); - protected int p = 40; + private long S = System.currentTimeMillis(); + protected int u = 40; public int spawnMonsters; public Random random = new Random(); - public boolean s = false; + public boolean x = false; public WorldProvider worldProvider; // CraftBukkit - remove final - protected List u = new ArrayList(); + protected List z = new ArrayList(); public IChunkProvider chunkProvider; // CraftBukkit - protected -> public - protected final IDataManager w; + protected final IDataManager B; public WorldData worldData; // CraftBukkit - protected -> public public boolean isLoading; - private boolean J; + private boolean T; public WorldMapCollection worldMaps; - private ArrayList K = new ArrayList(); - private boolean L; - private int M = 0; + private ArrayList U = new ArrayList(); + private boolean V; public boolean allowMonsters = true; // CraftBukkit - private -> public public boolean allowAnimals = true; // CraftBukkit - private -> public - static int A = 0; - private Set P = new HashSet(); - private int Q; - private List R; + private Set W = new HashSet(); + private int X; + int[] H; + private List Y; public boolean isStatic; + public double J; + public double K; + public double L; public WorldChunkManager getWorldChunkManager() { return this.worldProvider.b; @@ -112,19 +119,20 @@ public class World implements IBlockAccess { } // CraftBukkit - changed signature - public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen, org.bukkit.World.Environment env) { + public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, ChunkGenerator gen, org.bukkit.World.Environment env) { this.generator = gen; this.world = new CraftWorld((WorldServer) this, gen, env); tileEntitiesToUnload = new ArrayList(); // CraftBukkit end - this.Q = this.random.nextInt(12000); - this.R = new ArrayList(); + this.X = this.random.nextInt(12000); + this.H = new int['\u8000']; + this.Y = new ArrayList(); this.isStatic = false; - this.w = idatamanager; + this.B = idatamanager; this.worldMaps = new WorldMapCollection(idatamanager); this.worldData = idatamanager.c(); - this.s = this.worldData == null; + this.x = this.worldData == null; if (worldprovider != null) { this.worldProvider = worldprovider; } else if (this.worldData != null && this.worldData.h() == -1) { @@ -136,7 +144,7 @@ public class World implements IBlockAccess { boolean flag = false; if (this.worldData == null) { - this.worldData = new WorldData(i, s); + this.worldData = new WorldData(worldsettings, s); flag = true; } else { this.worldData.a(s); @@ -148,24 +156,27 @@ public class World implements IBlockAccess { this.c(); } - this.g(); + this.f(); this.x(); this.getServer().addWorld(this.world); // CraftBukkit } protected IChunkProvider b() { - IChunkLoader ichunkloader = this.w.a(this.worldProvider); + IChunkLoader ichunkloader = this.B.a(this.worldProvider); return new ChunkProviderLoadOrGenerate(this, ichunkloader, this.worldProvider.getChunkProvider()); } protected void c() { this.isLoading = true; + WorldChunkManager worldchunkmanager = this.getWorldChunkManager(); + List list = worldchunkmanager.a(); + Random random = new Random(this.getSeed()); + ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random); int i = 0; byte b0 = 64; - - int j; + int j = 0; // CraftBukkit start if (this.generator != null) { @@ -182,12 +193,27 @@ public class World implements IBlockAccess { } } } - - for (j = 0; !this.canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) { - i += this.random.nextInt(64) - this.random.nextInt(64); - } // CraftBukkit end + if (chunkposition != null) { + i = chunkposition.x; + j = chunkposition.z; + } else { + System.out.println("Unable to find spawn biome"); + } + + int k = 0; + + // CraftBukkit - use out own canSpawn + while (!canSpawn(i, j)) { + i += random.nextInt(64) - random.nextInt(64); + j += random.nextInt(64) - random.nextInt(64); + ++k; + if (k == 1000) { + break; + } + } + this.worldData.setSpawn(i, b0, j); this.isLoading = false; } @@ -218,13 +244,13 @@ public class World implements IBlockAccess { } private void w() { - this.k(); - this.w.a(this.worldData, this.players); + this.j(); + this.B.a(this.worldData, this.players); this.worldMaps.a(); } public int getTypeId(int i, int j, int k) { - return i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000 ? (j < 0 ? 0 : (j >= 128 ? 0 : this.getChunkAt(i >> 4, k >> 4).getTypeId(i & 15, j, k & 15))) : 0; + return i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 ? (j < 0 ? 0 : (j >= 128 ? 0 : this.getChunkAt(i >> 4, k >> 4).getTypeId(i & 15, j, k & 15))) : 0; } public boolean isEmpty(int i, int j, int k) { @@ -286,15 +312,17 @@ public class World implements IBlockAccess { // CraftBukkit end public boolean setRawTypeIdAndData(int i, int j, int k, int l, int i1) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; } else if (j >= 128) { return false; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); + boolean flag = chunk.a(i & 15, j, k & 15, l, i1); - return chunk.a(i & 15, j, k & 15, l, i1); + this.p(i, j, k); + return flag; } } else { return false; @@ -302,15 +330,17 @@ public class World implements IBlockAccess { } public boolean setRawTypeId(int i, int j, int k, int l) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; } else if (j >= 128) { return false; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); + boolean flag = chunk.a(i & 15, j, k & 15, l); - return chunk.a(i & 15, j, k & 15, l); + this.p(i, j, k); + return flag; } } else { return false; @@ -324,7 +354,7 @@ public class World implements IBlockAccess { } public int getData(int i, int j, int k) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return 0; } else if (j >= 128) { @@ -354,7 +384,7 @@ public class World implements IBlockAccess { } public boolean setRawData(int i, int j, int k, int l) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; } else if (j >= 128) { @@ -397,8 +427,8 @@ public class World implements IBlockAccess { } public void notify(int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(i, j, k); + for (int l = 0; l < this.z.size(); ++l) { + ((IWorldAccess) this.z.get(l)).a(i, j, k); } } @@ -408,25 +438,30 @@ public class World implements IBlockAccess { } public void g(int i, int j, int k, int l) { - if (k > l) { - int i1 = l; + int i1; + if (k > l) { + i1 = l; l = k; k = i1; } + for (i1 = k; i1 <= l; ++i1) { + this.b(EnumSkyBlock.SKY, i, i1, j); + } + this.b(i, k, j, i, l, j); } public void i(int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(i, j, k, i, j, k); + for (int l = 0; l < this.z.size(); ++l) { + ((IWorldAccess) this.z.get(l)).a(i, j, k, i, j, k); } } public void b(int i, int j, int k, int l, int i1, int j1) { - for (int k1 = 0; k1 < this.u.size(); ++k1) { - ((IWorldAccess) this.u.get(k1)).a(i, j, k, l, i1, j1); + for (int k1 = 0; k1 < this.z.size(); ++k1) { + ((IWorldAccess) this.z.get(k1)).a(i, j, k, l, i1, j1); } } @@ -482,7 +517,7 @@ public class World implements IBlockAccess { } public int a(int i, int j, int k, boolean flag) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (flag) { int l = this.getTypeId(i, j, k); @@ -524,35 +559,15 @@ public class World implements IBlockAccess { i &= 15; k &= 15; - return chunk.c(i, j, k, this.f); + return chunk.c(i, j, k, this.k); } } else { return 15; } } - public boolean m(int i, int j, int k) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { - if (j < 0) { - return false; - } else if (j >= 128) { - return true; - } else if (!this.isChunkLoaded(i >> 4, k >> 4)) { - return false; - } else { - Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - - i &= 15; - k &= 15; - return chunk.c(i, j, k); - } - } else { - return false; - } - } - public int getHighestBlockYAt(int i, int j) { - if (i >= -32000000 && j >= -32000000 && i < 32000000 && j <= 32000000) { + if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) { if (!this.isChunkLoaded(i >> 4, j >> 4)) { return 0; } else { @@ -565,28 +580,6 @@ public class World implements IBlockAccess { } } - public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - if (!this.worldProvider.e || enumskyblock != EnumSkyBlock.SKY) { - if (this.isLoaded(i, j, k)) { - if (enumskyblock == EnumSkyBlock.SKY) { - if (this.m(i, j, k)) { - l = 15; - } - } else if (enumskyblock == EnumSkyBlock.BLOCK) { - int i1 = this.getTypeId(i, j, k); - - if (Block.s[i1] > l) { - l = Block.s[i1]; - } - } - - if (this.a(enumskyblock, i, j, k) != l) { - this.a(enumskyblock, i, j, k, i, j, k); - } - } - } - } - public int a(EnumSkyBlock enumskyblock, int i, int j, int k) { if (j < 0) { j = 0; @@ -596,7 +589,7 @@ public class World implements IBlockAccess { j = 127; } - if (j >= 0 && j < 128 && i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + if (j >= 0 && j < 128 && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { int l = i >> 4; int i1 = k >> 4; @@ -612,8 +605,8 @@ public class World implements IBlockAccess { } } - public void b(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { - if (i >= -32000000 && k >= -32000000 && i < 32000000 && k <= 32000000) { + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j >= 0) { if (j < 128) { if (this.isChunkLoaded(i >> 4, k >> 4)) { @@ -621,8 +614,8 @@ public class World implements IBlockAccess { chunk.a(enumskyblock, i & 15, j, k & 15, l); - for (int i1 = 0; i1 < this.u.size(); ++i1) { - ((IWorldAccess) this.u.get(i1)).a(i, j, k); + for (int i1 = 0; i1 < this.z.size(); ++i1) { + ((IWorldAccess) this.z.get(i1)).a(i, j, k); } } } @@ -630,12 +623,12 @@ public class World implements IBlockAccess { } } - public float n(int i, int j, int k) { + public float m(int i, int j, int k) { return this.worldProvider.f[this.getLightLevel(i, j, k)]; } public boolean d() { - return this.f < 4; + return this.k < 4; } public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { @@ -806,31 +799,31 @@ public class World implements IBlockAccess { } public void makeSound(Entity entity, String s, float f, float f1) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, entity.locX, entity.locY - (double) entity.height, entity.locZ, f, f1); + for (int i = 0; i < this.z.size(); ++i) { + ((IWorldAccess) this.z.get(i)).a(s, entity.locX, entity.locY - (double) entity.height, entity.locZ, f, f1); } } public void makeSound(double d0, double d1, double d2, String s, float f, float f1) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, f, f1); + for (int i = 0; i < this.z.size(); ++i) { + ((IWorldAccess) this.z.get(i)).a(s, d0, d1, d2, f, f1); } } public void a(String s, int i, int j, int k) { - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(s, i, j, k); + for (int l = 0; l < this.z.size(); ++l) { + ((IWorldAccess) this.z.get(l)).a(s, i, j, k); } } public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(s, d0, d1, d2, d3, d4, d5); + for (int i = 0; i < this.z.size(); ++i) { + ((IWorldAccess) this.z.get(i)).a(s, d0, d1, d2, d3, d4, d5); } } public boolean strikeLightning(Entity entity) { - this.e.add(entity); + this.j.add(entity); return true; } @@ -883,14 +876,14 @@ public class World implements IBlockAccess { } protected void c(Entity entity) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).a(entity); + for (int i = 0; i < this.z.size(); ++i) { + ((IWorldAccess) this.z.get(i)).a(entity); } } protected void d(Entity entity) { - for (int i = 0; i < this.u.size(); ++i) { - ((IWorldAccess) this.u.get(i)).b(entity); + for (int i = 0; i < this.z.size(); ++i) { + ((IWorldAccess) this.z.get(i)).b(entity); } } @@ -917,10 +910,10 @@ public class World implements IBlockAccess { this.everyoneSleeping(); } - int i = entity.bH; - int j = entity.bJ; + int i = entity.bW; + int j = entity.bY; - if (entity.bG && this.isChunkLoaded(i, j)) { + if (entity.bV && this.isChunkLoaded(i, j)) { this.getChunkAt(i, j).b(entity); } @@ -929,11 +922,11 @@ public class World implements IBlockAccess { } public void addIWorldAccess(IWorldAccess iworldaccess) { - this.u.add(iworldaccess); + this.z.add(iworldaccess); } public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { - this.K.clear(); + this.U.clear(); int i = MathHelper.floor(axisalignedbb.a); int j = MathHelper.floor(axisalignedbb.d + 1.0D); int k = MathHelper.floor(axisalignedbb.b); @@ -948,7 +941,7 @@ public class World implements IBlockAccess { Block block = Block.byId[this.getTypeId(k1, i2, l1)]; if (block != null) { - block.a(this, k1, i2, l1, axisalignedbb, this.K); + block.a(this, k1, i2, l1, axisalignedbb, this.U); } } } @@ -959,19 +952,19 @@ public class World implements IBlockAccess { List list = this.b(entity, axisalignedbb.b(d0, d0, d0)); for (int j2 = 0; j2 < list.size(); ++j2) { - AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).e_(); + AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).f(); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.K.add(axisalignedbb1); + this.U.add(axisalignedbb1); } - axisalignedbb1 = entity.a_((Entity) list.get(j2)); + axisalignedbb1 = entity.b((Entity) list.get(j2)); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.K.add(axisalignedbb1); + this.U.add(axisalignedbb1); } } - return this.K; + return this.U; } public int a(float f) { @@ -994,25 +987,11 @@ public class World implements IBlockAccess { } public float b(float f) { - return this.worldProvider.a(this.worldData.f(), f); + return this.worldProvider.a(this.worldData.f(), f) + (float) (this.J + (this.K - this.J) * (double) f); } public int e(int i, int j) { - Chunk chunk = this.getChunkAtWorldCoords(i, j); - int k = 127; - - i &= 15; - - for (j &= 15; k > 0; --k) { - int l = chunk.getTypeId(i, k, j); - Material material = l == 0 ? Material.AIR : Block.byId[l].material; - - if (material.isSolid() || material.isLiquid()) { - return k + 1; - } - } - - return -1; + return this.getChunkAtWorldCoords(i, j).c(i & 15, j & 15); } public int f(int i, int j) { @@ -1024,7 +1003,7 @@ public class World implements IBlockAccess { for (j &= 15; k > 0; --k) { int l = chunk.getTypeId(i, k, j); - if (l != 0 && Block.byId[l].material.isSolid()) { + if (l != 0 && Block.byId[l].material.isSolid() && Block.byId[l].material != Material.LEAVES) { return k + 1; } } @@ -1036,7 +1015,7 @@ public class World implements IBlockAccess { NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l); byte b0 = 8; - if (this.a) { + if (this.f) { if (this.a(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { int j1 = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); @@ -1050,9 +1029,9 @@ public class World implements IBlockAccess { nextticklistentry.a((long) i1 + this.worldData.f()); } - if (!this.F.contains(nextticklistentry)) { - this.F.add(nextticklistentry); - this.E.add(nextticklistentry); + if (!this.O.contains(nextticklistentry)) { + this.O.add(nextticklistentry); + this.N.add(nextticklistentry); } } } @@ -1062,38 +1041,38 @@ public class World implements IBlockAccess { int i; Entity entity; - for (i = 0; i < this.e.size(); ++i) { - entity = (Entity) this.e.get(i); + for (i = 0; i < this.j.size(); ++i) { + entity = (Entity) this.j.get(i); // CraftBukkit start - fixed an NPE if (entity == null) { continue; } // CraftBukkit end - entity.m_(); + entity.s_(); if (entity.dead) { - this.e.remove(i--); + this.j.remove(i--); } } - this.entityList.removeAll(this.D); + this.entityList.removeAll(this.M); int j; int k; - for (i = 0; i < this.D.size(); ++i) { - entity = (Entity) this.D.get(i); - j = entity.bH; - k = entity.bJ; - if (entity.bG && this.isChunkLoaded(j, k)) { + for (i = 0; i < this.M.size(); ++i) { + entity = (Entity) this.M.get(i); + j = entity.bW; + k = entity.bY; + if (entity.bV && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } } - for (i = 0; i < this.D.size(); ++i) { - this.d((Entity) this.D.get(i)); + for (i = 0; i < this.M.size(); ++i) { + this.d((Entity) this.M.get(i)); } - this.D.clear(); + this.M.clear(); for (i = 0; i < this.entityList.size(); ++i) { entity = (Entity) this.entityList.get(i); @@ -1111,9 +1090,9 @@ public class World implements IBlockAccess { } if (entity.dead) { - j = entity.bH; - k = entity.bJ; - if (entity.bG && this.isChunkLoaded(j, k)) { + j = entity.bW; + k = entity.bY; + if (entity.bV && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } @@ -1122,71 +1101,72 @@ public class World implements IBlockAccess { } } - this.L = true; - Iterator iterator = this.c.iterator(); + this.V = true; + Iterator iterator = this.h.iterator(); while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); - if (!tileentity.g()) { - tileentity.g_(); + if (!tileentity.m() && tileentity.world != null) { + tileentity.h_(); } - if (tileentity.g()) { + if (tileentity.m()) { iterator.remove(); - Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); + if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) { + Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); - if (chunk != null) { - chunk.e(tileentity.x & 15, tileentity.y, tileentity.z & 15); + if (chunk != null) { + chunk.e(tileentity.x & 15, tileentity.y, tileentity.z & 15); + } } } } - this.L = false; - - // Craftbukkit start - if (!tileEntitiesToUnload.isEmpty()) { - this.c.removeAll(tileEntitiesToUnload); - this.tileEntitiesToUnload.clear(); + this.V = false; + if (!this.Q.isEmpty()) { + this.h.removeAll(this.Q); + this.Q.clear(); } - // Craftbukkit end - if (!this.G.isEmpty()) { - Iterator iterator1 = this.G.iterator(); + if (!this.P.isEmpty()) { + Iterator iterator1 = this.P.iterator(); while (iterator1.hasNext()) { TileEntity tileentity1 = (TileEntity) iterator1.next(); - if (!tileentity1.g()) { + if (!tileentity1.m()) { // CraftBukkit - order matters, moved down - /* if (!this.c.contains(tileentity1)) { - this.c.add(tileentity1); + /* if (!this.h.contains(tileentity1)) { + this.h.add(tileentity1); } */ - Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4); + if (this.isChunkLoaded(tileentity1.x >> 4, tileentity1.z >> 4)) { + Chunk chunk1 = this.getChunkAt(tileentity1.x >> 4, tileentity1.z >> 4); - if (chunk1 != null) { - chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1); - // CraftBukkit start - moved in from above - if (!this.c.contains(tileentity1)) { - this.c.add(tileentity1); + if (chunk1 != null) { + chunk1.a(tileentity1.x & 15, tileentity1.y, tileentity1.z & 15, tileentity1); + // CraftBukkit start - moved in from above + if (!this.h.contains(tileentity1)) { + this.h.add(tileentity1); + } + // CraftBukkit end } - // CraftBukkit end } this.notify(tileentity1.x, tileentity1.y, tileentity1.z); } } - this.G.clear(); + this.P.clear(); } } public void a(Collection collection) { - if (this.L) { - this.G.addAll(collection); + if (this.V) { + this.P.addAll(collection); } else { - this.c.addAll(collection); + this.h.addAll(collection); } } @@ -1200,29 +1180,29 @@ public class World implements IBlockAccess { byte b0 = 32; if (!flag || this.a(i - b0, 0, j - b0, i + b0, 128, j + b0)) { - entity.bo = entity.locX; - entity.bp = entity.locY; - entity.bq = entity.locZ; + entity.bE = entity.locX; + entity.bF = entity.locY; + entity.bG = entity.locZ; entity.lastYaw = entity.yaw; entity.lastPitch = entity.pitch; - if (flag && entity.bG) { + if (flag && entity.bV) { if (entity.vehicle != null) { - entity.E(); + entity.I(); } else { - entity.m_(); + entity.s_(); } } if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) { - entity.locX = entity.bo; + entity.locX = entity.bE; } if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) { - entity.locY = entity.bp; + entity.locY = entity.bF; } if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) { - entity.locZ = entity.bq; + entity.locZ = entity.bG; } if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) { @@ -1237,20 +1217,20 @@ public class World implements IBlockAccess { int l = MathHelper.floor(entity.locY / 16.0D); int i1 = MathHelper.floor(entity.locZ / 16.0D); - if (!entity.bG || entity.bH != k || entity.bI != l || entity.bJ != i1) { - if (entity.bG && this.isChunkLoaded(entity.bH, entity.bJ)) { - this.getChunkAt(entity.bH, entity.bJ).a(entity, entity.bI); + if (!entity.bV || entity.bW != k || entity.bX != l || entity.bY != i1) { + if (entity.bV && this.isChunkLoaded(entity.bW, entity.bY)) { + this.getChunkAt(entity.bW, entity.bY).a(entity, entity.bX); } if (this.isChunkLoaded(k, i1)) { - entity.bG = true; + entity.bV = true; this.getChunkAt(k, i1).a(entity); } else { - entity.bG = false; + entity.bV = false; } } - if (flag && entity.bG && entity.passenger != null) { + if (flag && entity.bV && entity.passenger != null) { if (!entity.passenger.dead && entity.passenger.vehicle == entity) { this.playerJoinedWorld(entity.passenger); } else { @@ -1267,7 +1247,7 @@ public class World implements IBlockAccess { for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity) list.get(i); - if (!entity.dead && entity.aI) { + if (!entity.dead && entity.aY) { return false; } } @@ -1546,33 +1526,33 @@ public class World implements IBlockAccess { } public void setTileEntity(int i, int j, int k, TileEntity tileentity) { - if (!tileentity.g()) { - if (this.L) { + if (tileentity != null && !tileentity.m()) { + if (this.V) { tileentity.x = i; tileentity.y = j; tileentity.z = k; - this.G.add(tileentity); + this.P.add(tileentity); } else { // CraftBukkit - order matters, moved down - // this.c.add(tileentity); + // this.h.add(tileentity); Chunk chunk = this.getChunkAt(i >> 4, k >> 4); if (chunk != null) { chunk.a(i & 15, j, k & 15, tileentity); - this.c.add(tileentity); // CraftBukkit - moved in from above + this.h.add(tileentity); // CraftBukkit - moved in from above } } } } - public void o(int i, int j, int k) { + public void n(int i, int j, int k) { TileEntity tileentity = this.getTileEntity(i, j, k); - if (tileentity != null && this.L) { - tileentity.h(); + if (tileentity != null && this.V) { + tileentity.i(); } else { if (tileentity != null) { - this.c.remove(tileentity); + this.h.remove(tileentity); } Chunk chunk = this.getChunkAt(i >> 4, k >> 4); @@ -1583,7 +1563,11 @@ public class World implements IBlockAccess { } } - public boolean p(int i, int j, int k) { + public void a(TileEntity tileentity) { + this.Q.add(tileentity); + } + + public boolean o(int i, int j, int k) { Block block = Block.byId[this.getTypeId(i, j, k)]; return block == null ? false : block.a(); @@ -1592,98 +1576,14 @@ public class World implements IBlockAccess { public boolean e(int i, int j, int k) { Block block = Block.byId[this.getTypeId(i, j, k)]; - return block == null ? false : block.material.h() && block.b(); + return block == null ? false : block.material.j() && block.b(); } - public boolean doLighting() { - if (this.M >= 50) { - return false; - } else { - ++this.M; - - boolean flag; - - try { - int i = 500; - - while (this.C.size() > 0) { - --i; - if (i <= 0) { - flag = true; - return flag; - } - - ((MetadataChunkBlock) this.C.remove(this.C.size() - 1)).a(this); - } - - flag = false; - } finally { - --this.M; - } - - return flag; - } - } - - public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) { - this.a(enumskyblock, i, j, k, l, i1, j1, true); - } - - public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1, boolean flag) { - if (!this.worldProvider.e || enumskyblock != EnumSkyBlock.SKY) { - ++A; - - try { - if (A == 50) { - return; - } - - int k1 = (l + i) / 2; - int l1 = (j1 + k) / 2; - - if (this.isLoaded(k1, 64, l1)) { - if (this.getChunkAtWorldCoords(k1, l1).isEmpty()) { - return; - } - - int i2 = this.C.size(); - int j2; - - if (flag) { - j2 = 5; - if (j2 > i2) { - j2 = i2; - } - - for (int k2 = 0; k2 < j2; ++k2) { - MetadataChunkBlock metadatachunkblock = (MetadataChunkBlock) this.C.get(this.C.size() - k2 - 1); - - if (metadatachunkblock.a == enumskyblock && metadatachunkblock.a(i, j, k, l, i1, j1)) { - return; - } - } - } - - this.C.add(new MetadataChunkBlock(enumskyblock, i, j, k, l, i1, j1)); - j2 = 1000000; - if (this.C.size() > 1000000) { - System.out.println("More than " + j2 + " updates, aborting lighting updates"); - this.C.clear(); - } - - return; - } - } finally { - --A; - } - } - } - - public void g() { + public void f() { int i = this.a(1.0F); - if (i != this.f) { - this.f = i; + if (i != this.k) { + this.k = i; } } @@ -1693,7 +1593,11 @@ public class World implements IBlockAccess { } public void doTick() { - this.i(); + this.J = this.K; + this.K += this.L; + this.L *= 0.98D; + this.getWorldChunkManager().b(); + this.h(); long i; if (this.everyoneDeeplySleeping()) { @@ -1706,7 +1610,7 @@ public class World implements IBlockAccess { if (!flag) { i = this.worldData.f() + 24000L; this.worldData.a(i - i % 24000L); - this.s(); + this.r(); } } @@ -1719,37 +1623,33 @@ public class World implements IBlockAccess { this.chunkProvider.unloadChunks(); int j = this.a(1.0F); - if (j != this.f) { - this.f = j; - - for (int k = 0; k < this.u.size(); ++k) { - ((IWorldAccess) this.u.get(k)).a(); - } + if (j != this.k) { + this.k = j; } i = this.worldData.f() + 1L; - if (i % (long) this.p == 0L) { + if (i % (long) this.u == 0L) { this.save(false, (IProgressUpdate) null); } this.worldData.a(i); this.a(false); - this.j(); + this.i(); } private void x() { if (this.worldData.hasStorm()) { - this.j = 1.0F; + this.o = 1.0F; if (this.worldData.isThundering()) { - this.l = 1.0F; + this.q = 1.0F; } } } - protected void i() { + protected void h() { if (!this.worldProvider.e) { - if (this.m > 0) { - --this.m; + if (this.r > 0) { + --this.r; } int i = this.worldData.getThunderDuration(); @@ -1797,34 +1697,34 @@ public class World implements IBlockAccess { } } - this.i = this.j; + this.n = this.o; if (this.worldData.hasStorm()) { - this.j = (float) ((double) this.j + 0.01D); + this.o = (float) ((double) this.o + 0.01D); } else { - this.j = (float) ((double) this.j - 0.01D); + this.o = (float) ((double) this.o - 0.01D); } - if (this.j < 0.0F) { - this.j = 0.0F; + if (this.o < 0.0F) { + this.o = 0.0F; } - if (this.j > 1.0F) { - this.j = 1.0F; + if (this.o > 1.0F) { + this.o = 1.0F; } - this.k = this.l; + this.p = this.q; if (this.worldData.isThundering()) { - this.l = (float) ((double) this.l + 0.01D); + this.q = (float) ((double) this.q + 0.01D); } else { - this.l = (float) ((double) this.l - 0.01D); + this.q = (float) ((double) this.q - 0.01D); } - if (this.l < 0.0F) { - this.l = 0.0F; + if (this.q < 0.0F) { + this.q = 0.0F; } - if (this.l > 1.0F) { - this.l = 1.0F; + if (this.q > 1.0F) { + this.q = 1.0F; } } } @@ -1847,8 +1747,8 @@ public class World implements IBlockAccess { // CraftBukkit end } - protected void j() { - this.P.clear(); + protected void i() { + this.W.clear(); int i; int j; @@ -1864,16 +1764,16 @@ public class World implements IBlockAccess { for (k = -b0; k <= b0; ++k) { for (l = -b0; l <= b0; ++l) { - this.P.add(new ChunkCoordIntPair(k + i, l + j)); + this.W.add(new ChunkCoordIntPair(k + i, l + j)); } } } - if (this.Q > 0) { - --this.Q; + if (this.X > 0) { + --this.X; } - Iterator iterator = this.P.iterator(); + Iterator iterator = this.W.iterator(); while (iterator.hasNext()) { ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); @@ -1881,13 +1781,15 @@ public class World implements IBlockAccess { i = chunkcoordintpair.x * 16; j = chunkcoordintpair.z * 16; Chunk chunk = this.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); + + chunk.h(); int j1; int k1; int l1; - if (this.Q == 0) { - this.g = this.g * 3 + 1013904223; - k = this.g >> 2; + if (this.X == 0) { + this.l = this.l * 3 + 1013904223; + k = this.l >> 2; l = k & 15; j1 = k >> 8 & 15; k1 = k >> 16 & 127; @@ -1899,35 +1801,35 @@ public class World implements IBlockAccess { if (entityhuman1 != null && entityhuman1.e((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D) > 4.0D) { this.makeSound((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F); - this.Q = this.random.nextInt(12000) + 6000; + this.X = this.random.nextInt(12000) + 6000; } } } - if (this.random.nextInt(100000) == 0 && this.v() && this.u()) { - this.g = this.g * 3 + 1013904223; - k = this.g >> 2; + if (this.random.nextInt(100000) == 0 && this.u() && this.t()) { + this.l = this.l * 3 + 1013904223; + k = this.l >> 2; l = i + (k & 15); j1 = j + (k >> 8 & 15); k1 = this.e(l, j1); if (this.s(l, k1, j1)) { this.strikeLightning(new EntityWeatherStorm(this, (double) l, (double) k1, (double) j1)); - this.m = 2; + this.r = 2; } } int i2; if (this.random.nextInt(16) == 0) { - this.g = this.g * 3 + 1013904223; - k = this.g >> 2; + this.l = this.l * 3 + 1013904223; + k = this.l >> 2; l = k & 15; j1 = k >> 8 & 15; k1 = this.e(l + i, j1 + j); - if (this.getWorldChunkManager().getBiome(l + i, j1 + j).c() && k1 >= 0 && k1 < 128 && chunk.a(EnumSkyBlock.BLOCK, l, k1, j1) < 10) { + if (this.getWorldChunkManager().getBiome(l + i, j1 + j).b() && k1 >= 0 && k1 < 128 && chunk.a(EnumSkyBlock.BLOCK, l, k1, j1) < 10) { l1 = chunk.getTypeId(l, k1 - 1, j1); i2 = chunk.getTypeId(l, k1, j1); - if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) { + if (this.u() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) { // CraftBukkit start BlockState blockState = this.getWorld().getBlockAt(l + i, k1, j1 + j).getState(); blockState.setTypeId(Block.SNOW.id); @@ -1940,8 +1842,27 @@ public class World implements IBlockAccess { // CraftBukkit end } - // CraftBukkit start - if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) { + if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) { + boolean flag = true; + + if (flag && this.getMaterial(l + i - 1, k1 - 1, j1 + j) != Material.WATER) { + flag = false; + } + + if (flag && this.getMaterial(l + i + 1, k1 - 1, j1 + j) != Material.WATER) { + flag = false; + } + + if (flag && this.getMaterial(l + i, k1 - 1, j1 + j - 1) != Material.WATER) { + flag = false; + } + + if (flag && this.getMaterial(l + i, k1 - 1, j1 + j + 1) != Material.WATER) { + flag = false; + } + + if (!flag) { + // CraftBukkit start BlockState blockState = this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j).getState(); blockState.setTypeId(Block.ICE.id); @@ -1950,14 +1871,17 @@ public class World implements IBlockAccess { if (!iceBlockForm.isCancelled()) { blockState.update(true); } + // CraftBukkit end + } } - // CraftBukkit end } } + this.p(i + this.random.nextInt(16), this.random.nextInt(128), j + this.random.nextInt(16)); + for (k = 0; k < 80; ++k) { - this.g = this.g * 3 + 1013904223; - l = this.g >> 2; + this.l = this.l * 3 + 1013904223; + l = this.l >> 2; j1 = l & 15; k1 = l >> 8 & 15; l1 = l >> 16 & 127; @@ -1969,10 +1893,231 @@ public class World implements IBlockAccess { } } - public boolean a(boolean flag) { - int i = this.E.size(); + public void p(int i, int j, int k) { + this.b(EnumSkyBlock.SKY, i, j, k); + this.b(EnumSkyBlock.BLOCK, i, j, k); + } - if (i != this.F.size()) { + private int d(int i, int j, int k, int l, int i1, int j1) { + int k1 = 0; + + if (this.isChunkLoaded(j, k, l)) { + k1 = 15; + } else { + if (j1 == 0) { + j1 = 1; + } + + for (int l1 = 0; l1 < 6; ++l1) { + int i2 = l1 % 2 * 2 - 1; + int j2 = j + l1 / 2 % 3 / 2 * i2; + int k2 = k + (l1 / 2 + 1) % 3 / 2 * i2; + int l2 = l + (l1 / 2 + 2) % 3 / 2 * i2; + int i3 = this.a(EnumSkyBlock.SKY, j2, k2, l2) - j1; + + if (i3 > k1) { + k1 = i3; + } + } + } + + return k1; + } + + private int e(int i, int j, int k, int l, int i1, int j1) { + int k1 = Block.s[i1]; + int l1 = this.a(EnumSkyBlock.BLOCK, j - 1, k, l) - j1; + int i2 = this.a(EnumSkyBlock.BLOCK, j + 1, k, l) - j1; + int j2 = this.a(EnumSkyBlock.BLOCK, j, k - 1, l) - j1; + int k2 = this.a(EnumSkyBlock.BLOCK, j, k + 1, l) - j1; + int l2 = this.a(EnumSkyBlock.BLOCK, j, k, l - 1) - j1; + int i3 = this.a(EnumSkyBlock.BLOCK, j, k, l + 1) - j1; + + if (l1 > k1) { + k1 = l1; + } + + if (i2 > k1) { + k1 = i2; + } + + if (j2 > k1) { + k1 = j2; + } + + if (k2 > k1) { + k1 = k2; + } + + if (l2 > k1) { + k1 = l2; + } + + if (i3 > k1) { + k1 = i3; + } + + return k1; + } + + public void b(EnumSkyBlock enumskyblock, int i, int j, int k) { + if (this.areChunksLoaded(i, j, k, 17)) { + int l = 0; + int i1 = 0; + int j1 = this.a(enumskyblock, i, j, k); + boolean flag = false; + int k1 = this.getTypeId(i, j, k); + int l1 = Block.q[k1]; + + if (l1 == 0) { + l1 = 1; + } + + boolean flag1 = false; + int i2; + + if (enumskyblock == EnumSkyBlock.SKY) { + i2 = this.d(j1, i, j, k, k1, l1); + } else { + i2 = this.e(j1, i, j, k, k1, l1); + } + + int j2; + int k2; + int l2; + int i3; + int j3; + int k3; + + if (i2 > j1) { + this.H[i1++] = 133152; + } else if (i2 < j1) { + if (enumskyblock != EnumSkyBlock.BLOCK) { + ; + } + + this.H[i1++] = 133152 + (j1 << 18); + + while (l < i1) { + j2 = this.H[l++]; + k1 = (j2 & 63) - 32 + i; + l1 = (j2 >> 6 & 63) - 32 + j; + i2 = (j2 >> 12 & 63) - 32 + k; + k2 = j2 >> 18 & 15; + l2 = this.a(enumskyblock, k1, l1, i2); + if (l2 == k2) { + this.a(enumskyblock, k1, l1, i2, 0); + --k2; + if (k2 > 0) { + i3 = k1 - i; + k3 = l1 - j; + j3 = i2 - k; + if (i3 < 0) { + i3 = -i3; + } + + if (k3 < 0) { + k3 = -k3; + } + + if (j3 < 0) { + j3 = -j3; + } + + if (i3 + k3 + j3 < 17) { + for (int l3 = 0; l3 < 6; ++l3) { + int i4 = l3 % 2 * 2 - 1; + int j4 = k1 + l3 / 2 % 3 / 2 * i4; + int k4 = l1 + (l3 / 2 + 1) % 3 / 2 * i4; + int l4 = i2 + (l3 / 2 + 2) % 3 / 2 * i4; + + l2 = this.a(enumskyblock, j4, k4, l4); + if (l2 == k2) { + this.H[i1++] = j4 - i + 32 + (k4 - j + 32 << 6) + (l4 - k + 32 << 12) + (k2 << 18); + } + } + } + } + } + } + + l = 0; + } + + while (l < i1) { + j1 = this.H[l++]; + int i5 = (j1 & 63) - 32 + i; + + j2 = (j1 >> 6 & 63) - 32 + j; + k1 = (j1 >> 12 & 63) - 32 + k; + l1 = this.a(enumskyblock, i5, j2, k1); + i2 = this.getTypeId(i5, j2, k1); + k2 = Block.q[i2]; + if (k2 == 0) { + k2 = 1; + } + + boolean flag2 = false; + + if (enumskyblock == EnumSkyBlock.SKY) { + l2 = this.d(l1, i5, j2, k1, i2, k2); + } else { + l2 = this.e(l1, i5, j2, k1, i2, k2); + } + + if (l2 != l1) { + this.a(enumskyblock, i5, j2, k1, l2); + if (l2 > l1) { + i3 = i5 - i; + k3 = j2 - j; + j3 = k1 - k; + if (i3 < 0) { + i3 = -i3; + } + + if (k3 < 0) { + k3 = -k3; + } + + if (j3 < 0) { + j3 = -j3; + } + + if (i3 + k3 + j3 < 17 && i1 < this.H.length - 6) { + if (this.a(enumskyblock, i5 - 1, j2, k1) < l2) { + this.H[i1++] = i5 - 1 - i + 32 + (j2 - j + 32 << 6) + (k1 - k + 32 << 12); + } + + if (this.a(enumskyblock, i5 + 1, j2, k1) < l2) { + this.H[i1++] = i5 + 1 - i + 32 + (j2 - j + 32 << 6) + (k1 - k + 32 << 12); + } + + if (this.a(enumskyblock, i5, j2 - 1, k1) < l2) { + this.H[i1++] = i5 - i + 32 + (j2 - 1 - j + 32 << 6) + (k1 - k + 32 << 12); + } + + if (this.a(enumskyblock, i5, j2 + 1, k1) < l2) { + this.H[i1++] = i5 - i + 32 + (j2 + 1 - j + 32 << 6) + (k1 - k + 32 << 12); + } + + if (this.a(enumskyblock, i5, j2, k1 - 1) < l2) { + this.H[i1++] = i5 - i + 32 + (j2 - j + 32 << 6) + (k1 - 1 - k + 32 << 12); + } + + if (this.a(enumskyblock, i5, j2, k1 + 1) < l2) { + this.H[i1++] = i5 - i + 32 + (j2 - j + 32 << 6) + (k1 + 1 - k + 32 << 12); + } + } + } + } + } + } + } + + public boolean a(boolean flag) { + int i = this.N.size(); + + if (i != this.O.size()) { throw new IllegalStateException("TickNextTick list out of synch"); } else { if (i > 1000) { @@ -1980,14 +2125,14 @@ public class World implements IBlockAccess { } for (int j = 0; j < i; ++j) { - NextTickListEntry nextticklistentry = (NextTickListEntry) this.E.first(); + NextTickListEntry nextticklistentry = (NextTickListEntry) this.N.first(); if (!flag && nextticklistentry.e > this.worldData.f()) { break; } - this.E.remove(nextticklistentry); - this.F.remove(nextticklistentry); + this.N.remove(nextticklistentry); + this.O.remove(nextticklistentry); byte b0 = 8; if (this.a(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { @@ -1999,12 +2144,12 @@ public class World implements IBlockAccess { } } - return this.E.size() != 0; + return this.N.size() != 0; } } public List b(Entity entity, AxisAlignedBB axisalignedbb) { - this.R.clear(); + this.Y.clear(); int i = MathHelper.floor((axisalignedbb.a - 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.d + 2.0D) / 16.0D); int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); @@ -2013,12 +2158,12 @@ public class World implements IBlockAccess { for (int i1 = i; i1 <= j; ++i1) { for (int j1 = k; j1 <= l; ++j1) { if (this.isChunkLoaded(i1, j1)) { - this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.R); + this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.Y); } } } - return this.R; + return this.Y; } public List a(Class oclass, AxisAlignedBB axisalignedbb) { @@ -2044,8 +2189,8 @@ public class World implements IBlockAccess { this.getChunkAtWorldCoords(i, k).f(); } - for (int l = 0; l < this.u.size(); ++l) { - ((IWorldAccess) this.u.get(l)).a(i, j, k, tileentity); + for (int l = 0; l < this.z.size(); ++l) { + ((IWorldAccess) this.z.get(l)).a(i, j, k, tileentity); } } @@ -2080,7 +2225,7 @@ public class World implements IBlockAccess { } public void b(List list) { - this.D.addAll(list); + this.M.addAll(list); } public boolean a(int i, int j, int k, int l, boolean flag, int i1) { @@ -2254,8 +2399,8 @@ public class World implements IBlockAccess { return abyte; } - public void k() { - this.w.b(); + public void j() { + this.B.b(); } public void setTime(long i) { @@ -2267,7 +2412,7 @@ public class World implements IBlockAccess { NextTickListEntry nextticklistentry; - for (Iterator iterator = this.F.iterator(); iterator.hasNext(); nextticklistentry.e += j) { + for (Iterator iterator = this.O.iterator(); iterator.hasNext(); nextticklistentry.e += j) { nextticklistentry = (NextTickListEntry) iterator.next(); } @@ -2292,7 +2437,7 @@ public class World implements IBlockAccess { public void a(Entity entity, byte b0) {} - public IChunkProvider o() { + public IChunkProvider n() { return this.chunkProvider; } @@ -2304,16 +2449,16 @@ public class World implements IBlockAccess { } } - public IDataManager p() { - return this.w; + public IDataManager o() { + return this.B; } - public WorldData q() { + public WorldData p() { return this.worldData; } public void everyoneSleeping() { - this.J = !this.players.isEmpty(); + this.T = !this.players.isEmpty(); Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2321,7 +2466,7 @@ public class World implements IBlockAccess { // CraftBukkit if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) { - this.J = false; + this.T = false; break; } } @@ -2337,8 +2482,8 @@ public class World implements IBlockAccess { } // CraftBukkit end - protected void s() { - this.J = false; + protected void r() { + this.T = false; Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2353,7 +2498,7 @@ public class World implements IBlockAccess { } public boolean everyoneDeeplySleeping() { - if (this.J && !this.isStatic) { + if (this.T && !this.isStatic) { Iterator iterator = this.players.iterator(); // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers @@ -2382,23 +2527,23 @@ public class World implements IBlockAccess { } public float c(float f) { - return (this.k + (this.l - this.k) * f) * this.d(f); + return (this.p + (this.q - this.p) * f) * this.d(f); } public float d(float f) { - return this.i + (this.j - this.i) * f; + return this.n + (this.o - this.n) * f; } - public boolean u() { + public boolean t() { return (double) this.c(1.0F) > 0.9D; } - public boolean v() { + public boolean u() { return (double) this.d(1.0F) > 0.2D; } public boolean s(int i, int j, int k) { - if (!this.v()) { + if (!this.u()) { return false; } else if (!this.isChunkLoaded(i, j, k)) { return false; @@ -2407,7 +2552,7 @@ public class World implements IBlockAccess { } else { BiomeBase biomebase = this.getWorldChunkManager().getBiome(i, k); - return biomebase.c() ? false : biomebase.d(); + return biomebase.b() ? false : biomebase.c(); } } @@ -2428,14 +2573,27 @@ public class World implements IBlockAccess { } public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) { - for (int j1 = 0; j1 < this.u.size(); ++j1) { - ((IWorldAccess) this.u.get(j1)).a(entityhuman, i, j, k, l, i1); + for (int j1 = 0; j1 < this.z.size(); ++j1) { + ((IWorldAccess) this.z.get(j1)).a(entityhuman, i, j, k, l, i1); } } + public Random t(int i, int j, int k) { + long l = (long) i * 341873128712L + (long) j * 132897987541L + this.p().getSeed() + (long) k; + + this.random.setSeed(l); + return this.random; + } + + public boolean v() { + return false; + } + + public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) {} + // CraftBukkit start public UUID getUUID() { - return this.w.getUUID(); + return this.B.getUUID(); } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/WorldChunkManager.java b/src/main/java/net/minecraft/server/WorldChunkManager.java deleted file mode 100644 index 3eff8654c6..0000000000 --- a/src/main/java/net/minecraft/server/WorldChunkManager.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class WorldChunkManager { - - private NoiseGeneratorOctaves2 e; - private NoiseGeneratorOctaves2 f; - private NoiseGeneratorOctaves2 g; - public double[] temperature; - public double[] rain; - public double[] c; - public BiomeBase[] d; - - protected WorldChunkManager() {} - - public WorldChunkManager(World world) { - this.e = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 9871L), 4); - this.f = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 39811L), 4); - this.g = new NoiseGeneratorOctaves2(new Random(world.getSeed() * 543321L), 2); - } - - public BiomeBase a(ChunkCoordIntPair chunkcoordintpair) { - return this.getBiome(chunkcoordintpair.x << 4, chunkcoordintpair.z << 4); - } - - public BiomeBase getBiome(int i, int j) { - return this.getBiomeData(i, j, 1, 1)[0]; - } - - public BiomeBase[] getBiomeData(int i, int j, int k, int l) { - this.d = this.a(this.d, i, j, k, l); - return this.d; - } - - public double[] a(double[] adouble, int i, int j, int k, int l) { - if (adouble == null || adouble.length < k * l) { - adouble = new double[k * l]; - } - - adouble = this.e.a(adouble, (double) i, (double) j, k, l, 0.02500000037252903D, 0.02500000037252903D, 0.25D); - this.c = this.g.a(this.c, (double) i, (double) j, k, l, 0.25D, 0.25D, 0.5882352941176471D); - int i1 = 0; - - for (int j1 = 0; j1 < k; ++j1) { - for (int k1 = 0; k1 < l; ++k1) { - double d0 = this.c[i1] * 1.1D + 0.5D; - double d1 = 0.01D; - double d2 = 1.0D - d1; - double d3 = (adouble[i1] * 0.15D + 0.7D) * d2 + d0 * d1; - - d3 = 1.0D - (1.0D - d3) * (1.0D - d3); - if (d3 < 0.0D) { - d3 = 0.0D; - } - - if (d3 > 1.0D) { - d3 = 1.0D; - } - - adouble[i1] = d3; - ++i1; - } - } - - return adouble; - } - - public BiomeBase[] a(BiomeBase[] abiomebase, int i, int j, int k, int l) { - if (abiomebase == null || abiomebase.length < k * l) { - abiomebase = new BiomeBase[k * l]; - } - - this.temperature = this.e.a(this.temperature, (double) i, (double) j, k, k, 0.02500000037252903D, 0.02500000037252903D, 0.25D); - this.rain = this.f.a(this.rain, (double) i, (double) j, k, k, 0.05000000074505806D, 0.05000000074505806D, 0.3333333333333333D); - this.c = this.g.a(this.c, (double) i, (double) j, k, k, 0.25D, 0.25D, 0.5882352941176471D); - int i1 = 0; - - for (int j1 = 0; j1 < k; ++j1) { - for (int k1 = 0; k1 < l; ++k1) { - double d0 = this.c[i1] * 1.1D + 0.5D; - double d1 = 0.01D; - double d2 = 1.0D - d1; - double d3 = (this.temperature[i1] * 0.15D + 0.7D) * d2 + d0 * d1; - - d1 = 0.0020D; - d2 = 1.0D - d1; - double d4 = (this.rain[i1] * 0.15D + 0.5D) * d2 + d0 * d1; - - d3 = 1.0D - (1.0D - d3) * (1.0D - d3); - if (d3 < 0.0D) { - d3 = 0.0D; - } - - if (d4 < 0.0D) { - d4 = 0.0D; - } - - if (d3 > 1.0D) { - d3 = 1.0D; - } - - if (d4 > 1.0D) { - d4 = 1.0D; - } - - this.temperature[i1] = d3; - this.rain[i1] = d4; - abiomebase[i1++] = BiomeBase.a(d3, d4); - } - } - - return abiomebase; - } - - // CraftBukkit start - public double getHumidity(int x, int z) { - return this.f.a(this.rain, (double)x, (double)z, 1, 1, 0.05000000074505806D, 0.05000000074505806D, 0.3333333333333333D)[0]; - } - // CraftBukkit end -} diff --git a/src/main/java/net/minecraft/server/WorldData.java b/src/main/java/net/minecraft/server/WorldData.java index 3e8ef772b6..a562a39b9d 100644 --- a/src/main/java/net/minecraft/server/WorldData.java +++ b/src/main/java/net/minecraft/server/WorldData.java @@ -19,9 +19,18 @@ public class WorldData { private int m; private boolean n; private int o; + private int p; + private boolean q; public WorldData(NBTTagCompound nbttagcompound) { this.a = nbttagcompound.getLong("RandomSeed"); + this.p = nbttagcompound.e("GameType"); + if (nbttagcompound.hasKey("MapFeatures")) { + this.q = nbttagcompound.m("MapFeatures"); + } else { + this.q = true; + } + this.b = nbttagcompound.e("SpawnX"); this.c = nbttagcompound.e("SpawnY"); this.d = nbttagcompound.e("SpawnZ"); @@ -40,13 +49,17 @@ public class WorldData { } } - public WorldData(long i, String s) { - this.a = i; + public WorldData(WorldSettings worldsettings, String s) { + this.a = worldsettings.a(); + this.p = worldsettings.b(); + this.q = worldsettings.c(); this.name = s; } public WorldData(WorldData worlddata) { this.a = worlddata.a; + this.p = worlddata.p; + this.q = worlddata.q; this.b = worlddata.b; this.c = worlddata.c; this.d = worlddata.d; @@ -90,6 +103,8 @@ public class WorldData { private void a(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) { nbttagcompound.setLong("RandomSeed", this.a); + nbttagcompound.a("GameType", this.p); + nbttagcompound.a("MapFeatures", this.q); nbttagcompound.a("SpawnX", this.b); nbttagcompound.a("SpawnY", this.c); nbttagcompound.a("SpawnZ", this.d); @@ -192,4 +207,16 @@ public class WorldData { public void setWeatherDuration(int i) { this.m = i; } + + public int n() { + return this.p; + } + + public boolean o() { + return this.q; + } + + public void d(int i) { + this.p = i; + } } diff --git a/src/main/java/net/minecraft/server/WorldGenClay.java b/src/main/java/net/minecraft/server/WorldGenClay.java deleted file mode 100644 index 0f16a82585..0000000000 --- a/src/main/java/net/minecraft/server/WorldGenClay.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class WorldGenClay extends WorldGenerator { - - private int a; - private int b; - - public WorldGenClay(int i) { - this.a = Block.CLAY.id; - this.b = i; - } - - public boolean a(World world, Random random, int i, int j, int k) { - if (world.getMaterial(i, j, k) != Material.WATER) { - return false; - } else { - float f = random.nextFloat() * 3.1415927F; - double d0 = (double) ((float) (i + 8) + MathHelper.sin(f) * (float) this.b / 8.0F); - double d1 = (double) ((float) (i + 8) - MathHelper.sin(f) * (float) this.b / 8.0F); - double d2 = (double) ((float) (k + 8) + MathHelper.cos(f) * (float) this.b / 8.0F); - double d3 = (double) ((float) (k + 8) - MathHelper.cos(f) * (float) this.b / 8.0F); - double d4 = (double) (j + random.nextInt(3) + 2); - double d5 = (double) (j + random.nextInt(3) + 2); - - for (int l = 0; l <= this.b; ++l) { - double d6 = d0 + (d1 - d0) * (double) l / (double) this.b; - double d7 = d4 + (d5 - d4) * (double) l / (double) this.b; - double d8 = d2 + (d3 - d2) * (double) l / (double) this.b; - double d9 = random.nextDouble() * (double) this.b / 16.0D; - double d10 = (double) (MathHelper.sin((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; - double d11 = (double) (MathHelper.sin((float) l * 3.1415927F / (float) this.b) + 1.0F) * d9 + 1.0D; - int i1 = MathHelper.floor(d6 - d10 / 2.0D); - int j1 = MathHelper.floor(d6 + d10 / 2.0D); - int k1 = MathHelper.floor(d7 - d11 / 2.0D); - int l1 = MathHelper.floor(d7 + d11 / 2.0D); - int i2 = MathHelper.floor(d8 - d10 / 2.0D); // CraftBukkit - d6 -> d8 - int j2 = MathHelper.floor(d8 + d10 / 2.0D); // CraftBukkit - d6 -> d8 - - for (int k2 = i1; k2 <= j1; ++k2) { - for (int l2 = k1; l2 <= l1; ++l2) { - for (int i3 = i2; i3 <= j2; ++i3) { - double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D); - double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D); - double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D); - - if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D) { - int j3 = world.getTypeId(k2, l2, i3); - - if (j3 == Block.SAND.id) { - world.setRawTypeId(k2, l2, i3, this.a); - } - } - } - } - } - } - - return true; - } - } -} diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java index 0dbe96bca6..319fea483d 100644 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ b/src/main/java/net/minecraft/server/WorldGenForest.java @@ -22,77 +22,89 @@ public class WorldGenForest extends WorldGenerator { int l = random.nextInt(3) + 5; boolean flag = true; - if (j >= 1 && j + l + 1 <= 128) { - int i1; - int j1; - int k1; - int l1; + if (j >= 1) { + int k1000 = j + l + 1; - for (i1 = j; i1 <= j + 1 + l; ++i1) { - byte b0 = 1; + world.getClass(); + if (k1000 <= 128) { + int j1; + int k1; + int l1; + int i2; - if (i1 == j) { - b0 = 0; - } + for (j1 = j; j1 <= j + 1 + l; ++j1) { + byte b0 = 1; - if (i1 >= j + 1 + l - 2) { - b0 = 2; - } + if (j1 == j) { + b0 = 0; + } - for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { - for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { - if (i1 >= 0 && i1 < 128) { - l1 = world.getTypeId(j1, i1, k1); - if (l1 != 0 && l1 != Block.LEAVES.id) { - flag = false; + if (j1 >= j + 1 + l - 2) { + b0 = 2; + } + + for (k1 = i - b0; k1 <= i + b0 && flag; ++k1) { + for (l1 = k - b0; l1 <= k + b0 && flag; ++l1) { + if (j1 >= 0) { + world.getClass(); + if (j1 < 128) { + i2 = world.getTypeId(k1, j1, l1); + if (i2 != 0 && i2 != Block.LEAVES.id) { + flag = false; + } + continue; + } } - } else { + flag = false; } } } - } - if (!flag) { - return false; - } else { - i1 = world.getTypeId(i, j - 1, k); - if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) { - world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + if (!flag) { + return false; + } - int i2; + j1 = world.getTypeId(i, j - 1, k); + if (j1 == Block.GRASS.id || j1 == Block.DIRT.id) { + world.getClass(); + if (j < 128 - l - 1) { + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - for (i2 = j - 3 + l; i2 <= j + l; ++i2) { - j1 = i2 - (j + l); - k1 = 1 - j1 / 2; + int j2; - for (l1 = i - k1; l1 <= i + k1; ++l1) { - int j2 = l1 - i; + for (j2 = j - 3 + l; j2 <= j + l; ++j2) { + k1 = j2 - (j + l); + l1 = 1 - k1 / 2; - for (int k2 = k - k1; k2 <= k + k1; ++k2) { - int l2 = k2 - k; + for (i2 = i - l1; i2 <= i + l1; ++i2) { + int k2 = i2 - i; - if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { - world.setRawTypeIdAndData(l1, i2, k2, Block.LEAVES.id, 2); + for (int l2 = k - l1; l2 <= k + l1; ++l2) { + int i3 = l2 - k; + + if ((Math.abs(k2) != l1 || Math.abs(i3) != l1 || random.nextInt(2) != 0 && k1 != 0) && !Block.o[world.getTypeId(i2, j2, l2)]) { + world.setRawTypeIdAndData(i2, j2, l2, Block.LEAVES.id, 2); + } } } } - } - for (i2 = 0; i2 < l; ++i2) { - j1 = world.getTypeId(i, j + i2, k); - if (j1 == 0 || j1 == Block.LEAVES.id) { - world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 2); + for (j2 = 0; j2 < l; ++j2) { + k1 = world.getTypeId(i, j + j2, k); + if (k1 == 0 || k1 == Block.LEAVES.id) { + world.setRawTypeIdAndData(i, j + j2, k, Block.LOG.id, 2); + } } - } - return true; - } else { - return false; + return true; + } } + + return false; } - } else { - return false; } + + return false; } } diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga1.java b/src/main/java/net/minecraft/server/WorldGenTaiga1.java index 01d4ce09a0..7901593300 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga1.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga1.java @@ -25,78 +25,90 @@ public class WorldGenTaiga1 extends WorldGenerator { int k1 = 1 + random.nextInt(j1 + 1); boolean flag = true; - if (j >= 1 && j + l + 1 <= 128) { - int l1; - int i2; - int j2; - int k2; - int l2; + if (j >= 1) { + int l1 = j + l + 1; - for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { - boolean flag1 = true; + world.getClass(); + if (l1 <= 128) { + int i2; + int j2; + int k2; + int l2; + int i3; - if (l1 - j < i1) { - l2 = 0; - } else { - l2 = k1; - } + for (i2 = j; i2 <= j + 1 + l && flag; ++i2) { + boolean flag1 = true; - for (i2 = i - l2; i2 <= i + l2 && flag; ++i2) { - for (j2 = k - l2; j2 <= k + l2 && flag; ++j2) { - if (l1 >= 0 && l1 < 128) { - k2 = world.getTypeId(i2, l1, j2); - if (k2 != 0 && k2 != Block.LEAVES.id) { - flag = false; + if (i2 - j < i1) { + i3 = 0; + } else { + i3 = k1; + } + + for (j2 = i - i3; j2 <= i + i3 && flag; ++j2) { + for (k2 = k - i3; k2 <= k + i3 && flag; ++k2) { + if (i2 >= 0) { + world.getClass(); + if (i2 < 128) { + l2 = world.getTypeId(j2, i2, k2); + if (l2 != 0 && l2 != Block.LEAVES.id) { + flag = false; + } + continue; + } } - } else { + flag = false; } } } - } - if (!flag) { - return false; - } else { - l1 = world.getTypeId(i, j - 1, k); - if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { - world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - l2 = 0; + if (!flag) { + return false; + } - for (i2 = j + l; i2 >= j + i1; --i2) { - for (j2 = i - l2; j2 <= i + l2; ++j2) { - k2 = j2 - i; + i2 = world.getTypeId(i, j - 1, k); + if (i2 == Block.GRASS.id || i2 == Block.DIRT.id) { + world.getClass(); + if (j < 128 - l - 1) { + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + i3 = 0; - for (int i3 = k - l2; i3 <= k + l2; ++i3) { - int j3 = i3 - k; + for (j2 = j + l; j2 >= j + i1; --j2) { + for (k2 = i - i3; k2 <= i + i3; ++k2) { + l2 = k2 - i; - if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.o[world.getTypeId(j2, i2, i3)]) { - world.setRawTypeIdAndData(j2, i2, i3, Block.LEAVES.id, 1); + for (int j3 = k - i3; j3 <= k + i3; ++j3) { + int k3 = j3 - k; + + if ((Math.abs(l2) != i3 || Math.abs(k3) != i3 || i3 <= 0) && !Block.o[world.getTypeId(k2, j2, j3)]) { + world.setRawTypeIdAndData(k2, j2, j3, Block.LEAVES.id, 1); + } } } + + if (i3 >= 1 && j2 == j + i1 + 1) { + --i3; + } else if (i3 < k1) { + ++i3; + } } - if (l2 >= 1 && i2 == j + i1 + 1) { - --l2; - } else if (l2 < k1) { - ++l2; + for (j2 = 0; j2 < l - 1; ++j2) { + k2 = world.getTypeId(i, j + j2, k); + if (k2 == 0 || k2 == Block.LEAVES.id) { + world.setRawTypeIdAndData(i, j + j2, k, Block.LOG.id, 1); + } } - } - for (i2 = 0; i2 < l - 1; ++i2) { - j2 = world.getTypeId(i, j + i2, k); - if (j2 == 0 || j2 == Block.LEAVES.id) { - world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 1); - } + return true; } - - return true; - } else { - return false; } + + return false; } - } else { - return false; } + + return false; } } diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga2.java b/src/main/java/net/minecraft/server/WorldGenTaiga2.java index d384a64ecc..6194736855 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -25,91 +25,103 @@ public class WorldGenTaiga2 extends WorldGenerator { int k1 = 2 + random.nextInt(2); boolean flag = true; - if (j >= 1 && j + l + 1 <= 128) { - int l1; - int i2; - int j2; - int k2; + if (j >= 1) { + int l1 = j + l + 1; - for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { - boolean flag1 = true; + world.getClass(); + if (l1 <= 128) { + int i2; + int j2; + int k2; + int l2; - if (l1 - j < i1) { - k2 = 0; - } else { - k2 = k1; - } + for (i2 = j; i2 <= j + 1 + l && flag; ++i2) { + boolean flag1 = true; - for (i2 = i - k2; i2 <= i + k2 && flag; ++i2) { - for (int l2 = k - k2; l2 <= k + k2 && flag; ++l2) { - if (l1 >= 0 && l1 < 128) { - j2 = world.getTypeId(i2, l1, l2); - if (j2 != 0 && j2 != Block.LEAVES.id) { - flag = false; + if (i2 - j < i1) { + l2 = 0; + } else { + l2 = k1; + } + + for (j2 = i - l2; j2 <= i + l2 && flag; ++j2) { + for (int i3 = k - l2; i3 <= k + l2 && flag; ++i3) { + if (i2 >= 0) { + world.getClass(); + if (i2 < 128) { + k2 = world.getTypeId(j2, i2, i3); + if (k2 != 0 && k2 != Block.LEAVES.id) { + flag = false; + } + continue; + } } - } else { + flag = false; } } } - } - if (!flag) { - return false; - } else { - l1 = world.getTypeId(i, j - 1, k); - if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) { - world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - k2 = random.nextInt(2); - i2 = 1; - byte b0 = 0; - - int i3; - int j3; - - for (j2 = 0; j2 <= j1; ++j2) { - j3 = j + l - j2; - - for (i3 = i - k2; i3 <= i + k2; ++i3) { - int k3 = i3 - i; - - for (int l3 = k - k2; l3 <= k + k2; ++l3) { - int i4 = l3 - k; - - if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) { - world.setRawTypeIdAndData(i3, j3, l3, Block.LEAVES.id, 1); - } - } - } - - if (k2 >= i2) { - k2 = b0; - b0 = 1; - ++i2; - if (i2 > k1) { - i2 = k1; - } - } else { - ++k2; - } - } - - j2 = random.nextInt(3); - - for (j3 = 0; j3 < l - j2; ++j3) { - i3 = world.getTypeId(i, j + j3, k); - if (i3 == 0 || i3 == Block.LEAVES.id) { - world.setRawTypeIdAndData(i, j + j3, k, Block.LOG.id, 1); - } - } - - return true; - } else { + if (!flag) { return false; } + + i2 = world.getTypeId(i, j - 1, k); + if (i2 == Block.GRASS.id || i2 == Block.DIRT.id) { + world.getClass(); + if (j < 128 - l - 1) { + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + l2 = random.nextInt(2); + j2 = 1; + byte b0 = 0; + + int j3; + int k3; + + for (k2 = 0; k2 <= j1; ++k2) { + k3 = j + l - k2; + + for (j3 = i - l2; j3 <= i + l2; ++j3) { + int l3 = j3 - i; + + for (int i4 = k - l2; i4 <= k + l2; ++i4) { + int j4 = i4 - k; + + if ((Math.abs(l3) != l2 || Math.abs(j4) != l2 || l2 <= 0) && !Block.o[world.getTypeId(j3, k3, i4)]) { + world.setRawTypeIdAndData(j3, k3, i4, Block.LEAVES.id, 1); + } + } + } + + if (l2 >= j2) { + l2 = b0; + b0 = 1; + ++j2; + if (j2 > k1) { + j2 = k1; + } + } else { + ++l2; + } + } + + k2 = random.nextInt(3); + + for (k3 = 0; k3 < l - k2; ++k3) { + j3 = world.getTypeId(i, j + k3, k); + if (j3 == 0 || j3 == Block.LEAVES.id) { + world.setRawTypeIdAndData(i, j + k3, k, Block.LOG.id, 1); + } + } + + return true; + } + } + + return false; } - } else { - return false; } + + return false; } } diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index f8fd47108f..021560fc33 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -22,77 +22,89 @@ public class WorldGenTrees extends WorldGenerator { int l = random.nextInt(3) + 4; boolean flag = true; - if (j >= 1 && j + l + 1 <= 128) { - int i1; - int j1; - int k1; - int l1; + if (j >= 1) { + int k1000 = j + l + 1; - for (i1 = j; i1 <= j + 1 + l; ++i1) { - byte b0 = 1; + world.getClass(); + if (k1000 <= 128) { + int j1; + int k1; + int l1; + int i2; - if (i1 == j) { - b0 = 0; - } + for (j1 = j; j1 <= j + 1 + l; ++j1) { + byte b0 = 1; - if (i1 >= j + 1 + l - 2) { - b0 = 2; - } + if (j1 == j) { + b0 = 0; + } - for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { - for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { - if (i1 >= 0 && i1 < 128) { - l1 = world.getTypeId(j1, i1, k1); - if (l1 != 0 && l1 != Block.LEAVES.id) { - flag = false; + if (j1 >= j + 1 + l - 2) { + b0 = 2; + } + + for (k1 = i - b0; k1 <= i + b0 && flag; ++k1) { + for (l1 = k - b0; l1 <= k + b0 && flag; ++l1) { + if (j1 >= 0) { + world.getClass(); + if (j1 < 128) { + i2 = world.getTypeId(k1, j1, l1); + if (i2 != 0 && i2 != Block.LEAVES.id) { + flag = false; + } + continue; + } } - } else { + flag = false; } } } - } - if (!flag) { - return false; - } else { - i1 = world.getTypeId(i, j - 1, k); - if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) { - world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + if (!flag) { + return false; + } - int i2; + j1 = world.getTypeId(i, j - 1, k); + if (j1 == Block.GRASS.id || j1 == Block.DIRT.id) { + world.getClass(); + if (j < 128 - l - 1) { + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - for (i2 = j - 3 + l; i2 <= j + l; ++i2) { - j1 = i2 - (j + l); - k1 = 1 - j1 / 2; + int j2; - for (l1 = i - k1; l1 <= i + k1; ++l1) { - int j2 = l1 - i; + for (j2 = j - 3 + l; j2 <= j + l; ++j2) { + k1 = j2 - (j + l); + l1 = 1 - k1 / 2; - for (int k2 = k - k1; k2 <= k + k1; ++k2) { - int l2 = k2 - k; + for (i2 = i - l1; i2 <= i + l1; ++i2) { + int k2 = i2 - i; - if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { - world.setRawTypeId(l1, i2, k2, Block.LEAVES.id); + for (int l2 = k - l1; l2 <= k + l1; ++l2) { + int i3 = l2 - k; + + if ((Math.abs(k2) != l1 || Math.abs(i3) != l1 || random.nextInt(2) != 0 && k1 != 0) && !Block.o[world.getTypeId(i2, j2, l2)]) { + world.setRawTypeId(i2, j2, l2, Block.LEAVES.id); + } } } } - } - for (i2 = 0; i2 < l; ++i2) { - j1 = world.getTypeId(i, j + i2, k); - if (j1 == 0 || j1 == Block.LEAVES.id) { - world.setRawTypeId(i, j + i2, k, Block.LOG.id); + for (j2 = 0; j2 < l; ++j2) { + k1 = world.getTypeId(i, j + j2, k); + if (k1 == 0 || k1 == Block.LEAVES.id) { + world.setRawTypeId(i, j + j2, k, Block.LOG.id); + } } - } - return true; - } else { - return false; + return true; + } } + + return false; } - } else { - return false; } + + return false; } } diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java index 8c6c992330..5bfb7d447a 100644 --- a/src/main/java/net/minecraft/server/WorldManager.java +++ b/src/main/java/net/minecraft/server/WorldManager.java @@ -24,8 +24,6 @@ public class WorldManager implements IWorldAccess { public void a(int i, int j, int k, int l, int i1, int j1) {} - public void a() {} - public void a(int i, int j, int k) { this.server.serverConfigurationManager.flagDirty(i, j, k, this.world.dimension); // CraftBukkit } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 2005a9bcee..3faa9ac4cd 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -20,11 +20,11 @@ public class WorldServer extends World implements BlockChangeDelegate { public boolean weirdIsOpCache = false; public boolean canSave; public final MinecraftServer server; // CraftBukkit - private -> public final - private EntityList G = new EntityList(); + private EntityList Q = new EntityList(); // CraftBukkit start - change signature - public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, org.bukkit.World.Environment env, ChunkGenerator gen) { - super(idatamanager, s, j, WorldProvider.byDimension(env.getId()), gen, env); + public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, WorldSettings worldsettings, org.bukkit.World.Environment env, ChunkGenerator gen) { + super(idatamanager, s, worldsettings, WorldProvider.byDimension(env.getId()), gen, env); this.server = minecraftserver; this.dimension = i; @@ -54,7 +54,7 @@ public class WorldServer extends World implements BlockChangeDelegate { } protected IChunkProvider b() { - IChunkLoader ichunkloader = this.w.a(this.worldProvider); + IChunkLoader ichunkloader = this.B.a(this.worldProvider); // CraftBukkit start InternalChunkGenerator gen; @@ -78,8 +78,8 @@ public class WorldServer extends World implements BlockChangeDelegate { public List getTileEntities(int i, int j, int k, int l, int i1, int j1) { ArrayList arraylist = new ArrayList(); - for (int k1 = 0; k1 < this.c.size(); ++k1) { - TileEntity tileentity = (TileEntity) this.c.get(k1); + for (int k1 = 0; k1 < this.h.size(); ++k1) { + TileEntity tileentity = (TileEntity) this.h.get(k1); if (tileentity.x >= i && tileentity.y >= j && tileentity.z >= k && tileentity.x < l && tileentity.y < i1 && tileentity.z < j1) { arraylist.add(tileentity); @@ -90,8 +90,8 @@ public class WorldServer extends World implements BlockChangeDelegate { } public boolean a(EntityHuman entityhuman, int i, int j, int k) { - int l = (int) MathHelper.abs((float) (i - this.worldData.c())); - int i1 = (int) MathHelper.abs((float) (k - this.worldData.e())); + int l = MathHelper.a(i - this.worldData.c()); + int i1 = MathHelper.a(k - this.worldData.e()); if (l > i1) { i1 = l; @@ -103,16 +103,16 @@ public class WorldServer extends World implements BlockChangeDelegate { protected void c(Entity entity) { super.c(entity); - this.G.a(entity.id, entity); + this.Q.a(entity.id, entity); } protected void d(Entity entity) { super.d(entity); - this.G.d(entity.id); + this.Q.d(entity.id); } public Entity getEntity(int i) { - return (Entity) this.G.a(i); + return (Entity) this.Q.a(i); } public boolean strikeLightning(Entity entity) { @@ -165,18 +165,18 @@ public class WorldServer extends World implements BlockChangeDelegate { } public void saveLevel() { - this.w.e(); + this.B.e(); } - protected void i() { - boolean flag = this.v(); + protected void h() { + boolean flag = this.u(); - super.i(); - if (flag != this.v()) { + super.h(); + if (flag != this.u()) { // CraftBukkit start - only sending weather packets to those affected for (int i = 0; i < this.players.size(); ++i) { if (((EntityPlayer) this.players.get(i)).world == this) { - ((EntityPlayer) this.players.get(i)).netServerHandler.sendPacket(new Packet70Bed(flag ? 2 : 1)); + ((EntityPlayer) this.players.get(i)).netServerHandler.sendPacket(new Packet70Bed(flag ? 2 : 1, 0)); } } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 5ea5e01f22..b02b3d3745 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -154,7 +154,7 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = chunk.world.getWorldChunkManager(); - BiomeBase[] biomeBase = wcm.getBiomeData(getX() << 4, getZ() << 4, 16, 16); + BiomeBase[] biomeBase = wcm.b((BiomeBase[])null, getX() << 4, getZ() << 4, 16, 16); if (includeBiome) { biome = new BiomeBase[256]; @@ -164,8 +164,9 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); - System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + //System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); + //System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + // TODO: Figure out new snapshot stuff } } World world = getWorld(); @@ -208,7 +209,7 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = world.getHandle().getWorldChunkManager(); - BiomeBase[] biomeBase = wcm.getBiomeData(x << 4, z << 4, 16, 16); + BiomeBase[] biomeBase = wcm.b((BiomeBase[])null, x << 4, z << 4, 16, 16); if (includeBiome) { biome = new BiomeBase[256]; @@ -218,8 +219,9 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; biomeRain = new double[256]; - System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); - System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + //System.arraycopy(wcm.temperature, 0, biomeTemp, 0, biomeTemp.length); + //System.arraycopy(wcm.rain, 0, biomeRain, 0, biomeRain.length); + // TODO: Figure out new snapshot stuff } } return new EmptyChunkSnapshot(x, z, world.getName(), world.getFullTime(), biome, biomeTemp, biomeRain); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 5ce5204fd5..0038182066 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -50,6 +50,7 @@ import net.minecraft.server.Item; import net.minecraft.server.ItemStack; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldMapCollection; +import net.minecraft.server.WorldSettings; import org.bukkit.*; import org.bukkit.permissions.Permissible; import org.bukkit.plugin.Plugin; @@ -79,7 +80,7 @@ import org.yaml.snakeyaml.error.MarkedYAMLException; public final class CraftServer implements Server { private final String serverName = "Craftbukkit"; private final String serverVersion; - private final String protocolVersion = "1.7.3"; + private final String protocolVersion = "1.8"; private final ServicesManager servicesManager = new SimpleServicesManager(); private final BukkitScheduler scheduler = new CraftScheduler(this); private final SimpleCommandMap commandMap = new SimpleCommandMap(this); @@ -489,7 +490,7 @@ public final class CraftServer implements Server { } int dimension = 10 + console.worlds.size(); - WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, dimension, seed, environment, generator); + WorldServer internal = new WorldServer(console, new ServerNBTManager(new File("."), name, true), name, dimension, new WorldSettings(seed, getDefaultGameMode().getValue(), true), environment, generator); if (!(worlds.containsKey(name.toLowerCase()))) { return null; @@ -532,7 +533,7 @@ public final class CraftServer implements Server { ChunkCoordinates chunkcoordinates = internal.getSpawn(); internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4); - while (internal.doLighting()) { + while (internal.v()) { ; } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0faf610eb1..98c98ad217 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -153,7 +153,7 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z); - if (save && !chunk.isEmpty()) { + if (save && !(chunk instanceof EmptyChunk)) { chunk.removeEntities(); world.chunkProviderServer.saveChunk(chunk); world.chunkProviderServer.saveChunkNOP(chunk); @@ -474,43 +474,37 @@ public class CraftWorld implements World { public Biome getBiome(int x, int z) { BiomeBase base = getHandle().getWorldChunkManager().getBiome(x, z); - if (base == BiomeBase.RAINFOREST) { - return Biome.RAINFOREST; - } else if (base == BiomeBase.SWAMPLAND) { + if (base == BiomeBase.SWAMPLAND) { return Biome.SWAMPLAND; - } else if (base == BiomeBase.SEASONAL_FOREST) { - return Biome.SEASONAL_FOREST; } else if (base == BiomeBase.FOREST) { return Biome.FOREST; - } else if (base == BiomeBase.SAVANNA) { - return Biome.SAVANNA; - } else if (base == BiomeBase.SHRUBLAND) { - return Biome.SHRUBLAND; } else if (base == BiomeBase.TAIGA) { return Biome.TAIGA; } else if (base == BiomeBase.DESERT) { return Biome.DESERT; } else if (base == BiomeBase.PLAINS) { return Biome.PLAINS; - } else if (base == BiomeBase.ICE_DESERT) { - return Biome.ICE_DESERT; - } else if (base == BiomeBase.TUNDRA) { - return Biome.TUNDRA; } else if (base == BiomeBase.HELL) { return Biome.HELL; } else if (base == BiomeBase.SKY) { return Biome.SKY; + } else if (base == BiomeBase.OCEAN) { + return Biome.OCEAN; + } else if (base == BiomeBase.EXTREME_HILLS) { + return Biome.EXTREME_HILLS; + } else if (base == BiomeBase.RIVER) { + return Biome.RIVER; } return null; } public double getTemperature(int x, int z) { - return getHandle().getWorldChunkManager().a((double[])null, x, z, 1, 1)[0]; + throw new UnsupportedOperationException("Not compatible with 1.8"); } public double getHumidity(int x, int z) { - return getHandle().getWorldChunkManager().getHumidity(x, z); + throw new UnsupportedOperationException("Not compatible with 1.8"); } public List getEntities() { @@ -810,7 +804,7 @@ public class CraftWorld implements World { loadChunk(chunkCoordX + x, chunkCoordZ + z); } else { if (isChunkLoaded(chunkCoordX + x, chunkCoordZ + z)) { - if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z).isEmpty()) { + if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z) instanceof EmptyChunk) { unloadChunk(chunkCoordX + x, chunkCoordZ + z, false); } else { unloadChunk(chunkCoordX + x, chunkCoordZ + z); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 139fc50f8f..40d66b5ec1 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -222,32 +222,26 @@ public class CraftBlock implements Block { } public static final Biome biomeBaseToBiome(BiomeBase base) { - if (base == BiomeBase.RAINFOREST) { - return Biome.RAINFOREST; - } else if (base == BiomeBase.SWAMPLAND) { + if (base == BiomeBase.SWAMPLAND) { return Biome.SWAMPLAND; - } else if (base == BiomeBase.SEASONAL_FOREST) { - return Biome.SEASONAL_FOREST; } else if (base == BiomeBase.FOREST) { return Biome.FOREST; - } else if (base == BiomeBase.SAVANNA) { - return Biome.SAVANNA; - } else if (base == BiomeBase.SHRUBLAND) { - return Biome.SHRUBLAND; } else if (base == BiomeBase.TAIGA) { return Biome.TAIGA; } else if (base == BiomeBase.DESERT) { return Biome.DESERT; } else if (base == BiomeBase.PLAINS) { return Biome.PLAINS; - } else if (base == BiomeBase.ICE_DESERT) { - return Biome.ICE_DESERT; - } else if (base == BiomeBase.TUNDRA) { - return Biome.TUNDRA; } else if (base == BiomeBase.HELL) { return Biome.HELL; } else if (base == BiomeBase.SKY) { return Biome.SKY; + } else if (base == BiomeBase.RIVER) { + return Biome.RIVER; + } else if (base == BiomeBase.EXTREME_HILLS) { + return Biome.EXTREME_HILLS; + } else if (base == BiomeBase.OCEAN) { + return Biome.OCEAN; } return null; @@ -308,7 +302,7 @@ public class CraftBlock implements Block { } public PistonMoveReaction getPistonMoveReaction() { - return PistonMoveReaction.getById(net.minecraft.server.Block.byId[this.getTypeId()].material.j()); + return PistonMoveReaction.getById(net.minecraft.server.Block.byId[this.getTypeId()].material.l()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 29e5ab4893..9c1cc85451 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -23,6 +23,8 @@ import java.util.List; import java.util.HashSet; import java.util.ArrayList; import java.util.Iterator; +import net.minecraft.server.DamageSource; +import org.bukkit.entity.HumanEntity; public class CraftLivingEntity extends CraftEntity implements LivingEntity { public CraftLivingEntity(final CraftServer server, final EntityLiving entity) { @@ -39,7 +41,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } if (entity instanceof EntityPlayer && health == 0) { - ((EntityPlayer) entity).die((Entity) null); + ((EntityPlayer) entity).die(DamageSource.j); } getHandle().health = health; @@ -125,7 +127,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public Arrow shootArrow() { net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle(); - EntityArrow arrow = new EntityArrow(world, getHandle()); + EntityArrow arrow = new EntityArrow(world, getHandle(), 1); world.addEntity(arrow); return (Arrow) arrow.getBukkitEntity(); @@ -174,11 +176,19 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public void damage(int amount) { - entity.damageEntity((Entity) null, amount); + entity.damageEntity(DamageSource.j, amount); } public void damage(int amount, org.bukkit.entity.Entity source) { - entity.damageEntity(((CraftEntity) source).getHandle(), amount); + DamageSource reason = DamageSource.a.j; + + if (source instanceof HumanEntity) { + reason = DamageSource.b(((CraftHumanEntity)source).getHandle()); + } else if (source instanceof LivingEntity) { + reason = DamageSource.a(((CraftLivingEntity)source).getHandle()); + } + + entity.damageEntity(reason, amount); } public Location getEyeLocation() {