diff options
Diffstat (limited to 'src/main/java/net')
128 files changed, 5673 insertions, 4440 deletions
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index 4eee4f7d..9ff2ccd1 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -22,41 +22,42 @@ public class Block { public static final boolean[] r = new boolean[256]; public static final int[] s = new int[256]; public static final boolean[] t = new boolean[256]; + public static boolean[] u = new boolean[256]; public static final Block STONE = (new BlockStone(1, 1)).c(1.5F).b(10.0F).a(h).a("stone"); public static final BlockGrass GRASS = (BlockGrass) (new BlockGrass(2)).c(0.6F).a(g).a("grass"); public static final Block DIRT = (new BlockDirt(3, 2)).c(0.5F).a(f).a("dirt"); public static final Block COBBLESTONE = (new Block(4, 16, Material.STONE)).c(2.0F).b(10.0F).a(h).a("stonebrick"); - public static final Block WOOD = (new Block(5, 4, Material.WOOD)).c(2.0F).b(5.0F).a(e).a("wood").g(); - public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(g).a("sapling").g(); - public static final Block BEDROCK = (new Block(7, 17, Material.STONE)).i().b(6000000.0F).a(h).a("bedrock").n(); - public static final Block WATER = (new BlockFlowing(8, Material.WATER)).c(100.0F).f(3).a("water").n().g(); - public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.WATER)).c(100.0F).f(3).a("water").n().g(); - public static final Block LAVA = (new BlockFlowing(10, Material.LAVA)).c(0.0F).a(1.0F).f(255).a("lava").n().g(); - public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.LAVA)).c(100.0F).a(1.0F).f(255).a("lava").n().g(); + public static final Block WOOD = (new Block(5, 4, Material.WOOD)).c(2.0F).b(5.0F).a(e).a("wood").i(); + public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(g).a("sapling").i(); + public static final Block BEDROCK = (new Block(7, 17, Material.STONE)).k().b(6000000.0F).a(h).a("bedrock").p(); + public static final Block WATER = (new BlockFlowing(8, Material.WATER)).c(100.0F).g(3).a("water").p().i(); + public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.WATER)).c(100.0F).g(3).a("water").p().i(); + public static final Block LAVA = (new BlockFlowing(10, Material.LAVA)).c(0.0F).a(1.0F).g(255).a("lava").p().i(); + public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.LAVA)).c(100.0F).a(1.0F).g(255).a("lava").p().i(); public static final Block SAND = (new BlockSand(12, 18)).c(0.5F).a(l).a("sand"); public static final Block GRAVEL = (new BlockGravel(13, 19)).c(0.6F).a(f).a("gravel"); public static final Block GOLD_ORE = (new BlockOre(14, 32)).c(3.0F).b(5.0F).a(h).a("oreGold"); 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").g(); + public static final Block LOG = (new BlockLog(17)).c(2.0F).a(e).a("log").i(); + public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).g(1).a(g).a("leaves").i(); 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"); public static final Block LAPIS_BLOCK = (new Block(22, 144, Material.STONE)).c(3.0F).b(5.0F).a(h).a("blockLapis"); - public static final Block DISPENSER = (new BlockDispenser(23)).c(3.5F).a(h).a("dispenser").g(); + public static final Block DISPENSER = (new BlockDispenser(23)).c(3.5F).a(h).a("dispenser").i(); public static final Block SANDSTONE = (new BlockSandStone(24)).a(h).c(0.8F).a("sandStone"); - public static final Block NOTE_BLOCK = (new BlockNote(25)).c(0.8F).a("musicBlock").g(); - public static final Block BED = (new BlockBed(26)).c(0.2F).a("bed").n().g(); - public static final Block GOLDEN_RAIL = (new BlockMinecartTrack(27, 179, true)).c(0.7F).a(i).a("goldenRail").g(); - public static final Block DETECTOR_RAIL = (new BlockMinecartDetector(28, 195)).c(0.7F).a(i).a("detectorRail").g(); - public static final Block PISTON_STICKY = (new BlockPiston(29, 106, true)).a("pistonStickyBase").g(); - public static final Block WEB = (new BlockWeb(30, 11)).f(1).c(4.0F).a("web"); + public static final Block NOTE_BLOCK = (new BlockNote(25)).c(0.8F).a("musicBlock").i(); + public static final Block BED = (new BlockBed(26)).c(0.2F).a("bed").p().i(); + public static final Block GOLDEN_RAIL = (new BlockMinecartTrack(27, 179, true)).c(0.7F).a(i).a("goldenRail").i(); + public static final Block DETECTOR_RAIL = (new BlockMinecartDetector(28, 195)).c(0.7F).a(i).a("detectorRail").i(); + public static final Block PISTON_STICKY = (new BlockPiston(29, 106, true)).a("pistonStickyBase").i(); + public static final Block WEB = (new BlockWeb(30, 11)).g(1).c(4.0F).a("web"); public static final BlockLongGrass LONG_GRASS = (BlockLongGrass) (new BlockLongGrass(31, 39)).c(0.0F).a(g).a("tallgrass"); public static final BlockDeadBush DEAD_BUSH = (BlockDeadBush) (new BlockDeadBush(32, 55)).c(0.0F).a(g).a("deadbush"); - public static final Block PISTON = (new BlockPiston(33, 107, false)).a("pistonBase").g(); - public static final BlockPistonExtension PISTON_EXTENSION = (BlockPistonExtension) (new BlockPistonExtension(34, 107)).g(); - public static final Block WOOL = (new BlockCloth()).c(0.8F).a(k).a("cloth").g(); + public static final Block PISTON = (new BlockPiston(33, 107, false)).a("pistonBase").i(); + public static final BlockPistonExtension PISTON_EXTENSION = (BlockPistonExtension) (new BlockPistonExtension(34, 107)).i(); + public static final Block WOOL = (new BlockCloth()).c(0.8F).a(k).a("cloth").i(); public static final BlockPistonMoving PISTON_MOVING = new BlockPistonMoving(36); public static final BlockFlower YELLOW_FLOWER = (BlockFlower) (new BlockFlower(37, 13)).c(0.0F).a(g).a("flower"); public static final BlockFlower RED_ROSE = (BlockFlower) (new BlockFlower(38, 12)).c(0.0F).a(g).a("rose"); @@ -70,73 +71,86 @@ public class Block { public static final Block TNT = (new BlockTNT(46, 8)).c(0.0F).a(g).a("tnt"); public static final Block BOOKSHELF = (new BlockBookshelf(47, 35)).c(1.5F).a(e).a("bookshelf"); 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(); - 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(); - public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 164)).c(0.0F).a(d).a("redstoneDust").n().g(); + public static final Block OBSIDIAN = (new BlockObsidian(49, 37)).c(50.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").i(); + public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).a("fire").p(); + public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(i).a("mobSpawner").p(); + public static final Block WOOD_STAIRS = (new BlockStairs(53, WOOD)).a("stairsWood").i(); + public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(e).a("chest").i(); + public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 164)).c(0.0F).a(d).a("redstoneDust").p().i(); public static final Block DIAMOND_ORE = (new BlockOre(56, 50)).c(3.0F).b(5.0F).a(h).a("oreDiamond"); 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").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(); - public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.WOOD)).c(3.0F).a(e).a("doorWood").n().g(); - public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(e).a("ladder").g(); - public static final Block RAILS = (new BlockMinecartTrack(66, 128, false)).c(0.7F).a(i).a("rail").g(); - public static final Block COBBLESTONE_STAIRS = (new BlockStairs(67, COBBLESTONE)).a("stairsStone").g(); - public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(e).a("sign").n().g(); - public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(e).a("lever").g(); - public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.textureId, EnumMobType.MOBS, Material.STONE)).c(0.5F).a(h).a("pressurePlate").g(); - public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.ORE)).c(5.0F).a(i).a("doorIron").n().g(); - public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.textureId, EnumMobType.EVERYTHING, Material.WOOD)).c(0.5F).a(e).a("pressurePlate").g(); - public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(h).a("oreRedstone").g(); - public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(h).a("oreRedstone").g(); - public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(e).a("notGate").g(); - public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(e).a("notGate").g(); - public static final Block STONE_BUTTON = (new BlockButton(77, STONE.textureId)).c(0.5F).a(h).a("button").g(); - public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(k).a("snow"); - public static final Block ICE = (new BlockIce(79, 67)).c(0.5F).f(3).a(j).a("ice"); + public static final Block CROPS = (new BlockCrops(59, 88)).c(0.0F).a(g).a("crops").p().i(); + public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).a("farmland").i(); + public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(h).a("furnace").i(); + public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(h).a(0.875F).a("furnace").i(); + public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(e).a("sign").p().i(); + public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.WOOD)).c(3.0F).a(e).a("doorWood").p().i(); + public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(e).a("ladder").i(); + public static final Block RAILS = (new BlockMinecartTrack(66, 128, false)).c(0.7F).a(i).a("rail").i(); + public static final Block COBBLESTONE_STAIRS = (new BlockStairs(67, COBBLESTONE)).a("stairsStone").i(); + public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(e).a("sign").p().i(); + public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(e).a("lever").i(); + public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.textureId, EnumMobType.MOBS, Material.STONE)).c(0.5F).a(h).a("pressurePlate").i(); + public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.ORE)).c(5.0F).a(i).a("doorIron").p().i(); + public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.textureId, EnumMobType.EVERYTHING, Material.WOOD)).c(0.5F).a(e).a("pressurePlate").i(); + public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(h).a("oreRedstone").i(); + public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(h).a("oreRedstone").i(); + public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(e).a("notGate").i(); + public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(e).a("notGate").i(); + public static final Block STONE_BUTTON = (new BlockButton(77, STONE.textureId)).c(0.5F).a(h).a("button").i(); + public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(k).a("snow").g(0); + public static final Block ICE = (new BlockIce(79, 67)).c(0.5F).g(3).a(j).a("ice"); public static final Block SNOW_BLOCK = (new BlockSnowBlock(80, 66)).c(0.2F).a(k).a("snow"); public static final Block CACTUS = (new BlockCactus(81, 70)).c(0.4F).a(k).a("cactus"); 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 SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(g).a("reeds").p(); + public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(h).a("jukebox").i(); 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 PUMPKIN = (new BlockPumpkin(86, 102, false)).c(1.0F).a(e).a("pumpkin").i(); 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"); - public static final Block GLOWSTONE = (new BlockLightStone(89, 105, Material.STONE)).c(0.3F).a(j).a(1.0F).a("lightgem"); + public static final Block GLOWSTONE = (new BlockLightStone(89, 105, Material.SHATTERABLE)).c(0.3F).a(j).a(1.0F).a("lightgem"); public static final BlockPortal PORTAL = (BlockPortal) (new BlockPortal(90, 14)).c(-1.0F).a(j).a(0.75F).a("portal"); - public static final Block JACK_O_LANTERN = (new BlockPumpkin(91, 102, true)).c(1.0F).a(e).a(1.0F).a("litpumpkin").g(); - public static final Block CAKE_BLOCK = (new BlockCake(92, 121)).c(0.5F).a(k).a("cake").n().g(); - public static final Block DIODE_OFF = (new BlockDiode(93, false)).c(0.0F).a(e).a("diode").n().g(); - 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 JACK_O_LANTERN = (new BlockPumpkin(91, 102, true)).c(1.0F).a(e).a(1.0F).a("litpumpkin").i(); + public static final Block CAKE_BLOCK = (new BlockCake(92, 121)).c(0.5F).a(k).a("cake").p().i(); + public static final Block DIODE_OFF = (new BlockDiode(93, false)).c(0.0F).a(e).a("diode").p().i(); + public static final Block DIODE_ON = (new BlockDiode(94, true)).c(0.0F).a(0.625F).a(e).a("diode").p().i(); + public static final Block LOCKED_CHEST = (new BlockLockedChest(95)).c(0.0F).a(1.0F).a(e).a("lockedchest").a(true).i(); + public static final Block TRAP_DOOR = (new BlockTrapdoor(96, Material.WOOD)).c(3.0F).a(e).a("trapdoor").p().i(); 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 BIG_MUSHROOM_1 = (new BlockHugeMushroom(99, Material.WOOD, 142, 0)).c(0.2F).a(e).a("mushroom").i(); + public static final Block BIG_MUSHROOM_2 = (new BlockHugeMushroom(100, Material.WOOD, 142, 1)).c(0.2F).a(e).a("mushroom").i(); + public static final Block IRON_FENCE = (new BlockThin(101, 85, 85, Material.ORE, true)).c(5.0F).b(10.0F).a(i).a("fenceIron"); + public static final Block THIN_GLASS = (new BlockThin(102, 49, 148, Material.SHATTERABLE, false)).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 static final Block PUMPKIN_STEM = (new BlockStem(104, PUMPKIN)).c(0.0F).a(e).a("pumpkinStem").i(); + public static final Block MELON_STEM = (new BlockStem(105, MELON)).c(0.0F).a(e).a("pumpkinStem").i(); + public static final Block VINE = (new BlockVine(106)).c(0.2F).a(g).a("vine").i(); + public static final Block FENCE_GATE = (new BlockFenceGate(107, 4)).c(2.0F).b(5.0F).a(e).a("fenceGate").i(); + public static final Block BRICK_STAIRS = (new BlockStairs(108, BRICK)).a("stairsBrick").i(); + public static final Block STONE_STAIRS = (new BlockStairs(109, SMOOTH_BRICK)).a("stairsStoneBrickSmooth").i(); + public static final BlockMycel MYCEL = (BlockMycel) (new BlockMycel(110)).c(0.6F).a(g).a("mycel"); + public static final Block WATER_LILY = (new BlockWaterLily(111, 76)).c(0.0F).a(g).a("waterlily"); + public static final Block NETHER_BRICK = (new Block(112, 224, Material.STONE)).c(2.0F).b(10.0F).a(h).a("netherBrick"); + public static final Block NETHER_FENCE = (new BlockFence(113, 224, Material.STONE)).c(2.0F).b(10.0F).a(h).a("netherFence"); + public static final Block NETHER_BRICK_STAIRS = (new BlockStairs(114, NETHER_BRICK)).a("stairsNetherBrick").i(); + public static final Block NETHER_WART = (new BlockNetherWart(115)).a("netherStalk").i(); + public static final Block ENCHANTMENT_TABLE = (new BlockEnchantmentTable(116)).c(5.0F).b(2000.0F).a("enchantmentTable"); + public static final Block BREWING_STAND = (new BlockBrewingStand(117)).c(0.5F).a(0.125F).a("brewingStand").i(); + public static final Block CAULDRON = (new BlockCauldron(118)).c(2.0F).a("cauldron").i(); + public static final Block ENDER_PORTAL = (new BlockEnderPortal(119, Material.PORTAL)).c(-1.0F).b(6000000.0F); + public static final Block ENDER_PORTAL_FRAME = (new BlockEnderPortalFrame(120)).a(j).a(0.125F).c(-1.0F).a("endPortalFrame").i().b(6000000.0F); + public static final Block WHITESTONE = (new Block(121, 175, Material.STONE)).c(3.0F).b(15.0F).a(h).a("whiteStone"); + public static final Block DRAGON_EGG = (new BlockDragonEgg(122, 167)).c(3.0F).b(15.0F).a(h).a(0.125F).a("dragonEgg"); public int textureId; public final int id; protected float strength; protected float durability; - protected boolean bD; - protected boolean bE; + protected boolean bR; + protected boolean bS; public double minX; public double minY; public double minZ; @@ -144,16 +158,16 @@ public class Block { public double maxY; public double maxZ; public StepSound stepSound; - public float bM; + public float ca; public final Material material; public float frictionFactor; private String name; protected Block(int i, Material material) { - this.bD = true; - this.bE = true; + this.bR = true; + this.bS = true; this.stepSound = d; - this.bM = 1.0F; + this.ca = 1.0F; this.frictionFactor = 0.6F; if (byId[i] != null) { throw new IllegalArgumentException("Slot " + i + " is already occupied by " + byId[i] + " when adding " + this); @@ -169,12 +183,12 @@ public class Block { } } - protected Block g() { + protected Block i() { t[this.id] = true; return this; } - protected void h() {} + protected void j() {} protected Block(int i, int j, Material material) { this(i, material); @@ -186,7 +200,7 @@ public class Block { return this; } - protected Block f(int i) { + protected Block g(int i) { q[this.id] = i; return this; } @@ -205,6 +219,10 @@ public class Block { return true; } + public int c() { + return 0; + } + protected Block c(float f) { this.strength = f; if (this.durability < f * 5.0F) { @@ -214,12 +232,12 @@ public class Block { return this; } - protected Block i() { + protected Block k() { this.c(-1.0F); return this; } - public float j() { + public float l() { return this.strength; } @@ -266,10 +284,10 @@ public class Block { } public boolean a(int i, boolean flag) { - return this.q_(); + return this.v_(); } - public boolean q_() { + public boolean v_() { return true; } @@ -279,7 +297,7 @@ public class Block { public void doPhysics(World world, int i, int j, int k, int l) {} - public int c() { + public int d() { return 10; } @@ -291,7 +309,7 @@ public class Block { return 1; } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return this.id; } @@ -299,21 +317,21 @@ public class Block { return this.strength < 0.0F ? 0.0F : (!entityhuman.b(this) ? 1.0F / this.strength / 100.0F : entityhuman.a(this) / this.strength / 30.0F); } - public final void g(World world, int i, int j, int k, int l) { - this.dropNaturally(world, i, j, k, l, 1.0F); + public final void b(World world, int i, int j, int k, int l, int i1) { + this.dropNaturally(world, i, j, k, l, 1.0F, i1); } - public void dropNaturally(World world, int i, int j, int k, int l, float f) { + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { if (!world.isStatic) { - int i1 = this.a(world.random); + int j1 = this.a(i1, world.random); - for (int j1 = 0; j1 < i1; ++j1) { + for (int k1 = 0; k1 < j1; ++k1) { // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions if (world.random.nextFloat() < f) { - int k1 = this.a(l, world.random); + int l1 = this.a(l, world.random, i1); - if (k1 > 0) { - this.a(world, i, j, k, new ItemStack(k1, 1, this.a_(l))); + if (l1 > 0) { + this.a(world, i, j, k, new ItemStack(l1, 1, this.c(l))); } } } @@ -333,7 +351,7 @@ public class Block { } } - protected int a_(int i) { + protected int c(int i) { return 0; } @@ -487,10 +505,36 @@ public class Block { return false; } + public void f() {} + 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); + entityhuman.c(0.025F); + if (this.b() && !isTileEntity[this.id] && EnchantmentManager.d(entityhuman.inventory)) { + ItemStack itemstack = this.a_(l); + + if (itemstack != null) { + this.a(world, i, j, k, itemstack); + } + } else { + int i1 = EnchantmentManager.e(entityhuman.inventory); + + this.b(world, i, j, k, l, i1); + } + } + + protected ItemStack a_(int i) { + int j = 0; + + if (this.id >= 0 && this.id < Item.byId.length && Item.byId[this.id].e()) { + j = i; + } + + return new ItemStack(this.id, 1, j); + } + + public int a(int i, Random random) { + return this.a(random); } public boolean f(World world, int i, int j, int k) { @@ -504,26 +548,26 @@ public class Block { return this; } - public String k() { - return StatisticCollector.a(this.l() + ".name"); + public String m() { + return StatisticCollector.a(this.n() + ".name"); } - public String l() { + public String n() { return this.name; } public void a(World world, int i, int j, int k, int l, int i1) {} - public boolean m() { - return this.bE; + public boolean o() { + return this.bS; } - protected Block n() { - this.bE = false; + protected Block p() { + this.bS = false; return this; } - public int e() { + public int g() { return this.material.l(); } @@ -535,7 +579,8 @@ public class Block { 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[LONG_GRASS.id] = (new ItemColoredBlock(LONG_GRASS.id - 256, true)).a(new String[] { "shrub", "grass", "fern"}); + Item.byId[WATER_LILY.id] = new ItemWaterLily(WATER_LILY.id - 256); Item.byId[PISTON.id] = new ItemPiston(PISTON.id - 256); Item.byId[PISTON_STICKY.id] = new ItemPiston(PISTON_STICKY.id - 256); Item.byId[BIG_MUSHROOM_1.id] = new ItemLog(BIG_MUSHROOM_1.id - 256, BIG_MUSHROOM_1); // CraftBukkit @@ -543,9 +588,27 @@ public class Block { Item.byId[MOB_SPAWNER.id] = new ItemMobSpawner(MOB_SPAWNER.id - 256); // CraftBukkit for (int i = 0; i < 256; ++i) { - if (byId[i] != null && Item.byId[i] == null) { - Item.byId[i] = new ItemBlock(i - 256); - byId[i].h(); + if (byId[i] != null) { + if (Item.byId[i] == null) { + Item.byId[i] = new ItemBlock(i - 256); + byId[i].j(); + } + + boolean flag = false; + + if (i > 0 && byId[i].c() == 10) { + flag = true; + } + + if (i > 0 && byId[i] instanceof BlockStep) { + flag = true; + } + + if (i == SOIL.id) { + flag = true; + } + + u[i] = flag; } } diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java index a5b3c6a2..5998675a 100644 --- a/src/main/java/net/minecraft/server/BlockButton.java +++ b/src/main/java/net/minecraft/server/BlockButton.java @@ -15,7 +15,7 @@ public class BlockButton extends Block { return null; } - public int c() { + public int d() { return 20; } @@ -81,7 +81,7 @@ public class BlockButton extends Block { } if (flag) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } } @@ -89,7 +89,7 @@ public class BlockButton extends Block { private boolean h(World world, int i, int j, int k) { if (!this.canPlace(world, i, j, k)) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); return false; } else { @@ -162,7 +162,7 @@ public class BlockButton extends Block { world.applyPhysics(i, j - 1, k, this.id); } - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); return true; } } @@ -245,4 +245,12 @@ public class BlockButton extends Block { } } } + + public void f() { + float f = 0.1875F; + float f1 = 0.125F; + float f2 = 0.125F; + + this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); + } } diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java index 792c51b2..b9da7d2a 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java @@ -53,13 +53,17 @@ public class BlockCactus extends Block { return false; } + public int c() { + return 13; + } + public boolean canPlace(World world, int i, int j, int k) { return !super.canPlace(world, i, j, k) ? false : this.f(world, i, j, k); } public void doPhysics(World world, int i, int j, int k, int l) { if (!this.f(world, i, j, k)) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } } diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index cb2bd448..b954f9aa 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -17,11 +17,11 @@ public class BlockDispenser extends BlockContainer { this.textureId = 45; } - public int c() { + public int d() { return 4; } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Block.DISPENSER.id; } @@ -111,7 +111,7 @@ public class BlockDispenser extends BlockContainer { double d2 = (double) k + (double) b1 * 0.6D + 0.5D; if (itemstack == null) { - world.e(1001, i, j, k, 0); + world.f(1001, i, j, k, 0); } else { // CraftBukkit start double d3 = random.nextDouble() * 0.1D + 0.2D; @@ -148,19 +148,25 @@ public class BlockDispenser extends BlockContainer { 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); + world.f(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); + world.f(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); + world.f(1002, i, j, k, 0); + } else if (itemstack.id == Item.POTION.id && ItemPotion.c(itemstack.getData())) { + EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData()); + + entitypotion.a((double) b0, 0.10000000149011612D, (double) b1, 1.375F, 3.0F); + world.addEntity(entitypotion); + world.f(1002, i, j, k, 0); } else { EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); // CraftBukkit start @@ -170,10 +176,10 @@ public class BlockDispenser extends BlockContainer { entityitem.motZ = motZ; // CraftBukkit end world.addEntity(entityitem); - world.e(1000, i, j, k, 0); + world.f(1000, i, j, k, 0); } - world.e(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); + world.f(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); } } } @@ -183,13 +189,13 @@ public class BlockDispenser extends BlockContainer { boolean flag = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k); if (flag) { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } } } public void a(World world, int i, int j, int k, Random random) { - if (world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k)) { + if (!world.isStatic && (world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k))) { this.dispense(world, i, j, k, random); } } diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 1c9b1b4c..c7ceab0e 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -21,7 +21,7 @@ public class BlockDoor extends Block { public int a(int i, int j) { if (i != 0 && i != 1) { - int k = this.d(j); + int k = this.e(j); if ((k == 0 || k == 2) ^ i <= 3) { return this.textureId; @@ -50,16 +50,20 @@ public class BlockDoor extends Block { return false; } + public int c() { + return 7; + } + public AxisAlignedBB e(World world, int i, int j, int k) { this.a((IBlockAccess)world, i, j, k); // CraftBukkit - Make sure this points to the below method! return super.e(world, i, j, k); } public void a(IBlockAccess iblockaccess, int i, int j, int k) { - this.c(this.d(iblockaccess.getData(i, j, k))); + this.d(this.e(iblockaccess.getData(i, j, k))); } - public void c(int i) { + public void d(int i) { float f = 0.1875F; this.a(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); @@ -160,7 +164,7 @@ public class BlockDoor extends Block { if (flag) { if (!world.isStatic) { - this.g(world, i, j, k, i1); + this.b(world, i, j, k, i1, 0); } } else if (l > 0 && Block.byId[l].isPowerSource()) { // CraftBukkit start @@ -184,7 +188,7 @@ public class BlockDoor extends Block { } } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return (i & 8) != 0 ? 0 : (this.material == Material.ORE ? Item.IRON_DOOR.id : Item.WOOD_DOOR.id); } @@ -193,20 +197,19 @@ public class BlockDoor extends Block { return super.a(world, i, j, k, vec3d, vec3d1); } - public int d(int i) { + public int e(int i) { return (i & 4) == 0 ? i - 1 & 3 : i & 3; } public boolean canPlace(World world, int i, int j, int 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); + return j >= world.height - 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) { + public static boolean f(int i) { return (i & 4) != 0; } - public int e() { + public int g() { return 1; } } diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java index ad4bb04b..b141828f 100644 --- a/src/main/java/net/minecraft/server/BlockFire.java +++ b/src/main/java/net/minecraft/server/BlockFire.java @@ -20,7 +20,7 @@ public class BlockFire extends Block { this.a(true); } - public void h() { + public void j() { this.a(Block.WOOD.id, 5, 20); this.a(Block.FENCE.id, 5, 20); this.a(Block.WOOD_STAIRS.id, 5, 20); @@ -50,22 +50,30 @@ public class BlockFire extends Block { return false; } + public int c() { + return 3; + } + public int a(Random random) { return 0; } - public int c() { + public int d() { return 40; } public void a(World world, int i, int j, int k, Random random) { boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id; + if (world.worldProvider instanceof WorldProviderSky && world.getTypeId(i, j - 1, k) == Block.BEDROCK.id) { + flag = true; + } + if (!this.canPlace(world, i, j, k)) { world.setTypeId(i, j, k, 0); } - 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))) { + if (!flag && world.w() && (world.v(i, j, k) || world.v(i - 1, j, k) || world.v(i + 1, j, k) || world.v(i, j, k - 1) || world.v(i, j, k + 1))) { world.setTypeId(i, j, k, 0); } else { int l = world.getData(i, j, k); @@ -74,7 +82,7 @@ public class BlockFire extends Block { world.setRawData(i, j, k, l + random.nextInt(3) / 2); } - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); if (!flag && !this.g(world, i, j, k)) { if (!world.e(i, j - 1, k) || l > 3) { world.setTypeId(i, j, k, 0); @@ -112,7 +120,7 @@ public class BlockFire extends Block { if (i2 > 0) { int j2 = (i2 + 40) / (l + 30); - 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)) { + if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.w() || !world.v(i1, k1, j1)) && !world.v(i1 - 1, k1, k) && !world.v(i1 + 1, k1, j1) && !world.v(i1, k1, j1 - 1) && !world.v(i1, k1, j1 + 1)) { int k2 = l + random.nextInt(5) / 4; if (k2 > 15) { @@ -167,7 +175,7 @@ public class BlockFire extends Block { } // CraftBukkit end - if (random.nextInt(i1 + 10) < 5 && !world.s(i, j, k)) { + if (random.nextInt(i1 + 10) < 5 && !world.v(i, j, k)) { int k1 = i1 + random.nextInt(5) / 4; if (k1 > 15) { @@ -206,7 +214,7 @@ public class BlockFire extends Block { } } - public boolean q_() { + public boolean v_() { return false; } @@ -231,11 +239,11 @@ public class BlockFire extends Block { } 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.worldProvider.dimension > 0 || 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 { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } } } diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index aaae7bc1..12469a09 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -85,7 +85,7 @@ public class BlockFlowing extends BlockFluids { world.setTypeId(i, j, k, 0); } else { world.setData(i, j, k, i1); - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); world.applyPhysics(i, j, k, this.id); } } else if (flag) { @@ -103,6 +103,12 @@ public class BlockFlowing extends BlockFluids { } if (!event.isCancelled()) { + if (this.material == Material.LAVA && world.getMaterial(i, j - 1, k) == Material.WATER) { + world.setTypeId(i, j - 1, k, Block.STONE.id); + this.h(world, i, j - 1, k); + return; + } + if (l >= 8) { world.setTypeIdAndData(i, j - 1, k, this.id, l); } else { @@ -152,7 +158,7 @@ public class BlockFlowing extends BlockFluids { if (this.material == Material.LAVA) { this.h(world, i, j, k); } else { - Block.byId[i1].g(world, i, j, k, world.getData(i, j, k)); + Block.byId[i1].b(world, i, j, k, world.getData(i, j, k), 0); } } @@ -160,7 +166,7 @@ public class BlockFlowing extends BlockFluids { } } - private int b(World world, int i, int j, int k, int l, int i1) { + private int c(World world, int i, int j, int k, int l, int i1) { int j1 = 1000; for (int k1 = 0; k1 < 4; ++k1) { @@ -190,7 +196,7 @@ public class BlockFlowing extends BlockFluids { } if (l < 4) { - int j2 = this.b(world, l1, j, i2, l + 1, k1); + int j2 = this.c(world, l1, j, i2, l + 1, k1); if (j2 < j1) { j1 = j2; @@ -232,7 +238,7 @@ public class BlockFlowing extends BlockFluids { if (!this.k(world, i1, j - 1, j1)) { this.c[l] = 0; } else { - this.c[l] = this.b(world, i1, j, j1, 1, l); + this.c[l] = this.c(world, i1, j, j1, 1, l); } } } @@ -261,7 +267,7 @@ public class BlockFlowing extends BlockFluids { } else { Material material = Block.byId[l].material; - return material.isSolid(); + return material == Material.PORTAL ? true : material.isSolid(); } } else { return true; @@ -295,7 +301,7 @@ public class BlockFlowing extends BlockFluids { 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()); + world.c(i, j, k, this.id, this.d()); } } } diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java index 5868eadb..7c8b2ca7 100644 --- a/src/main/java/net/minecraft/server/BlockGrass.java +++ b/src/main/java/net/minecraft/server/BlockGrass.java @@ -22,9 +22,6 @@ public class BlockGrass extends Block { public void a(World world, int i, int j, int k, Random random) { if (!world.isStatic) { if (world.getLightLevel(i, j + 1, k) < 4 && Block.q[world.getTypeId(i, j + 1, k)] > 2) { - if (random.nextInt(4) != 0) { - return; - } // CraftBukkit start org.bukkit.World bworld = world.getWorld(); org.bukkit.block.BlockState blockState = bworld.getBlockAt(i, j, k).getState(); @@ -38,30 +35,32 @@ public class BlockGrass extends Block { } // CraftBukkit end } else if (world.getLightLevel(i, j + 1, k) >= 9) { - int l = i + random.nextInt(3) - 1; - int i1 = j + random.nextInt(5) - 3; - int j1 = k + random.nextInt(3) - 1; - int k1 = world.getTypeId(l, i1 + 1, j1); + for (int l = 0; l < 4; ++l) { + int i1 = i + random.nextInt(3) - 1; + int j1 = j + random.nextInt(5) - 3; + int k1 = k + random.nextInt(3) - 1; + int l1 = world.getTypeId(i1, j1 + 1, k1); - if (world.getTypeId(l, i1, j1) == Block.DIRT.id && world.getLightLevel(l, i1 + 1, j1) >= 4 && Block.q[k1] <= 2) { - // CraftBukkit start - org.bukkit.World bworld = world.getWorld(); - org.bukkit.block.BlockState blockState = bworld.getBlockAt(l, i1, j1).getState(); - blockState.setTypeId(this.id); + if (world.getTypeId(i1, j1, k1) == Block.DIRT.id && world.getLightLevel(i1, j1 + 1, k1) >= 4 && Block.q[l1] <= 2) { + // 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); + BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState); + world.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - blockState.update(true); + if (!event.isCancelled()) { + blockState.update(true); + } + // CraftBukkit end } - // CraftBukkit end } } } } - public int a(int i, Random random) { - return Block.DIRT.a(0, random); + public int a(int i, Random random, int j) { + return Block.DIRT.a(0, random, j); } } diff --git a/src/main/java/net/minecraft/server/BlockIce.java b/src/main/java/net/minecraft/server/BlockIce.java index 44f3573b..7c22130b 100644 --- a/src/main/java/net/minecraft/server/BlockIce.java +++ b/src/main/java/net/minecraft/server/BlockIce.java @@ -32,12 +32,16 @@ public class BlockIce extends BlockBreakable { } // CraftBukkit end - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, Block.STATIONARY_WATER.id); } } - public int e() { + public int g() { return 0; } + + protected ItemStack a_(int i) { + return null; + } } diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java index 2c035124..4141ed19 100644 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ b/src/main/java/net/minecraft/server/BlockLeaves.java @@ -126,7 +126,7 @@ public class BlockLeaves extends BlockLeavesBase { if (event.isCancelled()) return; // CraftBukkit end - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } @@ -134,12 +134,12 @@ public class BlockLeaves extends BlockLeavesBase { return random.nextInt(20) == 0 ? 1 : 0; } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Block.SAPLING.id; } public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (!world.isStatic && entityhuman.K() != null && entityhuman.K().id == Item.SHEARS.id) { + if (!world.isStatic && entityhuman.P() != null && entityhuman.P().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 { @@ -147,7 +147,7 @@ public class BlockLeaves extends BlockLeavesBase { } } - protected int a_(int i) { + protected int c(int i) { return i & 3; } diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java index c7e205ae..ad607ceb 100644 --- a/src/main/java/net/minecraft/server/BlockLever.java +++ b/src/main/java/net/minecraft/server/BlockLever.java @@ -20,6 +20,10 @@ public class BlockLever extends Block { return false; } + public int c() { + return 12; + } + public boolean canPlace(World world, int i, int j, int k, int l) { return l == 1 && world.e(i, j - 1, k) ? true : (l == 2 && world.e(i, j, k + 1) ? true : (l == 3 && world.e(i, j, k - 1) ? true : (l == 4 && world.e(i + 1, j, k) ? true : l == 5 && world.e(i - 1, j, k)))); } @@ -55,7 +59,7 @@ public class BlockLever extends Block { } if (i1 == -1) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } else { world.setData(i, j, k, i1 + j1); @@ -92,7 +96,7 @@ public class BlockLever extends Block { } if (flag) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } } @@ -100,7 +104,7 @@ public class BlockLever extends Block { private boolean g(World world, int i, int j, int k) { if (!this.canPlace(world, i, j, k)) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); return false; } else { diff --git a/src/main/java/net/minecraft/server/BlockMinecartDetector.java b/src/main/java/net/minecraft/server/BlockMinecartDetector.java index f05415f7..12969fd0 100644 --- a/src/main/java/net/minecraft/server/BlockMinecartDetector.java +++ b/src/main/java/net/minecraft/server/BlockMinecartDetector.java @@ -12,7 +12,7 @@ public class BlockMinecartDetector extends BlockMinecartTrack { this.a(true); } - public int c() { + public int d() { return 20; } @@ -84,7 +84,7 @@ public class BlockMinecartDetector extends BlockMinecartTrack { } if (flag1) { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } } } diff --git a/src/main/java/net/minecraft/server/BlockMobSpawner.java b/src/main/java/net/minecraft/server/BlockMobSpawner.java index 7be3e865..d3a29ca8 100644 --- a/src/main/java/net/minecraft/server/BlockMobSpawner.java +++ b/src/main/java/net/minecraft/server/BlockMobSpawner.java @@ -12,28 +12,30 @@ public class BlockMobSpawner extends BlockContainer { return new TileEntityMobSpawner(); } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Block.MOB_SPAWNER.id; // CraftBukkit } public int a(Random random) { - return 0; // CraftBukkit + return 0; } // CraftBukkit start - public void dropNaturally(World world, int i, int j, int k, int l, float f) { + @Override + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { TileEntity entity = world.getTileEntity(i, j, k); if (entity instanceof TileEntityMobSpawner) { - super.dropNaturally(world, i, j, k, ((TileEntityMobSpawner) entity).getId(), f); + super.dropNaturally(world, i, j, k, ((TileEntityMobSpawner) entity).getId(), f, i1); } } + @Override public void remove(World world, int i, int j, int k) { - dropNaturally(world, i, j, k, 0, 1.0f); + dropNaturally(world, i, j, k, 0, 1.0f, 0); super.remove(world, i, j, k); } - protected int a_(int i) { + protected int c(int i) { return i; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index 775d7e18..37bfe158 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -14,7 +14,7 @@ public class BlockMushroom extends BlockFlower { } public void a(World world, int i, int j, int k, Random random) { - if (random.nextInt(100) == 0) { + if (random.nextInt(25) == 0) { byte b0 = 4; int l = 5; @@ -68,44 +68,37 @@ public class BlockMushroom extends BlockFlower { } } - protected boolean c(int i) { + protected boolean d(int i) { return Block.o[i]; } public boolean f(World world, int i, int j, int k) { - if (j >= 0) { - world.getClass(); - if (j < 128) { - return world.k(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)); - } - } + if (j >= 0 && j < world.height) { + int l = world.getTypeId(i, j - 1, k); - return false; + return l == Block.MYCEL.id || world.k(i, j, k) < 13 && this.d(l); + } else { + return false; + } } public boolean b(World world, int i, int j, int k, Random random) { - int l = world.getTypeId(i, j - 1, k); + int l = world.getData(i, j, 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; - 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 (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; - } + if (worldgenhugemushroom != null && worldgenhugemushroom.a(world, random, i, j, k)) { + return true; + } else { + world.setRawTypeIdAndData(i, j, k, this.id, l); + return false; } } } diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java index dd3dd4de..ed4771e8 100644 --- a/src/main/java/net/minecraft/server/BlockPiston.java +++ b/src/main/java/net/minecraft/server/BlockPiston.java @@ -3,7 +3,6 @@ package net.minecraft.server; import java.util.ArrayList; // CraftBukkit start -import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPistonExtendEvent; @@ -12,7 +11,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent; public class BlockPiston extends Block { private boolean a; - private boolean b; + private static boolean b; public BlockPiston(int i, int j, boolean flag) { super(i, j, Material.PISTON); @@ -22,9 +21,13 @@ public class BlockPiston extends Block { } public int a(int i, int j) { - int k = c(j); + int k = d(j); - return k > 5 ? this.textureId : (i == k ? (!d(j) && this.minX <= 0.0D && this.minY <= 0.0D && this.minZ <= 0.0D && this.maxX >= 1.0D && this.maxY >= 1.0D && this.maxZ >= 1.0D ? this.textureId : 110) : (i == PistonBlockTextures.a[k] ? 109 : 108)); + return k > 5 ? this.textureId : (i == k ? (!e(j) && this.minX <= 0.0D && this.minY <= 0.0D && this.minZ <= 0.0D && this.maxX >= 1.0D && this.maxY >= 1.0D && this.maxZ >= 1.0D ? this.textureId : 110) : (i == PistonBlockTextures.a[k] ? 109 : 108)); + } + + public int c() { + return 16; } public boolean a() { @@ -39,32 +42,32 @@ public class BlockPiston extends Block { int l = c(world, i, j, k, (EntityHuman) entityliving); world.setData(i, j, k, l); - if (!world.isStatic) { + if (!world.isStatic && !b) { this.g(world, i, j, k); } } public void doPhysics(World world, int i, int j, int k, int l) { - if (!world.isStatic && !this.b) { + if (!world.isStatic && !b) { this.g(world, i, j, k); } } public void a(World world, int i, int j, int k) { - if (!world.isStatic && world.getTileEntity(i, j, k) == null) { + if (!world.isStatic && world.getTileEntity(i, j, k) == null && !b) { this.g(world, i, j, k); } } private void g(World world, int i, int j, int k) { int l = world.getData(i, j, k); - int i1 = c(l); + int i1 = d(l); boolean flag = this.f(world, i, j, k, i1); if (l != 7) { - if (flag && !d(l)) { + if (flag && !e(l)) { // CraftBukkit start - int length = h(world, i, j, k, i1); + int length = g(world, i, j, k, i1); if (length >= 0) { org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); @@ -79,7 +82,7 @@ public class BlockPiston extends Block { world.setRawData(i, j, k, i1 | 8); world.playNote(i, j, k, 0, i1); } - } else if (!flag && d(l)) { + } else if (!flag && e(l)) { // CraftBukkit start org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); @@ -102,17 +105,19 @@ public class BlockPiston extends Block { } public void a(World world, int i, int j, int k, int l, int i1) { - this.b = true; + b = true; if (l == 0) { - if (this.i(world, i, j, k, i1)) { + if (this.h(world, i, j, k, i1)) { world.setData(i, j, k, i1 | 8); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "tile.piston.out", 0.5F, world.random.nextFloat() * 0.25F + 0.6F); + } else { + world.setRawData(i, j, k, i1); } } else if (l == 1) { TileEntity tileentity = world.getTileEntity(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1]); if (tileentity != null && tileentity instanceof TileEntityPiston) { - ((TileEntityPiston) tileentity).e(); + ((TileEntityPiston) tileentity).g(); } world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, i1); @@ -131,46 +136,46 @@ public class BlockPiston extends Block { if (tileentity1 != null && tileentity1 instanceof TileEntityPiston) { TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1; - if (tileentitypiston.d() == i1 && tileentitypiston.c()) { - tileentitypiston.e(); - i2 = tileentitypiston.a(); + if (tileentitypiston.f() == i1 && tileentitypiston.e()) { + tileentitypiston.g(); + i2 = tileentitypiston.c(); j2 = tileentitypiston.j(); flag = true; } } } - if (!flag && i2 > 0 && a(i2, world, j1, k1, l1, false) && (Block.byId[i2].e() == 0 || i2 == Block.PISTON.id || i2 == Block.PISTON_STICKY.id)) { - this.b = false; - world.setTypeId(j1, k1, l1, 0); - this.b = true; + if (!flag && i2 > 0 && a(i2, world, j1, k1, l1, false) && (Block.byId[i2].g() == 0 || i2 == Block.PISTON.id || i2 == Block.PISTON_STICKY.id)) { i += PistonBlockTextures.b[i1]; j += PistonBlockTextures.c[i1]; k += PistonBlockTextures.d[i1]; world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, j2); world.setTileEntity(i, j, k, BlockPistonMoving.a(i2, j2, i1, false, false)); + b = false; + world.setTypeId(j1, k1, l1, 0); + b = true; } else if (!flag) { - this.b = false; + b = false; world.setTypeId(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1], 0); - this.b = true; + b = true; } } else { - this.b = false; + b = false; world.setTypeId(i + PistonBlockTextures.b[i1], j + PistonBlockTextures.c[i1], k + PistonBlockTextures.d[i1], 0); - this.b = true; + b = true; } world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "tile.piston.in", 0.5F, world.random.nextFloat() * 0.15F + 0.6F); } - this.b = false; + b = false; } public void a(IBlockAccess iblockaccess, int i, int j, int k) { int l = iblockaccess.getData(i, j, k); - if (d(l)) { - switch (c(l)) { + if (e(l)) { + switch (d(l)) { case 0: this.a(0.0F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F); break; @@ -199,6 +204,10 @@ public class BlockPiston extends Block { } } + public void f() { + this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); super.a(world, i, j, k, axisalignedbb, arraylist); @@ -208,11 +217,11 @@ public class BlockPiston extends Block { return false; } - public static int c(int i) { + public static int d(int i) { return i & 7; } - public static boolean d(int i) { + public static boolean e(int i) { return (i & 8) != 0; } @@ -239,29 +248,27 @@ public class BlockPiston extends Block { return false; } else { if (i != Block.PISTON.id && i != Block.PISTON_STICKY.id) { - if (Block.byId[i].j() == -1.0F) { + if (Block.byId[i].l() == -1.0F) { return false; } - if (Block.byId[i].e() == 2) { + if (Block.byId[i].g() == 2) { return false; } - if (!flag && Block.byId[i].e() == 1) { + if (!flag && Block.byId[i].g() == 1) { return false; } - } else if (d(world.getData(j, k, l))) { + } else if (e(world.getData(j, k, l))) { return false; } - TileEntity tileentity = world.getTileEntity(j, k, l); - - return tileentity == null; + return !(Block.byId[i] instanceof BlockContainer); } } // CraftBukkkit boolean -> int - private static int h(World world, int i, int j, int k, int l) { + private static int g(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]; @@ -269,41 +276,36 @@ public class BlockPiston extends Block { 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; - } + if (j1 <= 0 || j1 >= world.height - 1) { + return -1; // CraftBukkit + } + + 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].g() != 1) { + if (l1 == 12) { + return -1; // CraftBukkit } - return l1; // CraftBukkit + i1 += PistonBlockTextures.b[l]; + j1 += PistonBlockTextures.c[l]; + k1 += PistonBlockTextures.d[l]; + ++l1; + continue; } } - - return -1; // CraftBukkit } return l1; // CraftBukkit } } - private boolean i(World world, int i, int j, int k, int l) { + private boolean 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]; @@ -313,36 +315,30 @@ public class BlockPiston extends Block { int i2; if (l1 < 13) { - label63: { - if (j1 > 0) { - world.getClass(); - if (j1 < 128 - 1) { - i2 = world.getTypeId(i1, j1, k1); - if (i2 != 0) { - if (!a(i2, world, i1, j1, k1, true)) { - return false; - } - - if (Block.byId[i2].e() != 1) { - if (l1 == 12) { - return false; - } - - i1 += PistonBlockTextures.b[l]; - j1 += PistonBlockTextures.c[l]; - k1 += PistonBlockTextures.d[l]; - ++l1; - continue; - } - - Block.byId[i2].g(world, i1, j1, k1, world.getData(i1, j1, k1)); - world.setTypeId(i1, j1, k1, 0); - } - break label63; + if (j1 <= 0 || j1 >= world.height - 1) { + return false; + } + + i2 = world.getTypeId(i1, j1, k1); + if (i2 != 0) { + if (!a(i2, world, i1, j1, k1, true)) { + return false; + } + + if (Block.byId[i2].g() != 1) { + if (l1 == 12) { + return false; } + + i1 += PistonBlockTextures.b[l]; + j1 += PistonBlockTextures.c[l]; + k1 += PistonBlockTextures.d[l]; + ++l1; + continue; } - return false; + Block.byId[i2].b(world, i1, j1, k1, world.getData(i1, j1, k1), 0); + world.setTypeId(i1, j1, k1, 0); } } diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java index 8a1ae401..501c61ce 100644 --- a/src/main/java/net/minecraft/server/BlockPistonExtension.java +++ b/src/main/java/net/minecraft/server/BlockPistonExtension.java @@ -26,8 +26,8 @@ public class BlockPistonExtension extends Block { if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) { l = world.getData(i, j, k); - if (BlockPiston.d(l)) { - Block.byId[j1].g(world, i, j, k, l); + if (BlockPiston.e(l)) { + Block.byId[j1].b(world, i, j, k, l, 0); world.setTypeId(i, j, k, 0); } } @@ -39,6 +39,10 @@ public class BlockPistonExtension extends Block { return i == k ? (this.a >= 0 ? this.a : ((j & 8) != 0 ? this.textureId - 1 : this.textureId)) : (i == PistonBlockTextures.a[k] ? 107 : 108); } + public int c() { + return 17; + } + public boolean a() { return false; } diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java index ba88a26c..4b9314be 100644 --- a/src/main/java/net/minecraft/server/BlockPortal.java +++ b/src/main/java/net/minecraft/server/BlockPortal.java @@ -166,7 +166,7 @@ public class BlockPortal extends BlockBreakable { world.getServer().getPluginManager().callEvent(event); // CraftBukkit end - entity.T(); + entity.Y(); } } } diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java index e0cf2fe5..f32adaa1 100644 --- a/src/main/java/net/minecraft/server/BlockPressurePlate.java +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -22,7 +22,7 @@ public class BlockPressurePlate extends Block { this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); } - public int c() { + public int d() { return 20; } @@ -52,7 +52,7 @@ public class BlockPressurePlate extends Block { } if (flag) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } } @@ -144,7 +144,7 @@ public class BlockPressurePlate extends Block { } if (flag1) { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } } @@ -182,7 +182,15 @@ public class BlockPressurePlate extends Block { return true; } - public int e() { + public void f() { + float f = 0.5F; + float f1 = 0.125F; + float f2 = 0.5F; + + this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); + } + + public int g() { return 1; } } diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java index 420bc11b..c751e6e1 100644 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -35,6 +35,21 @@ public class BlockPumpkin extends Block { public void a(World world, int i, int j, int k) { super.a(world, i, j, k); + if (world.getTypeId(i, j - 1, k) == Block.SNOW_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.SNOW_BLOCK.id) { + if (!world.isStatic) { + world.setTypeId(i, j, k, 0); + world.setTypeId(i, j - 1, k, 0); + world.setTypeId(i, j - 2, k, 0); + EntitySnowman entitysnowman = new EntitySnowman(world); + + entitysnowman.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); + world.addEntity(entitysnowman); + } + + for (int l = 0; l < 120; ++l) { + world.a("snowshovel", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 2.5D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); + } + } } 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 847e64c5..e78cdb66 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java @@ -42,7 +42,7 @@ public class BlockRedstoneTorch extends BlockTorch { this.a(true); } - public int c() { + public int d() { return 2; } @@ -145,14 +145,14 @@ public class BlockRedstoneTorch extends BlockTorch { public void doPhysics(World world, int i, int j, int k, int l) { super.doPhysics(world, i, j, k, l); - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } public boolean d(World world, int i, int j, int k, int l) { return l == 0 ? this.a(world, i, j, k, l) : false; } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Block.REDSTONE_TORCH_ON.id; } diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java index b57b6378..f6ee5487 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java @@ -33,6 +33,10 @@ public class BlockRedstoneWire extends Block { return false; } + public int c() { + return 5; + } + public boolean canPlace(World world, int i, int j, int k) { return world.e(i, j - 1, k); } @@ -280,7 +284,7 @@ public class BlockRedstoneWire extends Block { boolean flag = this.canPlace(world, i, j, k); if (!flag) { - this.g(world, i, j, k, i1); + this.b(world, i, j, k, i1, 0); world.setTypeId(i, j, k, 0); } else { this.g(world, i, j, k); @@ -290,7 +294,7 @@ public class BlockRedstoneWire extends Block { } } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Item.REDSTONE.id; } @@ -306,25 +310,25 @@ public class BlockRedstoneWire extends Block { } else if (l == 1) { return true; } else { - boolean flag = c(iblockaccess, i - 1, j, k, 1) || !iblockaccess.e(i - 1, j, k) && c(iblockaccess, i - 1, j - 1, k, -1); - boolean flag1 = c(iblockaccess, i + 1, j, k, 3) || !iblockaccess.e(i + 1, j, k) && c(iblockaccess, i + 1, j - 1, k, -1); - boolean flag2 = c(iblockaccess, i, j, k - 1, 2) || !iblockaccess.e(i, j, k - 1) && c(iblockaccess, i, j - 1, k - 1, -1); - boolean flag3 = c(iblockaccess, i, j, k + 1, 0) || !iblockaccess.e(i, j, k + 1) && c(iblockaccess, i, j - 1, k + 1, -1); + boolean flag = d(iblockaccess, i - 1, j, k, 1) || !iblockaccess.e(i - 1, j, k) && d(iblockaccess, i - 1, j - 1, k, -1); + boolean flag1 = d(iblockaccess, i + 1, j, k, 3) || !iblockaccess.e(i + 1, j, k) && d(iblockaccess, i + 1, j - 1, k, -1); + boolean flag2 = d(iblockaccess, i, j, k - 1, 2) || !iblockaccess.e(i, j, k - 1) && d(iblockaccess, i, j - 1, k - 1, -1); + boolean flag3 = d(iblockaccess, i, j, k + 1, 0) || !iblockaccess.e(i, j, k + 1) && d(iblockaccess, i, j - 1, k + 1, -1); if (!iblockaccess.e(i, j + 1, k)) { - if (iblockaccess.e(i - 1, j, k) && c(iblockaccess, i - 1, j + 1, k, -1)) { + if (iblockaccess.e(i - 1, j, k) && d(iblockaccess, i - 1, j + 1, k, -1)) { flag = true; } - if (iblockaccess.e(i + 1, j, k) && c(iblockaccess, i + 1, j + 1, k, -1)) { + if (iblockaccess.e(i + 1, j, k) && d(iblockaccess, i + 1, j + 1, k, -1)) { flag1 = true; } - if (iblockaccess.e(i, j, k - 1) && c(iblockaccess, i, j + 1, k - 1, -1)) { + if (iblockaccess.e(i, j, k - 1) && d(iblockaccess, i, j + 1, k - 1, -1)) { flag2 = true; } - if (iblockaccess.e(i, j, k + 1) && c(iblockaccess, i, j + 1, k + 1, -1)) { + if (iblockaccess.e(i, j, k + 1) && d(iblockaccess, i, j + 1, k + 1, -1)) { flag3 = true; } } @@ -344,14 +348,30 @@ public class BlockRedstoneWire extends Block { return true; } else if (i1 == 0) { return false; - } else if (Block.byId[i1].isPowerSource()) { + } else if (Block.byId[i1].isPowerSource() && l != -1) { return true; } else if (i1 != Block.DIODE_OFF.id && i1 != Block.DIODE_ON.id) { return false; } else { int j1 = iblockaccess.getData(i, j, k); - return l == Direction.e[j1 & 3]; + return l == (j1 & 3) || l == Direction.e[j1 & 3]; + } + } + + public static boolean d(IBlockAccess iblockaccess, int i, int j, int k, int l) { + if (c(iblockaccess, i, j, k, l)) { + return true; + } else { + int i1 = iblockaccess.getTypeId(i, j, k); + + if (i1 == Block.DIODE_ON.id) { + int j1 = iblockaccess.getData(i, j, k); + + return l == (j1 & 3); + } else { + return false; + } } } } diff --git a/src/main/java/net/minecraft/server/BlockSand.java b/src/main/java/net/minecraft/server/BlockSand.java index cc4ef57e..bc38fccb 100644 --- a/src/main/java/net/minecraft/server/BlockSand.java +++ b/src/main/java/net/minecraft/server/BlockSand.java @@ -11,30 +11,32 @@ public class BlockSand extends Block { } public void a(World world, int i, int j, int k) { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } public void doPhysics(World world, int i, int j, int k, int l) { - world.c(i, j, k, this.id, this.c()); + world.c(i, j, k, this.id, this.d()); } public void a(World world, int i, int j, int k, Random random) { - this.g(world, i, j, k); + this.h(world, i, j, k); } - private void g(World world, int i, int j, int k) { - if (d_(world, i, j - 1, k) && j >= 0) { + private void h(World world, int i, int j, int k) { + if (g(world, i, j - 1, k) && j >= 0) { byte b0 = 32; if (!instaFall && world.a(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { - // CraftBukkit Change call to add data - EntityFallingSand entityfallingsand = new EntityFallingSand(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k)); + if (!world.isStatic) { + // CraftBukkit Change call to add data + EntityFallingSand entityfallingsand = new EntityFallingSand(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k)); - world.addEntity(entityfallingsand); + world.addEntity(entityfallingsand); + } } else { world.setTypeId(i, j, k, 0); - while (d_(world, i, j - 1, k) && j > 0) { + while (g(world, i, j - 1, k) && j > 0) { --j; } @@ -45,11 +47,11 @@ public class BlockSand extends Block { } } - public int c() { + public int d() { return 3; } - public static boolean d_(World world, int i, int j, int k) { + public static boolean g(World world, int i, int j, int k) { int l = world.getTypeId(i, j, k); if (l == 0) { diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java index 91b9efd8..4eccdee0 100644 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ b/src/main/java/net/minecraft/server/BlockSapling.java @@ -16,7 +16,7 @@ public class BlockSapling extends BlockFlower { public void a(World world, int i, int j, int k, Random random) { if (!world.isStatic) { super.a(world, i, j, k, random); - if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(30) == 0) { + if (world.getLightLevel(i, j + 1, k) >= 9 && random.nextInt(7) == 0) { int l = world.getData(i, j, k); if ((l & 8) == 0) { @@ -42,15 +42,16 @@ public class BlockSapling extends BlockFlower { boolean grownTree; BlockChangeWithNotify delegate = new BlockChangeWithNotify(world); + // All of these are 'false' because we need the 'raw' calls so the block-delegate works if (l == 1) { - grownTree = new WorldGenTaiga2().generate(delegate, random, i, j, k); + grownTree = new WorldGenTaiga2(false).generate(delegate, random, i, j, k); } else if (l == 2) { - grownTree = new WorldGenForest().generate(delegate, random, i, j, k); + grownTree = new WorldGenForest(false).generate(delegate, random, i, j, k); } else { if (random.nextInt(10) == 0) { - grownTree = new WorldGenBigTree().generate(delegate, random, i, j, k); + grownTree = new WorldGenBigTree(false).generate(delegate, random, i, j, k); } else { - grownTree = new WorldGenTrees().generate(delegate, random, i, j, k); + grownTree = new WorldGenTrees(false).generate(delegate, random, i, j, k); } } @@ -60,7 +61,7 @@ public class BlockSapling extends BlockFlower { // CraftBukkit end } - protected int a_(int i) { + protected int c(int i) { return i & 3; } diff --git a/src/main/java/net/minecraft/server/BlockSign.java b/src/main/java/net/minecraft/server/BlockSign.java index 7a2e8fb0..888b79f3 100644 --- a/src/main/java/net/minecraft/server/BlockSign.java +++ b/src/main/java/net/minecraft/server/BlockSign.java @@ -52,6 +52,10 @@ public class BlockSign extends BlockContainer { } } + public int c() { + return -1; + } + public boolean b() { return false; } @@ -68,7 +72,7 @@ public class BlockSign extends BlockContainer { } } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Item.SIGN.id; } @@ -101,7 +105,7 @@ public class BlockSign extends BlockContainer { } if (flag) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java index bec19919..24a327cd 100644 --- a/src/main/java/net/minecraft/server/BlockSnow.java +++ b/src/main/java/net/minecraft/server/BlockSnow.java @@ -44,7 +44,7 @@ public class BlockSnow extends Block { private boolean g(World world, int i, int j, int k) { if (!this.canPlace(world, i, j, k)) { - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); return false; } else { @@ -66,7 +66,7 @@ public class BlockSnow extends Block { entityhuman.a(StatisticList.C[this.id], 1); } - public int a(int i, Random random) { + public int a(int i, Random random, int j) { return Item.SNOW_BALL.id; } @@ -82,7 +82,7 @@ public class BlockSnow extends Block { } // CraftBukkit end - this.g(world, i, j, k, world.getData(i, j, k)); + this.b(world, i, j, k, world.getData(i, j, k), 0); world.setTypeId(i, j, k, 0); } } diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index 54509332..9afaf178 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -14,7 +14,7 @@ public class BlockSoil extends Block { this.textureId = 87; this.a(true); this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F); - this.f(255); + this.g(255); } public AxisAlignedBB e(World world, int i, int j, int k) { @@ -34,18 +34,16 @@ public class BlockSoil extends Block { } public void a(World world, int i, int j, int k, Random random) { - if (random.nextInt(5) == 0) { - if (!this.h(world, i, j, k) && !world.s(i, j + 1, k)) { - int l = world.getData(i, j, k); - - if (l > 0) { - world.setData(i, j, k, l - 1); - } else if (!this.g(world, i, j, k)) { - world.setTypeId(i, j, k, Block.DIRT.id); - } - } else { - world.setData(i, j, k, 7); + if (!this.h(world, i, j, k) && !world.v(i, j + 1, k)) { + int l = world.getData(i, j, k); + + if (l > 0) { + world.setData(i, j, k, l - 1); + } else if (!this.g(world, i, j, k)) { + world.setTypeId(i, j, k, Block.DIRT.id); } + } else { + world.setData(i, j, k, 7); } } @@ -108,7 +106,7 @@ public class BlockSoil extends Block { } } - public int a(int i, Random random) { - return Block.DIRT.a(0, random); + public int a(int i, Random random, int j) { + return Block.DIRT.a(0, random, j); } } diff --git a/src/main/java/net/minecraft/server/BlockStairs.java b/src/main/java/net/minecraft/server/BlockStairs.java index f3830cb1..66d2a6cc 100644 --- a/src/main/java/net/minecraft/server/BlockStairs.java +++ b/src/main/java/net/minecraft/server/BlockStairs.java @@ -13,7 +13,7 @@ public class BlockStairs extends Block { this.c(block.strength); this.b(block.durability / 3.0F); this.a(block.stepSound); - this.f(255); + this.g(255); } public void a(IBlockAccess iblockaccess, int i, int j, int k) { @@ -32,6 +32,10 @@ public class BlockStairs extends Block { return false; } + public int c() { + return 10; + } + public void a(World world, int i, int j, int k, AxisAlignedBB axisalignedbb, ArrayList arraylist) { int l = world.getData(i, j, k); @@ -72,14 +76,6 @@ public class BlockStairs extends Block { return this.a.a(entity); } - public int a(int i, Random random) { - return this.a.a(i, random); - } - - public int a(Random random) { - return this.a.a(random); - } - public int a(int i, int j) { return this.a.a(i, 0); } @@ -88,16 +84,16 @@ public class BlockStairs extends Block { return this.a.a(i, 0); } - public int c() { - return this.a.c(); + public int d() { + return this.a.d(); } public void a(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { this.a.a(world, i, j, k, entity, vec3d); } - public boolean q_() { - return this.a.q_(); + public boolean v_() { + return this.a.v_(); } public boolean a(int i, boolean flag) { @@ -117,8 +113,8 @@ public class BlockStairs extends Block { this.a.remove(world, i, j, k); } - public void dropNaturally(World world, int i, int j, int k, int l, float f) { - this.a.dropNaturally(world, i, j, k, 0, f); // CraftBukkit - don't propagate stair direction + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { + this.a.dropNaturally(world, i, j, k, 0, f, i1); // CraftBukkit - don't propagate stair direction } public void b(World world, int i, int j, int k, Entity entity) { diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java index fd45ee70..1b091e70 100644 --- a/src/main/java/net/minecraft/server/BlockStationary.java +++ b/src/main/java/net/minecraft/server/BlockStationary.java @@ -27,7 +27,7 @@ public class BlockStationary extends BlockFluids { world.suppressPhysics = true; world.setRawTypeIdAndData(i, j, k, this.id - 1, l); world.b(i, j, k, i, j, k); - world.c(i, j, k, this.id - 1, this.c()); + world.c(i, j, k, this.id - 1, this.d()); world.suppressPhysics = false; } diff --git a/src/main/java/net/minecraft/server/BlockTrapdoor.java b/src/main/java/net/minecraft/server/BlockTrapdoor.java index 52cbbcf8..153e8961 100644 --- a/src/main/java/net/minecraft/server/BlockTrapdoor.java +++ b/src/main/java/net/minecraft/server/BlockTrapdoor.java @@ -25,20 +25,30 @@ public class BlockTrapdoor extends Block { return false; } + public int c() { + return 0; + } + public AxisAlignedBB e(World world, int i, int j, int k) { - this.a((IBlockAccess)world, i, j, k); // CraftBukkit - Make sure this points to the below method! + this.a(world, i, j, k); return super.e(world, i, j, k); } public void a(IBlockAccess iblockaccess, int i, int j, int k) { - this.c(iblockaccess.getData(i, j, k)); + this.d(iblockaccess.getData(i, j, k)); + } + + public void f() { + float f = 0.1875F; + + this.a(0.0F, 0.5F - f / 2.0F, 0.0F, 1.0F, 0.5F + f / 2.0F, 1.0F); } - public void c(int i) { + public void d(int i) { float f = 0.1875F; this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); - if (d(i)) { + if (e(i)) { if ((i & 3) == 0) { this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); } @@ -105,9 +115,9 @@ public class BlockTrapdoor extends Block { --j1; } - if (!world.e(j1, j, k1)) { + if (!f(world.getTypeId(j1, j, k1))) { world.setTypeId(i, j, k, 0); - this.g(world, i, j, k, i1); + this.b(world, i, j, k, i1, 0); } // CraftBukkit start @@ -179,11 +189,21 @@ public class BlockTrapdoor extends Block { --i; } - return world.e(i, j, k); + return f(world.getTypeId(i, j, k)); } } - public static boolean d(int i) { + public static boolean e(int i) { return (i & 4) != 0; } + + private static boolean f(int i) { + if (i <= 0) { + return false; + } else { + Block block = Block.byId[i]; + + return block != null && block.material.j() && block.b() || block == Block.GLOWSTONE; + } + } } diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index 82955f65..88d6917f 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -7,7 +7,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; -import org.bukkit.Bukkit; +import org.bukkit.Bukkit; // CraftBukkit public class Chunk { @@ -24,6 +24,7 @@ public class Chunk { public int k; public final int x; public final int z; + private boolean v; public Map tileEntities; public List[] entitySlices; public boolean done; @@ -36,14 +37,14 @@ public class Chunk { public Chunk(World world, int i, int j) { this.c = new int[256]; this.d = new boolean[256]; + this.v = false; this.tileEntities = new HashMap(); this.done = false; this.q = false; this.s = false; this.t = 0L; this.u = false; - world.getClass(); - this.entitySlices = new List[128 / 16]; + this.entitySlices = new List[world.height / 16]; this.world = world; this.x = i; this.z = j; @@ -71,14 +72,9 @@ public class Chunk { public Chunk(World world, byte[] abyte, int i, int j) { this(world, i, j); this.b = abyte; - - 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 + this.g = new NibbleArray(abyte.length, world.heightBits); + this.h = new NibbleArray(abyte.length, world.heightBits); + this.i = new NibbleArray(abyte.length, world.heightBits); } public boolean a(int i, int j) { @@ -92,22 +88,18 @@ public class Chunk { public void a() {} public void initLighting() { - - int i = 128 - 1; + int i = this.world.height - 1; int j; int k; for (j = 0; j < 16; ++j) { for (k = 0; k < 16; ++k) { + int l = this.world.height - 1; - int l = 128 - 1; + int i1; - int i1 = j << 11; - - int j1; - - for (j1 = i1 | k << 7; l > 0 && Block.q[this.b[j1 + l - 1] & 255] == 0; --l) { + for (i1 = j << this.world.heightBitsPlusFour | k << this.world.heightBits; l > 0 && Block.q[this.b[i1 + l - 1] & 255] == 0; --l) { ; } @@ -117,18 +109,17 @@ public class Chunk { } if (!this.world.worldProvider.e) { - int k1 = 15; - - int l1 = 128 - 1; + int j1 = 15; + int k1 = this.world.height - 1; do { - k1 -= Block.q[this.b[j1 + l1] & 255]; - if (k1 > 0) { - this.h.a(j, l1, k, k1); + j1 -= Block.q[this.b[i1 + k1] & 255]; + if (j1 > 0) { + this.h.a(j, k1, k, j1); } - --l1; - } while (l1 > 0 && k1 > 0); + --k1; + } while (k1 > 0 && j1 > 0); } } } @@ -148,44 +139,41 @@ public class Chunk { private void d(int i, int j) { this.d[i + j * 16] = true; - } - - private void i() { - World j0000 = this.world; - int j0001 = this.x * 16 + 8; - - 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; + this.v = true; + } + + private void k() { + if (this.world.areChunksLoaded(this.x * 16 + 8, this.world.height / 2, this.z * 16 + 8, 16)) { + for (int i = 0; i < 16; ++i) { + for (int j = 0; j < 16; ++j) { + if (this.d[i + j * 16]) { + this.d[i + j * 16] = false; + int k = this.b(i, j); + int l = this.x * 16 + i; + int i1 = this.z * 16 + j; + int j1 = this.world.getHighestBlockYAt(l - 1, i1); + int k1 = this.world.getHighestBlockYAt(l + 1, i1); + int l1 = this.world.getHighestBlockYAt(l, i1 - 1); + int i2 = this.world.getHighestBlockYAt(l, i1 + 1); + + if (k1 < j1) { + j1 = k1; } - if (i2 < k1) { - k1 = i2; + if (l1 < j1) { + j1 = l1; } - if (j2 < k1) { - k1 = j2; + if (i2 < j1) { + j1 = i2; } - 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); + this.f(l, i1, j1); + this.f(l - 1, i1, k); + this.f(l + 1, i1, k); + this.f(l, i1 - 1, k); + this.f(l, i1 + 1, k); + this.v = false; } } } @@ -203,16 +191,12 @@ public class Chunk { } private void d(int i, int j, int k, int l) { - if (l > k) { - World world = this.world; - - 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; + if (l > k && this.world.areChunksLoaded(i, this.world.height / 2, j, 16)) { + for (int i1 = k; i1 < l; ++i1) { + this.world.b(EnumSkyBlock.SKY, i, i1, j); } + + this.q = true; } } @@ -223,88 +207,87 @@ public class Chunk { if (j > l) { i1 = j; } - // - this.world.getClass(); - int j1 = i << 11; - for (int k1 = j1 | k << 7; i1 > 0 && Block.q[this.b[k1 + i1 - 1] & 255] == 0; --i1) { + for (int j1 = i << this.world.heightBitsPlusFour | k << this.world.heightBits; i1 > 0 && Block.q[this.b[j1 + 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.k) { this.k = i1; } else { + k1 = this.world.height - 1; - l1 = 128 - 1; - - 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; + 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; } } } - this.k = l1; + this.k = k1; } - l1 = this.x * 16 + i; - i2 = this.z * 16 + k; - if (i1 < l) { - for (j2 = i1; j2 < l; ++j2) { - this.h.a(i, j2, k, 15); - } - } else { - for (j2 = l; j2 < i1; ++j2) { - this.h.a(i, j2, k, 0); - } - } - - for (j2 = 15; i1 > 0 && j2 > 0; this.h.a(i, i1, k, j2)) { - --i1; - int k2 = Block.q[this.getTypeId(i, i1, k)]; + k1 = this.x * 16 + i; + l1 = this.z * 16 + k; + int j2; - if (k2 == 0) { - k2 = 1; + if (!this.world.worldProvider.e) { + if (i1 < l) { + for (i2 = i1; i2 < l; ++i2) { + this.h.a(i, i2, k, 15); + } + } else { + for (i2 = l; i2 < i1; ++i2) { + this.h.a(i, i2, k, 0); + } } - j2 -= k2; - if (j2 < 0) { - j2 = 0; + for (i2 = 15; i1 > 0 && i2 > 0; this.h.a(i, i1, k, i2)) { + --i1; + j2 = Block.q[this.getTypeId(i, i1, k)]; + if (j2 == 0) { + j2 = 1; + } + + i2 -= j2; + if (i2 < 0) { + i2 = 0; + } } } byte b0 = this.heightMap[k << 4 | i]; - int l2 = l; - int i3 = b0; + + j2 = l; + int k2 = b0; if (b0 < l) { - l2 = b0; - i3 = l; + j2 = b0; + k2 = l; + } + + if (!this.world.worldProvider.e) { + this.d(k1 - 1, l1, j2, k2); + this.d(k1 + 1, l1, j2, k2); + this.d(k1, l1 - 1, j2, k2); + this.d(k1, l1 + 1, j2, k2); + this.d(k1, l1, j2, k2); } - 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) { - byte[] abyte = this.b; - - int l = i << 11; - - return abyte[l | k << 7 | j] & 255; + return this.b[i << this.world.heightBitsPlusFour | k << this.world.heightBits | j] & 255; } public boolean a(int i, int j, int k, int l, int i1) { @@ -316,25 +299,21 @@ public class Chunk { } int k1 = this.heightMap[k << 4 | i] & 255; - byte[] j2000 = this.b; - - int j2001 = i << 11; + int l1 = this.b[i << this.world.heightBitsPlusFour | k << this.world.heightBits | j] & 255; - int i2 = j2000[j2001 | k << 7 | j] & 255; - - if (i2 == l && this.g.a(i, j, k) == i1) { + if (l1 == l && this.g.a(i, j, k) == i1) { return false; } else { - int j2 = this.x * 16 + i; - int k2 = this.z * 16 + k; - - j2000 = this.b; - - j2001 = i << 11; + int i2 = this.x * 16 + i; + int j2 = this.z * 16 + k; - j2000[j2001 | k << 7 | j] = (byte) (b0 & 255); - if (i2 != 0 && !this.world.isStatic) { - Block.byId[i2].remove(this.world, j2, j, k2); + this.b[i << this.world.heightBitsPlusFour | k << this.world.heightBits | j] = (byte) (b0 & 255); + if (l1 != 0) { + if (!this.world.isStatic) { + Block.byId[l1].remove(this.world, i2, j, j2); + } else if (Block.byId[l1] instanceof BlockContainer) { + this.world.n(i2, j, j2); + } } this.g.a(i, j, k, i1); @@ -347,17 +326,17 @@ public class Chunk { this.g(i, j, k); } - this.world.a(EnumSkyBlock.SKY, j2, j, k2, j2, j, k2); + this.world.a(EnumSkyBlock.SKY, i2, j, j2, i2, j, j2); } - this.world.a(EnumSkyBlock.BLOCK, j2, j, k2, j2, j, k2); + this.world.a(EnumSkyBlock.BLOCK, i2, j, j2, i2, j, j2); this.d(i, k); this.g.a(i, j, k, i1); TileEntity tileentity; if (l != 0) { if (!this.world.isStatic) { - Block.byId[l].a(this.world, j2, j, k2); + Block.byId[l].a(this.world, i2, j, j2); } if (Block.byId[l] instanceof BlockContainer) { @@ -368,13 +347,13 @@ public class Chunk { } if (tileentity != null) { - tileentity.g(); + tileentity.d(); } } - } else if (i2 > 0 && Block.byId[i2] instanceof BlockContainer) { + } else if (l1 > 0 && Block.byId[l1] instanceof BlockContainer) { tileentity = this.d(i, j, k); if (tileentity != null) { - tileentity.g(); + tileentity.d(); } } @@ -392,25 +371,17 @@ public class Chunk { } int j1 = this.heightMap[i1] & 255; - byte[] j2000 = this.b; + int k1 = this.b[i << this.world.heightBitsPlusFour | k << this.world.heightBits | j] & 255; - int j2001 = i << 11; - - int l1 = j2000[j2001 | k << 7 | j] & 255; - - if (l1 == l) { + if (k1 == l) { return false; } else { - int i2 = this.x * 16 + i; - int j2 = this.z * 16 + k; - - j2000 = this.b; - - j2001 = i << 11; + int l1 = this.x * 16 + i; + int i2 = this.z * 16 + k; - j2000[j2001 | k << 7 | j] = (byte) (b0 & 255); - if (l1 != 0) { - Block.byId[l1].remove(this.world, i2, j, j2); + this.b[i << this.world.heightBitsPlusFour | k << this.world.heightBits | j] = (byte) (b0 & 255); + if (k1 != 0) { + Block.byId[k1].remove(this.world, l1, j, i2); } this.g.a(i, j, k, 0); @@ -422,14 +393,14 @@ public class Chunk { this.g(i, j, k); } - this.world.a(EnumSkyBlock.SKY, i2, j, j2, i2, j, j2); - this.world.a(EnumSkyBlock.BLOCK, i2, j, j2, i2, j, j2); + this.world.a(EnumSkyBlock.SKY, l1, j, i2, l1, j, i2); + this.world.a(EnumSkyBlock.BLOCK, l1, j, i2, l1, j, i2); this.d(i, k); TileEntity tileentity; if (l != 0) { if (!this.world.isStatic) { - Block.byId[l].a(this.world, i2, j, j2); + Block.byId[l].a(this.world, l1, j, i2); } if (l > 0 && Block.byId[l] instanceof BlockContainer) { @@ -440,13 +411,13 @@ public class Chunk { } if (tileentity != null) { - tileentity.g(); + tileentity.d(); } } - } else if (l1 > 0 && Block.byId[l1] instanceof BlockContainer) { + } else if (k1 > 0 && Block.byId[k1] instanceof BlockContainer) { tileentity = this.d(i, j, k); if (tileentity != null) { - tileentity.g(); + tileentity.d(); } } @@ -459,18 +430,26 @@ public class Chunk { return this.g.a(i, j, k); } - public void b(int i, int j, int k, int l) { + public boolean b(int i, int j, int k, int l) { this.q = true; - this.g.a(i, j, k, l); - int i1 = this.getTypeId(i, j, k); + int i1 = this.g.a(i, j, k); + + if (i1 == l) { + return false; + } else { + this.g.a(i, j, k, l); + int j1 = this.getTypeId(i, j, k); - if (i1 > 0 && Block.byId[i1] instanceof BlockContainer) { - TileEntity tileentity = this.d(i, j, k); + if (j1 > 0 && Block.byId[j1] instanceof BlockContainer) { + TileEntity tileentity = this.d(i, j, k); - if (tileentity != null) { - tileentity.g(); - tileentity.n = l; + if (tileentity != null) { + tileentity.d(); + tileentity.p = l; + } } + + return true; } } @@ -481,7 +460,9 @@ public class Chunk { public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l) { this.q = true; if (enumskyblock == EnumSkyBlock.SKY) { - this.h.a(i, j, k, l); + if (!this.world.worldProvider.e) { + this.h.a(i, j, k, l); + } } else { if (enumskyblock != EnumSkyBlock.BLOCK) { return; @@ -492,7 +473,7 @@ public class Chunk { } public int c(int i, int j, int k, int l) { - int i1 = this.h.a(i, j, k); + int i1 = this.world.worldProvider.e ? 0 : this.h.a(i, j, k); if (i1 > 0) { a = true; @@ -531,15 +512,15 @@ public class Chunk { k = this.entitySlices.length - 1; } - entity.bV = true; - entity.bW = this.x; - entity.bX = k; - entity.bY = this.z; + entity.bW = true; + entity.bX = this.x; + entity.bY = k; + entity.bZ = this.z; this.entitySlices[k].add(entity); } public void b(Entity entity) { - this.a(entity, entity.bX); + this.a(entity, entity.bY); } public void a(Entity entity, int i) { @@ -577,7 +558,7 @@ public class Chunk { tileentity = (TileEntity) this.tileEntities.get(chunkposition); } - if (tileentity != null && tileentity.m()) { + if (tileentity != null && tileentity.l()) { this.tileEntities.remove(chunkposition); return null; } else { @@ -604,10 +585,10 @@ 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.n(); + tileentity.m(); this.tileEntities.put(chunkposition, tileentity); + // CraftBukkit start } else { - // CraftBukkit start System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.x + "," + tileentity.y + "," + tileentity.z + " (" + org.bukkit.Material.getMaterial(getTypeId(i, j, k)) + ") where there was no entity tile!"); // CraftBukkit end @@ -689,6 +670,16 @@ public class Chunk { if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) { list.add(entity1); + Entity[] aentity = entity1.aG(); + + if (aentity != null) { + for (int i1 = 0; i1 < aentity.length; ++i1) { + entity1 = aentity[i1]; + if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) { + list.add(entity1); + } + } + } } } } @@ -700,10 +691,14 @@ public class Chunk { if (i < 0) { i = 0; + } else if (i >= this.entitySlices.length) { + i = this.entitySlices.length - 1; } if (j >= this.entitySlices.length) { j = this.entitySlices.length - 1; + } else if (j < 0) { + j = 0; } for (int k = i; k <= j; ++k) { @@ -755,53 +750,40 @@ public class Chunk { int l2; int i3; int j3; - int k3; for (k2 = i; k2 < l; ++k2) { - for (i3 = k; i3 < j1; ++i3) { - - l2 = k2 << 11; - - j3 = l2 | i3 << 7 | j; - k3 = i1 - j; - System.arraycopy(this.b, j3, abyte, k1, k3); - k1 += k3; + for (l2 = k; l2 < j1; ++l2) { + i3 = k2 << this.world.heightBitsPlusFour | l2 << this.world.heightBits | j; + j3 = i1 - j; + System.arraycopy(this.b, i3, abyte, k1, j3); + k1 += j3; } } for (k2 = i; k2 < l; ++k2) { - for (i3 = k; i3 < j1; ++i3) { - - l2 = k2 << 11; - - j3 = (l2 | i3 << 7 | j) >> 1; - k3 = (i1 - j) / 2; - System.arraycopy(this.g.a, j3, abyte, k1, k3); - k1 += k3; + for (l2 = k; l2 < j1; ++l2) { + i3 = (k2 << this.world.heightBitsPlusFour | l2 << this.world.heightBits | j) >> 1; + j3 = (i1 - j) / 2; + System.arraycopy(this.g.a, i3, abyte, k1, j3); + k1 += j3; } } for (k2 = i; k2 < l; ++k2) { - for (i3 = k; i3 < j1; ++i3) { - - l2 = k2 << 11; - - j3 = (l2 | i3 << 7 | j) >> 1; - k3 = (i1 - j) / 2; - System.arraycopy(this.i.a, j3, abyte, k1, k3); - k1 += k3; + for (l2 = k; l2 < j1; ++l2) { + i3 = (k2 << this.world.heightBitsPlusFour | l2 << this.world.heightBits | j) >> 1; + j3 = (i1 - j) / 2; + System.arraycopy(this.i.a, i3, abyte, k1, j3); + k1 += j3; } } for (k2 = i; k2 < l; ++k2) { - for (i3 = k; i3 < j1; ++i3) { - - l2 = k2 << 11; - - j3 = (l2 | i3 << 7 | j) >> 1; - k3 = (i1 - j) / 2; - System.arraycopy(this.h.a, j3, abyte, k1, k3); - k1 += k3; + for (l2 = k; l2 < j1; ++l2) { + i3 = (k2 << this.world.heightBitsPlusFour | l2 << this.world.heightBits | j) >> 1; + j3 = (i1 - j) / 2; + System.arraycopy(this.h.a, i3, abyte, k1, j3); + k1 += j3; } } @@ -813,7 +795,11 @@ 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 void g() { + public boolean isEmpty() { + return false; + } + + public void h() { BlockRegister.a(this.b); } @@ -840,8 +826,7 @@ public class Chunk { int l = this.c[k]; if (l == -999) { - - int i1 = 128 - 1; + int i1 = this.world.height - 1; l = -1; @@ -862,7 +847,13 @@ public class Chunk { return l; } - public void h() { - this.i(); + public void i() { + if (this.v && !this.world.worldProvider.e) { + this.k(); + } + } + + public ChunkCoordIntPair j() { + return new ChunkCoordIntPair(this.x, this.z); } } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 4aef10cb..36351951 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -31,11 +31,7 @@ public class ChunkProviderServer implements IChunkProvider { // CraftBukkit end public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) { - - worldserver.getClass(); - EmptyChunk emptychunk = new EmptyChunk(worldserver, new byte[256 * 128], 0, 0); - - this.emptyChunk = emptychunk; + this.emptyChunk = new EmptyChunk(worldserver, new byte[256 * worldserver.height], 0, 0); this.world = worldserver; this.e = ichunkloader; this.chunkProvider = ichunkprovider; @@ -46,12 +42,16 @@ public class ChunkProviderServer implements IChunkProvider { } public void queueUnload(int i, int j) { - ChunkCoordinates chunkcoordinates = this.world.getSpawn(); - int k = i * 16 + 8 - chunkcoordinates.x; - int l = j * 16 + 8 - chunkcoordinates.z; - short short1 = 128; - - if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // CraftBukkit - added 'this.world.keepSpawnInMemory' + if (this.world.worldProvider.c()) { + ChunkCoordinates chunkcoordinates = this.world.getSpawn(); + int k = i * 16 + 8 - chunkcoordinates.x; + int l = j * 16 + 8 - chunkcoordinates.z; + short short1 = 128; + + if (k < -short1 || k > short1 || l < -short1 || l > short1 || !(this.world.keepSpawnInMemory)) { // CraftBukkit - added 'this.world.keepSpawnInMemory' + this.unloadQueue.add(i, j); // CraftBukkit + } + } else { this.unloadQueue.add(i, j); // CraftBukkit } } @@ -253,4 +253,12 @@ public class ChunkProviderServer implements IChunkProvider { public boolean canSave() { return !this.world.savingDisabled; } + + public List a(EnumCreatureType enumcreaturetype, int i, int j, int k) { + return this.chunkProvider.a(enumcreaturetype, i, j, k); + } + + public ChunkPosition a(World world, String s, int i, int j, int k) { + return this.chunkProvider.a(world, s, i, j, k); + } } diff --git a/src/main/java/net/minecraft/server/ContainerPlayer.java b/src/main/java/net/minecraft/server/ContainerPlayer.java index aa13bc7b..96f006e7 100644 --- a/src/main/java/net/minecraft/server/ContainerPlayer.java +++ b/src/main/java/net/minecraft/server/ContainerPlayer.java @@ -77,7 +77,7 @@ public class ContainerPlayer extends Container { ItemStack itemstack = null; Slot slot = (Slot) this.e.get(i); - if (slot != null && slot.b()) { + if (slot != null && slot.c()) { ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.cloneItemStack(); @@ -100,14 +100,14 @@ public class ContainerPlayer extends Container { if (itemstack1.count == 0) { slot.c((ItemStack) null); } else { - slot.c(); + slot.d(); } if (itemstack1.count == itemstack.count) { return null; } - slot.a(itemstack1); + slot.b(itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java index f0e29fa0..3f62b82d 100644 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ b/src/main/java/net/minecraft/server/ContainerWorkbench.java @@ -72,7 +72,7 @@ public class ContainerWorkbench extends Container { ItemStack itemstack = null; Slot slot = (Slot) this.e.get(i); - if (slot != null && slot.b()) { + if (slot != null && slot.c()) { ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.cloneItemStack(); @@ -95,14 +95,14 @@ public class ContainerWorkbench extends Container { if (itemstack1.count == 0) { slot.c((ItemStack) null); } else { - slot.c(); + slot.d(); } if (itemstack1.count == itemstack.count) { return null; } - slot.a(itemstack1); + slot.b(itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index 7a01145f..c306818b 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.NETHER_FENCE, 6), new Object[] { "###", "###", Character.valueOf('#'), Block.NETHER_BRICK}); 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}); @@ -53,10 +54,13 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Block.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), Item.COAL, Character.valueOf('#'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Block.TORCH, 4), new Object[] { "X", "#", Character.valueOf('X'), new ItemStack(Item.COAL, 1, 1), Character.valueOf('#'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Item.BOWL, 4), new Object[] { "# #", " # ", Character.valueOf('#'), Block.WOOD}); + this.registerShapedRecipe(new ItemStack(Item.GLASS_BOTTLE, 3), new Object[] { "# #", " # ", Character.valueOf('#'), Block.GLASS}); this.registerShapedRecipe(new ItemStack(Block.RAILS, 16), new Object[] { "X X", "X#X", "X X", Character.valueOf('X'), Item.IRON_INGOT, Character.valueOf('#'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Block.GOLDEN_RAIL, 6), new Object[] { "X X", "X#X", "XRX", Character.valueOf('X'), Item.GOLD_INGOT, Character.valueOf('R'), Item.REDSTONE, Character.valueOf('#'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Block.DETECTOR_RAIL, 6), new Object[] { "X X", "X#X", "XRX", Character.valueOf('X'), Item.IRON_INGOT, Character.valueOf('R'), Item.REDSTONE, Character.valueOf('#'), Block.STONE_PLATE}); this.registerShapedRecipe(new ItemStack(Item.MINECART, 1), new Object[] { "# #", "###", Character.valueOf('#'), Item.IRON_INGOT}); + this.registerShapedRecipe(new ItemStack(Item.CAULDRON, 1), new Object[] { "# #", "# #", "###", Character.valueOf('#'), Item.IRON_INGOT}); + this.registerShapedRecipe(new ItemStack(Item.BREWING_STAND, 1), new Object[] { " B ", "###", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('B'), Item.BLAZE_ROD}); this.registerShapedRecipe(new ItemStack(Block.JACK_O_LANTERN, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.PUMPKIN, Character.valueOf('B'), Block.TORCH}); this.registerShapedRecipe(new ItemStack(Item.STORAGE_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.CHEST, Character.valueOf('B'), Item.MINECART}); this.registerShapedRecipe(new ItemStack(Item.POWERED_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.FURNACE, Character.valueOf('B'), Item.MINECART}); @@ -69,6 +73,7 @@ public class CraftingManager { 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(Block.NETHER_BRICK_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.NETHER_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}); @@ -84,6 +89,8 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Block.PISTON, 1), new Object[] { "TTT", "#X#", "#R#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.IRON_INGOT, Character.valueOf('R'), Item.REDSTONE, Character.valueOf('T'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Block.PISTON_STICKY, 1), new Object[] { "S", "P", Character.valueOf('S'), Item.SLIME_BALL, Character.valueOf('P'), Block.PISTON}); this.registerShapedRecipe(new ItemStack(Item.BED, 1), new Object[] { "###", "XXX", Character.valueOf('#'), Block.WOOL, Character.valueOf('X'), Block.WOOD}); + this.registerShapedRecipe(new ItemStack(Block.ENCHANTMENT_TABLE, 1), new Object[] { " B ", "D#D", "###", Character.valueOf('#'), Block.OBSIDIAN, Character.valueOf('B'), Item.BOOK, Character.valueOf('D'), Item.DIAMOND}); + this.registerShapelessRecipe(new ItemStack(Item.EYE_OF_ENDER, 1), new Object[] { Item.ENDER_PEARL, Item.BLAZE_POWDER}); Collections.sort(this.b, new RecipeSorter(this)); System.out.println(this.b.size() + " recipes"); } @@ -171,15 +178,51 @@ public class CraftingManager { } public ItemStack craft(InventoryCrafting inventorycrafting) { - for (int i = 0; i < this.b.size(); ++i) { - CraftingRecipe craftingrecipe = (CraftingRecipe) this.b.get(i); + int i = 0; + ItemStack itemstack = null; + ItemStack itemstack1 = null; + + int j; + + for (j = 0; j < inventorycrafting.getSize(); ++j) { + ItemStack itemstack2 = inventorycrafting.getItem(j); + + if (itemstack2 != null) { + if (i == 0) { + itemstack = itemstack2; + } + + if (i == 1) { + itemstack1 = itemstack2; + } - if (craftingrecipe.a(inventorycrafting)) { - return craftingrecipe.b(inventorycrafting); + ++i; } } - return null; + if (i == 2 && itemstack.id == itemstack1.id && itemstack.count == 1 && itemstack1.count == 1 && Item.byId[itemstack.id].g()) { + Item item = Item.byId[itemstack.id]; + int k = item.getMaxDurability() - itemstack.g(); + int l = item.getMaxDurability() - itemstack1.g(); + int i1 = k + l + item.getMaxDurability() * 10 / 100; + int j1 = item.getMaxDurability() - i1; + + if (j1 < 0) { + j1 = 0; + } + + return new ItemStack(itemstack.id, 1, j1); + } else { + for (j = 0; j < this.b.size(); ++j) { + CraftingRecipe craftingrecipe = (CraftingRecipe) this.b.get(j); + + if (craftingrecipe.a(inventorycrafting)) { + return craftingrecipe.b(inventorycrafting); + } + } + + return null; + } } public List b() { diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 38e407bf..2625ad35 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -22,8 +22,8 @@ public abstract class Entity { private static int entityCount = 0; public int id; - public double aX; - public boolean aY; + public double bb; + public boolean bc; public Entity passenger; public Entity vehicle; public World world; @@ -43,83 +43,82 @@ public abstract class Entity { public final AxisAlignedBB boundingBox; public boolean onGround; public boolean positionChanged; - public boolean bs; - public boolean bt; - public boolean velocityChanged; - protected boolean bv; public boolean bw; + public boolean bx; + public boolean velocityChanged; + protected boolean bz; + public boolean bA; public boolean dead; public float height; public float length; public float width; - public float bB; - public float bC; + public float bF; + public float bG; public float fallDistance; // CraftBukkit - private -> public private int b; - public double bE; - public double bF; - public double bG; - public float bH; - public float bI; - public boolean bJ; - public float bK; + public double bI; + public double bJ; + public double bK; + public float bL; + public float bM; + public boolean bN; + public float bO; protected Random random; public int ticksLived; public int maxFireTicks; - public int fireTicks; - public int maxAirTicks; // CraftBukkit - protected - >public - protected boolean bQ; + public int fireTicks; // CraftBukkit - private -> public + public int maxAirTicks; // CraftBukkit - protected -> public + protected boolean bS; public int noDamageTicks; public int airTicks; private boolean justCreated; protected boolean fireProof; protected DataWatcher datawatcher; - private double d; private double e; - public boolean bV; - public int bW; + private double f; + public boolean bW; public int bX; public int bY; - public boolean bZ; + public int bZ; public boolean ca; + public boolean cb; public UUID uniqueId = UUID.randomUUID(); // CraftBukkit public Entity(World world) { this.id = entityCount++; - this.aX = 1.0D; - this.aY = false; + this.bb = 1.0D; + this.bc = false; this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); this.onGround = false; - this.bt = false; + this.bx = false; this.velocityChanged = false; - this.bw = true; + this.bA = true; this.dead = false; this.height = 0.0F; this.length = 0.6F; this.width = 1.8F; - this.bB = 0.0F; - this.bC = 0.0F; + this.bF = 0.0F; + this.bG = 0.0F; this.fallDistance = 0.0F; this.b = 1; - this.bH = 0.0F; - this.bI = 0.0F; - this.bJ = false; - this.bK = 0.0F; + this.bL = 0.0F; + this.bM = 0.0F; + this.bN = false; + this.bO = 0.0F; this.random = new Random(); this.ticksLived = 0; this.maxFireTicks = 1; this.fireTicks = 0; - this.maxAirTicks = 300; - this.bQ = false; + this.bS = false; this.noDamageTicks = 0; - this.airTicks = 300; this.justCreated = true; this.fireProof = false; this.datawatcher = new DataWatcher(); - this.bV = false; + this.bW = false; this.world = world; this.setPosition(0.0D, 0.0D, 0.0D); this.datawatcher.a(0, Byte.valueOf((byte) 0)); + this.datawatcher.a(1, Short.valueOf((short) 300)); this.b(); } @@ -185,20 +184,21 @@ 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.bH, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.bH + (double) f1, d2 + (double) f); + this.boundingBox.c(d0 - (double) f, d1 - (double) this.height + (double) this.bL, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.bL + (double) f1, d2 + (double) f); } - public void s_() { - this.aa(); + public void w_() { + this.af(); } - public void aa() { + public void af() { + MethodProfiler.a("entityBaseTick"); if (this.vehicle != null && this.vehicle.dead) { this.vehicle = null; } ++this.ticksLived; - this.bB = this.bC; + this.bF = this.bG; this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; @@ -218,8 +218,8 @@ public abstract class Entity { } } - if (this.f_()) { - if (!this.bQ && !this.justCreated) { + if (this.i_()) { + if (!this.bS && !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) { @@ -246,10 +246,10 @@ public abstract class Entity { } this.fallDistance = 0.0F; - this.bQ = true; + this.bS = true; this.fireTicks = 0; } else { - this.bQ = false; + this.bS = false; } if (this.world.isStatic) { @@ -280,12 +280,13 @@ public abstract class Entity { } } - if (this.ap()) { - this.am(); + if (this.aA()) { + this.av(); + this.fallDistance *= 0.5F; } if (this.locY < -64.0D) { - this.ah(); + this.ao(); } if (!this.world.isStatic) { @@ -294,9 +295,10 @@ public abstract class Entity { } this.justCreated = false; + MethodProfiler.a(); } - protected void am() { + protected void av() { if (!this.fireProof) { // CraftBukkit start - TODO: this event spams! if (this instanceof EntityLiving) { @@ -319,22 +321,33 @@ public abstract class Entity { server.getPluginManager().callEvent(combustEvent); if (!combustEvent.isCancelled()) { - this.fireTicks = 600; + this.j(15); } } else { - // reset fire level back to max - this.fireTicks = 600; + this.j(15); } return; } // CraftBukkit end this.damageEntity(DamageSource.LAVA, 4); - this.fireTicks = 600; + this.j(15); + } + } + + public void j(int i) { + int j = i * 20; + + if (this.fireTicks < j) { + this.fireTicks = j; } } - protected void ah() { + public void aw() { + this.fireTicks = 0; + } + + protected void ao() { this.die(); } @@ -346,18 +359,19 @@ public abstract class Entity { } public void move(double d0, double d1, double d2) { - if (this.bJ) { + if (this.bN) { 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.bH; + this.locY = this.boundingBox.b + (double) this.height - (double) this.bL; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; } else { - this.bH *= 0.4F; + MethodProfiler.a("move"); + this.bL *= 0.4F; double d3 = this.locX; double d4 = this.locZ; - if (this.bv) { - this.bv = false; + if (this.bz) { + this.bz = false; d0 *= 0.25D; d1 *= 0.05000000074505806D; d2 *= 0.25D; @@ -403,7 +417,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.bw && d6 != d1) { + if (!this.bA && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -418,7 +432,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.bw && d5 != d0) { + if (!this.bA && d5 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -429,7 +443,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.bw && d7 != d2) { + if (!this.bA && d7 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -439,13 +453,13 @@ public abstract class Entity { double d10; int k; - if (this.bI > 0.0F && flag1 && (flag || this.bH < 0.05F) && (d5 != d0 || d7 != d2)) { + if (this.bM > 0.0F && flag1 && (flag || this.bL < 0.05F) && (d5 != d0 || d7 != d2)) { d9 = d0; d10 = d1; double d11 = d2; d0 = d5; - d1 = (double) this.bI; + d1 = (double) this.bM; d2 = d7; AxisAlignedBB axisalignedbb1 = this.boundingBox.clone(); @@ -457,7 +471,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.bw && d6 != d1) { + if (!this.bA && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -468,7 +482,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.bw && d5 != d0) { + if (!this.bA && d5 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -479,18 +493,18 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.bw && d7 != d2) { + if (!this.bA && d7 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } - if (!this.bw && d6 != d1) { + if (!this.bA && d6 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } else { - d1 = (double) (-this.bI); + d1 = (double) (-this.bM); for (k = 0; k < list.size(); ++k) { d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1); @@ -508,18 +522,20 @@ public abstract class Entity { double d12 = this.boundingBox.b - (double) ((int) this.boundingBox.b); if (d12 > 0.0D) { - this.bH = (float) ((double) this.bH + d12 + 0.01D); + this.bL = (float) ((double) this.bL + d12 + 0.01D); } } } + MethodProfiler.a(); + MethodProfiler.a("rest"); this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; - this.locY = this.boundingBox.b + (double) this.height - (double) this.bH; + this.locY = this.boundingBox.b + (double) this.height - (double) this.bL; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; this.positionChanged = d5 != d0 || d7 != d2; - this.bs = d6 != d1; + this.bw = d6 != d1; this.onGround = d6 != d1 && d6 < 0.0D; - this.bt = this.positionChanged || this.bs; + this.bx = this.positionChanged || this.bw; this.a(d1, this.onGround); if (d5 != d0) { this.motX = 0.0D; @@ -559,27 +575,19 @@ public abstract class Entity { } // CraftBukkit end - if (this.e_() && !flag && this.vehicle == null) { - this.bC = (float) ((double) this.bC + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); + if (this.g_() && !flag && this.vehicle == null) { + this.bG = (float) ((double) this.bG + (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); k = this.world.getTypeId(l, i1, j1); - if (this.world.getTypeId(l, i1 - 1, j1) == Block.FENCE.id) { + if (k == 0 && this.world.getTypeId(l, i1 - 1, j1) == Block.FENCE.id) { k = this.world.getTypeId(l, i1 - 1, j1); } - 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) { - stepsound = Block.SNOW.stepSound; - this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } else if (!Block.byId[k].material.isLiquid()) { - this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); - } - + if (this.bG > (float) this.b && k > 0) { + this.b = (int) this.bG + 1; + this.a(l, i1, j1, k); Block.byId[k].b(this.world, l, i1, j1, this); } } @@ -605,7 +613,7 @@ public abstract class Entity { } } - boolean flag2 = this.an(); + boolean flag2 = this.ay(); if (this.world.d(this.boundingBox.shrink(0.0010D, 0.0010D, 0.0010D))) { this.burn(1); @@ -617,11 +625,11 @@ public abstract class Entity { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.fireTicks = 300; + this.j(8); } } else { - // CraftBukkit end - reset fire level back to max - this.fireTicks = 300; + // CraftBukkit end + this.j(8); } } } else if (this.fireTicks <= 0) { @@ -632,17 +640,30 @@ public abstract class Entity { this.world.makeSound(this, "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); this.fireTicks = -this.maxFireTicks; } + + MethodProfiler.a(); + } + } + + protected void a(int i, int j, int k, int l) { + StepSound stepsound = Block.byId[l].stepSound; + + if (this.world.getTypeId(i, j + 1, k) == Block.SNOW.id) { + stepsound = Block.SNOW.stepSound; + this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); + } else if (!Block.byId[l].material.isLiquid()) { + this.world.makeSound(this, stepsound.getName(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2()); } } - protected boolean e_() { + protected boolean g_() { return true; } protected void a(double d0, boolean flag) { if (flag) { if (this.fallDistance > 0.0F) { - this.a(this.fallDistance); + this.b(this.fallDistance); this.fallDistance = 0.0F; } } else if (d0 < 0.0D) { @@ -650,7 +671,7 @@ public abstract class Entity { } } - public AxisAlignedBB f() { + public AxisAlignedBB h_() { return null; } @@ -672,33 +693,37 @@ public abstract class Entity { } } - protected void a(float f) { + public final boolean ax() { + return this.fireProof; + } + + protected void b(float f) { if (this.passenger != null) { - this.passenger.a(f); + this.passenger.b(f); } } - public boolean an() { - return this.bQ || this.world.s(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + public boolean ay() { + return this.bS || this.world.v(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); } - public boolean ao() { - return this.bQ; + public boolean az() { + return this.bS; } - public boolean f_() { + public boolean i_() { return this.world.a(this.boundingBox.b(0.0D, -0.4000000059604645D, 0.0D).shrink(0.0010D, 0.0010D, 0.0010D), Material.WATER, this); } public boolean a(Material material) { - double d0 = this.locY + (double) this.t(); + double d0 = this.locY + (double) this.x(); int i = MathHelper.floor(this.locX); int j = MathHelper.d((float) MathHelper.floor(d0)); int k = MathHelper.floor(this.locZ); int l = this.world.getTypeId(i, j, k); if (l != 0 && Block.byId[l].material == material) { - float f = BlockFluids.c(this.world.getData(i, j, k)) - 0.11111111F; + float f = BlockFluids.d(this.world.getData(i, j, k)) - 0.11111111F; float f1 = (float) (j + 1) - f; return d0 < (double) f1; @@ -707,11 +732,11 @@ public abstract class Entity { } } - public float t() { + public float x() { return 0.0F; } - public boolean ap() { + public boolean aA() { return this.world.a(this.boundingBox.b(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA); } @@ -734,12 +759,11 @@ public abstract class Entity { } } - public float a_(float f) { + public float a(float f) { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locZ); - World world = this.world; - if (world.isLoaded(i, 128 / 2, j)) { + if (this.world.isLoaded(i, this.world.height / 2, j)) { double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D; int k = MathHelper.floor(this.locY - (double) this.height + d0); @@ -766,7 +790,7 @@ public abstract class Entity { this.lastZ = this.locZ = d2; this.lastYaw = this.yaw = f; this.lastPitch = this.pitch = f1; - this.bH = 0.0F; + this.bL = 0.0F; double d3 = (double) (this.lastYaw - f); if (d3 < -180.0D) { @@ -782,15 +806,15 @@ public abstract class Entity { } public void setPositionRotation(double d0, double d1, double d2, float f, float f1) { - 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.bI = this.lastX = this.locX = d0; + this.bJ = this.lastY = this.locY = d1 + (double) this.height; + this.bK = this.lastZ = this.locZ = d2; this.yaw = f; this.pitch = f1; this.setPosition(this.locX, this.locY, this.locZ); } - public float g(Entity entity) { + public float h(Entity entity) { float f = (float) (this.locX - entity.locX); float f1 = (float) (this.locY - entity.locY); float f2 = (float) (this.locZ - entity.locZ); @@ -814,7 +838,7 @@ public abstract class Entity { return (double) MathHelper.a(d3 * d3 + d4 * d4 + d5 * d5); } - public double h(Entity entity) { + public double i(Entity entity) { double d0 = this.locX - entity.locX; double d1 = this.locY - entity.locY; double d2 = this.locZ - entity.locZ; @@ -844,42 +868,42 @@ public abstract class Entity { d1 *= d3; d0 *= 0.05000000074505806D; d1 *= 0.05000000074505806D; - d0 *= (double) (1.0F - this.bK); - d1 *= (double) (1.0F - this.bK); - this.b(-d0, 0.0D, -d1); - entity.b(d0, 0.0D, d1); + d0 *= (double) (1.0F - this.bO); + d1 *= (double) (1.0F - this.bO); + this.b_(-d0, 0.0D, -d1); + entity.b_(d0, 0.0D, d1); } } } - public void b(double d0, double d1, double d2) { + public void b_(double d0, double d1, double d2) { this.motX += d0; this.motY += d1; this.motZ += d2; - this.ca = true; + this.cb = true; } - protected void aq() { + protected void aB() { this.velocityChanged = true; } public boolean damageEntity(DamageSource damagesource, int i) { - this.aq(); + this.aB(); return false; } - public boolean r_() { + public boolean e_() { return false; } - public boolean g() { + public boolean f_() { return false; } public void b(Entity entity, int i) {} public boolean c(NBTTagCompound nbttagcompound) { - String s = this.ar(); + String s = this.aC(); if (!this.dead && s != null) { nbttagcompound.setString("id", s); @@ -891,7 +915,7 @@ public abstract class Entity { } public void d(NBTTagCompound nbttagcompound) { - nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY + (double) this.bH, this.locZ})); + nbttagcompound.a("Pos", (NBTBase) this.a(new double[] { this.locX, this.locY + (double) this.bL, 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 @@ -908,7 +932,7 @@ public abstract class Entity { nbttagcompound.a("Rotation", (NBTBase) this.a(new float[] { this.yaw, this.pitch})); nbttagcompound.a("FallDistance", this.fallDistance); nbttagcompound.a("Fire", (short) this.fireTicks); - nbttagcompound.a("Air", (short) this.airTicks); + nbttagcompound.a("Air", (short) this.getAirTicks()); nbttagcompound.a("OnGround", this.onGround); // CraftBukkit start nbttagcompound.setLong("WorldUUIDLeast", this.world.getUUID().getLeastSignificantBits()); @@ -920,9 +944,9 @@ public abstract class Entity { } public void e(NBTTagCompound nbttagcompound) { - NBTTagList nbttaglist = nbttagcompound.l("Pos"); - NBTTagList nbttaglist1 = nbttagcompound.l("Motion"); - NBTTagList nbttaglist2 = nbttagcompound.l("Rotation"); + NBTTagList nbttaglist = nbttagcompound.m("Pos"); + NBTTagList nbttaglist1 = nbttagcompound.m("Motion"); + NBTTagList nbttaglist2 = nbttagcompound.m("Rotation"); this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; @@ -941,15 +965,15 @@ public abstract class Entity { } // CraftBukkit end */ - 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.lastX = this.bI = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; + this.lastY = this.bJ = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; + this.lastZ = this.bK = 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"); - this.fireTicks = nbttagcompound.d("Fire"); - this.airTicks = nbttagcompound.d("Air"); - this.onGround = nbttagcompound.m("OnGround"); + this.fallDistance = nbttagcompound.h("FallDistance"); + this.fireTicks = nbttagcompound.e("Fire"); + this.setAirTicks(nbttagcompound.e("Air")); + this.onGround = nbttagcompound.n("OnGround"); this.setPosition(this.locX, this.locY, this.locZ); // CraftBukkit start @@ -1004,7 +1028,7 @@ public abstract class Entity { // CraftBukkit end } - protected final String ar() { + protected final String aC() { return EntityTypes.b(this); } @@ -1020,7 +1044,7 @@ public abstract class Entity { for (int j = 0; j < i; ++j) { double d0 = adouble1[j]; - nbttaglist.a((NBTBase) (new NBTTagDouble(d0))); + nbttaglist.a((NBTBase) (new NBTTagDouble((String) null, d0))); } return nbttaglist; @@ -1034,7 +1058,7 @@ public abstract class Entity { for (int j = 0; j < i; ++j) { float f = afloat1[j]; - nbttaglist.a((NBTBase) (new NBTTagFloat(f))); + nbttaglist.a((NBTBase) (new NBTTagFloat((String) null, f))); } return nbttaglist; @@ -1056,17 +1080,17 @@ public abstract class Entity { return entityitem; } - public boolean ac() { + public boolean aj() { return !this.dead; } - public boolean O() { + public boolean T() { for (int i = 0; i < 8; ++i) { - float f = ((float) ((i >> 0) % 2) - 0.5F) * this.length * 0.9F; + float f = ((float) ((i >> 0) % 2) - 0.5F) * this.length * 0.8F; float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F; - float f2 = ((float) ((i >> 2) % 2) - 0.5F) * this.length * 0.9F; + float f2 = ((float) ((i >> 2) % 2) - 0.5F) * this.length * 0.8F; int j = MathHelper.floor(this.locX + (double) f); - int k = MathHelper.floor(this.locY + (double) this.t() + (double) f1); + int k = MathHelper.floor(this.locY + (double) this.x() + (double) f1); int l = MathHelper.floor(this.locZ + (double) f2); if (this.world.e(j, k, l)) { @@ -1081,40 +1105,40 @@ public abstract class Entity { return false; } - public AxisAlignedBB b(Entity entity) { + public AxisAlignedBB a_(Entity entity) { return null; } - public void I() { + public void M() { if (this.vehicle.dead) { this.vehicle = null; } else { this.motX = 0.0D; this.motY = 0.0D; this.motZ = 0.0D; - this.s_(); + this.w_(); if (this.vehicle != null) { - this.vehicle.g_(); - this.e += (double) (this.vehicle.yaw - this.vehicle.lastYaw); + this.vehicle.i(); + this.f += (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) { + for (this.e += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.f >= 180.0D; this.f -= 360.0D) { ; } - while (this.e < -180.0D) { - this.e += 360.0D; + while (this.f < -180.0D) { + this.f += 360.0D; } - while (this.d >= 180.0D) { - this.d -= 360.0D; + while (this.e >= 180.0D) { + this.e -= 360.0D; } - while (this.d < -180.0D) { - this.d += 360.0D; + while (this.e < -180.0D) { + this.e += 360.0D; } - double d0 = this.e * 0.5D; - double d1 = this.d * 0.5D; + double d0 = this.f * 0.5D; + double d1 = this.e * 0.5D; float f = 10.0F; if (d0 > (double) f) { @@ -1133,23 +1157,23 @@ public abstract class Entity { d1 = (double) (-f); } - this.e -= d0; - this.d -= d1; + this.f -= d0; + this.e -= d1; this.yaw = (float) ((double) this.yaw + d0); this.pitch = (float) ((double) this.pitch + d1); } } } - public void g_() { - this.passenger.setPosition(this.locX, this.locY + this.n() + this.passenger.M(), this.locZ); + public void i() { + this.passenger.setPosition(this.locX, this.locY + this.q() + this.passenger.R(), this.locZ); } - public double M() { + public double R() { return (double) this.height; } - public double n() { + public double q() { return (double) this.width * 0.75D; } @@ -1172,8 +1196,8 @@ public abstract class Entity { // so this method is needed // CraftBukkit end - this.d = 0.0D; this.e = 0.0D; + this.f = 0.0D; if (entity == null) { if (this.vehicle != null) { // CraftBukkit start @@ -1213,18 +1237,26 @@ public abstract class Entity { } } - public Vec3D ai() { + public float j_() { + return 0.1F; + } + + public Vec3D ap() { return null; } - public void T() {} + public void Y() {} public ItemStack[] getEquipment() { return null; } + public boolean z() { + return this.fireTicks > 0 || this.k(0); + } + public boolean isSneaking() { - return this.e(1); + return this.k(1); } public void setSneak(boolean flag) { @@ -1232,18 +1264,18 @@ public abstract class Entity { } public boolean isSprinting() { - return this.e(3); + return this.k(3); } public void setSprinting(boolean flag) { this.a(3, flag); } - public void h(boolean flag) { + public void g(boolean flag) { this.a(4, flag); } - protected boolean e(int i) { + protected boolean k(int i) { return (this.datawatcher.getByte(0) & 1 << i) != 0; } @@ -1257,6 +1289,14 @@ public abstract class Entity { } } + public int getAirTicks() { + return this.datawatcher.b(1); + } + + public void setAirTicks(int i) { + this.datawatcher.watch(1, Short.valueOf((short) i)); + } + public void a(EntityWeatherStorm entityweatherstorm) { // CraftBukkit start EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(entityweatherstorm.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.LIGHTNING, 5); @@ -1271,7 +1311,7 @@ public abstract class Entity { ++this.fireTicks; if (this.fireTicks == 0) { - this.fireTicks = 300; + this.j(8); } } @@ -1350,16 +1390,18 @@ public abstract class Entity { if (b0 == 5) { this.motZ = (double) f; } - } - return false; + return true; + } else { + return false; + } } - public void q() { - this.bv = true; + public void s() { + this.bz = true; } - public String Y() { + public String ad() { String s = EntityTypes.b(this); if (s == null) { @@ -1368,4 +1410,12 @@ public abstract class Entity { return StatisticCollector.a("entity." + s + ".name"); } + + public Entity[] aG() { + return null; + } + + public boolean a(Entity entity) { + return this == entity; + } } diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 3c6f9ad2..22b8c205 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -43,7 +43,7 @@ public class EntityArrow extends Entity { this.shooter = entityliving; this.fromPlayer = entityliving instanceof EntityHuman; this.b(0.5F, 0.5F); - this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.t(), entityliving.locZ, entityliving.yaw, entityliving.pitch); + this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.x(), entityliving.locZ, entityliving.yaw, entityliving.pitch); this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); this.locY -= 0.10000000149011612D; this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); @@ -79,8 +79,8 @@ public class EntityArrow extends Entity { this.k = 0; } - public void s_() { - super.s_(); + public void w_() { + super.w_(); if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) { float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); @@ -142,7 +142,7 @@ public class EntityArrow extends Entity { for (k = 0; k < list.size(); ++k) { Entity entity1 = (Entity) list.get(k); - if (entity1.r_() && (entity1 != this.shooter || this.l >= 5)) { + if (entity1.e_() && (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); @@ -174,7 +174,15 @@ public class EntityArrow extends Entity { int l = (int) Math.ceil((double) f2 * 2.0D); if (this.d) { - l = l * 3 / 2 + 1; + l += this.random.nextInt(l / 2 + 2); + } + + DamageSource damagesource = null; + + if (this.shooter == null) { + damagesource = DamageSource.arrow(this, this); + } else { + damagesource = DamageSource.arrow(this, this.shooter); } // CraftBukkit start @@ -196,18 +204,18 @@ 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(DamageSource.arrow(this, this.shooter), event.getDamage()); + stick = movingobjectposition.entity.damageEntity(damagesource, event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.arrow(this, this.shooter), l); + stick = movingobjectposition.entity.damageEntity(damagesource, l); } if (stick) { // CraftBukkit end if (movingobjectposition.entity instanceof EntityLiving) { - ++((EntityLiving) movingobjectposition.entity).aD; + ++((EntityLiving) movingobjectposition.entity).aH; } - this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); + this.world.makeSound(this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.die(); } else { this.motX *= -0.10000000149011612D; @@ -230,7 +238,7 @@ public class EntityArrow extends Entity { this.locX -= this.motX / (double) f2 * 0.05000000074505806D; this.locY -= this.motY / (double) f2 * 0.05000000074505806D; this.locZ -= this.motZ / (double) f2 * 0.05000000074505806D; - this.world.makeSound(this, "random.drr", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); + this.world.makeSound(this, "random.bowhit", 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.shake = 7; this.d = false; @@ -270,7 +278,7 @@ public class EntityArrow extends Entity { float f3 = 0.99F; f1 = 0.05F; - if (this.ao()) { + if (this.az()) { for (int i1 = 0; i1 < 4; ++i1) { float f4 = 0.25F; @@ -300,14 +308,14 @@ public class EntityArrow extends Entity { } public void a(NBTTagCompound nbttagcompound) { - 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"); + this.e = nbttagcompound.e("xTile"); + this.f = nbttagcompound.e("yTile"); + this.g = nbttagcompound.e("zTile"); + this.h = nbttagcompound.d("inTile") & 255; + this.i = nbttagcompound.d("inData") & 255; + this.shake = nbttagcompound.d("shake") & 255; + this.inGround = nbttagcompound.d("inGround") == 1; + this.fromPlayer = nbttagcompound.n("player"); } public void a_(EntityHuman entityhuman) { diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index d959ed36..9bdbae6b 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -16,15 +16,12 @@ import org.bukkit.event.vehicle.VehicleUpdateEvent; public class EntityBoat extends Entity { - public int damage; - public int b; - public int c; - private int d; + private int a; + private double b; + private double c; + private double d; private double e; private double f; - private double g; - private double h; - private double i; // CraftBukkit start public double maxSpeed = 0.4D; @@ -49,29 +46,30 @@ public class EntityBoat extends Entity { public EntityBoat(World world) { super(world); - this.damage = 0; - this.b = 0; - this.c = 1; - this.aY = true; + this.bc = true; this.b(1.5F, 0.6F); this.height = this.width / 2.0F; } - protected boolean e_() { + protected boolean g_() { return false; } - protected void b() {} + protected void b() { + this.datawatcher.a(17, new Integer(0)); + this.datawatcher.a(18, new Integer(1)); + this.datawatcher.a(19, new Integer(0)); + } - public AxisAlignedBB b(Entity entity) { + public AxisAlignedBB a_(Entity entity) { return entity.boundingBox; } - public AxisAlignedBB f() { + public AxisAlignedBB h_() { return this.boundingBox; } - public boolean g() { + public boolean f_() { return true; } @@ -88,7 +86,7 @@ public class EntityBoat extends Entity { this.world.getServer().getPluginManager().callEvent(new VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit } - public double n() { + public double q() { return (double) this.width * 0.0D - 0.30000001192092896D; } @@ -107,18 +105,17 @@ public class EntityBoat extends Entity { // i = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end - this.c = -this.c; - this.b = 10; - this.damage += i * 10; - this.aq(); - if (this.damage > 40) { - + this.d(-this.l()); + this.c(10); + this.setDamage(this.getDamage() + i * 10); + this.aB(); + if (this.getDamage() > 40) { // CraftBukkit start VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { - this.damage = 40; // Maximize damage so this doesn't get triggered again right away + this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end @@ -146,11 +143,11 @@ public class EntityBoat extends Entity { } } - public boolean r_() { + public boolean e_() { return !this.dead; } - public void s_() { + public void w_() { // CraftBukkit start double prevX = this.locX; double prevY = this.locY; @@ -159,13 +156,13 @@ public class EntityBoat extends Entity { float prevPitch = this.pitch; // CraftBukkit end - super.s_(); - if (this.b > 0) { - --this.b; + super.w_(); + if (this.k() > 0) { + this.c(this.k() - 1); } - if (this.damage > 0) { - --this.damage; + if (this.getDamage() > 0) { + this.setDamage(this.getDamage() - 1); } this.lastX = this.locX; @@ -184,35 +181,59 @@ public class EntityBoat extends Entity { } } - double d3; + double d3 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); double d4; double d5; - double d6; + + if (d3 > 0.15D) { + d4 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D); + d5 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D); + + for (int j = 0; (double) j < 1.0D + d3 * 60.0D; ++j) { + double d6 = (double) (this.random.nextFloat() * 2.0F - 1.0F); + double d7 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D; + double d8; + double d9; + + if (this.random.nextBoolean()) { + d8 = this.locX - d4 * d6 * 0.8D + d5 * d7; + d9 = this.locZ - d5 * d6 * 0.8D - d4 * d7; + this.world.a("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ); + } else { + d8 = this.locX + d4 + d5 * d6 * 0.7D; + d9 = this.locZ + d5 - d4 * d6 * 0.7D; + this.world.a("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ); + } + } + } + + double d10; + double d11; if (this.world.isStatic) { - if (this.d > 0) { - d3 = this.locX + (this.e - this.locX) / (double) this.d; - d4 = this.locY + (this.f - this.locY) / (double) this.d; - d5 = this.locZ + (this.g - this.locZ) / (double) this.d; + if (this.a > 0) { + d4 = this.locX + (this.b - this.locX) / (double) this.a; + d5 = this.locY + (this.c - this.locY) / (double) this.a; + d10 = this.locZ + (this.d - this.locZ) / (double) this.a; - for (d6 = this.h - (double) this.yaw; d6 < -180.0D; d6 += 360.0D) { + for (d11 = this.e - (double) this.yaw; d11 < -180.0D; d11 += 360.0D) { ; } - while (d6 >= 180.0D) { - d6 -= 360.0D; + while (d11 >= 180.0D) { + d11 -= 360.0D; } - this.yaw = (float) ((double) this.yaw + d6 / (double) this.d); - this.pitch = (float) ((double) this.pitch + (this.i - (double) this.pitch) / (double) this.d); - --this.d; - this.setPosition(d3, d4, d5); + this.yaw = (float) ((double) this.yaw + d11 / (double) this.a); + this.pitch = (float) ((double) this.pitch + (this.f - (double) this.pitch) / (double) this.a); + --this.a; + this.setPosition(d4, d5, d10); this.c(this.yaw, this.pitch); } else { - d3 = this.locX + this.motX; - d4 = this.locY + this.motY; - d5 = this.locZ + this.motZ; - this.setPosition(d3, d4, d5); + d4 = this.locX + this.motX; + d5 = this.locY + this.motY; + d10 = this.locZ + this.motZ; + this.setPosition(d4, d5, d10); if (this.onGround) { this.motX *= 0.5D; this.motY *= 0.5D; @@ -225,8 +246,8 @@ public class EntityBoat extends Entity { } } else { if (d0 < 1.0D) { - d3 = d0 * 2.0D - 1.0D; - this.motY += 0.03999999910593033D * d3; + d4 = d0 * 2.0D - 1.0D; + this.motY += 0.03999999910593033D * d4; } else { if (this.motY < 0.0D) { this.motY /= 2.0D; @@ -254,21 +275,21 @@ public class EntityBoat extends Entity { // CraftBukkit end // CraftBukkit - d3 = this.maxSpeed; - if (this.motX < -d3) { - this.motX = -d3; + d4 = this.maxSpeed; + if (this.motX < -d4) { + this.motX = -d4; } - if (this.motX > d3) { - this.motX = d3; + if (this.motX > d4) { + this.motX = d4; } - if (this.motZ < -d3) { - this.motZ = -d3; + if (this.motZ < -d4) { + this.motZ = -d4; } - if (this.motZ > d3) { - this.motZ = d3; + if (this.motZ > d4) { + this.motZ = d4; } if (this.onGround && !landBoats) { // CraftBukkit @@ -278,30 +299,7 @@ public class EntityBoat extends Entity { } this.move(this.motX, this.motY, this.motZ); - d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d4 > 0.15D) { - d5 = Math.cos((double) this.yaw * 3.141592653589793D / 180.0D); - d6 = Math.sin((double) this.yaw * 3.141592653589793D / 180.0D); - - for (int j = 0; (double) j < 1.0D + d4 * 60.0D; ++j) { - double d7 = (double) (this.random.nextFloat() * 2.0F - 1.0F); - double d8 = (double) (this.random.nextInt(2) * 2 - 1) * 0.7D; - double d9; - double d10; - - if (this.random.nextBoolean()) { - d9 = this.locX - d5 * d7 * 0.8D + d6 * d8; - d10 = this.locZ - d6 * d7 * 0.8D - d5 * d8; - this.world.a("splash", d9, this.locY - 0.125D, d10, this.motX, this.motY, this.motZ); - } else { - d9 = this.locX + d5 + d6 * d7 * 0.7D; - d10 = this.locZ + d6 - d5 * d7 * 0.7D; - this.world.a("splash", d9, this.locY - 0.125D, d10, this.motX, this.motY, this.motZ); - } - } - } - - if (this.positionChanged && d4 > 0.15D) { + if (this.positionChanged && d3 > 0.2D) { if (!this.world.isStatic) { // CraftBukkit start Vehicle vehicle = (Vehicle) this.getBukkitEntity(); @@ -321,7 +319,7 @@ public class EntityBoat extends Entity { for (k = 0; k < 2; ++k) { this.a(Item.STICK.id, 1, 0.0F); } - }// CraftBukkit + } // CraftBukkit } } else { this.motX *= 0.9900000095367432D; @@ -331,11 +329,10 @@ public class EntityBoat extends Entity { this.pitch = 0.0F; d5 = (double) this.yaw; - d6 = this.lastX - this.locX; - double d11 = this.lastZ - this.locZ; - - if (d6 * d6 + d11 * d11 > 0.0010D) { - d5 = (double) ((float) (Math.atan2(d11, d6) * 180.0D / 3.141592653589793D)); + d10 = this.lastX - this.locX; + d11 = this.lastZ - this.locZ; + if (d10 * d10 + d11 * d11 > 0.0010D) { + d5 = (double) ((float) (Math.atan2(d11, d10) * 180.0D / 3.141592653589793D)); } double d12; @@ -382,7 +379,7 @@ public class EntityBoat extends Entity { for (l = 0; l < list.size(); ++l) { Entity entity = (Entity) list.get(l); - if (entity != this.passenger && entity.g() && entity instanceof EntityBoat) { + if (entity != this.passenger && entity.f_() && entity instanceof EntityBoat) { entity.collide(this); } } @@ -405,12 +402,12 @@ public class EntityBoat extends Entity { } } - public void g_() { + public void i() { 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.n() + this.passenger.M(), this.locZ + d1); + this.passenger.setPosition(this.locX + d0, this.locY + this.q() + this.passenger.R(), this.locZ + d1); } } @@ -438,4 +435,28 @@ public class EntityBoat extends Entity { return true; } } + + public void setDamage(int i) { + this.datawatcher.watch(19, Integer.valueOf(i)); + } + + public int getDamage() { + return this.datawatcher.getInt(19); + } + + public void c(int i) { + this.datawatcher.watch(17, Integer.valueOf(i)); + } + + public int k() { + return this.datawatcher.getInt(17); + } + + public void d(int i) { + this.datawatcher.watch(18, Integer.valueOf(i)); + } + + public int l() { + return this.datawatcher.getInt(18); + } } diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java index 2cd58802..4f21a3ff 100644 --- a/src/main/java/net/minecraft/server/EntityChicken.java +++ b/src/main/java/net/minecraft/server/EntityChicken.java @@ -19,12 +19,15 @@ public class EntityChicken extends EntityAnimal { super(world); this.texture = "/mob/chicken.png"; this.b(0.3F, 0.7F); - this.health = 4; this.j = this.random.nextInt(6000) + 6000; } - public void s() { - super.s(); + public int getMaxHealth() { + return 4; + } + + public void d() { + super.d(); this.h = this.b; this.g = this.c; this.c = (float) ((double) this.c + (double) (this.onGround ? -1 : 4) * 0.3D); @@ -46,14 +49,14 @@ public class EntityChicken extends EntityAnimal { } this.b += this.i * 2.0F; - if (!this.world.isStatic && --this.j <= 0) { + if (!this.l() && !this.world.isStatic && --this.j <= 0) { this.world.makeSound(this, "mob.chickenplop", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.b(Item.EGG.id, 1); this.j = this.random.nextInt(6000) + 6000; } } - protected void a(float f) {} + protected void b(float f) {} public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); @@ -63,33 +66,42 @@ public class EntityChicken extends EntityAnimal { super.a(nbttagcompound); } - protected String h() { + protected String c_() { return "mob.chicken"; } - protected String i() { + protected String m() { return "mob.chickenhurt"; } - protected String j() { + protected String n() { return "mob.chickenhurt"; } - protected int k() { + protected int e() { return Item.FEATHER.id; } - protected void a(boolean flag) { + protected void a(boolean flag, int i) { // CraftBukkit start - whole method List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(3); + int j = this.random.nextInt(3) + this.random.nextInt(1 + i); + + if (j > 0) { + loot.add(new org.bukkit.inventory.ItemStack(Item.FEATHER.id, j)); + } - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(Item.FEATHER.id, count)); - loot.add(new org.bukkit.inventory.ItemStack(this.fireTicks > 0 ? Item.COOKED_CHICKEN.id : Item.RAW_CHICKEN.id, 1)); + if (this.z()) { + this.b(Item.COOKED_CHICKEN.id, 1); + } else { + this.b(Item.RAW_CHICKEN.id, 1); } CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + return new EntityChicken(this.world); + } } diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index 41e67767..1e3cb075 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -4,10 +4,8 @@ package net.minecraft.server; import java.util.List; import org.bukkit.Location; -import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.player.PlayerBucketFillEvent; // CraftBukkit end @@ -19,6 +17,10 @@ public class EntityCow extends EntityAnimal { this.b(0.9F, 1.3F); } + public int getMaxHealth() { + return 10; + } + public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); } @@ -27,39 +29,39 @@ public class EntityCow extends EntityAnimal { super.a(nbttagcompound); } - protected String h() { + protected String c_() { return "mob.cow"; } - protected String i() { + protected String m() { return "mob.cowhurt"; } - protected String j() { + protected String n() { return "mob.cowhurt"; } - protected float l() { + protected float o() { return 0.4F; } - protected int k() { + protected int e() { return Item.LEATHER.id; } - protected void a(boolean flag) { + protected void a(boolean flag, int i) { // CraftBukkit start - whole method List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(3); + int j = this.random.nextInt(3) + this.random.nextInt(1 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(Item.LEATHER.id, count)); + if (j > 0) { + loot.add(new org.bukkit.inventory.ItemStack(Item.LEATHER.id, j)); } - count = this.random.nextInt(3) + 1; + j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(this.fireTicks > 0 ? Item.COOKED_BEEF.id : Item.RAW_BEEF.id, count)); + if (j > 0) { + loot.add(new org.bukkit.inventory.ItemStack(this.z() ? Item.COOKED_BEEF.id : Item.RAW_BEEF.id, j)); } CraftEventFactory.callEntityDeathEvent(this, loot); @@ -87,7 +89,11 @@ public class EntityCow extends EntityAnimal { return true; } else { - return false; + return super.b(entityhuman); } } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + return new EntityCow(this.world); + } } diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index 605a852d..0f0bf221 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -17,16 +17,17 @@ public abstract class EntityCreature extends EntityLiving { super(world); } - protected boolean v() { + protected boolean w() { return false; } - protected void c_() { + protected void m_() { + MethodProfiler.a("ai"); if (this.f > 0) { --this.f; } - this.e = this.v(); + this.e = this.w(); float f = 16.0F; if (this.target == null) { @@ -49,7 +50,7 @@ public abstract class EntityCreature extends EntityLiving { if (this.target != null) { this.pathEntity = this.world.findPath(this, this.target, f); } - } else if (!this.target.ac()) { + } else if (!this.target.aj()) { // CraftBukkit start EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED); this.world.getServer().getPluginManager().callEvent(event); @@ -63,27 +64,29 @@ public abstract class EntityCreature extends EntityLiving { } // CraftBukkit end } else { - float f1 = this.target.g(this); + float f1 = this.target.h(this); - if (this.f(this.target)) { + if (this.g(this.target)) { this.a(this.target, f1); } else { this.b(this.target, f1); } } + MethodProfiler.a(); 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.f > 0 || this.random.nextInt(80) == 0)) { - this.A(); + } else if (!this.e && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.f > 0) && this.aS < 100) { + this.C(); } int i = MathHelper.floor(this.boundingBox.b + 0.5D); - boolean flag = this.ao(); - boolean flag1 = this.ap(); + boolean flag = this.az(); + boolean flag1 = this.aA(); this.pitch = 0.0F; if (this.pathEntity != null && this.random.nextInt(100) != 0) { + MethodProfiler.a("followpath"); Vec3D vec3d = this.pathEntity.a(this); double d0 = (double) (this.length * 2.0F); @@ -97,7 +100,7 @@ public abstract class EntityCreature extends EntityLiving { } } - this.aS = false; + this.aW = false; if (vec3d != null) { double d1 = vec3d.a - this.locX; double d2 = vec3d.c - this.locZ; @@ -106,7 +109,7 @@ public abstract class EntityCreature extends EntityLiving { float f2 = (float) (TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; float f3 = f2 - this.yaw; - for (this.aQ = this.aU; f3 < -180.0F; f3 += 360.0F) { + for (this.aU = this.aY; f3 < -180.0F; f3 += 360.0F) { ; } @@ -130,12 +133,12 @@ public abstract 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.aP = -MathHelper.sin(f3) * this.aQ * 1.0F; - this.aQ = MathHelper.cos(f3) * this.aQ * 1.0F; + this.aT = -MathHelper.sin(f3) * this.aU * 1.0F; + this.aU = MathHelper.cos(f3) * this.aU * 1.0F; } if (d3 > 0.0D) { - this.aS = true; + this.aW = true; } } @@ -143,20 +146,23 @@ public abstract class EntityCreature extends EntityLiving { this.a(this.target, 30.0F, 30.0F); } - if (this.positionChanged && !this.B()) { - this.aS = true; + if (this.positionChanged && !this.D()) { + this.aW = true; } if (this.random.nextFloat() < 0.8F && (flag || flag1)) { - this.aS = true; + this.aW = true; } + + MethodProfiler.a(); } else { - super.c_(); + super.m_(); this.pathEntity = null; } } - protected void A() { + protected void C() { + MethodProfiler.a("stroll"); boolean flag = false; int i = -1; int j = -1; @@ -181,6 +187,8 @@ public abstract class EntityCreature extends EntityLiving { if (flag) { this.pathEntity = this.world.a(this, i, j, k, 10.0F); } + + MethodProfiler.a(); } protected void a(Entity entity, float f) {} @@ -195,15 +203,15 @@ public abstract class EntityCreature extends EntityLiving { return null; } - public boolean d() { + public boolean g() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); - return super.d() && this.a(i, j, k) >= 0.0F; + return super.g() && this.a(i, j, k) >= 0.0F; } - public boolean B() { + public boolean D() { return this.pathEntity != null; } @@ -211,7 +219,7 @@ public abstract class EntityCreature extends EntityLiving { this.pathEntity = pathentity; } - public Entity C() { + public Entity E() { return this.target; } @@ -219,8 +227,8 @@ public abstract class EntityCreature extends EntityLiving { this.target = entity; } - protected float D() { - float f = super.D(); + protected float F() { + float f = super.F(); if (this.f > 0) { f *= 2.0F; diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 0a1be51d..94ed2f4a 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -16,6 +16,10 @@ public class EntityCreeper extends EntityMonster { this.texture = "/mob/creeper.png"; } + public int getMaxHealth() { + return 20; + } + protected void b() { super.b(); this.datawatcher.a(16, Byte.valueOf((byte) -1)); @@ -31,7 +35,7 @@ public class EntityCreeper extends EntityMonster { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.datawatcher.watch(17, Byte.valueOf((byte) (nbttagcompound.m("powered") ? 1 : 0))); + this.datawatcher.watch(17, Byte.valueOf((byte) (nbttagcompound.n("powered") ? 1 : 0))); } protected void b(Entity entity, float f) { @@ -46,10 +50,10 @@ public class EntityCreeper extends EntityMonster { } } - public void s_() { + public void w_() { this.b = this.fuseTicks; if (this.world.isStatic) { - int i = this.w(); + int i = this.A(); if (i > 0 && this.fuseTicks == 0) { this.world.makeSound(this, "random.fuse", 1.0F, 0.5F); @@ -65,7 +69,7 @@ public class EntityCreeper extends EntityMonster { } } - super.s_(); + super.w_(); if (this.target == null && this.fuseTicks > 0) { this.b(-1); --this.fuseTicks; @@ -75,24 +79,24 @@ public class EntityCreeper extends EntityMonster { } } - protected String i() { + protected String m() { return "mob.creeper"; } - protected String j() { + protected String n() { return "mob.creeperdeath"; } public void die(DamageSource damagesource) { super.die(damagesource); if (damagesource.getEntity() instanceof EntitySkeleton) { - this.b(Item.GOLD_RECORD.id + this.random.nextInt(2), 1); + this.b(Item.RECORD_1.id + this.random.nextInt(2), 1); } } protected void a(Entity entity, float f) { if (!this.world.isStatic) { - int i = this.w(); + int i = this.A(); if ((i > 0 || f >= 3.0F) && (i <= 0 || f >= 7.0F)) { this.b(-1); @@ -132,11 +136,11 @@ public class EntityCreeper extends EntityMonster { return this.datawatcher.getByte(17) == 1; } - protected int k() { + protected int e() { return Item.SULPHUR.id; } - private int w() { + private int A() { return this.datawatcher.getByte(16); } diff --git a/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java b/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java index b6d310d3..5855df98 100644 --- a/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java +++ b/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java @@ -15,7 +15,7 @@ public class EntityDamageSourceIndirect extends EntityDamageSource { public String a(EntityHuman entityhuman) { // CraftBukkit start - String source = (this.n == null) ? "Herobrine" : this.n.Y(); + String source = (this.n == null) ? "Herobrine" : this.n.ad(); return StatisticCollector.a("death." + this.m, new Object[] { entityhuman.name, source}); // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 5459af4d..9a573809 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -1,8 +1,6 @@ package net.minecraft.server; -import java.util.List; - -// CraftBukkit start +import org.bukkit.Location; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -10,325 +8,82 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerEggThrowEvent; -// CraftBukkit end - -public class EntityEgg extends Entity { - private int b = -1; - private int c = -1; - private int d = -1; - private int e = 0; - private boolean f = false; - public int a = 0; - public EntityLiving thrower; // CraftBukkit - private -> public - private int h; - private int i = 0; +public class EntityEgg extends EntityProjectile { public EntityEgg(World world) { super(world); - this.b(0.25F, 0.25F); } - protected void b() {} - public EntityEgg(World world, EntityLiving entityliving) { - super(world); - this.thrower = entityliving; - this.b(0.25F, 0.25F); - this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.t(), entityliving.locZ, entityliving.yaw, entityliving.pitch); - this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.locY -= 0.10000000149011612D; - this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - float f = 0.4F; - - this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f); - this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); + super(world, entityliving); } public EntityEgg(World world, double d0, double d1, double d2) { - super(world); - this.h = 0; - this.b(0.25F, 0.25F); - this.setPosition(d0, d1, d2); - this.height = 0.0F; + super(world, d0, d1, d2); } - public void a(double d0, double d1, double d2, float f, float f1) { - float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); - - d0 /= (double) f2; - d1 /= (double) f2; - d2 /= (double) f2; - d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d0 *= (double) f; - d1 *= (double) f; - d2 *= (double) f; - this.motX = d0; - this.motY = d1; - this.motZ = d2; - float f3 = MathHelper.a(d0 * d0 + d2 * d2); - - this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); - this.h = 0; - } - - public void s_() { - this.bE = this.locX; - this.bF = this.locY; - this.bG = this.locZ; - super.s_(); - if (this.a > 0) { - --this.a; - } - - if (this.f) { - int i = this.world.getTypeId(this.b, this.c, this.d); - - if (i == this.e) { - ++this.h; - if (this.h == 1200) { - this.die(); - } - - return; - } - - this.f = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.h = 0; - this.i = 0; - } else { - ++this.i; - } - - 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.a(vec3d, vec3d1); - - vec3d = Vec3D.create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); - } - - if (!this.world.isStatic) { - Entity entity = null; - List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - - for (int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - 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.b(movingobjectposition1.f); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } - - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); - } - } - - if (movingobjectposition != null) { - // CraftBukkit start - ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(phe); + protected void a(MovingObjectPosition movingobjectposition) { + // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); - if (movingobjectposition.entity != null) { - boolean stick; - if (movingobjectposition.entity instanceof EntityLiving) { - org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); - Projectile projectile = (Projectile) this.getBukkitEntity(); + if (movingobjectposition.entity != null) { + boolean stick; + if (movingobjectposition.entity instanceof EntityLiving) { + org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); + Projectile projectile = (Projectile) this.getBukkitEntity(); - // TODO @see EntityArrow#162 - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - stick = !projectile.doesBounce(); - } else { - // this function returns if the egg should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.thrower), event.getDamage()); - } - } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.thrower), 0); - } - - if (stick) { - ; // Original code does nothing *yet* - } - } - - boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0; - int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1; - if (!hatching) { - numHatching = 0; - } - - CreatureType hatchingType = CreatureType.CHICKEN; - - if (this.thrower instanceof EntityPlayer) { - org.bukkit.entity.Player player = (this.thrower == null) ? null : (org.bukkit.entity.Player) this.thrower.getBukkitEntity(); - - PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); + // TODO @see EntityArrow#162 + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); this.world.getServer().getPluginManager().callEvent(event); - hatching = event.isHatching(); - numHatching = event.getNumHatches(); - hatchingType = event.getHatchType(); - } - - if (hatching) { - for (int k = 0; k < numHatching; k++) { - Entity entity = null; - switch (hatchingType) { - case CHICKEN: - entity = new EntityChicken(this.world); - break; - case COW: - entity = new EntityCow(this.world); - break; - case CREEPER: - entity = new EntityCreeper(this.world); - break; - case GHAST: - entity = new EntityGhast(this.world); - break; - case GIANT: - entity = new EntityGiantZombie(this.world); - break; - case PIG: - entity = new EntityPig(this.world); - break; - case PIG_ZOMBIE: - entity = new EntityPigZombie(this.world); - break; - case SHEEP: - entity = new EntitySheep(this.world); - break; - case SKELETON: - entity = new EntitySkeleton(this.world); - break; - case SPIDER: - entity = new EntitySpider(this.world); - break; - case ZOMBIE: - entity = new EntityZombie(this.world); - break; - case SQUID: - entity = new EntitySquid(this.world); - break; - case SLIME: - entity = new EntitySlime(this.world); - break; - case WOLF: - entity = new EntityWolf(this.world); - break; - default: - entity = new EntityChicken(this.world); - break; - } - - entity.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - this.world.addEntity(entity, SpawnReason.EGG); - // CraftBukkit end + if (event.isCancelled()) { + stick = !projectile.doesBounce(); + } else { + // this function returns if the egg should stick in or not, i.e. !bounce + stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), event.getDamage()); } + } else { + stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0); } - for (int l = 0; l < 8; ++l) { - this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); + if (stick) { + ; // Original code does nothing *yet* } - - this.die(); - } - - this.locX += this.motX; - this.locY += this.motY; - this.locZ += this.motZ; - float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); - - this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; } - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; + boolean hatching = !this.world.isStatic && this.random.nextInt(8) == 0; + int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1; + if (!hatching) { + numHatching = 0; } - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } + CreatureType hatchingType = CreatureType.CHICKEN; - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; - } + if (this.shooter instanceof EntityPlayer) { + org.bukkit.entity.Player player = (this.shooter == null) ? null : (org.bukkit.entity.Player) this.shooter.getBukkitEntity(); - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = 0.99F; - float f3 = 0.03F; + PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); + this.world.getServer().getPluginManager().callEvent(event); - if (this.ao()) { - for (int i1 = 0; i1 < 4; ++i1) { - float f4 = 0.25F; + hatching = event.isHatching(); + numHatching = event.getNumHatches(); + hatchingType = event.getHatchType(); + } - 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); + if (hatching) { + for (int k = 0; k < numHatching; k++) { + world.getWorld().spawn(new Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), SpawnReason.EGG); } - - f2 = 0.8F; } + // CraftBukkit end - this.motX *= (double) f2; - this.motY *= (double) f2; - this.motZ *= (double) f2; - this.motY -= (double) f3; - this.setPosition(this.locX, this.locY, this.locZ); - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("xTile", (short) this.b); - nbttagcompound.a("yTile", (short) this.c); - nbttagcompound.a("zTile", (short) this.d); - nbttagcompound.a("inTile", (byte) this.e); - nbttagcompound.a("shake", (byte) this.a); - nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0)); - } - - public void a(NBTTagCompound nbttagcompound) { - this.b = nbttagcompound.d("xTile"); - this.c = nbttagcompound.d("yTile"); - this.d = nbttagcompound.d("zTile"); - this.e = nbttagcompound.c("inTile") & 255; - this.a = nbttagcompound.c("shake") & 255; - this.f = nbttagcompound.c("inGround") == 1; - } + for (int j = 0; j < 8; ++j) { + this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); + } - 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); + if (!this.world.isStatic) { this.die(); } } diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java index 2890c9af..3362f41e 100644 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java @@ -19,10 +19,14 @@ public class EntityEnderman extends EntityMonster { public EntityEnderman(World world) { super(world); this.texture = "/mob/enderman.png"; - this.aU = 0.2F; - this.damage = 5; + this.aY = 0.2F; + this.damage = 7; this.b(0.6F, 2.9F); - this.bI = 1.0F; + this.bM = 1.0F; + } + + public int getMaxHealth() { + return 40; } protected void b() { @@ -34,17 +38,17 @@ public class EntityEnderman extends EntityMonster { public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.a("carried", (short) this.getCarriedId()); - nbttagcompound.a("carryingData", (short) this.getCarriedData()); // Craftbukkit - fixed from carriedData + nbttagcompound.a("carriedData", (short) this.getCarriedData()); } public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.setCarriedId(nbttagcompound.d("carried")); - this.setCarriedData(nbttagcompound.d("carryingData")); + this.setCarriedId(nbttagcompound.e("carried")); + this.setCarriedData(nbttagcompound.e("carriedData")); } protected Entity findTarget() { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, 64.0D); + EntityHuman entityhuman = this.world.b(this, 64.0D); if (entityhuman != null) { if (this.c(entityhuman)) { @@ -60,8 +64,8 @@ public class EntityEnderman extends EntityMonster { return null; } - public float a_(float f) { - return super.a_(f); + public float a(float f) { + return super.a(f); } private boolean c(EntityHuman entityhuman) { @@ -70,24 +74,24 @@ public class EntityEnderman extends EntityMonster { if (itemstack != null && itemstack.id == Block.PUMPKIN.id) { return false; } else { - Vec3D vec3d = entityhuman.c(1.0F).b(); - Vec3D vec3d1 = Vec3D.create(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.width / 2.0F) - entityhuman.locY + (double) entityhuman.t(), this.locZ - entityhuman.locZ); + Vec3D vec3d = entityhuman.d(1.0F).b(); + Vec3D vec3d1 = Vec3D.create(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.width / 2.0F) - (entityhuman.locY + (double) entityhuman.x()), this.locZ - entityhuman.locZ); double d0 = vec3d1.c(); vec3d1 = vec3d1.b(); double d1 = vec3d.a(vec3d1); - return d1 > 1.0D - 0.025D / d0 ? entityhuman.f(this) : false; + return d1 > 1.0D - 0.025D / d0 ? entityhuman.g(this) : false; } } - public void s() { - if (this.an()) { + public void d() { + if (this.ay()) { this.damageEntity(DamageSource.DROWN, 1); } this.a = this.target != null; - this.aU = this.target != null ? 4.5F : 0.3F; + this.aY = this.target != null ? 6.5F : 0.3F; int i; if (!this.world.isStatic) { @@ -137,30 +141,36 @@ public class EntityEnderman extends EntityMonster { this.world.a("portal", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.length, this.locY + this.random.nextDouble() * (double) this.width - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.length, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D); } - if (this.world.d() && !this.world.isStatic) { - float f = this.a_(1.0F); + if (this.world.e() && !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) { - this.fireTicks = 300; + this.target = null; + this.u_(); } } - this.aS = false; + if (this.ay()) { + this.target = null; + this.u_(); + } + + this.aW = false; if (this.target != null) { this.a(this.target, 100.0F, 100.0F); } - if (!this.world.isStatic) { + if (!this.world.isStatic && this.aj()) { if (this.target != null) { if (this.target instanceof EntityHuman && this.c((EntityHuman) this.target)) { - this.aP = this.aQ = 0.0F; - this.aU = 0.0F; - if (this.target.h(this) < 16.0D) { - this.w(); + this.aT = this.aU = 0.0F; + this.aY = 0.0F; + if (this.target.i(this) < 16.0D) { + this.u_(); } this.g = 0; - } else if (this.target.h(this) > 256.0D && this.g++ >= 30 && this.e(this.target)) { + } else if (this.target.i(this) > 256.0D && this.g++ >= 30 && this.f(this.target)) { this.g = 0; } } else { @@ -168,19 +178,19 @@ public class EntityEnderman extends EntityMonster { } } - super.s(); + super.d(); } - protected boolean w() { + protected boolean u_() { double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D; double d1 = this.locY + (double) (this.random.nextInt(64) - 32); double d2 = this.locZ + (this.random.nextDouble() - 0.5D) * 64.0D; - return this.a(d0, d1, d2); + return this.b(d0, d1, d2); } - protected boolean e(Entity entity) { - Vec3D vec3d = Vec3D.create(this.locX - entity.locX, this.boundingBox.b + (double) (this.width / 2.0F) - entity.locY + (double) entity.t(), this.locZ - entity.locZ); + protected boolean f(Entity entity) { + Vec3D vec3d = Vec3D.create(this.locX - entity.locX, this.boundingBox.b + (double) (this.width / 2.0F) - entity.locY + (double) entity.x(), this.locZ - entity.locZ); vec3d = vec3d.b(); double d0 = 16.0D; @@ -188,10 +198,10 @@ public class EntityEnderman extends EntityMonster { double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.b * d0; double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.c * d0; - return this.a(d1, d2, d3); + return this.b(d1, d2, d3); } - protected boolean a(double d0, double d1, double d2) { + protected boolean b(double d0, double d1, double d2) { double d3 = this.locX; double d4 = this.locY; double d5 = this.locZ; @@ -244,39 +254,43 @@ public class EntityEnderman extends EntityMonster { this.world.a("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); } + this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); + this.world.makeSound(this, "mob.endermen.portal", 1.0F, 1.0F); return true; } } - protected String h() { - return "mob.zombie"; + protected String c_() { + return "mob.endermen.idle"; } - protected String i() { - return "mob.zombiehurt"; + protected String m() { + return "mob.endermen.hit"; } - protected String j() { - return "mob.zombiedeath"; + protected String n() { + return "mob.endermen.death"; } - protected int k() { + protected int e() { return Item.ENDER_PEARL.id; } - protected void a(boolean flag) { - int i = this.k(); + protected void a(boolean flag, int i) { + int j = this.e(); - // CraftBukkit start - whole method - List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(2); + if (j > 0) { + // CraftBukkit start - whole method + List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + int count = this.random.nextInt(2 + i); - if ((i > 0) && (count > 0)) { - loot.add(new org.bukkit.inventory.ItemStack(i, count)); - } + if ((j > 0) && (count > 0)) { + loot.add(new org.bukkit.inventory.ItemStack(j, count)); + } - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end + CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end + } } public void setCarriedId(int i) { @@ -295,51 +309,34 @@ public class EntityEnderman extends EntityMonster { return this.datawatcher.getByte(17); } + public boolean damageEntity(DamageSource damagesource, int i) { + if (damagesource instanceof EntityDamageSourceIndirect) { + for (int j = 0; j < 64; ++j) { + if (this.u_()) { + return true; + } + } + + return false; + } else { + return super.damageEntity(damagesource, i); + } + } + static { - b[Block.STONE.id] = true; b[Block.GRASS.id] = true; b[Block.DIRT.id] = true; - b[Block.COBBLESTONE.id] = true; - b[Block.WOOD.id] = true; b[Block.SAND.id] = true; b[Block.GRAVEL.id] = true; - b[Block.GOLD_ORE.id] = true; - b[Block.IRON_ORE.id] = true; - b[Block.COAL_ORE.id] = true; - b[Block.LOG.id] = true; - b[Block.LEAVES.id] = true; - b[Block.SPONGE.id] = true; - b[Block.GLASS.id] = true; - b[Block.LAPIS_ORE.id] = true; - b[Block.LAPIS_BLOCK.id] = true; - b[Block.SANDSTONE.id] = true; - b[Block.WOOL.id] = true; b[Block.YELLOW_FLOWER.id] = true; b[Block.RED_ROSE.id] = true; b[Block.BROWN_MUSHROOM.id] = true; b[Block.RED_MUSHROOM.id] = true; - b[Block.GOLD_BLOCK.id] = true; - b[Block.IRON_BLOCK.id] = true; - b[Block.BRICK.id] = true; b[Block.TNT.id] = true; - b[Block.BOOKSHELF.id] = true; - b[Block.MOSSY_COBBLESTONE.id] = true; - b[Block.DIAMOND_ORE.id] = true; - b[Block.DIAMOND_BLOCK.id] = true; - b[Block.WORKBENCH.id] = true; - b[Block.REDSTONE_ORE.id] = true; - b[Block.GLOWING_REDSTONE_ORE.id] = true; - b[Block.ICE.id] = true; b[Block.CACTUS.id] = true; b[Block.CLAY.id] = true; b[Block.PUMPKIN.id] = true; - b[Block.NETHERRACK.id] = true; - b[Block.SOUL_SAND.id] = true; - b[Block.GLOWSTONE.id] = true; - b[Block.JACK_O_LANTERN.id] = true; - b[Block.SMOOTH_BRICK.id] = true; - b[Block.BIG_MUSHROOM_1.id] = true; - b[Block.BIG_MUSHROOM_2.id] = true; b[Block.MELON.id] = true; + b[Block.MYCEL.id] = true; } } diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java index e9f09756..b8c0a9ae 100644 --- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java +++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java @@ -5,9 +5,8 @@ public class EntityExperienceOrb extends Entity { public int a; public int b = 0; public int c; - private int e = 5; + private int d = 5; public int value; // CraftBukkit - priv to pub - public float d = (float) (Math.random() * 3.141592653589793D * 2.0D); public EntityExperienceOrb(World world, double d0, double d1, double d2, int i) { super(world); @@ -21,7 +20,7 @@ public class EntityExperienceOrb extends Entity { this.value = i; } - protected boolean e_() { + protected boolean g_() { return false; } @@ -33,8 +32,8 @@ public class EntityExperienceOrb extends Entity { protected void b() {} - public void s_() { - super.s_(); + public void w_() { + super.w_(); if (this.c > 0) { --this.c; } @@ -56,7 +55,7 @@ public class EntityExperienceOrb extends Entity { if (entityhuman != null) { double d1 = (entityhuman.locX - this.locX) / d0; - double d2 = (entityhuman.locY + (double) entityhuman.t() - this.locY) / d0; + double d2 = (entityhuman.locY + (double) entityhuman.x() - this.locY) / d0; double d3 = (entityhuman.locZ - this.locZ) / d0; double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); double d5 = 1.0D - d4; @@ -95,7 +94,7 @@ public class EntityExperienceOrb extends Entity { } } - public boolean f_() { + public boolean i_() { return this.world.a(this.boundingBox, Material.WATER, this); } @@ -104,9 +103,9 @@ public class EntityExperienceOrb extends Entity { } public boolean damageEntity(DamageSource damagesource, int i) { - this.aq(); - this.e -= i; - if (this.e <= 0) { + this.aB(); + this.d -= i; + if (this.d <= 0) { this.die(); } @@ -114,30 +113,30 @@ public class EntityExperienceOrb extends Entity { } public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("Health", (short) ((byte) this.e)); + nbttagcompound.a("Health", (short) ((byte) this.d)); nbttagcompound.a("Age", (short) this.b); nbttagcompound.a("Value", (short) this.value); } public void a(NBTTagCompound nbttagcompound) { - this.e = nbttagcompound.d("Health") & 255; - this.b = nbttagcompound.d("Age"); - this.value = nbttagcompound.d("Value"); + this.d = nbttagcompound.e("Health") & 255; + this.b = nbttagcompound.e("Age"); + this.value = nbttagcompound.e("Value"); } public void a_(EntityHuman entityhuman) { if (!this.world.isStatic) { - if (this.c == 0 && entityhuman.w == 0) { - entityhuman.w = 2; - this.world.makeSound(this, "random.pop", 0.2F, 0.5F * ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F)); + if (this.c == 0 && entityhuman.x == 0) { + entityhuman.x = 2; + this.world.makeSound(this, "random.orb", 0.1F, 0.5F * ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.8F)); entityhuman.receive(this, 1); - entityhuman.d(this.value); + entityhuman.h(this.value); this.die(); } } } - public int j_() { + public int g() { return this.value; } diff --git a/src/main/java/net/minecraft/server/EntityFallingSand.java b/src/main/java/net/minecraft/server/EntityFallingSand.java index dead5a74..2546f1e6 100644 --- a/src/main/java/net/minecraft/server/EntityFallingSand.java +++ b/src/main/java/net/minecraft/server/EntityFallingSand.java @@ -14,8 +14,8 @@ public class EntityFallingSand extends Entity { public EntityFallingSand(World world, double d0, double d1, double d2, int i, int data) { super(world); this.a = i; + this.bc = true; this.data = data; // CraftBukkit - this.aY = true; this.b(0.98F, 0.98F); this.height = this.width / 2.0F; this.setPosition(d0, d1, d2); @@ -27,17 +27,17 @@ public class EntityFallingSand extends Entity { this.lastZ = d2; } - protected boolean e_() { + protected boolean g_() { return false; } protected void b() {} - public boolean r_() { + public boolean e_() { return !this.dead; } - public void s_() { + public void w_() { if (this.a == 0) { this.die(); } else { @@ -54,18 +54,22 @@ public class EntityFallingSand extends Entity { int j = MathHelper.floor(this.locY); int k = MathHelper.floor(this.locZ); - if (this.world.getTypeId(i, j, k) == this.a) { + if (this.b == 1 && this.world.getTypeId(i, j, k) == this.a) { this.world.setTypeId(i, j, k, 0); + } else if (!this.world.isStatic && this.b == 1) { + this.die(); } if (this.onGround) { this.motX *= 0.699999988079071D; this.motZ *= 0.699999988079071D; this.motY *= -0.5D; - this.die(); - // CraftBukkit -- setTypeId => setTypeIdAndData - if ((!this.world.a(this.a, i, j, k, true, 1) || BlockSand.d_(this.world, i, j - 1, k) || !this.world.setTypeIdAndData(i, j, k, this.a, this.data)) && !this.world.isStatic) { - this.b(this.a, 1); + if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) { + this.die(); + // CraftBukkit -- setTypeId => setTypeIdAndData + if ((!this.world.a(this.a, i, j, k, true, 1) || BlockSand.g(this.world, i, j - 1, k) || !this.world.setTypeIdAndData(i, j, k, this.a, this.data)) && !this.world.isStatic) { + this.b(this.a, 1); + } } } else if (this.b > 100 && !this.world.isStatic) { this.b(this.a, 1); @@ -80,7 +84,7 @@ public class EntityFallingSand extends Entity { } protected void a(NBTTagCompound nbttagcompound) { - this.a = nbttagcompound.c("Tile") & 255; - this.data = nbttagcompound.c("Data") & 15; // CraftBukkit + this.a = nbttagcompound.d("Tile") & 255; + this.data = nbttagcompound.d("Data") & 15; // CraftBukkit } } diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 99937ae9..32ec99a2 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -15,15 +15,14 @@ import org.bukkit.event.entity.ProjectileHitEvent; public class EntityFireball extends Entity { + private int e = -1; private int f = -1; private int g = -1; - private int h = -1; - private int i = 0; - private boolean j = false; - public int a = 0; + private int h = 0; + private boolean i = false; public EntityLiving shooter; - private int k; - private int l = 0; + private int j; + private int k = 0; public double dirX; public double dirY; public double dirZ; @@ -61,33 +60,33 @@ public class EntityFireball extends Entity { this.dirZ = d2 / d3 * 0.1D; } - public void s_() { - super.s_(); - this.fireTicks = 10; - if (this.a > 0) { - --this.a; + public void w_() { + super.w_(); + this.j(1); + if (!this.world.isStatic && (this.shooter == null || this.shooter.dead)) { + this.die(); } - if (this.j) { - int i = this.world.getTypeId(this.f, this.g, this.h); + if (this.i) { + int i = this.world.getTypeId(this.e, this.f, this.g); - if (i == this.i) { - ++this.k; - if (this.k == 1200) { + if (i == this.h) { + ++this.j; + if (this.j == 1200) { this.die(); } return; } - this.j = false; + this.i = false; this.motX *= (double) (this.random.nextFloat() * 0.2F); this.motY *= (double) (this.random.nextFloat() * 0.2F); this.motZ *= (double) (this.random.nextFloat() * 0.2F); + this.j = 0; this.k = 0; - this.l = 0; } else { - ++this.l; + ++this.k; } Vec3D vec3d = Vec3D.create(this.locX, this.locY, this.locZ); @@ -107,7 +106,7 @@ public class EntityFireball extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.r_() && (entity1 != this.shooter || this.l >= 25)) { + if (entity1.e_() && (!entity1.a((Entity) this.shooter) || this.k >= 25)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.b((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); @@ -128,49 +127,6 @@ public class EntityFireball extends Entity { } if (movingobjectposition != null) { - // CraftBukkit start - ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(phe); - // CraftBukkit end - if (!this.world.isStatic) { - // CraftBukkit start - if (movingobjectposition.entity != null) { - boolean stick; - if (movingobjectposition.entity instanceof EntityLiving) { - org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); - Projectile projectile = (Projectile) this.getBukkitEntity(); - - // TODO @see EntityArrow#162 - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); - this.world.getServer().getPluginManager().callEvent(event); - - this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); - - if (event.isCancelled()) { - stick = !projectile.doesBounce(); - } else { - // this function returns if the fireball should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage()); - } - } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 0); - } - if (stick) { - ; - } - } - - ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this)); - this.world.getServer().getPluginManager().callEvent(event); - - if (!event.isCancelled()) { - // give 'this' instead of (Entity) null so we know what causes the damage - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); - } - // CraftBukkit end - } - - this.die(); } this.locX += this.motX; @@ -200,7 +156,7 @@ public class EntityFireball extends Entity { this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; float f2 = 0.95F; - if (this.ao()) { + if (this.az()) { for (int k = 0; k < 4; ++k) { float f3 = 0.25F; @@ -220,32 +176,83 @@ public class EntityFireball extends Entity { this.setPosition(this.locX, this.locY, this.locZ); } + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + // CraftBukkit start + ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(phe); + // CraftBukkit end + if (!this.world.isStatic) { + // CraftBukkit start + if (movingobjectposition.entity != null) { + boolean stick; + if (movingobjectposition.entity instanceof EntityLiving) { + org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); + Projectile projectile = (Projectile) this.getBukkitEntity(); + + // TODO @see EntityArrow#162 + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); + this.world.getServer().getPluginManager().callEvent(event); + + this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); + + if (event.isCancelled()) { + stick = !projectile.doesBounce(); + } else { + // this function returns if the fireball should stick in or not, i.e. !bounce + stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), event.getDamage()); + } + } else { + stick = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 0); + } + if (stick) { + ; + } + } + + ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) CraftEntity.getEntity(this.world.getServer(), this)); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + } + // CraftBukkit end + } + + // this.world.createExplosion((Entity) null, this.locX, this.locY, this.locZ, 1.0F, true); // CraftBukkit + this.die(); + } + } + public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("xTile", (short) this.f); - nbttagcompound.a("yTile", (short) this.g); - nbttagcompound.a("zTile", (short) this.h); - nbttagcompound.a("inTile", (byte) this.i); - nbttagcompound.a("shake", (byte) this.a); - nbttagcompound.a("inGround", (byte) (this.j ? 1 : 0)); + 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("inGround", (byte) (this.i ? 1 : 0)); } public void a(NBTTagCompound nbttagcompound) { - this.f = nbttagcompound.d("xTile"); - this.g = nbttagcompound.d("yTile"); - this.h = nbttagcompound.d("zTile"); - this.i = nbttagcompound.c("inTile") & 255; - this.a = nbttagcompound.c("shake") & 255; - this.j = nbttagcompound.c("inGround") == 1; + this.e = nbttagcompound.e("xTile"); + this.f = nbttagcompound.e("yTile"); + this.g = nbttagcompound.e("zTile"); + this.h = nbttagcompound.d("inTile") & 255; + this.i = nbttagcompound.d("inGround") == 1; } - public boolean r_() { + public boolean e_() { return true; } + public float j_() { + return 1.0F; + } + public boolean damageEntity(DamageSource damagesource, int i) { - this.aq(); + this.aB(); if (damagesource.getEntity() != null) { - Vec3D vec3d = damagesource.getEntity().ai(); + Vec3D vec3d = damagesource.getEntity().ap(); if (vec3d != null) { this.motX = vec3d.a; @@ -256,9 +263,17 @@ public class EntityFireball extends Entity { this.dirZ = this.motZ * 0.1D; } + if (damagesource.getEntity() instanceof EntityLiving) { + this.shooter = (EntityLiving) damagesource.getEntity(); + } + return true; } else { return false; } } + + public float a(float f) { + return 1.0F; + } } diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java index a1ab1f25..7a60dac0 100644 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/src/main/java/net/minecraft/server/EntityFishingHook.java @@ -32,12 +32,12 @@ public class EntityFishingHook extends Entity { public EntityFishingHook(World world) { super(world); this.b(0.25F, 0.25F); - this.bZ = true; + this.ca = true; } public EntityFishingHook(World world, EntityHuman entityhuman) { super(world); - this.bZ = true; + this.ca = true; this.owner = entityhuman; this.owner.hookedFish = this; this.b(0.25F, 0.25F); @@ -79,8 +79,8 @@ public class EntityFishingHook extends Entity { this.i = 0; } - public void s_() { - super.s_(); + public void w_() { + super.w_(); 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 EntityFishingHook extends Entity { this.c(this.yaw, this.pitch); } else { if (!this.world.isStatic) { - ItemStack itemstack = this.owner.K(); + ItemStack itemstack = this.owner.P(); - if (this.owner.dead || !this.owner.ac() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.h(this.owner) > 1024.0D) { + if (this.owner.dead || !this.owner.aj() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.i(this.owner) > 1024.0D) { this.die(); this.owner.hookedFish = null; return; @@ -168,7 +168,7 @@ public class EntityFishingHook extends Entity { for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity) list.get(j); - if (entity1.r_() && (entity1 != this.owner || this.j >= 5)) { + if (entity1.e_() && (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); @@ -207,7 +207,7 @@ public class EntityFishingHook extends Entity { stick = movingobjectposition.entity.damageEntity(DamageSource.projectile((Entity) this, this.owner), event.getDamage()); } } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile((Entity) this, this.owner), 0); + stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0); } if (!stick) { // CraftBukkit end @@ -267,7 +267,7 @@ public class EntityFishingHook extends Entity { } else { short short1 = 500; - if (this.world.s(MathHelper.floor(this.locX), MathHelper.floor(this.locY) + 1, MathHelper.floor(this.locZ))) { + if (this.world.v(MathHelper.floor(this.locX), MathHelper.floor(this.locY) + 1, MathHelper.floor(this.locZ))) { short1 = 300; } @@ -325,15 +325,15 @@ public class EntityFishingHook extends Entity { } 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.a = nbttagcompound.c("shake") & 255; - this.h = nbttagcompound.c("inGround") == 1; + this.d = nbttagcompound.e("xTile"); + this.e = nbttagcompound.e("yTile"); + this.f = nbttagcompound.e("zTile"); + this.g = nbttagcompound.d("inTile") & 255; + this.a = nbttagcompound.d("shake") & 255; + this.h = nbttagcompound.d("inGround") == 1; } - public int i() { + public int j() { byte b0 = 0; if (this.c != null) { @@ -347,6 +347,7 @@ public class EntityFishingHook extends Entity { return 0; } // CraftBukkit end + double d0 = this.owner.locX - this.locX; double d1 = this.owner.locY - this.locY; double d2 = this.owner.locZ - this.locZ; @@ -369,6 +370,7 @@ public class EntityFishingHook extends Entity { return 0; } // CraftBukkit end + double d5 = this.owner.locX - this.locX; double d6 = this.owner.locY - this.locY; double d7 = this.owner.locZ - this.locZ; diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index 2ef30782..ff10ab4d 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -21,7 +21,17 @@ public class EntityGhast extends EntityFlying implements IMonster { this.texture = "/mob/ghast.png"; this.b(4.0F, 4.0F); this.fireProof = true; - this.ax = 5; + this.az = 5; + } + + public boolean damageEntity(DamageSource damagesource, int i) { + if ("fireball".equals(damagesource.l()) && damagesource.getEntity() instanceof EntityHuman) { + super.damageEntity(damagesource, 1000); + ((EntityHuman) damagesource.getEntity()).a((Statistic) AchievementList.y); + return true; + } else { + return super.damageEntity(damagesource, i); + } } protected void b() { @@ -29,19 +39,23 @@ public class EntityGhast extends EntityFlying implements IMonster { this.datawatcher.a(16, Byte.valueOf((byte) 0)); } - public void s_() { - super.s_(); + public int getMaxHealth() { + return 10; + } + + public void w_() { + super.w_(); byte b0 = this.datawatcher.getByte(16); this.texture = b0 == 1 ? "/mob/ghast_fire.png" : "/mob/ghast.png"; } - protected void c_() { + protected void m_() { if (!this.world.isStatic && this.world.difficulty == 0) { this.die(); } - this.ad(); + this.ak(); this.e = this.f; double d0 = this.b - this.locX; double d1 = this.c - this.locY; @@ -84,7 +98,7 @@ public class EntityGhast extends EntityFlying implements IMonster { if (this.target == null || this.h-- <= 0) { // CraftBukkit start - Entity target = this.world.findNearbyPlayer(this, 100.0D); + Entity target = this.world.b(this, 100.0D); if (target != null) { EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER); this.world.getServer().getPluginManager().callEvent(event); @@ -105,23 +119,23 @@ public class EntityGhast extends EntityFlying implements IMonster { double d4 = 64.0D; - if (this.target != null && this.target.h(this) < d4 * d4) { + if (this.target != null && this.target.i(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.U = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; - if (this.f(this.target)) { + this.V = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; + if (this.g(this.target)) { if (this.f == 10) { - this.world.makeSound(this, "mob.ghast.charge", this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } ++this.f; if (this.f == 20) { - this.world.makeSound(this, "mob.ghast.fireball", this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.a((EntityHuman) null, 1008, (int) this.locX, (int) this.locY, (int) this.locZ, 0); EntityFireball entityfireball = new EntityFireball(this.world, this, d5, d6, d7); double d8 = 4.0D; - Vec3D vec3d = this.c(1.0F); + Vec3D vec3d = this.d(1.0F); entityfireball.locX = this.locX + vec3d.a * d8; entityfireball.locY = this.locY + (double) (this.width / 2.0F) + 0.5D; @@ -133,7 +147,7 @@ public class EntityGhast extends EntityFlying implements IMonster { --this.f; } } else { - this.U = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; + this.V = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; if (this.f > 0) { --this.f; } @@ -165,31 +179,47 @@ public class EntityGhast extends EntityFlying implements IMonster { return true; } - protected String h() { + protected String c_() { return "mob.ghast.moan"; } - protected String i() { + protected String m() { return "mob.ghast.scream"; } - protected String j() { + protected String n() { return "mob.ghast.death"; } - protected int k() { + protected int e() { return Item.SULPHUR.id; } - protected float l() { + protected void a(boolean flag, int i) { + int j = this.random.nextInt(2) + this.random.nextInt(1 + i); + + int k; + + for (k = 0; k < j; ++k) { + this.b(Item.GHAST_TEAR.id, 1); + } + + j = this.random.nextInt(3) + this.random.nextInt(1 + i); + + for (k = 0; k < j; ++k) { + this.b(Item.SULPHUR.id, 1); + } + } + + protected float o() { return 10.0F; } - public boolean d() { - return this.random.nextInt(20) == 0 && super.d() && this.world.difficulty > 0; + public boolean g() { + return this.random.nextInt(20) == 0 && super.g() && this.world.difficulty > 0; } - public int m() { + public int p() { return 1; } } diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 3cce8409..0688632d 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -23,45 +23,45 @@ public abstract class EntityHuman extends EntityLiving { public Container defaultContainer; public Container activeContainer; protected FoodMetaData foodData = new FoodMetaData(); - protected int n = 0; - public byte o = 0; - public int p = 0; - public float q; + protected int o = 0; + public byte p = 0; + public int q = 0; public float r; - public boolean s = false; - public int t = 0; + public float s; + public boolean t = false; + public int u = 0; public String name; public int dimension; - public int w = 0; - public double x; + public int x = 0; public double y; public double z; public double A; public double B; public double C; + public double D; // CraftBukkit start public boolean sleeping; public boolean fauxSleeping; public String spawnWorld = ""; - public int sleepTicks; // CraftBukkit end - public ChunkCoordinates E; - public float F; + + public ChunkCoordinates F; + public int sleepTicks; // CraftBukkit private -> public public float G; + public float H; private ChunkCoordinates b; private ChunkCoordinates c; - public int H = 20; - protected boolean I = false; - public float J; + public int I = 20; + protected boolean J = false; + public float K; public PlayerAbilities abilities = new PlayerAbilities(); - public int exp; - public int expLevel; public int expTotal; + public int exp; + public float expLevel; private ItemStack d; private int e; - protected float O = 0.1F; - protected float P = 0.02F; - private int f = 0; + protected float P = 0.1F; + protected float Q = 0.02F; public EntityFishingHook hookedFish = null; public EntityHuman(World world) { @@ -72,62 +72,65 @@ public abstract class EntityHuman extends EntityLiving { ChunkCoordinates chunkcoordinates = world.getSpawn(); this.setPositionRotation((double) chunkcoordinates.x + 0.5D, (double) (chunkcoordinates.y + 1), (double) chunkcoordinates.z + 0.5D, 0.0F, 0.0F); - this.health = 20; - this.ae = "humanoid"; - this.ad = 180.0F; + this.af = "humanoid"; + this.ae = 180.0F; this.maxFireTicks = 20; this.texture = "/mob/char.png"; } + public int getMaxHealth() { + return 20; + } + protected void b() { super.b(); this.datawatcher.a(16, Byte.valueOf((byte) 0)); this.datawatcher.a(17, Byte.valueOf((byte) 0)); } - public boolean o_() { + public boolean H() { return this.d != null; } - public void E() { + public void I() { if (this.d != null) { this.d.a(this.world, this, this.e); } - this.F(); + this.J(); } - public void F() { + public void J() { this.d = null; this.e = 0; if (!this.world.isStatic) { - this.h(false); + this.g(false); } } - public boolean G() { - return this.o_() && Item.byId[this.d.id].b(this.d) == EnumAnimation.c; + public boolean K() { + return this.H() && Item.byId[this.d.id].d(this.d) == EnumAnimation.d; } - public void s_() { + public void w_() { if (this.d != null) { ItemStack itemstack = this.inventory.getItemInHand(); if (itemstack != this.d) { - this.F(); + this.J(); } else { if (this.e <= 25 && this.e % 4 == 0) { this.b(itemstack, 5); } if (--this.e == 0 && !this.world.isStatic) { - this.C(); + this.G(); } } } - if (this.w > 0) { - --this.w; + if (this.x > 0) { + --this.x; } if (this.isSleeping()) { @@ -137,9 +140,9 @@ public abstract class EntityHuman extends EntityLiving { } if (!this.world.isStatic) { - if (!this.w()) { + if (!this.C()) { this.a(true, true, false); - } else if (this.world.d()) { + } else if (this.world.e()) { this.a(false, true, true); } } @@ -150,7 +153,7 @@ public abstract class EntityHuman extends EntityLiving { } } - super.s_(); + super.w_(); if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.b(this)) { this.closeInventory(); this.activeContainer = this.defaultContainer; @@ -162,45 +165,45 @@ public abstract class EntityHuman extends EntityLiving { } } - if (this.fireTicks > 0 && this.abilities.isInvulnerable) { - this.fireTicks = 0; + if (this.z() && this.abilities.isInvulnerable) { + this.aw(); } - 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; + this.A = this.D; + double d0 = this.locX - this.B; + double d1 = this.locY - this.C; + double d2 = this.locZ - this.D; double d3 = 10.0D; if (d0 > d3) { - this.x = this.A = this.locX; + this.y = this.B = this.locX; } if (d2 > d3) { - this.z = this.C = this.locZ; + this.A = this.D = this.locZ; } if (d1 > d3) { - this.y = this.B = this.locY; + this.z = this.C = this.locY; } if (d0 < -d3) { - this.x = this.A = this.locX; + this.y = this.B = this.locX; } if (d2 < -d3) { - this.z = this.C = this.locZ; + this.A = this.D = this.locZ; } if (d1 < -d3) { - this.y = this.B = this.locY; + this.z = this.C = this.locY; } - this.A += d0 * 0.25D; - this.C += d2 * 0.25D; - this.B += d1 * 0.25D; + this.B += d0 * 0.25D; + this.D += d2 * 0.25D; + this.C += d1 * 0.25D; this.a(StatisticList.k, 1); if (this.vehicle == null) { this.c = null; @@ -212,6 +215,10 @@ public abstract class EntityHuman extends EntityLiving { } protected void b(ItemStack itemstack, int i) { + if (itemstack.m() == EnumAnimation.c) { + this.world.makeSound(this, "random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); + } + 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); @@ -222,15 +229,15 @@ public abstract class EntityHuman extends EntityLiving { 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); + vec3d1 = vec3d1.add(this.locX, this.locY + (double) this.x(), 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); + this.world.makeSound(this, "random.eat", 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } } - protected void C() { + protected void G() { if (this.d != null) { this.b(this.d, 16); int i = this.d.count; @@ -243,67 +250,67 @@ public abstract class EntityHuman extends EntityLiving { } } - this.F(); + this.J(); } } - protected boolean H() { - return this.health <= 0 || this.isSleeping(); + protected boolean L() { + return this.getHealth() <= 0 || this.isSleeping(); } protected void closeInventory() { this.activeContainer = this.defaultContainer; } - public void I() { + public void M() { double d0 = this.locX; double d1 = this.locY; double d2 = this.locZ; - super.I(); - this.q = this.r; - this.r = 0.0F; + super.M(); + this.r = this.s; + this.s = 0.0F; this.h(this.locX - d0, this.locY - d1, this.locZ - d2); } - private int o() { + private int A() { return this.hasEffect(MobEffectList.FASTER_DIG) ? 6 - (1 + this.getEffect(MobEffectList.FASTER_DIG).getAmplifier()) * 1 : (this.hasEffect(MobEffectList.SLOWER_DIG) ? 6 + (1 + this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier()) * 2 : 6); } - protected void c_() { - int i = this.o(); + protected void m_() { + int i = this.A(); - if (this.s) { - ++this.t; - if (this.t >= i) { - this.t = 0; - this.s = false; + if (this.t) { + ++this.u; + if (this.u >= i) { + this.u = 0; + this.t = false; } } else { - this.t = 0; + this.u = 0; } - this.am = (float) this.t / (float) i; + this.an = (float) this.u / (float) i; } - public void s() { - if (this.n > 0) { - --this.n; + public void d() { + if (this.o > 0) { + --this.o; } - if (this.world.difficulty == 0 && this.health < 20 && this.ticksLived % 20 * 12 == 0) { + if (this.world.difficulty == 0 && this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 * 12 == 0) { // CraftBukkit - added regain reason of "REGEN" for filtering purposes. - this.c(1, RegainReason.REGEN); + this.d(1, RegainReason.REGEN); } - this.inventory.h(); - this.q = this.r; - super.s(); - this.aj = this.O; + this.inventory.i(); + this.r = this.s; + super.d(); this.ak = this.P; + this.al = this.Q; if (this.isSprinting()) { - this.aj = (float) ((double) this.aj + (double) this.O * 0.3D); this.ak = (float) ((double) this.ak + (double) this.P * 0.3D); + this.al = (float) ((double) this.al + (double) this.Q * 0.3D); } float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); @@ -314,17 +321,17 @@ public abstract class EntityHuman extends EntityLiving { f = 0.1F; } - if (!this.onGround || this.health <= 0) { + if (!this.onGround || this.getHealth() <= 0) { f = 0.0F; } - if (this.onGround || this.health <= 0) { + if (this.onGround || this.getHealth() <= 0) { f1 = 0.0F; } - this.r += (f - this.r) * 0.4F; - this.av += (f1 - this.av) * 0.8F; - if (this.health > 0) { + this.s += (f - this.s) * 0.4F; + this.ax += (f1 - this.ax) * 0.8F; + if (this.getHealth() > 0) { List list = this.world.b((Entity) this, this.boundingBox.b(1.0D, 0.0D, 1.0D)); if (list != null) { @@ -332,14 +339,14 @@ public abstract class EntityHuman extends EntityLiving { Entity entity = (Entity) list.get(i); if (!entity.dead) { - this.j(entity); + this.k(entity); } } } } } - private void j(Entity entity) { + private void k(Entity entity) { entity.a_(this); } @@ -352,10 +359,10 @@ public abstract class EntityHuman extends EntityLiving { this.a(new ItemStack(Item.APPLE, 1), true); } - this.inventory.j(); + this.inventory.k(); 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); + this.motX = (double) (-MathHelper.cos((this.at + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motZ = (double) (-MathHelper.sin((this.at + this.yaw) * 3.1415927F / 180.0F) * 0.1F); } else { this.motX = this.motZ = 0.0D; } @@ -365,7 +372,7 @@ public abstract class EntityHuman extends EntityLiving { } public void b(Entity entity, int i) { - this.p += i; + this.q += i; if (entity instanceof EntityHuman) { this.a(StatisticList.A, 1); } else { @@ -373,7 +380,13 @@ public abstract class EntityHuman extends EntityLiving { } } - public void J() { + protected int f(int i) { + int j = EnchantmentManager.a(this.inventory); + + return j > 0 && this.random.nextInt(j + 1) > 0 ? i : super.f(i); + } + + public void N() { this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, 1), false); } @@ -383,7 +396,7 @@ public abstract class EntityHuman extends EntityLiving { public void a(ItemStack itemstack, boolean flag) { if (itemstack != null) { - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.t(), this.locZ, itemstack); + EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.x(), this.locZ, itemstack); entityitem.pickupDelay = 40; float f = 0.1F; @@ -433,24 +446,30 @@ public abstract class EntityHuman extends EntityLiving { public float a(Block block) { float f = this.inventory.a(block); + float f1 = f; + int i = EnchantmentManager.b(this.inventory); - if (this.a(Material.WATER)) { - f /= 5.0F; - } - - if (!this.onGround) { - f /= 5.0F; + if (i > 0 && this.inventory.b(block)) { + f1 = f + (float) (i * i + 1); } if (this.hasEffect(MobEffectList.FASTER_DIG)) { - f *= 1.0F + (float) (this.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F; + f1 *= 1.0F + (float) (this.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F; } if (this.hasEffect(MobEffectList.SLOWER_DIG)) { - f *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F; + f1 *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F; } - return f; + if (this.a(Material.WATER) && !EnchantmentManager.g(this.inventory)) { + f1 /= 5.0F; + } + + if (!this.onGround) { + f1 /= 5.0F; + } + + return f1; } public boolean b(Block block) { @@ -459,17 +478,17 @@ public abstract class EntityHuman extends EntityLiving { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.l("Inventory"); + NBTTagList nbttaglist = nbttagcompound.m("Inventory"); this.inventory.b(nbttaglist); - 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"); + this.dimension = nbttagcompound.f("Dimension"); + this.sleeping = nbttagcompound.n("Sleeping"); + this.sleepTicks = nbttagcompound.e("SleepTimer"); + this.expLevel = nbttagcompound.h("XpP"); + this.expTotal = nbttagcompound.f("XpLevel"); + this.exp = nbttagcompound.f("XpTotal"); if (this.sleeping) { - this.E = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + this.F = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); this.a(true, true, false); } @@ -481,10 +500,11 @@ public abstract class EntityHuman extends EntityLiving { // CraftBukkit end if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { - this.b = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ")); + this.b = new ChunkCoordinates(nbttagcompound.f("SpawnX"), nbttagcompound.f("SpawnY"), nbttagcompound.f("SpawnZ")); } this.foodData.a(nbttagcompound); + this.abilities.b(nbttagcompound); } public void b(NBTTagCompound nbttagcompound) { @@ -493,9 +513,9 @@ 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); + nbttagcompound.a("XpP", this.expLevel); + nbttagcompound.a("XpLevel", this.expTotal); + nbttagcompound.a("XpTotal", this.exp); if (this.b != null) { nbttagcompound.a("SpawnX", this.b.x); nbttagcompound.a("SpawnY", this.b.y); @@ -504,19 +524,22 @@ public abstract class EntityHuman extends EntityLiving { } this.foodData.b(nbttagcompound); + this.abilities.a(nbttagcompound); } public void a(IInventory iinventory) {} + public void c(int i, int j, int k) {} + public void b(int i, int j, int k) {} public void receive(Entity entity, int i) {} - public float t() { + public float x() { return 0.12F; } - protected void m_() { + protected void w() { this.height = 1.62F; } @@ -524,8 +547,8 @@ public abstract class EntityHuman extends EntityLiving { if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { return false; } else { - this.aO = 0; - if (this.health <= 0) { + this.aS = 0; + if (this.getHealth() <= 0) { return false; } else { if (this.isSleeping() && !this.world.isStatic) { @@ -540,7 +563,7 @@ public abstract class EntityHuman extends EntityLiving { } if (this.world.difficulty == 1) { - i = i / 3 + 1; + i = i / 2 + 1; } if (this.world.difficulty == 3) { @@ -587,7 +610,31 @@ public abstract class EntityHuman extends EntityLiving { } } - protected boolean n_() { + protected int b(DamageSource damagesource, int i) { + int j = super.b(damagesource, i); + + if (j <= 0) { + return 0; + } else { + int k = EnchantmentManager.a(this.inventory, damagesource); + + if (k > 20) { + k = 20; + } + + if (k > 0 && k <= 20) { + int l = 25 - k; + int i1 = j * l + this.aq; + + j = i1 / 25; + this.aq = i1 % 25; + } + + return j; + } + } + + protected boolean y() { return false; } @@ -601,7 +648,7 @@ public abstract class EntityHuman extends EntityLiving { } } - if (!(entityliving instanceof EntityHuman) || this.n_()) { + if (!(entityliving instanceof EntityHuman) || this.y()) { 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(); @@ -609,7 +656,7 @@ public abstract class EntityHuman extends EntityLiving { Entity entity = (Entity) iterator.next(); EntityWolf entitywolf1 = (EntityWolf) entity; - if (entitywolf1.isTamed() && entitywolf1.C() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { + if (entitywolf1.isTamed() && entitywolf1.E() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { // CraftBukkit start org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entityliving.getBukkitEntity(); @@ -634,22 +681,23 @@ public abstract class EntityHuman extends EntityLiving { } } - protected void b(DamageSource damagesource, int i) { - if (!damagesource.ignoresArmor() && this.G()) { - i = 1 + i >> 1; - } + protected void g(int i) { + this.inventory.d(i); + } - if (!damagesource.ignoresArmor()) { - int j = 25 - this.inventory.i(); - int k = i * j + this.f; + protected int O() { + return this.inventory.j(); + } - this.inventory.d(i); - i = k / 25; - this.f = k % 25; + protected void c(DamageSource damagesource, int i) { + if (!damagesource.ignoresArmor() && this.K()) { + i = 1 + i >> 1; } - this.b(damagesource.c()); - super.b(damagesource, i); + i = this.d(damagesource, i); + i = this.b(damagesource, i); + this.c(damagesource.e()); + super.c(damagesource, i); } public void a(TileEntityFurnace tileentityfurnace) {} @@ -658,48 +706,70 @@ public abstract class EntityHuman extends EntityLiving { public void a(TileEntitySign tileentitysign) {} - public void c(Entity entity) { + public void a(TileEntityBrewingStand tileentitybrewingstand) {} + + public void e(Entity entity) { if (!entity.b(this)) { - ItemStack itemstack = this.K(); + ItemStack itemstack = this.P(); if (itemstack != null && entity instanceof EntityLiving) { itemstack.a((EntityLiving) entity); // CraftBukkit - bypass infinite items; <= 0 -> == 0 if (itemstack.count == 0) { itemstack.a(this); - this.L(); + this.Q(); } } } } - public ItemStack K() { + public ItemStack P() { return this.inventory.getItemInHand(); } - public void L() { + public void Q() { this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); } - public double M() { + public double R() { return (double) (this.height - 0.5F); } - public void v() { - if (!this.s || this.t >= this.o() / 2 || this.t < 0) { - this.t = -1; - this.s = true; + public void r_() { + if (!this.t || this.u >= this.A() / 2 || this.u < 0) { + this.u = -1; + this.t = true; } } - public void d(Entity entity) { + public void f(Entity entity) { int i = this.inventory.a(entity); - if (i > 0) { - boolean flag = this.motY < 0.0D && !this.onGround && !this.p() && !this.ao(); + if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) { + i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); + } + + if (this.hasEffect(MobEffectList.WEAKNESS)) { + i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier(); + } + + int j = 0; + int k = 0; + + if (entity instanceof EntityLiving) { + k = EnchantmentManager.a(this.inventory, (EntityLiving) entity); + j += EnchantmentManager.b(this.inventory, (EntityLiving) entity); + } + + if (this.isSprinting()) { + ++j; + } + + if (i > 0 || k > 0) { + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.r() && !this.az() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving; if (flag) { - i = i * 3 / 2 + 1; + i += this.random.nextInt(i / 2 + 2); } // CraftBukkit start - Don't call the event when the entity is human since it will be called with damageEntity @@ -718,6 +788,7 @@ public abstract class EntityHuman extends EntityLiving { } // CraftBukkit end + i += k; boolean flag1 = entity.damageEntity(DamageSource.playerAttack(this), i); // CraftBukkit start - Return when the damage fails so that the item will not lose durability @@ -727,42 +798,57 @@ public abstract class EntityHuman extends EntityLiving { // CraftBukkit end if (flag1) { - if (this.isSprinting()) { - 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)); + if (j > 0) { + entity.b_((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F)); this.motX *= 0.6D; this.motZ *= 0.6D; this.setSprinting(false); } if (flag) { - this.e(entity); + this.c(entity); + } + + if (k > 0) { + this.d(entity); + } + + if (i >= 18) { + this.a((Statistic) AchievementList.E); } } - ItemStack itemstack = this.K(); + ItemStack itemstack = this.P(); 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.L(); + this.Q(); } } if (entity instanceof EntityLiving) { - if (entity.ac()) { + if (entity.aj()) { this.a((EntityLiving) entity, true); } this.a(StatisticList.w, i); + int l = EnchantmentManager.c(this.inventory, (EntityLiving) entity); + + if (l > 0) { + entity.j(l * 4); + } } - this.b(0.3F); + this.c(0.3F); } } - public void e(Entity entity) {} + public void c(Entity entity) {} + + public void d(Entity entity) {} public void a(ItemStack itemstack) {} @@ -774,13 +860,13 @@ public abstract class EntityHuman extends EntityLiving { } } - public boolean O() { - return !this.sleeping && super.O(); + public boolean T() { + return !this.sleeping && super.T(); } public EnumBedError a(int i, int j, int k) { if (!this.world.isStatic) { - if (this.isSleeping() || !this.ac()) { + if (this.isSleeping() || !this.aj()) { return EnumBedError.OTHER_PROBLEM; } @@ -788,13 +874,21 @@ public abstract class EntityHuman extends EntityLiving { return EnumBedError.NOT_POSSIBLE_HERE; } - if (this.world.d()) { + if (this.world.e()) { return EnumBedError.NOT_POSSIBLE_NOW; } if (Math.abs(this.locX - (double) i) > 3.0D || Math.abs(this.locY - (double) j) > 2.0D || Math.abs(this.locZ - (double) k) > 3.0D) { return EnumBedError.TOO_FAR_AWAY; } + + double d0 = 8.0D; + double d1 = 5.0D; + List list = this.world.a(EntityMonster.class, AxisAlignedBB.b((double) i - d0, (double) j - d1, (double) k - d0, (double) i + d0, (double) j + d1, (double) k + d0)); + + if (!list.isEmpty()) { + return EnumBedError.NOT_SAFE; + } } // CraftBukkit start @@ -815,7 +909,7 @@ public abstract class EntityHuman extends EntityLiving { this.height = 0.2F; if (this.world.isLoaded(i, j, k)) { int l = this.world.getData(i, j, k); - int i1 = BlockBed.c(l); + int i1 = BlockBed.d(l); float f = 0.5F; float f1 = 0.5F; @@ -836,7 +930,7 @@ public abstract class EntityHuman extends EntityLiving { f = 0.9F; } - this.b(i1); + this.c(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)); @@ -844,7 +938,7 @@ public abstract class EntityHuman extends EntityLiving { this.sleeping = true; this.sleepTicks = 0; - this.E = new ChunkCoordinates(i, j, k); + this.F = new ChunkCoordinates(i, j, k); this.motX = this.motZ = this.motY = 0.0D; if (!this.world.isStatic) { this.world.everyoneSleeping(); @@ -853,24 +947,24 @@ public abstract class EntityHuman extends EntityLiving { return EnumBedError.OK; } - private void b(int i) { - this.F = 0.0F; + private void c(int i) { this.G = 0.0F; + this.H = 0.0F; switch (i) { case 0: - this.G = -1.8F; + this.H = -1.8F; break; case 1: - this.F = 1.8F; + this.G = 1.8F; break; case 2: - this.G = 1.8F; + this.H = 1.8F; break; case 3: - this.F = -1.8F; + this.G = -1.8F; } } @@ -878,9 +972,9 @@ public abstract class EntityHuman extends EntityLiving { if (this.fauxSleeping && !this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! this.b(0.6F, 1.8F); - this.m_(); - ChunkCoordinates chunkcoordinates = this.E; - ChunkCoordinates chunkcoordinates1 = this.E; + this.w(); + ChunkCoordinates chunkcoordinates = this.F; + ChunkCoordinates chunkcoordinates1 = this.F; 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); @@ -920,16 +1014,16 @@ public abstract class EntityHuman extends EntityLiving { } if (flag2) { - this.a(this.E); + this.a(this.F); } } - private boolean w() { - return this.world.getTypeId(this.E.x, this.E.y, this.E.z) == Block.BED.id; + private boolean C() { + return this.world.getTypeId(this.F.x, this.F.y, this.F.z) == Block.BED.id; } public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) { - IChunkProvider ichunkprovider = world.n(); + IChunkProvider ichunkprovider = world.p(); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); @@ -973,13 +1067,13 @@ public abstract class EntityHuman extends EntityLiving { public void a(Statistic statistic, int i) {} - protected void S() { - super.S(); + protected void X() { + super.X(); this.a(StatisticList.u, 1); if (this.isSprinting()) { - this.b(0.8F); + this.c(0.8F); } else { - this.b(0.2F); + this.c(0.2F); } } @@ -990,20 +1084,20 @@ public abstract class EntityHuman extends EntityLiving { if (this.abilities.isFlying) { double d3 = this.motY; - float f2 = this.ak; + float f2 = this.al; - this.ak = 0.05F; + this.al = 0.05F; super.a(f, f1); this.motY = d3 * 0.6D; - this.ak = f2; + this.al = f2; } else { super.a(f, f1); } - this.a(this.locX - d0, this.locY - d1, this.locZ - d2); + this.b(this.locX - d0, this.locY - d1, this.locZ - d2); } - public void a(double d0, double d1, double d2) { + public void b(double d0, double d1, double d2) { if (this.vehicle == null) { int i; @@ -1011,15 +1105,15 @@ 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); + this.c(0.015F * (float) i * 0.01F); } - } else if (this.ao()) { + } else if (this.az()) { 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); + this.c(0.015F * (float) i * 0.01F); } - } else if (this.p()) { + } else if (this.r()) { if (d1 > 0.0D) { this.a(StatisticList.o, (int) Math.round(d1 * 100.0D)); } @@ -1028,9 +1122,9 @@ public abstract class EntityHuman extends EntityLiving { if (i > 0) { this.a(StatisticList.l, i); if (this.isSprinting()) { - this.b(0.099999994F * (float) i * 0.01F); + this.c(0.099999994F * (float) i * 0.01F); } else { - this.b(0.01F * (float) i * 0.01F); + this.c(0.01F * (float) i * 0.01F); } } } else { @@ -1063,13 +1157,13 @@ public abstract class EntityHuman extends EntityLiving { } } - protected void a(float f) { + protected void b(float f) { if (!this.abilities.canFly) { if (f >= 2.0F) { this.a(StatisticList.n, (int) Math.round((double) f * 100.0D)); } - super.a(f); + super.b(f); } } @@ -1079,33 +1173,41 @@ public abstract class EntityHuman extends EntityLiving { } } - public void T() { - if (this.H > 0) { - this.H = 10; + public void Y() { + if (this.I > 0) { + this.I = 10; } else { - this.I = true; + this.J = true; } } - public void d(int i) { + public void h(int i) { + this.q += i; + this.expLevel += (float) i / (float) this.Z(); this.exp += i; - this.expTotal += i; - while (this.exp >= this.U()) { - this.exp -= this.U(); - this.y(); + while (this.expLevel >= 1.0F) { + --this.expLevel; + this.D(); + } + } + + public void b(int i) { + this.expTotal -= i; + if (this.expTotal < 0) { + this.expTotal = 0; } } - public int U() { - return (this.expLevel + 1) * 10; + public int Z() { + return 7 + (this.expTotal * 7 >> 1); } - private void y() { - ++this.expLevel; + private void D() { + ++this.expTotal; } - public void b(float f) { + public void c(float f) { if (!this.abilities.isInvulnerable) { if (!this.world.isStatic) { this.foodData.a(f); @@ -1117,12 +1219,12 @@ public abstract class EntityHuman extends EntityLiving { return this.foodData; } - public boolean c(boolean flag) { + public boolean b(boolean flag) { return (flag || this.foodData.b()) && !this.abilities.isInvulnerable; } - public boolean W() { - return this.health > 0 && this.health < 20; + public boolean ab() { + return this.getHealth() > 0 && this.getHealth() < this.getMaxHealth(); } public void a(ItemStack itemstack, int i) { @@ -1130,24 +1232,38 @@ public abstract class EntityHuman extends EntityLiving { this.d = itemstack; this.e = i; if (!this.world.isStatic) { - this.h(true); + this.g(true); } } } - public boolean c(int i, int j, int k) { + public boolean d(int i, int j, int k) { return true; } protected int a(EntityHuman entityhuman) { - return this.expTotal >> 1; + int i = this.expTotal * 7; + + return i > 100 ? 100 : i; } - protected boolean X() { + protected boolean ac() { return true; } - public String Y() { + public String ad() { return this.name; } + + public void e(int i) {} + + public void copyTo(EntityHuman entityhuman) { + this.inventory.a(entityhuman.inventory); + this.health = entityhuman.health; + this.foodData = entityhuman.foodData; + this.expTotal = entityhuman.expTotal; + this.exp = entityhuman.exp; + this.expLevel = entityhuman.expLevel; + this.q = entityhuman.q; + } } diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index 695e42e0..7f82da61 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 e_() { + protected boolean g_() { return false; } @@ -41,8 +41,8 @@ public class EntityItem extends Entity { protected void b() {} - public void s_() { - super.s_(); + public void w_() { + super.w_(); // CraftBukkit start int currentTick = (int) (System.currentTimeMillis() / 50); this.pickupDelay -= (currentTick - this.lastTick); @@ -87,7 +87,7 @@ public class EntityItem extends Entity { } } - public boolean f_() { + public boolean i_() { return this.world.a(this.boundingBox, Material.WATER, this); } @@ -96,7 +96,7 @@ public class EntityItem extends Entity { } public boolean damageEntity(DamageSource damagesource, int i) { - this.aq(); + this.aB(); this.f -= i; if (this.f <= 0) { this.die(); @@ -112,9 +112,9 @@ public class EntityItem extends Entity { } public void a(NBTTagCompound nbttagcompound) { - this.f = nbttagcompound.d("Health") & 255; - this.b = nbttagcompound.d("Age"); - NBTTagCompound nbttagcompound1 = nbttagcompound.k("Item"); + this.f = nbttagcompound.e("Health") & 255; + this.b = nbttagcompound.e("Age"); + NBTTagCompound nbttagcompound1 = nbttagcompound.l("Item"); this.itemStack = ItemStack.a(nbttagcompound1); if (this.itemStack == null) { @@ -153,6 +153,14 @@ public class EntityItem extends Entity { entityhuman.a((Statistic) AchievementList.t); } + if (this.itemStack.id == Item.DIAMOND.id) { + entityhuman.a((Statistic) AchievementList.w); + } + + if (this.itemStack.id == Item.BLAZE_ROD.id) { + entityhuman.a((Statistic) AchievementList.z); + } + this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, i); if (this.itemStack.count <= 0) { @@ -162,7 +170,7 @@ public class EntityItem extends Entity { } } - public String Y() { + public String ad() { 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 05870457..56e6dc8c 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -17,117 +17,124 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; public abstract class EntityLiving extends Entity { public int maxNoDamageTicks = 20; - public float S; public float T; - public float U = 0.0F; + public float U; public float V = 0.0F; - protected float W; + public float W = 0.0F; protected float X; protected float Y; protected float Z; - protected boolean aa = true; + protected float aa; + protected boolean ab = true; protected String texture = "/mob/char.png"; - 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; + protected boolean ad = true; + protected float ae = 0.0F; + protected String af = null; + protected float ag = 1.0F; + protected int ah = 0; + protected float ai = 0.0F; + public boolean aj = false; + public float ak = 0.1F; + public float al = 0.02F; public float am; - public int health = 10; - public int ao; + public float an; + protected int health = this.getMaxHealth(); + public int ap; + protected int aq; private int a; public int hurtTicks; - public int aq; - public float ar = 0.0F; + public int as; + public float at = 0.0F; public int deathTicks = 0; public int attackTicks = 0; - 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 aw; + public float ax; + protected boolean ay = false; + protected int az; + public int aA = -1; + public float aB = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); public float aC; - private EntityHuman b = null; - private int c = 0; - public int aD = 0; - public int aE = 0; + public float aD; + public float aE; + protected EntityHuman aF = null; + protected int aG = 0; + public int aH = 0; + public int aI = 0; protected HashMap effects = new HashMap(); - protected int aG; - protected double aH; - protected double aI; - protected double aJ; - protected double aK; + private boolean b = true; + private int c; + protected int aK; protected double aL; - float aM = 0.0F; + protected double aM; + protected double aN; + protected double aO; + protected double aP; + float aQ = 0.0F; public int lastDamage = 0; // CraftBukkit - protected -> public - 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; + protected int aS = 0; + protected float aT; + protected float aU; + protected float aV; + protected boolean aW = false; + protected float aX = 0.0F; + protected float aY = 0.7F; + private int d = 0; + private Entity e; + protected int aZ = 0; public int expToDrop = 0; // CraftBukkit added public EntityLiving(World world) { super(world); - this.aY = true; - this.T = (float) (Math.random() + 1.0D) * 0.01F; + this.bc = true; + this.U = (float) (Math.random() + 1.0D) * 0.01F; this.setPosition(this.locX, this.locY, this.locZ); - this.S = (float) Math.random() * 12398.0F; + this.T = (float) Math.random() * 12398.0F; this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); - this.bI = 0.5F; + this.bM = 0.5F; } - protected void b() {} + protected void b() { + this.datawatcher.a(8, Integer.valueOf(this.c)); + } - 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 g(Entity entity) { + return this.world.a(Vec3D.create(this.locX, this.locY + (double) this.x(), this.locZ), Vec3D.create(entity.locX, entity.locY + (double) entity.x(), entity.locZ)) == null; } - public boolean r_() { + public boolean e_() { return !this.dead; } - public boolean g() { + public boolean f_() { return !this.dead; } - public float t() { + public float x() { return this.width * 0.85F; } - public int e() { + public int h() { return 80; } - public void Z() { - String s = this.h(); + public void ae() { + String s = this.c_(); if (s != null) { - this.world.makeSound(this, s, this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, s, this.o(), this.w()); } } - public void aa() { - this.al = this.am; - super.aa(); + public void af() { + this.am = this.an; + super.af(); + MethodProfiler.a("mobBaseTick"); if (this.random.nextInt(1000) < this.a++) { - this.a = -this.e(); - this.Z(); + this.a = -this.h(); + this.ae(); } - if (this.ac() && this.O()) { + if (this.aj() && this.T()) { // CraftBukkit start EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.SUFFOCATION, 1); this.world.getServer().getPluginManager().callEvent(event); @@ -138,18 +145,16 @@ public abstract class EntityLiving extends Entity { // CraftBukkit end } - if (this.fireProof || this.world.isStatic) { - this.fireTicks = 0; + if (this.ax() || this.world.isStatic) { + this.aw(); } - int i; + if (this.aj() && this.a(Material.WATER) && !this.f() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id))) { + this.setAirTicks(this.f(this.getAirTicks())); + if (this.getAirTicks() == -20) { + this.setAirTicks(0); - if (this.ac() && this.a(Material.WATER) && !this.b_() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id))) { - --this.airTicks; - if (this.airTicks == -20) { - this.airTicks = 0; - - for (i = 0; i < 8; ++i) { + for (int i = 0; i < 8; ++i) { float f = this.random.nextFloat() - this.random.nextFloat(); float f1 = this.random.nextFloat() - this.random.nextFloat(); float f2 = this.random.nextFloat() - this.random.nextFloat(); @@ -167,12 +172,12 @@ public abstract class EntityLiving extends Entity { // CraftBukkit end } - this.fireTicks = 0; + this.aw(); } else { - this.airTicks = this.maxAirTicks; + this.setAirTicks(300); } - this.au = this.av; + this.aw = this.ax; if (this.attackTicks > 0) { --this.attackTicks; } @@ -186,56 +191,28 @@ public abstract class EntityLiving extends Entity { } if (this.health <= 0) { - ++this.deathTicks; - if (this.deathTicks > 20) { - // CraftBukkit start - update getExpReward() below if this changes! - if (expToDrop > 0) { - i = expToDrop; - - while (i > 0) { - int j = EntityExperienceOrb.b(i); - - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } - } - // CraftBukkit end - - this.ag(); - this.die(); - - for (i = 0; i < 20; ++i) { - double d0 = this.random.nextGaussian() * 0.02D; - double d1 = this.random.nextGaussian() * 0.02D; - double d2 = this.random.nextGaussian() * 0.02D; - - this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, this.locY + (double) (this.random.nextFloat() * this.width), this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, d0, d1, d2); - } - } + this.ag(); } - if (this.c > 0) { - --this.c; + if (this.aG > 0) { + --this.aG; } else { - this.b = null; + this.aF = null; } - this.aj(); - this.Z = this.Y; - this.V = this.U; + this.aq(); + this.aa = this.Z; + this.W = this.V; this.lastYaw = this.yaw; this.lastPitch = this.pitch; - } - - protected int a(EntityHuman entityhuman) { - return this.ax; + MethodProfiler.a(); } // CraftBukkit start public int getExpReward() { - int exp = a(this.b); - - if (this.c > 0 || this.X()) { + int exp = a(this.aF); + + if (!this.world.isStatic && (this.aG > 0 || this.ac()) && !this.l()) { return exp; } else { return 0; @@ -243,11 +220,47 @@ public abstract class EntityLiving extends Entity { } // CraftBukkit end - protected boolean X() { + protected void ag() { + ++this.deathTicks; + if (this.deathTicks == 20) { + int i; + + // CraftBukkit start - update getExpReward() below if the removed if() changes! + i = expToDrop; + while (i > 0) { + int j = EntityExperienceOrb.b(i); + + i -= j; + this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); + } + // CraftBukkit end + + this.an(); + this.die(); + + for (i = 0; i < 20; ++i) { + double d0 = this.random.nextGaussian() * 0.02D; + double d1 = this.random.nextGaussian() * 0.02D; + double d2 = this.random.nextGaussian() * 0.02D; + + this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, this.locY + (double) (this.random.nextFloat() * this.width), this.locZ + (double) (this.random.nextFloat() * this.length * 2.0F) - (double) this.length, d0, d1, d2); + } + } + } + + protected int f(int i) { + return i - 1; + } + + protected int a(EntityHuman entityhuman) { + return this.az; + } + + protected boolean ac() { return false; } - public void ab() { + public void ah() { for (int i = 0; i < 20; ++i) { double d0 = this.random.nextGaussian() * 0.02D; double d1 = this.random.nextGaussian() * 0.02D; @@ -258,33 +271,34 @@ public abstract class EntityLiving extends Entity { } } - public void I() { - super.I(); - this.W = this.X; - this.X = 0.0F; + public void M() { + super.M(); + this.X = this.Y; + this.Y = 0.0F; + this.fallDistance = 0.0F; } - public void s_() { - super.s_(); - if (this.aD > 0) { - if (this.aE <= 0) { - this.aE = 60; + public void w_() { + super.w_(); + if (this.aH > 0) { + if (this.aI <= 0) { + this.aI = 60; } - --this.aE; - if (this.aE <= 0) { - --this.aD; + --this.aI; + if (this.aI <= 0) { + --this.aH; } } - this.s(); + this.d(); double d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f = MathHelper.a(d0 * d0 + d1 * d1); - float f1 = this.U; + float f1 = this.V; float f2 = 0.0F; - this.W = this.X; + this.X = this.Y; float f3 = 0.0F; if (f > 0.05F) { @@ -294,7 +308,7 @@ public abstract class EntityLiving extends Entity { f1 = (float) TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; } - if (this.am > 0.0F) { + if (this.an > 0.0F) { f1 = this.yaw; } @@ -302,11 +316,11 @@ public abstract class EntityLiving extends Entity { f3 = 0.0F; } - this.X += (f3 - this.X) * 0.3F; + this.Y += (f3 - this.Y) * 0.3F; float f4; - for (f4 = f1 - this.U; f4 < -180.0F; f4 += 360.0F) { + for (f4 = f1 - this.V; f4 < -180.0F; f4 += 360.0F) { ; } @@ -314,11 +328,11 @@ public abstract class EntityLiving extends Entity { f4 -= 360.0F; } - this.U += f4 * 0.3F; + this.V += f4 * 0.3F; float f5; - for (f5 = this.yaw - this.U; f5 < -180.0F; f5 += 360.0F) { + for (f5 = this.yaw - this.V; f5 < -180.0F; f5 += 360.0F) { ; } @@ -336,9 +350,9 @@ public abstract class EntityLiving extends Entity { f5 = 75.0F; } - this.U = this.yaw - f5; + this.V = this.yaw - f5; if (f5 * f5 > 2500.0F) { - this.U += f5 * 0.2F; + this.V += f5 * 0.2F; } if (flag) { @@ -353,12 +367,12 @@ public abstract class EntityLiving extends Entity { this.lastYaw += 360.0F; } - while (this.U - this.V < -180.0F) { - this.V -= 360.0F; + while (this.V - this.W < -180.0F) { + this.W -= 360.0F; } - while (this.U - this.V >= 180.0F) { - this.V += 360.0F; + while (this.V - this.W >= 180.0F) { + this.W += 360.0F; } while (this.pitch - this.lastPitch < -180.0F) { @@ -369,7 +383,7 @@ public abstract class EntityLiving extends Entity { this.lastPitch += 360.0F; } - this.Y += f2; + this.Z += f2; } protected void b(float f, float f1) { @@ -377,11 +391,11 @@ public abstract class EntityLiving extends Entity { } // CraftBukkit start - delegate so we can handle providing a reason for health being regained - public void c(int i) { - c(i, RegainReason.CUSTOM); + public void d(int i) { + d(i, RegainReason.CUSTOM); } - public void c(int i, RegainReason regainReason) { + public void d(int i, RegainReason regainReason) { if (this.health > 0) { EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason); this.world.getServer().getPluginManager().callEvent(event); @@ -390,23 +404,39 @@ public abstract class EntityLiving extends Entity { this.health += event.getAmount(); } // CraftBukkit end - if (this.health > 20) { - this.health = 20; + + if (this.health > this.getMaxHealth()) { + this.health = this.getMaxHealth(); } this.noDamageTicks = this.maxNoDamageTicks / 2; } } + public abstract int getMaxHealth(); + + public int getHealth() { + return this.health; + } + + public void setHealth(int i) { + this.health = i; + if (i > this.getMaxHealth()) { + i = this.getMaxHealth(); + } + } + public boolean damageEntity(DamageSource damagesource, int i) { if (this.world.isStatic) { return false; } else { - this.aO = 0; + this.aS = 0; if (this.health <= 0) { return false; + } else if (damagesource.k() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { + return false; } else { - this.aB = 1.5F; + this.aD = 1.5F; boolean flag = true; if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { @@ -414,37 +444,37 @@ public abstract class EntityLiving extends Entity { return false; } - this.b(damagesource, i - this.lastDamage); + this.c(damagesource, i - this.lastDamage); this.lastDamage = i; flag = false; } else { this.lastDamage = i; - this.ao = this.health; + this.ap = this.health; this.noDamageTicks = this.maxNoDamageTicks; - this.b(damagesource, i); - this.hurtTicks = this.aq = 10; + this.c(damagesource, i); + this.hurtTicks = this.as = 10; } - this.ar = 0.0F; + this.at = 0.0F; Entity entity = damagesource.getEntity(); if (entity != null) { if (entity instanceof EntityHuman) { - this.c = 60; - this.b = (EntityHuman) entity; + this.aG = 60; + this.aF = (EntityHuman) entity; } else if (entity instanceof EntityWolf) { EntityWolf entitywolf = (EntityWolf) entity; if (entitywolf.isTamed()) { - this.c = 60; - this.b = null; + this.aG = 60; + this.aF = null; } } } if (flag) { this.world.a(this, (byte) 2); - this.aq(); + this.aB(); if (entity != null) { double d0 = entity.locX - this.locX; @@ -454,21 +484,21 @@ public abstract class EntityLiving extends Entity { d0 = (Math.random() - Math.random()) * 0.01D; } - this.ar = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; + this.at = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; this.a(entity, i, d0, d1); } else { - this.ar = (float) ((int) (Math.random() * 2.0D) * 180); + this.at = (float) ((int) (Math.random() * 2.0D) * 180); } } if (this.health <= 0) { if (flag) { - this.world.makeSound(this, this.j(), this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, this.n(), this.o(), this.w()); } this.die(damagesource); } else if (flag) { - this.world.makeSound(this, this.i(), this.l(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, this.m(), this.o(), this.w()); } return true; @@ -476,28 +506,66 @@ public abstract class EntityLiving extends Entity { } } - protected void b(DamageSource damagesource, int i) { + private float w() { + return this.l() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; + } + + protected int O() { + return 0; + } + + protected void g(int i) {} + + protected int d(DamageSource damagesource, int i) { + if (!damagesource.ignoresArmor()) { + int j = 25 - this.O(); + int k = i * j + this.aq; + + this.g(i); + i = k / 25; + this.aq = k % 25; + } + + return i; + } + + protected int b(DamageSource damagesource, int i) { + if (this.hasEffect(MobEffectList.RESISTANCE)) { + int j = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; + int k = 25 - j; + int l = i * k + this.aq; + + i = l / 25; + this.aq = l % 25; + } + + return i; + } + + protected void c(DamageSource damagesource, int i) { + i = this.d(damagesource, i); + i = this.b(damagesource, i); this.health -= i; } - protected float l() { + protected float o() { return 1.0F; } - protected String h() { + protected String c_() { return null; } - protected String i() { - return "random.hurt"; + protected String m() { + return "damage.hurtflesh"; } - protected String j() { - return "random.hurt"; + protected String n() { + return "damage.hurtflesh"; } public void a(Entity entity, int i, double d0, double d1) { - this.ca = true; + this.cb = true; float f = MathHelper.a(d0 * d0 + d1 * d1); float f1 = 0.4F; @@ -515,43 +583,58 @@ public abstract class EntityLiving extends Entity { public void die(DamageSource damagesource) { Entity entity = damagesource.getEntity(); - if (this.ag >= 0 && entity != null) { - entity.b(this, this.ag); + if (this.ah >= 0 && entity != null) { + entity.b(this, this.ah); } if (entity != null) { entity.a(this); } - this.aw = true; + this.ay = true; if (!this.world.isStatic) { - this.a(this.c > 0); + int i = 0; + + if (entity instanceof EntityHuman) { + i = EnchantmentManager.f(((EntityHuman) entity).inventory); + } + + if (!this.l()) { + this.a(this.aG > 0, i); + } } this.world.a(this, (byte) 3); } - protected void a(boolean flag) { - int i = this.k(); + protected void a(boolean flag, int i) { + int j = this.e(); // CraftBukkit start - whole method List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(3); - if ((i > 0) && (count > 0)) { - loot.add(new org.bukkit.inventory.ItemStack(i, count)); - } + if (j > 0) { + int k = this.random.nextInt(3); - CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end + if (i > 0) { + k += this.random.nextInt(i + 1); + } + + if (k > 0) { + loot.add(new org.bukkit.inventory.ItemStack(j, k)); + } + + CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end + } } - protected int k() { + protected int e() { return 0; } - protected void a(float f) { - super.a(f); + protected void b(float f) { + super.b(f); int i = (int) Math.ceil((double) (f - 3.0F)); if (i > 0) { @@ -560,7 +643,15 @@ public abstract class EntityLiving extends Entity { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled() && event.getDamage() != 0) { - this.damageEntity(DamageSource.FALL, event.getDamage()); + i = event.getDamage(); + + if (i > 4) { + this.world.makeSound(this, "damage.fallbig", 1.0F, 1.0F); + } else { + this.world.makeSound(this, "damage.fallsmall", 1.0F, 1.0F); + } + + this.damageEntity(DamageSource.FALL, i); } // CraftBukkit end @@ -577,7 +668,7 @@ public abstract class EntityLiving extends Entity { public void a(float f, float f1) { double d0; - if (this.ao()) { + if (this.az()) { d0 = this.locY; this.a(f, f1, 0.02F); this.move(this.motX, this.motY, this.motZ); @@ -588,7 +679,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.ap()) { + } else if (this.aA()) { d0 = this.locY; this.a(f, f1, 0.02F); this.move(this.motX, this.motY, this.motZ); @@ -612,7 +703,7 @@ public abstract class EntityLiving extends Entity { } float f3 = 0.16277136F / (f2 * f2 * f2); - float f4 = this.onGround ? this.aj * f3 : this.ak; + float f4 = this.onGround ? this.ak * f3 : this.al; this.a(f, f1, f4); f2 = 0.91F; @@ -625,7 +716,7 @@ public abstract class EntityLiving extends Entity { } } - if (this.p()) { + if (this.r()) { float f5 = 0.15F; if (this.motX < (double) (-f5)) { @@ -655,7 +746,7 @@ public abstract class EntityLiving extends Entity { } this.move(this.motX, this.motY, this.motZ); - if (this.positionChanged && this.p()) { + if (this.positionChanged && this.r()) { this.motY = 0.2D; } @@ -665,7 +756,7 @@ public abstract class EntityLiving extends Entity { this.motZ *= (double) f2; } - this.aA = this.aB; + this.aC = this.aD; d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f6 = MathHelper.a(d0 * d0 + d1 * d1) * 4.0F; @@ -674,11 +765,11 @@ public abstract class EntityLiving extends Entity { f6 = 1.0F; } - this.aB += (f6 - this.aB) * 0.4F; - this.aC += this.aB; + this.aD += (f6 - this.aD) * 0.4F; + this.aE += this.aD; } - public boolean p() { + public boolean r() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); @@ -710,45 +801,49 @@ public abstract class EntityLiving extends Entity { } public void a(NBTTagCompound nbttagcompound) { - this.health = nbttagcompound.d("Health"); + this.health = nbttagcompound.e("Health"); if (!nbttagcompound.hasKey("Health")) { - this.health = 10; + this.health = this.getMaxHealth(); } - this.hurtTicks = nbttagcompound.d("HurtTime"); - this.deathTicks = nbttagcompound.d("DeathTime"); - this.attackTicks = nbttagcompound.d("AttackTime"); + this.hurtTicks = nbttagcompound.e("HurtTime"); + this.deathTicks = nbttagcompound.e("DeathTime"); + this.attackTicks = nbttagcompound.e("AttackTime"); if (nbttagcompound.hasKey("ActiveEffects")) { - NBTTagList nbttaglist = nbttagcompound.l("ActiveEffects"); + NBTTagList nbttaglist = nbttagcompound.m("ActiveEffects"); - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); - byte b0 = nbttagcompound1.c("Id"); - byte b1 = nbttagcompound1.c("Amplifier"); - int j = nbttagcompound1.e("Duration"); + byte b0 = nbttagcompound1.d("Id"); + byte b1 = nbttagcompound1.d("Amplifier"); + int j = nbttagcompound1.f("Duration"); this.effects.put(Integer.valueOf(b0), new MobEffect(b0, j, b1)); } } } - public boolean ac() { + public boolean aj() { return !this.dead && this.health > 0; } - public boolean b_() { + public boolean f() { return false; } - 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; + public void d() { + if (this.d > 0) { + --this.d; + } + + if (this.aK > 0) { + double d0 = this.locX + (this.aL - this.locX) / (double) this.aK; + double d1 = this.locY + (this.aM - this.locY) / (double) this.aK; + double d2 = this.locZ + (this.aN - this.locZ) / (double) this.aK; double d3; - for (d3 = this.aK - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) { + for (d3 = this.aO - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) { ; } @@ -756,9 +851,9 @@ public abstract class EntityLiving extends Entity { d3 -= 360.0D; } - 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.yaw = (float) ((double) this.yaw + d3 / (double) this.aK); + this.pitch = (float) ((double) this.pitch + (this.aP - (double) this.pitch) / (double) this.aK); + --this.aK; 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)); @@ -779,59 +874,71 @@ public abstract class EntityLiving extends Entity { } } - if (this.H()) { - this.aS = false; - this.aP = 0.0F; - this.aQ = 0.0F; - this.aR = 0.0F; - } else if (!this.ai) { - this.c_(); + MethodProfiler.a("ai"); + if (this.L()) { + this.aW = false; + this.aT = 0.0F; + this.aU = 0.0F; + this.aV = 0.0F; + } else if (!this.aj) { + this.m_(); } - boolean flag = this.ao(); - boolean flag1 = this.ap(); + MethodProfiler.a(); + boolean flag = this.az(); + boolean flag1 = this.aA(); - if (this.aS) { + if (this.aW) { if (flag) { this.motY += 0.03999999910593033D; } else if (flag1) { this.motY += 0.03999999910593033D; - } else if (this.onGround) { - this.S(); + } else if (this.onGround && this.d == 0) { + this.X(); + this.d = 10; } + } else { + this.d = 0; } - this.aP *= 0.98F; - this.aQ *= 0.98F; - this.aR *= 0.9F; - float f = this.aj; + this.aT *= 0.98F; + this.aU *= 0.98F; + this.aV *= 0.9F; + float f = this.ak; - this.aj *= this.D(); - this.a(this.aP, this.aQ); - this.aj = f; + this.ak *= this.F(); + this.a(this.aT, this.aU); + this.ak = f; + MethodProfiler.a("push"); 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.g()) { + if (entity.f_()) { entity.collide(this); } } } + + MethodProfiler.a(); } - protected boolean H() { + protected boolean L() { return this.health <= 0; } - public boolean G() { + public boolean K() { return false; } - protected void S() { + protected void X() { this.motY = 0.41999998688697815D; + if (this.hasEffect(MobEffectList.JUMP)) { + this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); + } + if (this.isSprinting()) { float f = this.yaw * 0.017453292F; @@ -839,78 +946,76 @@ public abstract class EntityLiving extends Entity { this.motZ += (double) (MathHelper.cos(f) * 0.2F); } - this.ca = true; + this.cb = true; } protected boolean d_() { return true; } - protected void ad() { + protected void ak() { EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - if (this.d_() && entityhuman != null) { + if (entityhuman != null) { double d0 = entityhuman.locX - this.locX; double d1 = entityhuman.locY - this.locY; double d2 = entityhuman.locZ - this.locZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; - if (d3 > 16384.0D) { + if (this.d_() && d3 > 16384.0D) { this.die(); } - if (this.aO > 600 && this.random.nextInt(800) == 0) { - if (d3 < 1024.0D) { - this.aO = 0; - } else { - this.die(); - } + if (this.aS > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.d_()) { + this.die(); + } else if (d3 < 1024.0D) { + this.aS = 0; } } } - protected void c_() { - ++this.aO; + protected void m_() { + ++this.aS; EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - this.ad(); - this.aP = 0.0F; - this.aQ = 0.0F; + this.ak(); + this.aT = 0.0F; + this.aU = 0.0F; float f = 8.0F; if (this.random.nextFloat() < 0.02F) { entityhuman = this.world.findNearbyPlayer(this, (double) f); if (entityhuman != null) { - this.d = entityhuman; - this.aV = 10 + this.random.nextInt(20); + this.e = entityhuman; + this.aZ = 10 + this.random.nextInt(20); } else { - this.aR = (this.random.nextFloat() - 0.5F) * 20.0F; + this.aV = (this.random.nextFloat() - 0.5F) * 20.0F; } } - 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; + if (this.e != null) { + this.a(this.e, 10.0F, (float) this.q_()); + if (this.aZ-- <= 0 || this.e.dead || this.e.i(this) > (double) (f * f)) { + this.e = null; } } else { if (this.random.nextFloat() < 0.05F) { - this.aR = (this.random.nextFloat() - 0.5F) * 20.0F; + this.aV = (this.random.nextFloat() - 0.5F) * 20.0F; } - this.yaw += this.aR; - this.pitch = this.aT; + this.yaw += this.aV; + this.pitch = this.aX; } - boolean flag = this.ao(); - boolean flag1 = this.ap(); + boolean flag = this.az(); + boolean flag1 = this.aA(); if (flag || flag1) { - this.aS = this.random.nextFloat() < 0.8F; + this.aW = this.random.nextFloat() < 0.8F; } } - protected int u() { + protected int q_() { return 40; } @@ -922,9 +1027,9 @@ public abstract class EntityLiving extends Entity { if (entity instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) entity; - d2 = this.locY + (double) this.t() - (entityliving.locY + (double) entityliving.t()); + d2 = this.locY + (double) this.x() - (entityliving.locY + (double) entityliving.x()); } else { - d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.t()); + d2 = (entity.boundingBox.b + entity.boundingBox.e) / 2.0D - (this.locY + (double) this.x()); } double d3 = (double) MathHelper.a(d0 * d0 + d1 * d1); @@ -935,12 +1040,12 @@ public abstract class EntityLiving extends Entity { this.yaw = this.b(this.yaw, f2, f); } - public boolean ae() { - return this.d != null; + public boolean al() { + return this.e != null; } - public Entity af() { - return this.d; + public Entity am() { + return this.e; } private float b(float f, float f1, float f2) { @@ -965,13 +1070,13 @@ public abstract class EntityLiving extends Entity { return f + f3; } - public void ag() {} + public void an() {} - public boolean d() { + public boolean g() { return this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox); } - protected void ah() { + protected void ao() { // CraftBukkit start EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.VOID, 4); this.world.getServer().getPluginManager().callEvent(event); @@ -984,11 +1089,11 @@ public abstract class EntityLiving extends Entity { // CraftBukkit end } - public Vec3D ai() { - return this.c(1.0F); + public Vec3D ap() { + return this.d(1.0F); } - public Vec3D c(float f) { + public Vec3D d(float f) { float f1; float f2; float f3; @@ -1012,7 +1117,7 @@ public abstract class EntityLiving extends Entity { } } - public int m() { + public int p() { return 4; } @@ -1020,7 +1125,7 @@ public abstract class EntityLiving extends Entity { return false; } - protected void aj() { + protected void aq() { Iterator iterator = this.effects.keySet().iterator(); while (iterator.hasNext()) { @@ -1029,7 +1134,47 @@ public abstract class EntityLiving extends Entity { if (!mobeffect.tick(this) && !this.world.isStatic) { iterator.remove(); - this.c(mobeffect); + this.d(mobeffect); + } + } + + int i; + + if (this.b) { + if (!this.world.isStatic) { + if (!this.effects.isEmpty()) { + i = PotionBrewer.a(this.effects.values()); + this.datawatcher.watch(8, Integer.valueOf(i)); + } else { + this.datawatcher.watch(8, Integer.valueOf(0)); + } + } + + this.b = false; + } + + if (this.random.nextBoolean()) { + i = this.datawatcher.getInt(8); + if (i > 0) { + double d0 = (double) (i >> 16 & 255) / 255.0D; + double d1 = (double) (i >> 8 & 255) / 255.0D; + double d2 = (double) (i >> 0 & 255) / 255.0D; + + this.world.a("mobSpell", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.length, this.locY + this.random.nextDouble() * (double) this.width - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.length, d0, d1, d2); + } + } + } + + public void ar() { + Iterator iterator = this.effects.keySet().iterator(); + + while (iterator.hasNext()) { + Integer integer = (Integer) iterator.next(); + MobEffect mobeffect = (MobEffect) this.effects.get(integer); + + if (!this.world.isStatic) { + iterator.remove(); + this.d(mobeffect); } } } @@ -1047,22 +1192,46 @@ public abstract class EntityLiving extends Entity { } public void addEffect(MobEffect mobeffect) { - if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { - ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect); - this.b((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))); - } else { - this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); - this.a(mobeffect); + if (this.a(mobeffect)) { + if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) { + ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect); + this.c((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))); + } else { + this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); + this.b(mobeffect); + } } } - protected void a(MobEffect mobeffect) {} + public boolean a(MobEffect mobeffect) { + if (this.t() == EnchantmentDamage.b) { + int i = mobeffect.getEffectId(); - protected void b(MobEffect mobeffect) {} + if (i == MobEffectList.REGENERATION.id || i == MobEffectList.POISON.id) { + return false; + } + } - protected void c(MobEffect mobeffect) {} + return true; + } + + public boolean at() { + return this.t() == EnchantmentDamage.b; + } + + protected void b(MobEffect mobeffect) { + this.b = true; + } - protected float D() { + protected void c(MobEffect mobeffect) { + this.b = true; + } + + protected void d(MobEffect mobeffect) { + this.b = true; + } + + protected float F() { float f = 1.0F; if (this.hasEffect(MobEffectList.FASTER_MOVEMENT)) { @@ -1075,4 +1244,33 @@ public abstract class EntityLiving extends Entity { return f; } + + public void a_(double d0, double d1, double d2) { + this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); + } + + public boolean l() { + return false; + } + + public EnchantmentDamage t() { + return EnchantmentDamage.a; + } + + public void c(ItemStack itemstack) { + this.world.makeSound(this, "random.break", 0.8F, 0.8F + this.world.random.nextFloat() * 0.4F); + + for (int i = 0; i < 5; ++i) { + 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.x(), this.locZ); + this.world.a("iconcrack_" + itemstack.getItem().id, vec3d1.a, vec3d1.b, vec3d1.c, vec3d.a, vec3d.b + 0.05D, vec3d.c); + } + } } diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 5cce3667..74aafbeb 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -17,21 +17,18 @@ import org.bukkit.event.vehicle.VehicleUpdateEvent; public class EntityMinecart extends Entity implements IInventory { private ItemStack[] items; - public int damage; - public int b; - public int c; - private boolean i; + private int e; + private boolean f; public int type; - public int e; - public double f; - public double g; + public double b; + public double c; private static final int[][][] matrix = new int[][][] { { { 0, 0, -1}, { 0, 0, 1}}, { { -1, 0, 0}, { 1, 0, 0}}, { { -1, -1, 0}, { 1, 0, 0}}, { { -1, 0, 0}, { 1, -1, 0}}, { { 0, 0, -1}, { 0, -1, 1}}, { { 0, -1, -1}, { 0, 0, 1}}, { { 0, 0, 1}, { 1, 0, 0}}, { { 0, 0, 1}, { -1, 0, 0}}, { { 0, 0, -1}, { -1, 0, 0}}, { { 0, 0, -1}, { 1, 0, 0}}}; - private int k; + private int h; + private double i; + private double j; + private double k; private double l; private double m; - private double n; - private double o; - private double p; // CraftBukkit start public boolean slowWhenEmpty = true; @@ -51,30 +48,33 @@ public class EntityMinecart extends Entity implements IInventory { public EntityMinecart(World world) { super(world); this.items = new ItemStack[27]; // CraftBukkit - this.damage = 0; - this.b = 0; - this.c = 1; - this.i = false; - this.aY = true; + this.e = 0; + this.f = false; + this.bc = true; this.b(0.98F, 0.7F); this.height = this.width / 2.0F; } - protected boolean e_() { + protected boolean g_() { return false; } - protected void b() {} + protected void b() { + this.datawatcher.a(16, new Byte((byte) 0)); + this.datawatcher.a(17, new Integer(0)); + this.datawatcher.a(18, new Integer(1)); + this.datawatcher.a(19, new Integer(0)); + } - public AxisAlignedBB b(Entity entity) { + public AxisAlignedBB a_(Entity entity) { return entity.boundingBox; } - public AxisAlignedBB f() { + public AxisAlignedBB h_() { return null; } - public boolean g() { + public boolean f_() { return true; } @@ -92,7 +92,7 @@ public class EntityMinecart extends Entity implements IInventory { this.world.getServer().getPluginManager().callEvent(new VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit } - public double n() { + public double q() { return (double) this.width * 0.0D - 0.30000001192092896D; } @@ -112,11 +112,11 @@ public class EntityMinecart extends Entity implements IInventory { i = event.getDamage(); // CraftBukkit end - this.c = -this.c; - this.b = 10; - this.aq(); - this.damage += i * 10; - if (this.damage > 40) { + this.d(-this.m()); + this.c(10); + this.aB(); + this.setDamage(this.getDamage() + i * 10); + if (this.getDamage() > 40) { if (this.passenger != null) { this.passenger.mount(this); } @@ -126,7 +126,7 @@ public class EntityMinecart extends Entity implements IInventory { this.world.getServer().getPluginManager().callEvent(destroyEvent); if (destroyEvent.isCancelled()) { - this.damage = 40; // Maximize damage so this doesn't get triggered again right away + this.setDamage(40); // Maximize damage so this doesn't get triggered again right away return true; } // CraftBukkit end @@ -175,7 +175,7 @@ public class EntityMinecart extends Entity implements IInventory { } } - public boolean r_() { + public boolean e_() { return !this.dead; } @@ -210,7 +210,7 @@ public class EntityMinecart extends Entity implements IInventory { super.die(); } - public void s_() { + public void w_() { // CraftBukkit start double prevX = this.locX; double prevY = this.locY; @@ -219,34 +219,38 @@ public class EntityMinecart extends Entity implements IInventory { float prevPitch = this.pitch; // CraftBukkit end - if (this.b > 0) { - --this.b; + if (this.l() > 0) { + this.c(this.l() - 1); + } + + if (this.getDamage() > 0) { + this.setDamage(this.getDamage() - 1); } - if (this.damage > 0) { - --this.damage; + if (this.j() && this.random.nextInt(4) == 0) { + this.world.a("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D); } - double d0; + if (this.world.isStatic) { + if (this.h > 0) { + double d0 = this.locX + (this.i - this.locX) / (double) this.h; + double d1 = this.locY + (this.j - this.locY) / (double) this.h; + double d2 = this.locZ + (this.k - this.locZ) / (double) this.h; - if (this.world.isStatic && this.k > 0) { - if (this.k > 0) { - double d1 = this.locX + (this.l - this.locX) / (double) this.k; - double d2 = this.locY + (this.m - this.locY) / (double) this.k; - double d3 = this.locZ + (this.n - this.locZ) / (double) this.k; + double d3; - for (d0 = this.o - (double) this.yaw; d0 < -180.0D; d0 += 360.0D) { + for (d3 = this.l - (double) this.yaw; d3 < -180.0D; d3 += 360.0D) { ; } - while (d0 >= 180.0D) { - d0 -= 360.0D; + while (d3 >= 180.0D) { + d3 -= 360.0D; } - this.yaw = (float) ((double) this.yaw + d0 / (double) this.k); - this.pitch = (float) ((double) this.pitch + (this.p - (double) this.pitch) / (double) this.k); - --this.k; - this.setPosition(d1, d2, d3); + this.yaw = (float) ((double) this.yaw + d3 / (double) this.h); + this.pitch = (float) ((double) this.pitch + (this.m - (double) this.pitch) / (double) this.h); + --this.h; + this.setPosition(d0, d1, d2); this.c(this.yaw, this.pitch); } else { this.setPosition(this.locX, this.locY, this.locZ); @@ -267,25 +271,23 @@ public class EntityMinecart extends Entity implements IInventory { // CraftBukkit double d4 = this.maxSpeed; - boolean flag = false; - - d0 = 0.0078125D; + double d5 = 0.0078125D; int l = this.world.getTypeId(i, j, k); - if (BlockMinecartTrack.c(l)) { + if (BlockMinecartTrack.d(l)) { Vec3D vec3d = this.h(this.locX, this.locY, this.locZ); int i1 = this.world.getData(i, j, k); this.locY = (double) j; + boolean flag = false; boolean flag1 = false; - boolean flag2 = false; if (l == Block.GOLDEN_RAIL.id) { - flag1 = (i1 & 8) != 0; - flag2 = !flag1; + flag = (i1 & 8) != 0; + flag1 = !flag; } - if (((BlockMinecartTrack) Block.byId[l]).f()) { + if (((BlockMinecartTrack) Block.byId[l]).h()) { i1 &= 7; } @@ -294,41 +296,41 @@ public class EntityMinecart extends Entity implements IInventory { } if (i1 == 2) { - this.motX -= d0; + this.motX -= d5; } if (i1 == 3) { - this.motX += d0; + this.motX += d5; } if (i1 == 4) { - this.motZ += d0; + this.motZ += d5; } if (i1 == 5) { - this.motZ -= d0; + this.motZ -= d5; } int[][] aint = matrix[i1]; - double d5 = (double) (aint[1][0] - aint[0][0]); - double d6 = (double) (aint[1][2] - aint[0][2]); - double d7 = Math.sqrt(d5 * d5 + d6 * d6); - double d8 = this.motX * d5 + this.motZ * d6; + double d6 = (double) (aint[1][0] - aint[0][0]); + double d7 = (double) (aint[1][2] - aint[0][2]); + double d8 = Math.sqrt(d6 * d6 + d7 * d7); + double d9 = this.motX * d6 + this.motZ * d7; - if (d8 < 0.0D) { - d5 = -d5; + if (d9 < 0.0D) { d6 = -d6; + d7 = -d7; } - double d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + double d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - this.motX = d9 * d5 / d7; - this.motZ = d9 * d6 / d7; - double d10; + this.motX = d10 * d6 / d8; + this.motZ = d10 * d7 / d8; + double d11; - if (flag2) { - d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d10 < 0.03D) { + if (flag1) { + d11 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + if (d11 < 0.03D) { this.motX *= 0.0D; this.motY *= 0.0D; this.motZ *= 0.0D; @@ -339,39 +341,39 @@ public class EntityMinecart extends Entity implements IInventory { } } - d10 = 0.0D; - double d11 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; - double d12 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; - double d13 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; - double d14 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; + d11 = 0.0D; + double d12 = (double) i + 0.5D + (double) aint[0][0] * 0.5D; + double d13 = (double) k + 0.5D + (double) aint[0][2] * 0.5D; + double d14 = (double) i + 0.5D + (double) aint[1][0] * 0.5D; + double d15 = (double) k + 0.5D + (double) aint[1][2] * 0.5D; - d5 = d13 - d11; d6 = d14 - d12; - double d15; + d7 = d15 - d13; double d16; double d17; + double d18; - if (d5 == 0.0D) { + if (d6 == 0.0D) { this.locX = (double) i + 0.5D; - d10 = this.locZ - (double) k; - } else if (d6 == 0.0D) { + d11 = this.locZ - (double) k; + } else if (d7 == 0.0D) { this.locZ = (double) k + 0.5D; - d10 = this.locX - (double) i; + d11 = this.locX - (double) i; } else { - d16 = this.locX - d11; - d15 = this.locZ - d12; - d17 = (d16 * d5 + d15 * d6) * 2.0D; - d10 = d17; + d16 = this.locX - d12; + d18 = this.locZ - d13; + d17 = (d16 * d6 + d18 * d7) * 2.0D; + d11 = d17; } - this.locX = d11 + d5 * d10; - this.locZ = d12 + d6 * d10; + this.locX = d12 + d6 * d11; + this.locZ = d13 + d7 * d11; this.setPosition(this.locX, this.locY + (double) this.height, this.locZ); d16 = this.motX; - d15 = this.motZ; + d18 = this.motZ; if (this.passenger != null) { d16 *= 0.75D; - d15 *= 0.75D; + d18 *= 0.75D; } if (d16 < -d4) { @@ -382,15 +384,15 @@ public class EntityMinecart extends Entity implements IInventory { d16 = d4; } - if (d15 < -d4) { - d15 = -d4; + if (d18 < -d4) { + d18 = -d4; } - if (d15 > d4) { - d15 = d4; + if (d18 > d4) { + d18 = d4; } - this.move(d16, 0.0D, d15); + this.move(d16, 0.0D, d18); if (aint[0][1] != 0 && MathHelper.floor(this.locX) - i == aint[0][0] && MathHelper.floor(this.locZ) - k == aint[0][2]) { this.setPosition(this.locX, this.locY + (double) aint[0][1], this.locZ); } else if (aint[1][1] != 0 && MathHelper.floor(this.locX) - i == aint[1][0] && MathHelper.floor(this.locZ) - k == aint[1][2]) { @@ -404,18 +406,17 @@ public class EntityMinecart extends Entity implements IInventory { this.motZ *= 0.996999979019165D; } else { if (this.type == 2) { - d17 = (double) MathHelper.a(this.f * this.f + this.g * this.g); + d17 = (double) MathHelper.a(this.b * this.b + this.c * this.c); if (d17 > 0.01D) { - flag = true; - this.f /= d17; - this.g /= d17; - double d18 = 0.04D; + this.b /= d17; + this.c /= d17; + double d19 = 0.04D; this.motX *= 0.800000011920929D; this.motY *= 0.0D; this.motZ *= 0.800000011920929D; - this.motX += this.f * d18; - this.motZ += this.g * d18; + this.motX += this.b * d19; + this.motZ += this.c * d19; } else { this.motX *= 0.8999999761581421D; this.motY *= 0.0D; @@ -431,12 +432,12 @@ public class EntityMinecart extends Entity implements IInventory { Vec3D vec3d1 = this.h(this.locX, this.locY, this.locZ); if (vec3d1 != null && vec3d != null) { - double d19 = (vec3d.b - vec3d1.b) * 0.05D; + double d20 = (vec3d.b - vec3d1.b) * 0.05D; - d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d9 > 0.0D) { - this.motX = this.motX / d9 * (d9 + d19); - this.motZ = this.motZ / d9 * (d9 + d19); + d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + if (d10 > 0.0D) { + this.motX = this.motX / d10 * (d10 + d20); + this.motZ = this.motZ / d10 * (d10 + d20); } this.setPosition(this.locX, vec3d1.b, this.locZ); @@ -446,35 +447,35 @@ public class EntityMinecart extends Entity implements IInventory { int k1 = MathHelper.floor(this.locZ); if (j1 != i || k1 != k) { - d9 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - this.motX = d9 * (double) (j1 - i); - this.motZ = d9 * (double) (k1 - k); + d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + this.motX = d10 * (double) (j1 - i); + this.motZ = d10 * (double) (k1 - k); } - double d20; + double d21; if (this.type == 2) { - d20 = (double) MathHelper.a(this.f * this.f + this.g * this.g); - if (d20 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) { - this.f /= d20; - this.g /= d20; - if (this.f * this.motX + this.g * this.motZ < 0.0D) { - this.f = 0.0D; - this.g = 0.0D; + d21 = (double) MathHelper.a(this.b * this.b + this.c * this.c); + if (d21 > 0.01D && this.motX * this.motX + this.motZ * this.motZ > 0.0010D) { + this.b /= d21; + this.c /= d21; + if (this.b * this.motX + this.c * this.motZ < 0.0D) { + this.b = 0.0D; + this.c = 0.0D; } else { - this.f = this.motX; - this.g = this.motZ; + this.b = this.motX; + this.c = this.motZ; } } } - if (flag1) { - d20 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); - if (d20 > 0.01D) { - double d21 = 0.06D; + if (flag) { + d21 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); + if (d21 > 0.01D) { + double d22 = 0.06D; - this.motX += this.motX / d20 * d21; - this.motZ += this.motZ / d20 * d21; + this.motX += this.motX / d21 * d22; + this.motZ += this.motZ / d21 * d22; } else if (i1 == 1) { if (this.world.e(i - 1, j, k)) { this.motX = 0.02D; @@ -525,29 +526,29 @@ public class EntityMinecart extends Entity implements IInventory { } this.pitch = 0.0F; - double d22 = this.lastX - this.locX; - double d23 = this.lastZ - this.locZ; + double d23 = this.lastX - this.locX; + double d24 = this.lastZ - this.locZ; - if (d22 * d22 + d23 * d23 > 0.0010D) { - this.yaw = (float) (Math.atan2(d23, d22) * 180.0D / 3.141592653589793D); - if (this.i) { + if (d23 * d23 + d24 * d24 > 0.0010D) { + this.yaw = (float) (Math.atan2(d24, d23) * 180.0D / 3.141592653589793D); + if (this.f) { this.yaw += 180.0F; } } - double d24; + double d25; - for (d24 = (double) (this.yaw - this.lastYaw); d24 >= 180.0D; d24 -= 360.0D) { + for (d25 = (double) (this.yaw - this.lastYaw); d25 >= 180.0D; d25 -= 360.0D) { ; } - while (d24 < -180.0D) { - d24 += 360.0D; + while (d25 < -180.0D) { + d25 += 360.0D; } - if (d24 < -170.0D || d24 >= 170.0D) { + if (d25 < -170.0D || d25 >= 170.0D) { this.yaw += 180.0F; - this.i = !this.i; + this.f = !this.f; } this.c(this.yaw, this.pitch); @@ -571,25 +572,29 @@ 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.g() && entity instanceof EntityMinecart) { + if (entity != this.passenger && entity.f_() && entity instanceof EntityMinecart) { entity.collide(this); } } } if (this.passenger != null && this.passenger.dead) { - this.passenger.vehicle = null; // CraftBukkit + if (this.passenger.vehicle == this) { + this.passenger.vehicle = null; + } + this.passenger = null; } - if (flag && this.random.nextInt(4) == 0) { + if (this.e > 0) { --this.e; - if (this.e < 0) { - this.f = this.g = 0.0D; - } + } - this.world.a("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D); + if (this.e <= 0) { + this.b = this.c = 0.0D; } + + this.a(this.e > 0); } } @@ -604,11 +609,11 @@ public class EntityMinecart extends Entity implements IInventory { int l = this.world.getTypeId(i, j, k); - if (BlockMinecartTrack.c(l)) { + if (BlockMinecartTrack.d(l)) { int i1 = this.world.getData(i, j, k); d1 = (double) j; - if (((BlockMinecartTrack) Block.byId[l]).f()) { + if (((BlockMinecartTrack) Block.byId[l]).h()) { i1 &= 7; } @@ -662,8 +667,8 @@ public class EntityMinecart extends Entity implements IInventory { protected void b(NBTTagCompound nbttagcompound) { nbttagcompound.a("Type", this.type); if (this.type == 2) { - nbttagcompound.a("PushX", this.f); - nbttagcompound.a("PushZ", this.g); + nbttagcompound.a("PushX", this.b); + nbttagcompound.a("PushZ", this.c); nbttagcompound.a("Fuel", (short) this.e); } else if (this.type == 1) { NBTTagList nbttaglist = new NBTTagList(); @@ -683,19 +688,19 @@ public class EntityMinecart extends Entity implements IInventory { } protected void a(NBTTagCompound nbttagcompound) { - this.type = nbttagcompound.e("Type"); + this.type = nbttagcompound.f("Type"); if (this.type == 2) { - this.f = nbttagcompound.h("PushX"); - this.g = nbttagcompound.h("PushZ"); - this.e = nbttagcompound.d("Fuel"); + this.b = nbttagcompound.i("PushX"); + this.c = nbttagcompound.i("PushZ"); + this.e = nbttagcompound.e("Fuel"); } else if (this.type == 1) { - NBTTagList nbttaglist = nbttagcompound.l("Items"); + NBTTagList nbttaglist = nbttagcompound.m("Items"); this.items = new ItemStack[this.getSize()]; - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); - int j = nbttagcompound1.c("Slot") & 255; + int j = nbttagcompound1.d("Slot") & 255; if (j >= 0 && j < this.items.length) { this.items[j] = ItemStack.a(nbttagcompound1); @@ -749,17 +754,18 @@ public class EntityMinecart extends Entity implements IInventory { d1 *= d3; d0 *= 0.10000000149011612D; d1 *= 0.10000000149011612D; - d0 *= (double) (1.0F - this.bK); - d1 *= (double) (1.0F - this.bK); + d0 *= (double) (1.0F - this.bO); + d1 *= (double) (1.0F - this.bO); d0 *= 0.5D; d1 *= 0.5D; if (entity instanceof EntityMinecart) { double d4 = entity.locX - this.locX; double d5 = entity.locZ - this.locZ; - double d6 = d4 * entity.motZ + d5 * entity.lastX; + Vec3D vec3d = Vec3D.create(d4, 0.0D, d5).b(); + Vec3D vec3d1 = Vec3D.create((double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F), 0.0D, (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F)).b(); + double d6 = Math.abs(vec3d.a(vec3d1)); - d6 *= d6; - if (d6 > 5.0D) { + if (d6 < 0.800000011920929D) { return; } @@ -769,28 +775,28 @@ public class EntityMinecart extends Entity implements IInventory { if (((EntityMinecart) entity).type == 2 && this.type != 2) { this.motX *= 0.20000000298023224D; this.motZ *= 0.20000000298023224D; - this.b(entity.motX - d0, 0.0D, entity.motZ - d1); - entity.motX *= 0.699999988079071D; - entity.motZ *= 0.699999988079071D; + this.b_(entity.motX - d0, 0.0D, entity.motZ - d1); + entity.motX *= 0.949999988079071D; + entity.motZ *= 0.949999988079071D; } else if (((EntityMinecart) entity).type != 2 && this.type == 2) { entity.motX *= 0.20000000298023224D; entity.motZ *= 0.20000000298023224D; - entity.b(this.motX + d0, 0.0D, this.motZ + d1); - this.motX *= 0.699999988079071D; - this.motZ *= 0.699999988079071D; + entity.b_(this.motX + d0, 0.0D, this.motZ + d1); + this.motX *= 0.949999988079071D; + this.motZ *= 0.949999988079071D; } else { d7 /= 2.0D; d8 /= 2.0D; this.motX *= 0.20000000298023224D; this.motZ *= 0.20000000298023224D; - this.b(d7 - d0, 0.0D, d8 - d1); + this.b_(d7 - d0, 0.0D, d8 - d1); entity.motX *= 0.20000000298023224D; entity.motZ *= 0.20000000298023224D; - entity.b(d7 + d0, 0.0D, d8 + d1); + entity.b_(d7 + d0, 0.0D, d8 + d1); } } else { - this.b(-d0, 0.0D, -d1); - entity.b(d0 / 4.0D, 0.0D, d1 / 4.0D); + this.b_(-d0, 0.0D, -d1); + entity.b_(d0 / 4.0D, 0.0D, d1 / 4.0D); } } } @@ -875,21 +881,57 @@ public class EntityMinecart extends Entity implements IInventory { entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); } - this.e += 1200; + this.e += 3600; } - this.f = this.locX - entityhuman.locX; - this.g = this.locZ - entityhuman.locZ; + this.b = this.locX - entityhuman.locX; + this.c = this.locZ - entityhuman.locZ; } return true; } public boolean a(EntityHuman entityhuman) { - return this.dead ? false : entityhuman.h(this) <= 64.0D; + return this.dead ? false : entityhuman.i(this) <= 64.0D; + } + + protected boolean j() { + return (this.datawatcher.getByte(16) & 1) != 0; } - public void e() {} + protected void a(boolean flag) { + if (flag) { + this.datawatcher.watch(16, Byte.valueOf((byte) (this.datawatcher.getByte(16) | 1))); + } else { + this.datawatcher.watch(16, Byte.valueOf((byte) (this.datawatcher.getByte(16) & -2))); + } + } + + public void f() {} + + public void g() {} + + public void setDamage(int i) { + this.datawatcher.watch(19, Integer.valueOf(i)); + } + + public int getDamage() { + return this.datawatcher.getInt(19); + } + + public void c(int i) { + this.datawatcher.watch(17, Integer.valueOf(i)); + } + + public int l() { + return this.datawatcher.getInt(17); + } + + public void d(int i) { + this.datawatcher.watch(18, Integer.valueOf(i)); + } - public void t_() {} + public int m() { + return this.datawatcher.getInt(18); + } } diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java index 2edf909f..79600d57 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -13,31 +13,30 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { public EntityMonster(World world) { super(world); - this.health = 20; - this.ax = 5; + this.az = 5; } - public void s() { - float f = this.a_(1.0F); + public void d() { + float f = this.a(1.0F); if (f > 0.5F) { - this.aO += 2; + this.aS += 2; } - super.s(); + super.d(); } - public void s_() { - super.s_(); + public void w_() { + super.w_(); if (!this.world.isStatic && this.world.difficulty == 0) { this.die(); } } protected Entity findTarget() { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, 16.0D); + EntityHuman entityhuman = this.world.b(this, 16.0D); - return entityhuman != null && this.f(entityhuman) ? entityhuman : null; + return entityhuman != null && this.g(entityhuman) ? entityhuman : null; } public boolean damageEntity(DamageSource damagesource, int i) { @@ -71,7 +70,17 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { } } - protected boolean c(Entity entity) { + protected boolean d(Entity entity) { + int i = this.damage; + + if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) { + i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); + } + + if (this.hasEffect(MobEffectList.WEAKNESS)) { + i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier(); + } + // 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. @@ -80,22 +89,23 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(this.getBukkitEntity(), damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, this.damage); this.world.getServer().getPluginManager().callEvent(event); + i = event.getDamage(); if (!event.isCancelled()) { - return entity.damageEntity(DamageSource.mobAttack(this), event.getDamage()); + return entity.damageEntity(DamageSource.mobAttack(this), i); } return false; } // CraftBukkit end - return entity.damageEntity(DamageSource.mobAttack((EntityLiving) this), this.damage); + return entity.damageEntity(DamageSource.mobAttack(this), i); } 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; - this.c(entity); + this.d(entity); } } @@ -111,7 +121,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { super.a(nbttagcompound); } - public boolean d() { + protected boolean y() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); @@ -121,7 +131,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { } else { int l = this.world.getLightLevel(i, j, k); - if (this.world.t()) { + if (this.world.v()) { int i1 = this.world.k; this.world.k = 10; @@ -129,7 +139,11 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { this.world.k = i1; } - return l <= this.random.nextInt(8) && super.d(); + return l <= this.random.nextInt(8); } } + + public boolean g() { + return this.y() && super.g(); + } } diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java index c0441a8e..7ab4def7 100644 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ b/src/main/java/net/minecraft/server/EntityPainting.java @@ -43,7 +43,7 @@ public class EntityPainting extends Entity { this.e = enumart; this.b(l); - if (this.i()) { + if (this.j()) { arraylist.add(enumart); } } @@ -121,10 +121,10 @@ public class EntityPainting extends Entity { return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); } - public void s_() { + public void w_() { if (this.f++ == 100 && !this.world.isStatic) { this.f = 0; - if (!this.i()) { + if (!this.j()) { // CraftBukkit start Material material = this.world.getMaterial((int)this.locX, (int)this.locY, (int)this.locZ); RemoveCause cause; @@ -152,7 +152,7 @@ public class EntityPainting extends Entity { } } - public boolean i() { + public boolean j() { if (this.world.getEntities(this, this.boundingBox).size() > 0) { return false; } else { @@ -210,7 +210,7 @@ public class EntityPainting extends Entity { } } - public boolean r_() { + public boolean e_() { return true; } @@ -234,12 +234,12 @@ public class EntityPainting extends Entity { } } - if(!dead) { - this.die(); - this.aq(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } + if (dead) return true; // CraftBukkit end + + this.die(); + this.aB(); + this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); } return true; @@ -259,7 +259,7 @@ public class EntityPainting extends Entity { ++this.fireTicks; if (this.fireTicks == 0) { - this.fireTicks = 300; + this.j(8); } } // CraftBukkit end @@ -273,10 +273,10 @@ public class EntityPainting extends Entity { } public void a(NBTTagCompound nbttagcompound) { - this.a = nbttagcompound.c("Dir"); - this.b = nbttagcompound.e("TileX"); - this.c = nbttagcompound.e("TileY"); - this.d = nbttagcompound.e("TileZ"); + this.a = nbttagcompound.d("Dir"); + this.b = nbttagcompound.f("TileX"); + this.c = nbttagcompound.f("TileY"); + this.d = nbttagcompound.f("TileZ"); String s = nbttagcompound.getString("Motive"); EnumArt[] aenumart = EnumArt.values(); int i = aenumart.length; @@ -298,25 +298,19 @@ public class EntityPainting extends Entity { public void move(double d0, double d1, double d2) { if (!this.world.isStatic && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (dead) return; // CraftBukkit - // CraftBukkit start - if(!dead) { - this.die(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } - // CraftBukkit end + this.die(); + this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); } } - public void b(double d0, double d1, double d2) { + public void b_(double d0, double d1, double d2) { if (!this.world.isStatic && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (dead) return; // CraftBukkit - // CraftBukkit start - if(!dead) { - this.die(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } - // CraftBukkit end + 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 c4c00194..8c6829f8 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -13,7 +13,12 @@ public class EntityPig extends EntityAnimal { this.b(0.9F, 0.9F); } + public int getMaxHealth() { + return 10; + } + protected void b() { + super.b(); this.datawatcher.a(16, Byte.valueOf((byte) 0)); } @@ -24,23 +29,25 @@ public class EntityPig extends EntityAnimal { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.setSaddle(nbttagcompound.m("Saddle")); + this.setSaddle(nbttagcompound.n("Saddle")); } - protected String h() { + protected String c_() { return "mob.pig"; } - protected String i() { + protected String m() { return "mob.pig"; } - protected String j() { + protected String n() { return "mob.pigdeath"; } public boolean b(EntityHuman entityhuman) { - if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { + if (super.b(entityhuman)) { + return true; + } else if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { entityhuman.mount(this); return true; } else { @@ -48,8 +55,8 @@ public class EntityPig extends EntityAnimal { } } - protected int k() { - return this.fireTicks > 0 ? Item.GRILLED_PORK.id : Item.PORK.id; + protected int e() { + return this.z() ? Item.GRILLED_PORK.id : Item.PORK.id; } public boolean hasSaddle() { @@ -84,10 +91,14 @@ public class EntityPig extends EntityAnimal { } } - protected void a(float f) { - super.a(f); + protected void b(float f) { + super.b(f); if (f > 5.0F && this.passenger instanceof EntityHuman) { ((EntityHuman) this.passenger).a((Statistic) AchievementList.u); } } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + return new EntityPig(this.world); + } } diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 3c4cbd98..84c42746 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -16,21 +16,21 @@ public class EntityPigZombie extends EntityZombie { public EntityPigZombie(World world) { super(world); this.texture = "/mob/pigzombie.png"; - this.aU = 0.5F; + this.aY = 0.5F; this.damage = 5; this.fireProof = true; } - public void s_() { - this.aU = this.target != null ? 0.95F : 0.5F; + public void w_() { + this.aY = this.target != null ? 0.95F : 0.5F; if (this.soundDelay > 0 && --this.soundDelay == 0) { - this.world.makeSound(this, "mob.zombiepig.zpigangry", this.l() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); + this.world.makeSound(this, "mob.zombiepig.zpigangry", this.o() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); } - super.s_(); + super.w_(); } - public boolean d() { + public boolean g() { return this.world.difficulty > 0 && this.world.containsEntity(this.boundingBox) && this.world.getEntities(this, this.boundingBox).size() == 0 && !this.world.c(this.boundingBox); } @@ -41,15 +41,15 @@ public class EntityPigZombie extends EntityZombie { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.angerLevel = nbttagcompound.d("Anger"); + this.angerLevel = nbttagcompound.e("Anger"); } protected Entity findTarget() { return this.angerLevel == 0 ? null : super.findTarget(); } - public void s() { - super.s(); + public void d() { + super.d(); } public boolean damageEntity(DamageSource damagesource, int i) { @@ -64,17 +64,17 @@ public class EntityPigZombie extends EntityZombie { if (entity1 instanceof EntityPigZombie) { EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; - entitypigzombie.e(entity); + entitypigzombie.f(entity); } } - this.e(entity); + this.f(entity); } return super.damageEntity(damagesource, i); } - private void e(Entity entity) { + private void f(Entity entity) { // CraftBukkit start org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity(); @@ -97,19 +97,35 @@ public class EntityPigZombie extends EntityZombie { this.soundDelay = this.random.nextInt(40); } - protected String h() { + protected String c_() { return "mob.zombiepig.zpig"; } - protected String i() { + protected String m() { return "mob.zombiepig.zpighurt"; } - protected String j() { + protected String n() { return "mob.zombiepig.zpigdeath"; } - protected int k() { - return Item.GRILLED_PORK.id; + protected void a(boolean flag, int i) { + int j = this.random.nextInt(2 + i); + + int k; + + for (k = 0; k < j; ++k) { + this.b(Item.ROTTEN_FLESH.id, 1); + } + + j = this.random.nextInt(2 + i); + + for (k = 0; k < j; ++k) { + this.b(Item.GOLD_NUGGET.id, 1); + } + } + + protected int e() { + return Item.ROTTEN_FLESH.id; } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 45cc613c..2bcef14b 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -24,15 +24,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public double e; public List chunkCoordIntPairQueue = new LinkedList(); public Set playerChunkCoordIntPairs = new HashSet(); - 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; + private int cd = -99999999; + private boolean ce = true; + private int cf = -99999999; + private int cg = 60; + private ItemStack[] ch = new ItemStack[] { null, null, null, null, null}; + private int ci = 0; public boolean h; public int i; + public boolean j = false; public EntityPlayer(MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) { super(world); @@ -51,7 +52,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.bI = 0.0F; + this.bM = 0.0F; this.name = s; this.height = 0.0F; @@ -69,7 +70,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); if (nbttagcompound.hasKey("playerGameType")) { - this.itemInWorldManager.a(nbttagcompound.e("playerGameType")); + this.itemInWorldManager.a(nbttagcompound.f("playerGameType")); } } @@ -106,38 +107,43 @@ public class EntityPlayer extends EntityHuman implements ICrafting { // CraftBukkit end } + public void b(int i) { + super.b(i); + this.cf = -1; + } + public void syncInventory() { this.activeContainer.a((ICrafting) this); } public ItemStack[] getEquipment() { - return this.cg; + return this.ch; } - protected void m_() { + protected void w() { this.height = 0.0F; } - public float t() { + public float x() { return 1.62F; } - public void s_() { + public void w_() { this.itemInWorldManager.c(); - --this.cf; + --this.cg; this.activeContainer.a(); for (int i = 0; i < 5; ++i) { - ItemStack itemstack = this.b(i); + ItemStack itemstack = this.c(i); - if (itemstack != this.cg[i]) { + if (itemstack != this.ch[i]) { this.b.getTracker(this.dimension).a(this, new Packet5EntityEquipment(this.id, i, itemstack)); - this.cg[i] = itemstack; + this.ch[i] = itemstack; } } } - public ItemStack b(int i) { + public ItemStack c(int i) { return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; } @@ -179,7 +185,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public boolean damageEntity(DamageSource damagesource, int i) { - if (this.cf > 0) { + if (this.cg > 0) { return false; } else { // CraftBukkit - this.b.pvpMode -> this.world.pvpMode @@ -203,21 +209,21 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - protected boolean n_() { + protected boolean y() { return this.b.pvpMode; } - public void c(int i) { - super.c(i, RegainReason.EATING); + public void d(int i) { + super.d(i); } - public void b(boolean flag) { - super.s_(); + public void a(boolean flag) { + super.w_(); for (int i = 0; i < this.inventory.getSize(); ++i) { ItemStack itemstack = this.inventory.getItem(i); - if (itemstack != null && Item.byId[itemstack.id].i_() && this.netServerHandler.b() <= 2) { + if (itemstack != null && Item.byId[itemstack.id].n_() && this.netServerHandler.b() <= 2) { Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this); if (packet != null) { @@ -240,31 +246,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting { WorldServer worldserver = this.b.getWorldServer(this.dimension); this.chunkCoordIntPairQueue.remove(chunkcoordintpair); - NetServerHandler netserverhandler = this.netServerHandler; - - int j = chunkcoordintpair.x * 16; - int k = chunkcoordintpair.z * 16; - - worldserver.getClass(); - Packet51MapChunk packet51mapchunk = new Packet51MapChunk(j, 0, k, 16, 128, 16, worldserver); + this.netServerHandler.sendPacket(new Packet51MapChunk(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, 16, worldserver.height, 16, worldserver)); + List list = worldserver.getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, worldserver.height, chunkcoordintpair.z * 16 + 16); - 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)); + for (int j = 0; j < list.size(); ++j) { + this.a((TileEntity) list.get(j)); } } } } - if (this.I) { + if (this.J) { //if (this.b.propertyManager.getBoolean("allow-nether", true)) { // CraftBukkit if (this.activeContainer != this.defaultContainer) { this.closeInventory(); @@ -273,49 +265,80 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (this.vehicle != null) { this.mount(this.vehicle); } else { - 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.K += 0.0125F; + if (this.K >= 1.0F) { + this.K = 1.0F; + this.I = 10; + boolean flag2 = false; + byte b0; + + if (this.dimension == -1) { + b0 = 0; + } else { + b0 = -1; + } + + this.b.serverConfigurationManager.a(this, b0); + this.cf = -1; this.cc = -1; + this.cd = -1; + this.a((Statistic) AchievementList.x); } } - this.I = false; + this.J = false; //} // CraftBukkit } else { - if (this.J > 0.0F) { - this.J -= 0.05F; + if (this.K > 0.0F) { + this.K -= 0.05F; } - if (this.J < 0.0F) { - this.J = 0.0F; + if (this.K < 0.0F) { + this.K = 0.0F; } } - if (this.H > 0) { - --this.H; + if (this.I > 0) { + --this.I; + } + + if (this.getHealth() != this.cc || this.cd != this.foodData.a() || this.foodData.c() == 0.0F != this.ce) { + this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.getHealth(), this.foodData.a(), this.foodData.c())); + this.cc = this.getHealth(); + this.cd = this.foodData.a(); + this.ce = this.foodData.c() == 0.0F; } - if (this.health != this.cb || this.cc != this.foodData.a() || this.foodData.c() == 0.0F != this.cd) { - this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.health, this.foodData.a(), this.foodData.c())); - this.cb = this.health; - this.cc = this.foodData.a(); - this.cd = this.foodData.c() == 0.0F; + if (this.exp != this.cf) { + this.cf = this.exp; + this.netServerHandler.sendPacket(new Packet43SetExperience(this.expLevel, this.exp, this.expTotal)); } + } - if (this.expTotal != this.ce) { - this.ce = this.expTotal; - this.netServerHandler.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel)); + public void e(int i) { + if (this.dimension == 1 && i == 1) { + this.a((Statistic) AchievementList.C); + this.world.kill(this); + this.j = true; + this.netServerHandler.sendPacket(new Packet70Bed(4, 0)); + } else { + this.a((Statistic) AchievementList.B); + ChunkCoordinates chunkcoordinates = this.b.getWorldServer(i).d(); + + if (chunkcoordinates != null) { + this.netServerHandler.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F); + } + + this.b.serverConfigurationManager.a(this, 1); + this.cf = -1; + this.cc = -1; + this.cd = -1; } } private void a(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.l(); + Packet packet = tileentity.k(); if (packet != null) { this.netServerHandler.sendPacket(packet); @@ -344,17 +367,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.activeContainer.a(); } - public void v() { - if (!this.s) { - this.t = -1; - this.s = true; + public void r_() { + if (!this.t) { + this.u = -1; + this.t = true; EntityTracker entitytracker = this.b.getTracker(this.dimension); entitytracker.a(this, new Packet18ArmAnimation(this, 1)); } } - public void w() {} + public void A() {} public EnumBedError a(int i, int j, int k) { EnumBedError enumbederror = super.a(i, j, k); @@ -406,39 +429,55 @@ public class EntityPlayer extends EntityHuman implements ICrafting { super.a(d0, flag); } - private void au() { - this.ch = this.ch % 100 + 1; + private void aH() { + this.ci = this.ci % 100 + 1; } public void b(int i, int j, int k) { - this.au(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 1, "Crafting", 9)); + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 1, "Crafting", 9)); this.activeContainer = new ContainerWorkbench(this.inventory, this.world, i, j, k); - this.activeContainer.windowId = this.ch; + this.activeContainer.windowId = this.ci; + this.activeContainer.a((ICrafting) this); + } + + public void c(int i, int j, int k) { + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 4, "Enchanting", 9)); + this.activeContainer = new ContainerEnchantTable(this.inventory, this.world, i, j, k); + this.activeContainer.windowId = this.ci; this.activeContainer.a((ICrafting) this); } public void a(IInventory iinventory) { - this.au(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 0, iinventory.getName(), iinventory.getSize())); + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 0, iinventory.getName(), iinventory.getSize())); this.activeContainer = new ContainerChest(this.inventory, iinventory); - this.activeContainer.windowId = this.ch; + this.activeContainer.windowId = this.ci; this.activeContainer.a((ICrafting) this); } public void a(TileEntityFurnace tileentityfurnace) { - this.au(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 2, tileentityfurnace.getName(), tileentityfurnace.getSize())); + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 2, tileentityfurnace.getName(), tileentityfurnace.getSize())); this.activeContainer = new ContainerFurnace(this.inventory, tileentityfurnace); - this.activeContainer.windowId = this.ch; + this.activeContainer.windowId = this.ci; this.activeContainer.a((ICrafting) this); } public void a(TileEntityDispenser tileentitydispenser) { - this.au(); - this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ch, 3, tileentitydispenser.getName(), tileentitydispenser.getSize())); + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 3, tileentitydispenser.getName(), tileentitydispenser.getSize())); this.activeContainer = new ContainerDispenser(this.inventory, tileentitydispenser); - this.activeContainer.windowId = this.ch; + this.activeContainer.windowId = this.ci; + this.activeContainer.a((ICrafting) this); + } + + public void a(TileEntityBrewingStand tileentitybrewingstand) { + this.aH(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.ci, 5, tileentitybrewingstand.getName(), tileentitybrewingstand.getSize())); + this.activeContainer = new ContainerBrewingStand(this.inventory, tileentitybrewingstand); + this.activeContainer.windowId = this.ci; this.activeContainer.a((ICrafting) this); } @@ -467,24 +506,24 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void closeInventory() { this.netServerHandler.sendPacket(new Packet101CloseWindow(this.activeContainer.windowId)); - this.z(); + this.D(); } - public void y() { + public void C() { if (!this.h) { this.netServerHandler.sendPacket(new Packet103SetSlot(-1, -1, this.inventory.l())); } } - public void z() { + public void D() { 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.aP = f; - this.aQ = f1; - this.aS = flag; + this.aT = f; + this.aU = f1; + this.aW = flag; this.setSneak(flag1); this.pitch = f2; this.yaw = f3; @@ -503,7 +542,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void A() { + public void E() { if (this.vehicle != null) { this.mount(this.vehicle); } @@ -517,8 +556,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void B() { - this.cb = -99999999; + public void s_() { + this.cc = -99999999; } public void a(String s) { @@ -528,25 +567,20 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.netServerHandler.sendPacket(new Packet3Chat(s1)); } - protected void C() { + protected void G() { this.netServerHandler.sendPacket(new Packet38EntityStatus(this.id, (byte) 9)); - super.C(); + super.G(); } public void a(ItemStack itemstack, int i) { super.a(itemstack, i); - if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().b(itemstack) == EnumAnimation.b) { + if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d(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)); @@ -554,9 +588,30 @@ public class EntityPlayer extends EntityHuman implements ICrafting { protected void c(MobEffect mobeffect) { super.c(mobeffect); + this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect)); + } + + protected void d(MobEffect mobeffect) { + super.d(mobeffect); this.netServerHandler.sendPacket(new Packet42RemoveMobEffect(this.id, mobeffect)); } + public void a_(double d0, double d1, double d2) { + this.netServerHandler.a(d0, d1, d2, this.yaw, this.pitch); + } + + public void c(Entity entity) { + EntityTracker entitytracker = this.b.getTracker(this.dimension); + + entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6)); + } + + public void d(Entity entity) { + EntityTracker entitytracker = this.b.getTracker(this.dimension); + + entitytracker.sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7)); + } + // CraftBukkit start public long timeOffset = 0; public boolean relativeTime = true; diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java new file mode 100644 index 00000000..018580e5 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityProjectile.java @@ -0,0 +1,224 @@ +package net.minecraft.server; + +import java.util.List; + +public abstract class EntityProjectile extends Entity { + + private int blockX = -1; + private int blockY = -1; + private int blockZ = -1; + private int inBlockId = 0; + protected boolean inGround = false; + public int shake = 0; + public EntityLiving shooter; // CraftBukkit - prot to public + private int h; + private int i = 0; + + public EntityProjectile(World world) { + super(world); + this.b(0.25F, 0.25F); + } + + protected void b() {} + + public EntityProjectile(World world, EntityLiving entityliving) { + super(world); + this.shooter = entityliving; + this.b(0.25F, 0.25F); + this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.x(), entityliving.locZ, entityliving.yaw, entityliving.pitch); + this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); + this.locY -= 0.10000000149011612D; + this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); + this.setPosition(this.locX, this.locY, this.locZ); + this.height = 0.0F; + float f = 0.4F; + + this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); + this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); + this.motY = (double) (-MathHelper.sin((this.pitch + this.d()) / 180.0F * 3.1415927F) * f); + this.a(this.motX, this.motY, this.motZ, this.c(), 1.0F); + } + + public EntityProjectile(World world, double d0, double d1, double d2) { + super(world); + this.h = 0; + this.b(0.25F, 0.25F); + this.setPosition(d0, d1, d2); + this.height = 0.0F; + } + + protected float c() { + return 1.5F; + } + + protected float d() { + return 0.0F; + } + + public void a(double d0, double d1, double d2, float f, float f1) { + float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); + + d0 /= (double) f2; + d1 /= (double) f2; + d2 /= (double) f2; + d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; + d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; + d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; + d0 *= (double) f; + d1 *= (double) f; + d2 *= (double) f; + this.motX = d0; + this.motY = d1; + this.motZ = d2; + float f3 = MathHelper.a(d0 * d0 + d2 * d2); + + this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); + this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); + this.h = 0; + } + + public void w_() { + this.bI = this.locX; + this.bJ = this.locY; + this.bK = this.locZ; + super.w_(); + if (this.shake > 0) { + --this.shake; + } + + if (this.inGround) { + int i = this.world.getTypeId(this.blockX, this.blockY, this.blockZ); + + if (i == this.inBlockId) { + ++this.h; + if (this.h == 1200) { + this.die(); + } + + return; + } + + this.inGround = false; + this.motX *= (double) (this.random.nextFloat() * 0.2F); + this.motY *= (double) (this.random.nextFloat() * 0.2F); + this.motZ *= (double) (this.random.nextFloat() * 0.2F); + this.h = 0; + this.i = 0; + } else { + ++this.i; + } + + 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.a(vec3d, vec3d1); + + vec3d = Vec3D.create(this.locX, this.locY, this.locZ); + vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + if (movingobjectposition != null) { + vec3d1 = Vec3D.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); + } + + if (!this.world.isStatic) { + Entity entity = null; + List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + for (int j = 0; j < list.size(); ++j) { + Entity entity1 = (Entity) list.get(j); + + if (entity1.e_() && (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.b(movingobjectposition1.f); + + if (d1 < d0 || d0 == 0.0D) { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) { + this.a(movingobjectposition); + } + + this.locX += this.motX; + this.locY += this.motY; + this.locZ += this.motZ; + float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); + + this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); + + for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { + ; + } + + while (this.pitch - this.lastPitch >= 180.0F) { + this.lastPitch += 360.0F; + } + + while (this.yaw - this.lastYaw < -180.0F) { + this.lastYaw -= 360.0F; + } + + while (this.yaw - this.lastYaw >= 180.0F) { + this.lastYaw += 360.0F; + } + + this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; + this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; + float f2 = 0.99F; + float f3 = this.e(); + + if (this.az()) { + for (int k = 0; k < 4; ++k) { + float f4 = 0.25F; + + this.world.a("bubble", this.locX - this.motX * (double) f4, this.locY - this.motY * (double) f4, this.locZ - this.motZ * (double) f4, this.motX, this.motY, this.motZ); + } + + f2 = 0.8F; + } + + this.motX *= (double) f2; + this.motY *= (double) f2; + this.motZ *= (double) f2; + this.motY -= (double) f3; + this.setPosition(this.locX, this.locY, this.locZ); + } + + protected float e() { + return 0.03F; + } + + protected abstract void a(MovingObjectPosition movingobjectposition); + + public void b(NBTTagCompound nbttagcompound) { + nbttagcompound.a("xTile", (short) this.blockX); + nbttagcompound.a("yTile", (short) this.blockY); + nbttagcompound.a("zTile", (short) this.blockZ); + nbttagcompound.a("inTile", (byte) this.inBlockId); + nbttagcompound.a("shake", (byte) this.shake); + nbttagcompound.a("inGround", (byte) (this.inGround ? 1 : 0)); + } + + public void a(NBTTagCompound nbttagcompound) { + this.blockX = nbttagcompound.e("xTile"); + this.blockY = nbttagcompound.e("yTile"); + this.blockZ = nbttagcompound.e("zTile"); + this.inBlockId = nbttagcompound.d("inTile") & 255; + this.shake = nbttagcompound.d("shake") & 255; + this.inGround = nbttagcompound.d("inGround") == 1; + } + + public void a_(EntityHuman entityhuman) {} +} diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index 64bce954..02ca25d6 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -13,12 +13,16 @@ public class EntitySheep extends EntityAnimal { this.b(0.9F, 1.3F); } + public int getMaxHealth() { + return 8; + } + protected void b() { super.b(); this.datawatcher.a(16, new Byte((byte) 0)); } - protected void a(boolean flag) { + protected void a(boolean flag, int i) { // CraftBukkit start - whole method java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); @@ -30,7 +34,7 @@ public class EntitySheep extends EntityAnimal { // CraftBukkit end } - protected int k() { + protected int e() { return Block.WOOL.id; } @@ -54,7 +58,7 @@ public class EntitySheep extends EntityAnimal { itemstack.damage(1, entityhuman); } - return false; + return super.b(entityhuman); } public void b(NBTTagCompound nbttagcompound) { @@ -65,19 +69,19 @@ public class EntitySheep extends EntityAnimal { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.setSheared(nbttagcompound.m("Sheared")); - this.setColor(nbttagcompound.c("Color")); + this.setSheared(nbttagcompound.n("Sheared")); + this.setColor(nbttagcompound.d("Color")); } - protected String h() { + protected String c_() { return "mob.sheep"; } - protected String i() { + protected String m() { return "mob.sheep"; } - protected String j() { + protected String n() { return "mob.sheep"; } @@ -110,4 +114,17 @@ public class EntitySheep extends EntityAnimal { return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : (i < 18 ? 12 : (random.nextInt(500) == 0 ? 6 : 0)))); } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + EntitySheep entitysheep = (EntitySheep) entityanimal; + EntitySheep entitysheep1 = new EntitySheep(this.world); + + if (this.random.nextBoolean()) { + entitysheep1.setColor(this.getColor()); + } else { + entitysheep1.setColor(entitysheep.getColor()); + } + + return entitysheep1; + } } diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java deleted file mode 100644 index 5c9a5b5d..00000000 --- a/src/main/java/net/minecraft/server/EntitySilverfish.java +++ /dev/null @@ -1,128 +0,0 @@ -package net.minecraft.server; - -public class EntitySilverfish extends EntityMonster { - - private int a; - - public EntitySilverfish(World world) { - super(world); - this.texture = "/mob/silverfish.png"; - this.b(0.3F, 0.7F); - this.aU = 0.6F; - this.damage = 1; // CraftBukkit - 0 -> 1, temporary fix for Silverfish base damage. - } - - protected boolean e_() { - return false; - } - - protected Entity findTarget() { - double d0 = 8.0D; - - return this.world.findNearbyPlayer(this, d0); - } - - protected String h() { - return "mob.spider"; - } - - protected String i() { - return "mob.spider"; - } - - protected String j() { - return "mob.spiderdeath"; - } - - public boolean damageEntity(DamageSource damagesource, int i) { - if (this.a <= 0 && damagesource instanceof EntityDamageSource) { - this.a = 20; - } - - return super.damageEntity(damagesource, i); - } - - protected void a(Entity entity, float f) { - if (this.attackTicks <= 0 && f < 1.2F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) { - this.attackTicks = 20; - entity.damageEntity(DamageSource.mobAttack(this), this.damage); - } - } - - public void b(NBTTagCompound nbttagcompound) { - super.b(nbttagcompound); - } - - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); - } - - protected int k() { - return 0; - } - - public void s_() { - this.U = this.yaw; - super.s_(); - } - - protected void c_() { - super.c_(); - if (!this.world.isStatic) { - int i; - int j; - int k; - int l; - - if (this.a > 0) { - --this.a; - if (this.a == 0) { - i = MathHelper.floor(this.locX); - j = MathHelper.floor(this.locY); - k = MathHelper.floor(this.locZ); - boolean flag = false; - - for (l = 0; !flag && l <= 5 && l >= -5; l = l <= 0 ? 1 - l : 0 - l) { - for (int i1 = 0; !flag && i1 <= 10 && i1 >= -10; i1 = i1 <= 0 ? 1 - i1 : 0 - i1) { - for (int j1 = 0; !flag && j1 <= 10 && j1 >= -10; j1 = j1 <= 0 ? 1 - j1 : 0 - j1) { - int k1 = this.world.getTypeId(i + i1, j + l, k + j1); - - if (k1 == Block.MONSTER_EGGS.id) { - this.world.e(2001, i + i1, j + l, k + j1, Block.MONSTER_EGGS.id + this.world.getData(i + i1, j + l, k + j1) * 256); - this.world.setTypeId(i + i1, j + l, k + j1, 0); - Block.MONSTER_EGGS.postBreak(this.world, i + i1, j + l, k + j1, 0); - if (this.random.nextBoolean()) { - flag = true; - break; - } - } - } - } - } - } - } - - if (this.target == null && !this.B()) { - i = MathHelper.floor(this.locX); - j = MathHelper.floor(this.locY + 0.5D); - k = MathHelper.floor(this.locZ); - int l1 = this.random.nextInt(6); - - l = this.world.getTypeId(i + PistonBlockTextures.b[l1], j + PistonBlockTextures.c[l1], k + PistonBlockTextures.d[l1]); - if (BlockMonsterEggs.c(l)) { - this.world.setTypeIdAndData(i + PistonBlockTextures.b[l1], j + PistonBlockTextures.c[l1], k + PistonBlockTextures.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.d(l)); - this.ab(); - this.die(); - } else { - this.A(); - } - } else if (this.target != null && !this.B()) { - this.target = null; - } - } - } - - protected float a(int i, int j, int k) { - return this.world.getTypeId(i, j - 1, k) == Block.STONE.id ? 10.0F : super.a(i, j, k); - } -} diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index 8ff71b6c..0f159efd 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -14,15 +14,19 @@ public class EntitySkeleton extends EntityMonster { this.texture = "/mob/skeleton.png"; } - protected String h() { + public int getMaxHealth() { + return 20; + } + + protected String c_() { return "mob.skeleton"; } - protected String i() { + protected String m() { return "mob.skeletonhurt"; } - protected String j() { + protected String n() { return "mob.skeletonhurt"; } @@ -32,7 +36,7 @@ public class EntitySkeleton extends EntityMonster { public void die(DamageSource damagesource) { super.die(damagesource); - if (damagesource.e() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { + if (damagesource.g() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) damagesource.getEntity(); double d0 = entityhuman.locX - this.locX; double d1 = entityhuman.locZ - this.locZ; @@ -43,9 +47,9 @@ public class EntitySkeleton extends EntityMonster { } } - public void s() { - if (this.world.d() && !this.world.isStatic) { - float f = this.a_(1.0F); + public void d() { + if (this.world.e() && !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 @@ -53,13 +57,13 @@ public class EntitySkeleton extends EntityMonster { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.fireTicks = 300; + this.j(8); } // CraftBukkit end } } - super.s(); + super.d(); } protected void a(Entity entity, float f) { @@ -69,7 +73,7 @@ public class EntitySkeleton extends EntityMonster { if (this.attackTicks == 0) { EntityArrow entityarrow = new EntityArrow(this.world, this, 1.0F); - double d2 = entity.locY + (double) entity.t() - 0.699999988079071D - entityarrow.locY; + double d2 = entity.locY + (double) entity.x() - 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)); @@ -91,20 +95,20 @@ public class EntitySkeleton extends EntityMonster { super.a(nbttagcompound); } - protected int k() { + protected int e() { return Item.ARROW.id; } - protected void a(boolean flag) { + protected void a(boolean flag, int i) { // CraftBukkit start - whole method java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(3); + int count = this.random.nextInt(3 + i); if (count > 0) { loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count)); } - count = this.random.nextInt(3); + count = this.random.nextInt(3 + i); if (count > 0) { loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count)); } @@ -112,4 +116,8 @@ public class EntitySkeleton extends EntityMonster { org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } + + public EnchantmentDamage t() { + return EnchantmentDamage.b; + } } diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java index 310c8e5e..f4de6574 100644 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ b/src/main/java/net/minecraft/server/EntitySlime.java @@ -4,6 +4,7 @@ public class EntitySlime extends EntityLiving implements IMonster { public float a; public float b; + public float c; private int size = 0; public EntitySlime(World world) { @@ -14,7 +15,7 @@ public class EntitySlime extends EntityLiving implements IMonster { this.height = 0.0F; this.size = this.random.nextInt(20) + 10; this.setSize(i); - this.ax = i; + this.az = i; } protected void b() { @@ -25,8 +26,14 @@ public class EntitySlime extends EntityLiving implements IMonster { public void setSize(int i) { this.datawatcher.watch(16, new Byte((byte) i)); this.b(0.6F * (float) i, 0.6F * (float) i); - this.health = i * i; this.setPosition(this.locX, this.locY, this.locZ); + this.setHealth(this.getMaxHealth()); + } + + public int getMaxHealth() { + int i = this.getSize(); + + return i * i; } public int getSize() { @@ -40,14 +47,27 @@ public class EntitySlime extends EntityLiving implements IMonster { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.setSize(nbttagcompound.e("Size") + 1); + this.setSize(nbttagcompound.f("Size") + 1); + } + + protected String w() { + return "slime"; + } + + protected String E() { + return "mob.slime"; } - public void s_() { - this.b = this.a; + public void w_() { + if (!this.world.isStatic && this.world.difficulty == 0 && this.getSize() > 0) { + this.dead = true; + } + + this.b += (this.a - this.b) * 0.5F; + this.c = this.b; boolean flag = this.onGround; - super.s_(); + super.w_(); if (this.onGround && !flag) { int i = this.getSize(); @@ -57,101 +77,142 @@ public class EntitySlime extends EntityLiving implements IMonster { float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1; float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1; - this.world.a("slime", this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); + this.world.a(this.w(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); } - if (i > 2) { - this.world.makeSound(this, "mob.slime", this.l(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); + if (this.G()) { + this.world.makeSound(this, this.E(), this.o(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); } this.a = -0.5F; } - this.a *= 0.6F; + this.B(); } - protected void c_() { - this.ad(); - EntityHuman entityhuman = this.world.findNearbyPlayer(this, 16.0D); + protected void m_() { + this.ak(); + EntityHuman entityhuman = this.world.b(this, 16.0D); if (entityhuman != null) { this.a(entityhuman, 10.0F, 20.0F); } if (this.onGround && this.size-- <= 0) { - this.size = this.random.nextInt(20) + 10; + this.size = this.A(); if (entityhuman != null) { this.size /= 3; } - this.aS = true; - if (this.getSize() > 1) { - this.world.makeSound(this, "mob.slime", this.l(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); + this.aW = true; + if (this.I()) { + this.world.makeSound(this, this.E(), this.o(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); } this.a = 1.0F; - this.aP = 1.0F - this.random.nextFloat() * 2.0F; - this.aQ = (float) (1 * this.getSize()); + this.aT = 1.0F - this.random.nextFloat() * 2.0F; + this.aU = (float) (1 * this.getSize()); } else { - this.aS = false; + this.aW = false; if (this.onGround) { - this.aP = this.aQ = 0.0F; + this.aT = this.aU = 0.0F; } } } + protected void B() { + this.a *= 0.6F; + } + + protected int A() { + return this.random.nextInt(20) + 10; + } + + protected EntitySlime y() { + return new EntitySlime(this.world); + } + public void die() { int i = this.getSize(); - if (!this.world.isStatic && i > 1 && this.health == 0) { + if (!this.world.isStatic && i > 1 && this.getHealth() <= 0) { + int j = 2 + this.random.nextInt(3); + // CraftBukkit start - org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent(this.getBukkitEntity(), 4); + org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent(this.getBukkitEntity(), j); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled() && event.getCount() > 0) { - for (int j = 0; j < event.getCount(); ++j) { - float f = ((float) (j % 2) - 0.5F) * (float) i / 4.0F; - float f1 = ((float) (j / 2) - 0.5F) * (float) i / 4.0F; - EntitySlime entityslime = new EntitySlime(this.world); - - entityslime.setSize(i / 2); - entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); - this.world.addEntity(entityslime); - } + j = event.getCount(); + } else { + super.die(); + return; } // CraftBukkit end + + for (int k = 0; k < j; ++k) { + float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; + float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; + EntitySlime entityslime = this.y(); + + entityslime.setSize(i / 2); + entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); + this.world.addEntity(entityslime); + } } super.die(); } public void a_(EntityHuman entityhuman) { - int i = this.getSize(); + if (this.C()) { + int i = this.getSize(); - if (i > 1 && this.f(entityhuman) && (double) this.g(entityhuman) < 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), i)) { - this.world.makeSound(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + if (this.g(entityhuman) && (double) this.h(entityhuman) < 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), this.D())) { + this.world.makeSound(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + } } } - protected String i() { + protected boolean C() { + return this.getSize() > 1; + } + + protected int D() { + return this.getSize(); + } + + protected String m() { return "mob.slime"; } - protected String j() { + protected String n() { return "mob.slime"; } - protected int k() { + protected int e() { return this.getSize() == 1 ? Item.SLIME_BALL.id : 0; } - public boolean d() { + public boolean g() { Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - return (this.getSize() == 1 || this.world.difficulty > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 16.0D; + return (this.getSize() == 1 || this.world.difficulty > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D ? super.g() : false; + } + + protected float o() { + return 0.4F * (float) this.getSize(); + } + + protected int q_() { + return 0; + } + + protected boolean I() { + return this.getSize() > 1; } - protected float l() { - return 0.6F; + protected boolean G() { + return this.getSize() > 2; } } diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index 90c3f47a..a5861272 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -1,7 +1,5 @@ package net.minecraft.server; -import java.util.List; - // CraftBukkit start import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.entity.Projectile; @@ -10,248 +8,65 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit end -public class EntitySnowball extends Entity { - - private int b = -1; - private int c = -1; - private int d = -1; - private int e = 0; - private boolean f = false; - public int a = 0; - public EntityLiving shooter; // CraftBukkit - private -> public - private int h; - private int i = 0; +public class EntitySnowball extends EntityProjectile { public EntitySnowball(World world) { super(world); - this.b(0.25F, 0.25F); } - protected void b() {} - public EntitySnowball(World world, EntityLiving entityliving) { - super(world); - this.shooter = entityliving; - this.b(0.25F, 0.25F); - this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.t(), entityliving.locZ, entityliving.yaw, entityliving.pitch); - this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.locY -= 0.10000000149011612D; - this.locZ -= (double) (MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * 0.16F); - this.setPosition(this.locX, this.locY, this.locZ); - this.height = 0.0F; - float f = 0.4F; - - this.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f); - this.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f); - this.a(this.motX, this.motY, this.motZ, 1.5F, 1.0F); + super(world, entityliving); } public EntitySnowball(World world, double d0, double d1, double d2) { - super(world); - this.h = 0; - this.b(0.25F, 0.25F); - this.setPosition(d0, d1, d2); - this.height = 0.0F; - } - - public void a(double d0, double d1, double d2, float f, float f1) { - float f2 = MathHelper.a(d0 * d0 + d1 * d1 + d2 * d2); - - d0 /= (double) f2; - d1 /= (double) f2; - d2 /= (double) f2; - d0 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d1 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d2 += this.random.nextGaussian() * 0.007499999832361937D * (double) f1; - d0 *= (double) f; - d1 *= (double) f; - d2 *= (double) f; - this.motX = d0; - this.motY = d1; - this.motZ = d2; - float f3 = MathHelper.a(d0 * d0 + d2 * d2); - - this.lastYaw = this.yaw = (float) (Math.atan2(d0, d2) * 180.0D / 3.1415927410125732D); - this.lastPitch = this.pitch = (float) (Math.atan2(d1, (double) f3) * 180.0D / 3.1415927410125732D); - this.h = 0; + super(world, d0, d1, d2); } - public void s_() { - this.bE = this.locX; - this.bF = this.locY; - this.bG = this.locZ; - super.s_(); - if (this.a > 0) { - --this.a; - } - - if (this.f) { - int i = this.world.getTypeId(this.b, this.c, this.d); - - if (i == this.e) { - ++this.h; - if (this.h == 1200) { - this.die(); - } - - return; - } - - this.f = false; - this.motX *= (double) (this.random.nextFloat() * 0.2F); - this.motY *= (double) (this.random.nextFloat() * 0.2F); - this.motZ *= (double) (this.random.nextFloat() * 0.2F); - this.h = 0; - this.i = 0; - } else { - ++this.i; - } - - 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.a(vec3d, vec3d1); - - vec3d = Vec3D.create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); - if (movingobjectposition != null) { - vec3d1 = Vec3D.create(movingobjectposition.f.a, movingobjectposition.f.b, movingobjectposition.f.c); - } - - if (!this.world.isStatic) { - Entity entity = null; - List list = this.world.b((Entity) this, this.boundingBox.a(this.motX, this.motY, this.motZ).b(1.0D, 1.0D, 1.0D)); - double d0 = 0.0D; - - for (int j = 0; j < list.size(); ++j) { - Entity entity1 = (Entity) list.get(j); - - 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.b(movingobjectposition1.f); - - if (d1 < d0 || d0 == 0.0D) { - entity = entity1; - d0 = d1; - } - } - } - } + protected void a(MovingObjectPosition movingobjectposition) { + if (movingobjectposition.entity != null) { + byte b0 = 0; - if (entity != null) { - movingobjectposition = new MovingObjectPosition(entity); + if (movingobjectposition.entity instanceof EntityBlaze) { + b0 = 3; } - } - - if (movingobjectposition != null) { // CraftBukkit start - ProjectileHitEvent phe = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(phe); + ProjectileHitEvent hitEvent = new ProjectileHitEvent((Projectile) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(hitEvent); + boolean stick = false; if (movingobjectposition.entity != null) { - boolean stick; if (movingobjectposition.entity instanceof EntityLiving) { org.bukkit.entity.Entity damagee = movingobjectposition.entity.getBukkitEntity(); Projectile projectile = (Projectile) this.getBukkitEntity(); // TODO @see EntityArrow#162 - EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, 0); + EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(projectile, damagee, EntityDamageEvent.DamageCause.PROJECTILE, b0); this.world.getServer().getPluginManager().callEvent(event); this.shooter = (projectile.getShooter() == null) ? null : ((CraftLivingEntity) projectile.getShooter()).getHandle(); + b0 = (byte) event.getDamage(); if (event.isCancelled()) { stick = !projectile.doesBounce(); } else { // this function returns if the snowball should stick in or not, i.e. !bounce - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), event.getDamage()); + stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0); } } else { - stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), 0); - } - if (stick) { - ; + stick = movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.shooter), b0); } } - // CraftBukkit end - for (int k = 0; k < 8; ++k) { - this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); + if (stick) { + // CraftBukkit end + ; } - - this.die(); - } - - this.locX += this.motX; - this.locY += this.motY; - this.locZ += this.motZ; - float f1 = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); - - this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); - - for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { - ; - } - - while (this.pitch - this.lastPitch >= 180.0F) { - this.lastPitch += 360.0F; - } - - while (this.yaw - this.lastYaw < -180.0F) { - this.lastYaw -= 360.0F; - } - - while (this.yaw - this.lastYaw >= 180.0F) { - this.lastYaw += 360.0F; } - this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; - this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = 0.99F; - float f3 = 0.03F; - - if (this.ao()) { - for (int l = 0; l < 4; ++l) { - 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); - } - - f2 = 0.8F; + for (int i = 0; i < 8; ++i) { + this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); } - this.motX *= (double) f2; - this.motY *= (double) f2; - this.motZ *= (double) f2; - this.motY -= (double) f3; - this.setPosition(this.locX, this.locY, this.locZ); - } - - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.a("xTile", (short) this.b); - nbttagcompound.a("yTile", (short) this.c); - nbttagcompound.a("zTile", (short) this.d); - nbttagcompound.a("inTile", (byte) this.e); - nbttagcompound.a("shake", (byte) this.a); - nbttagcompound.a("inGround", (byte) (this.f ? 1 : 0)); - } - - public void a(NBTTagCompound nbttagcompound) { - this.b = nbttagcompound.d("xTile"); - this.c = nbttagcompound.d("yTile"); - this.d = nbttagcompound.d("zTile"); - this.e = nbttagcompound.c("inTile") & 255; - this.a = nbttagcompound.c("shake") & 255; - this.f = nbttagcompound.c("inGround") == 1; - } - - 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); + if (!this.world.isStatic) { this.die(); } } diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index 1bccda26..bc724ec7 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -11,43 +11,63 @@ public class EntitySpider extends EntityMonster { super(world); this.texture = "/mob/spider.png"; this.b(1.4F, 0.9F); - this.aU = 0.8F; + this.aY = 0.8F; } - public double n() { + protected void b() { + super.b(); + this.datawatcher.a(16, new Byte((byte) 0)); + } + + public void d() { + super.d(); + } + + public void w_() { + super.w_(); + if (!this.world.isStatic) { + this.a(this.positionChanged); + } + } + + public int getMaxHealth() { + return 16; + } + + public double q() { return (double) this.width * 0.75D - 0.5D; } - protected boolean e_() { + protected boolean g_() { return false; } protected Entity findTarget() { - float f = this.a_(1.0F); + float f = this.a(1.0F); if (f < 0.5F) { double d0 = 16.0D; - return this.world.findNearbyPlayer(this, d0); + return this.world.b(this, d0); } else { return null; } } - protected String h() { + protected String c_() { return "mob.spider"; } - protected String i() { + protected String m() { return "mob.spider"; } - protected String j() { + protected String n() { return "mob.spiderdeath"; } protected void a(Entity entity, float f) { - float f1 = this.a_(1.0F); + float f1 = this.a(1.0F); if (f1 > 0.5F && this.random.nextInt(100) == 0) { // CraftBukkit start @@ -88,13 +108,44 @@ public class EntitySpider extends EntityMonster { super.a(nbttagcompound); } - protected int k() { + protected int e() { return Item.STRING.id; } - public boolean p() { - return this.positionChanged; + protected void a(boolean flag, int i) { + super.a(flag, i); + if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) { + this.b(Item.SPIDER_EYE.id, 1); + } + } + + public boolean r() { + return this.o_(); } - public void q() {} + public void s() {} + + public EnchantmentDamage t() { + return EnchantmentDamage.c; + } + + public boolean a(MobEffect mobeffect) { + return mobeffect.getEffectId() == MobEffectList.POISON.id ? false : super.a(mobeffect); + } + + public boolean o_() { + return (this.datawatcher.getByte(16) & 1) != 0; + } + + public void a(boolean flag) { + byte b0 = this.datawatcher.getByte(16); + + if (flag) { + b0 = (byte) (b0 | 1); + } else { + b0 &= -2; + } + + this.datawatcher.watch(16, Byte.valueOf(b0)); + } } diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java index f4396701..6127b77f 100644 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ b/src/main/java/net/minecraft/server/EntitySquid.java @@ -26,6 +26,10 @@ public class EntitySquid extends EntityWaterAnimal { this.m = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } + public int getMaxHealth() { + return 10; + } + public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); } @@ -34,31 +38,31 @@ public class EntitySquid extends EntityWaterAnimal { super.a(nbttagcompound); } - protected String h() { + protected String c_() { return null; } - protected String i() { + protected String m() { return null; } - protected String j() { + protected String n() { return null; } - protected float l() { + protected float o() { return 0.4F; } - protected int k() { + protected int e() { return 0; } - protected void a(boolean flag) { + protected void a(boolean flag, int i) { // CraftBukkit start - whole method java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); - int count = this.random.nextInt(3) + 1; + int count = this.random.nextInt(3 + i) + 1; if (count > 0) { loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.INK_SACK, count)); } @@ -68,15 +72,15 @@ public class EntitySquid extends EntityWaterAnimal { } public boolean b(EntityHuman entityhuman) { - return false; + return super.b(entityhuman); } - public boolean ao() { + public boolean az() { return this.world.a(this.boundingBox.b(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this); } - public void s() { - super.s(); + public void d() { + super.d(); this.b = this.a; this.g = this.c; this.i = this.h; @@ -89,7 +93,7 @@ public class EntitySquid extends EntityWaterAnimal { } } - if (this.ao()) { + if (this.az()) { float f; if (this.h < 3.1415927F) { @@ -107,20 +111,20 @@ public class EntitySquid extends EntityWaterAnimal { this.n *= 0.99F; } - if (!this.ai) { + if (!this.aj) { 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.U += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.U) * 0.1F; - this.yaw = this.U; + this.V += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.V) * 0.1F; + this.yaw = this.V; 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.j = MathHelper.abs(MathHelper.sin(this.h)) * 3.1415927F * 0.25F; - if (!this.ai) { + if (!this.aj) { this.motX = 0.0D; this.motY -= 0.08D; this.motY *= 0.9800000190734863D; @@ -135,8 +139,11 @@ public class EntitySquid extends EntityWaterAnimal { this.move(this.motX, this.motY, this.motZ); } - protected void c_() { - if (this.random.nextInt(50) == 0 || !this.bQ || this.o == 0.0F && this.p == 0.0F && this.q == 0.0F) { + protected void m_() { + ++this.aS; + if (this.aS > 100) { + this.o = this.p = this.q = 0.0F; + } else if (this.random.nextInt(50) == 0 || !this.bS || this.o == 0.0F && this.p == 0.0F && this.q == 0.0F) { float f = this.random.nextFloat() * 3.1415927F * 2.0F; this.o = MathHelper.cos(f) * 0.2F; @@ -144,6 +151,10 @@ public class EntitySquid extends EntityWaterAnimal { this.q = MathHelper.sin(f) * 0.2F; } - this.ad(); + this.ak(); + } + + public boolean g() { + return this.locY > 45.0D && this.locY < (double) this.world.seaLevel && super.g(); } -}
\ 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 66a8451f..c445a03e 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.aY = true; + this.bc = 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 e_() { + protected boolean g_() { return false; } - public boolean r_() { + public boolean e_() { return !this.dead; } - public void s_() { + public void w_() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; @@ -95,6 +95,6 @@ public class EntityTNTPrimed extends Entity { } protected void a(NBTTagCompound nbttagcompound) { - this.fuseTicks = nbttagcompound.c("Fuse"); + this.fuseTicks = nbttagcompound.d("Fuse"); } } diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java index a62eaf0b..31bccaaa 100644 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ b/src/main/java/net/minecraft/server/EntityTracker.java @@ -37,21 +37,31 @@ public class EntityTracker { this.addEntity(entity, 64, 5, true); } else if (entity instanceof EntityArrow) { this.addEntity(entity, 64, 20, false); + } else if (entity instanceof EntitySmallFireball) { + this.addEntity(entity, 64, 10, false); } else if (entity instanceof EntityFireball) { this.addEntity(entity, 64, 10, false); } else if (entity instanceof EntitySnowball) { this.addEntity(entity, 64, 10, true); + } else if (entity instanceof EntityEnderPearl) { + this.addEntity(entity, 64, 10, true); + } else if (entity instanceof EntityEnderSignal) { + this.addEntity(entity, 64, 10, true); } else if (entity instanceof EntityEgg) { this.addEntity(entity, 64, 10, true); + } else if (entity instanceof EntityPotion) { + this.addEntity(entity, 64, 10, true); } else if (entity instanceof EntityItem) { this.addEntity(entity, 64, 20, true); } else if (entity instanceof EntityMinecart) { - this.addEntity(entity, 160, 5, true); + this.addEntity(entity, 80, 3, true); } else if (entity instanceof EntityBoat) { - this.addEntity(entity, 160, 5, true); + this.addEntity(entity, 80, 3, true); } else if (entity instanceof EntitySquid) { - this.addEntity(entity, 160, 3, true); + this.addEntity(entity, 64, 3, true); } else if (entity instanceof IAnimal) { + this.addEntity(entity, 80, 3, true); + } else if (entity instanceof EntityEnderDragon) { this.addEntity(entity, 160, 3, true); } else if (entity instanceof EntityTNTPrimed) { this.addEntity(entity, 160, 10, true); @@ -61,6 +71,8 @@ public class EntityTracker { this.addEntity(entity, 160, Integer.MAX_VALUE, false); } else if (entity instanceof EntityExperienceOrb) { this.addEntity(entity, 160, 20, true); + } else if (entity instanceof EntityEnderCrystal) { + this.addEntity(entity, 256, Integer.MAX_VALUE, false); } } diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java index bee64153..53d676ed 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 || this.tracker.ca) { + if (++this.l % this.c == 0 || this.tracker.cb) { 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); @@ -70,8 +70,8 @@ public class EntityTrackerEntry { int k1 = j - this.e; int l1 = k - this.f; Object object = null; - boolean flag = Math.abs(i) >= 8 || Math.abs(j) >= 8 || Math.abs(k) >= 8; - boolean flag1 = Math.abs(l - this.g) >= 8 || Math.abs(i1 - this.h) >= 8; + boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4; + boolean flag1 = Math.abs(l - this.g) >= 4 || Math.abs(i1 - this.h) >= 4; if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.t <= 400) { if (flag && flag1) { @@ -126,27 +126,26 @@ public class EntityTrackerEntry { } } - this.tracker.ca = false; + this.tracker.cb = false; if (this.tracker.velocityChanged) { // CraftBukkit start - create PlayerVelocity event boolean cancelled = false; - if(this.tracker instanceof EntityPlayer) { + if (this.tracker instanceof EntityPlayer) { org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.tracker.getBukkitEntity(); org.bukkit.util.Vector velocity = player.getVelocity(); org.bukkit.event.player.PlayerVelocityEvent event = new org.bukkit.event.player.PlayerVelocityEvent(player, velocity); this.tracker.world.getServer().getPluginManager().callEvent(event); - if(event.isCancelled()) { + if (event.isCancelled()) { cancelled = true; - } - else if(!velocity.equals(event.getVelocity())) { + } else if (!velocity.equals(event.getVelocity())) { player.setVelocity(velocity); } } - if(!cancelled) { + if (!cancelled) { this.b((Packet) (new Packet28EntityVelocity(this.tracker))); } // CraftBukkit end @@ -235,6 +234,10 @@ public class EntityTrackerEntry { } private Packet b() { + if (this.tracker.dead) { + System.out.println("Fetching addPacket for removed entity"); + } + if (this.tracker instanceof EntityItem) { EntityItem entityitem = (EntityItem) this.tracker; Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem); @@ -271,6 +274,8 @@ public class EntityTrackerEntry { return new Packet23VehicleSpawn(this.tracker, 1); } else if (this.tracker instanceof IAnimal) { return new Packet24MobSpawn((EntityLiving) this.tracker); + } else if (this.tracker instanceof EntityEnderDragon) { + return new Packet24MobSpawn((EntityLiving) this.tracker); } else if (this.tracker instanceof EntityFishingHook) { return new Packet23VehicleSpawn(this.tracker, 90); } else if (this.tracker instanceof EntityArrow) { @@ -279,40 +284,73 @@ public class EntityTrackerEntry { 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) { - EntityFireball entityfireball = (EntityFireball) this.tracker; - // CraftBukkit start - added check for null shooter - int shooter = ((EntityFireball) this.tracker).shooter != null ? ((EntityFireball) this.tracker).shooter.id : 1; - Packet23VehicleSpawn packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, shooter); - // CraftBukkit end - - packet23vehiclespawn.e = (int) (entityfireball.dirX * 8000.0D); - packet23vehiclespawn.f = (int) (entityfireball.dirY * 8000.0D); - packet23vehiclespawn.g = (int) (entityfireball.dirZ * 8000.0D); - return packet23vehiclespawn; - } else if (this.tracker instanceof EntityEgg) { - return new Packet23VehicleSpawn(this.tracker, 62); - } else if (this.tracker instanceof EntityTNTPrimed) { - return new Packet23VehicleSpawn(this.tracker, 50); + } else if (this.tracker instanceof EntityPotion) { + return new Packet23VehicleSpawn(this.tracker, 73, ((EntityPotion) this.tracker).f()); + } else if (this.tracker instanceof EntityEnderPearl) { + return new Packet23VehicleSpawn(this.tracker, 65); + } else if (this.tracker instanceof EntityEnderSignal) { + return new Packet23VehicleSpawn(this.tracker, 72); } else { - if (this.tracker instanceof EntityFallingSand) { - EntityFallingSand entityfallingsand = (EntityFallingSand) this.tracker; + Packet23VehicleSpawn packet23vehiclespawn; - if (entityfallingsand.a == Block.SAND.id) { - return new Packet23VehicleSpawn(this.tracker, 70); + if (this.tracker instanceof EntitySmallFireball) { + EntitySmallFireball entitysmallfireball = (EntitySmallFireball) this.tracker; + + packet23vehiclespawn = null; + if (entitysmallfireball.shooter != null) { + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 64, entitysmallfireball.shooter.id); + } else { + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 64, 0); } - if (entityfallingsand.a == Block.GRAVEL.id) { - return new Packet23VehicleSpawn(this.tracker, 71); + packet23vehiclespawn.e = (int) (entitysmallfireball.dirX * 8000.0D); + packet23vehiclespawn.f = (int) (entitysmallfireball.dirY * 8000.0D); + packet23vehiclespawn.g = (int) (entitysmallfireball.dirZ * 8000.0D); + return packet23vehiclespawn; + } else if (this.tracker instanceof EntityFireball) { + EntityFireball entityfireball = (EntityFireball) this.tracker; + + packet23vehiclespawn = null; + if (entityfireball.shooter != null) { + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, ((EntityFireball) this.tracker).shooter.id); + } else { + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, 0); } - } - if (this.tracker instanceof EntityPainting) { - return new Packet25EntityPainting((EntityPainting) this.tracker); - } else if (this.tracker instanceof EntityExperienceOrb) { - return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker); + packet23vehiclespawn.e = (int) (entityfireball.dirX * 8000.0D); + packet23vehiclespawn.f = (int) (entityfireball.dirY * 8000.0D); + packet23vehiclespawn.g = (int) (entityfireball.dirZ * 8000.0D); + return packet23vehiclespawn; + } else if (this.tracker instanceof EntityEgg) { + return new Packet23VehicleSpawn(this.tracker, 62); + } else if (this.tracker instanceof EntityTNTPrimed) { + return new Packet23VehicleSpawn(this.tracker, 50); + } else if (this.tracker instanceof EntityEnderCrystal) { + return new Packet23VehicleSpawn(this.tracker, 51); } else { - throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!"); + if (this.tracker instanceof EntityFallingSand) { + EntityFallingSand entityfallingsand = (EntityFallingSand) this.tracker; + + if (entityfallingsand.a == Block.SAND.id) { + return new Packet23VehicleSpawn(this.tracker, 70); + } + + if (entityfallingsand.a == Block.GRAVEL.id) { + return new Packet23VehicleSpawn(this.tracker, 71); + } + + if (entityfallingsand.a == Block.DRAGON_EGG.id) { + return new Packet23VehicleSpawn(this.tracker, 74); + } + } + + 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/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java index 61136bc7..6ce6853a 100644 --- a/src/main/java/net/minecraft/server/EntityTypes.java +++ b/src/main/java/net/minecraft/server/EntityTypes.java @@ -86,9 +86,17 @@ public class EntityTypes { static { a(EntityItem.class, "Item", 1); a(EntityExperienceOrb.class, "XPOrb", 2); + a(EntityPainting.class, "Painting", 9); a(EntityArrow.class, "Arrow", 10); a(EntitySnowball.class, "Snowball", 11); - a(EntityPainting.class, "Painting", 9); + a(EntityFireball.class, "Fireball", 12); + a(EntitySmallFireball.class, "SmallFireball", 13); + a(EntityEnderPearl.class, "ThrownEnderpearl", 14); + a(EntityEnderSignal.class, "EyeOfEnderSignal", 15); + a(EntityTNTPrimed.class, "PrimedTnt", 20); + a(EntityFallingSand.class, "FallingSand", 21); + a(EntityMinecart.class, "Minecart", 40); + a(EntityBoat.class, "Boat", 41); a(EntityLiving.class, "Mob", 48); a(EntityMonster.class, "Monster", 49); a(EntityCreeper.class, "Creeper", 50); @@ -102,15 +110,18 @@ public class EntityTypes { a(EntityEnderman.class, "Enderman", 58); a(EntityCaveSpider.class, "CaveSpider", 59); a(EntitySilverfish.class, "Silverfish", 60); + a(EntityBlaze.class, "Blaze", 61); + a(EntityLavaSlime.class, "LavaSlime", 62); + a(EntityEnderDragon.class, "EnderDragon", 63); a(EntityPig.class, "Pig", 90); a(EntitySheep.class, "Sheep", 91); a(EntityCow.class, "Cow", 92); a(EntityChicken.class, "Chicken", 93); a(EntitySquid.class, "Squid", 94); a(EntityWolf.class, "Wolf", 95); - a(EntityTNTPrimed.class, "PrimedTnt", 20); - a(EntityFallingSand.class, "FallingSand", 21); - a(EntityMinecart.class, "Minecart", 40); - a(EntityBoat.class, "Boat", 41); + a(EntityMushroomCow.class, "MushroomCow", 96); + a(EntitySnowman.class, "SnowMan", 97); + a(EntityVillager.class, "Villager", 120); + a(EntityEnderCrystal.class, "EnderCrystal", 200); } } diff --git a/src/main/java/net/minecraft/server/EntityWeatherStorm.java b/src/main/java/net/minecraft/server/EntityWeatherStorm.java index 6706e4f0..1080fcc0 100644 --- a/src/main/java/net/minecraft/server/EntityWeatherStorm.java +++ b/src/main/java/net/minecraft/server/EntityWeatherStorm.java @@ -36,6 +36,7 @@ public class EntityWeatherStorm extends EntityWeather { this.lifeTicks = 2; this.a = this.random.nextLong(); this.c = this.random.nextInt(3) + 1; + // CraftBukkit if (!isEffect && world.difficulty >= 2 && world.areChunksLoaded(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) { int i = MathHelper.floor(d0); @@ -72,8 +73,8 @@ public class EntityWeatherStorm extends EntityWeather { } } - public void s_() { - super.s_(); + public void w_() { + super.w_(); 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 2fa72eed..5be38edc 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -26,18 +26,21 @@ public class EntityWolf extends EntityAnimal { super(world); this.texture = "/mob/wolf.png"; this.b(0.8F, 0.8F); - this.aU = 1.1F; - this.health = 8; + this.aY = 1.1F; + } + + public int getMaxHealth() { + return this.isTamed() ? 20 : 8; } protected void b() { super.b(); this.datawatcher.a(16, Byte.valueOf((byte) 0)); this.datawatcher.a(17, ""); - this.datawatcher.a(18, new Integer(this.health)); + this.datawatcher.a(18, new Integer(this.getHealth())); } - protected boolean e_() { + protected boolean g_() { return false; } @@ -54,8 +57,8 @@ public class EntityWolf extends EntityAnimal { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.setAngry(nbttagcompound.m("Angry")); - this.setSitting(nbttagcompound.m("Sitting")); + this.setAngry(nbttagcompound.n("Angry")); + this.setSitting(nbttagcompound.n("Sitting")); String s = nbttagcompound.getString("Owner"); if (s.length() > 0) { @@ -65,44 +68,44 @@ public class EntityWolf extends EntityAnimal { } protected boolean d_() { - return !this.isTamed(); + return this.isAngry(); } - protected String h() { + protected String c_() { return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getInt(18) < 10 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark"); } - protected String i() { + protected String m() { return "mob.wolf.hurt"; } - protected String j() { + protected String n() { return "mob.wolf.death"; } - protected float l() { + protected float o() { return 0.4F; } - protected int k() { + protected int e() { return -1; } - protected void c_() { - super.c_(); - if (!this.e && !this.B() && this.isTamed() && this.vehicle == null) { + protected void m_() { + super.m_(); + if (!this.e && !this.D() && this.isTamed() && this.vehicle == null) { EntityHuman entityhuman = this.world.a(this.getOwnerName()); if (entityhuman != null) { - float f = entityhuman.g(this); + float f = entityhuman.h(this); if (f > 5.0F) { this.c(entityhuman, f); } - } else if (!this.ao()) { + } else if (!this.az()) { this.setSitting(true); } - } else if (this.target == null && !this.B() && !this.isTamed() && this.world.random.nextInt(100) == 0) { + } else if (this.target == null && !this.D() && !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,20 +123,20 @@ public class EntityWolf extends EntityAnimal { } } - if (this.ao()) { + if (this.az()) { this.setSitting(false); } if (!this.world.isStatic) { - this.datawatcher.watch(18, Integer.valueOf(this.health)); + this.datawatcher.watch(18, Integer.valueOf(this.getHealth())); } } - public void s() { - super.s(); + public void d() { + super.d(); this.a = false; - if (this.ae() && !this.B() && !this.isAngry()) { - Entity entity = this.af(); + if (this.al() && !this.D() && !this.isAngry()) { + Entity entity = this.am(); if (entity instanceof EntityHuman) { EntityHuman entityhuman = (EntityHuman) entity; @@ -143,13 +146,13 @@ 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]).m(); + this.a = ((ItemFood) Item.byId[itemstack.id]).p(); } } } } - if (!this.ai && this.g && !this.h && !this.B() && this.onGround) { + if (!this.aj && this.g && !this.h && !this.D() && this.onGround) { this.h = true; this.i = 0.0F; this.j = 0.0F; @@ -157,8 +160,8 @@ public class EntityWolf extends EntityAnimal { } } - public void s_() { - super.s_(); + public void w_() { + super.w_(); this.c = this.b; if (this.a) { this.b += (1.0F - this.b) * 0.4F; @@ -167,17 +170,17 @@ public class EntityWolf extends EntityAnimal { } if (this.a) { - this.aV = 10; + this.aZ = 10; } - if (this.an()) { + if (this.ay()) { this.g = true; this.h = false; this.i = 0.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.world.makeSound(this, "mob.wolf.shake", this.o(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } this.j = this.i; @@ -203,12 +206,12 @@ public class EntityWolf extends EntityAnimal { } } - public float t() { + public float x() { return this.width * 0.8F; } - protected int u() { - return this.isSitting() ? 20 : super.u(); + protected int q_() { + return this.isSitting() ? 20 : super.q_(); } private void c(Entity entity, float f) { @@ -232,7 +235,7 @@ public class EntityWolf extends EntityAnimal { } } - protected boolean v() { + protected boolean w() { return this.isSitting() || this.h; } @@ -366,12 +369,12 @@ public class EntityWolf extends EntityAnimal { this.setTamed(true); this.setPathEntity((PathEntity) null); this.setSitting(true); - this.health = 20; + this.setHealth(20); this.setOwnerName(entityhuman.name); - this.b(true); + this.a(true); this.world.a(this, (byte) 7); } else { - this.b(false); + this.a(false); this.world.a(this, (byte) 6); } } @@ -382,9 +385,9 @@ public class EntityWolf extends EntityAnimal { if (itemstack != null && Item.byId[itemstack.id] instanceof ItemFood) { ItemFood itemfood = (ItemFood) Item.byId[itemstack.id]; - if (itemfood.m() && this.datawatcher.getInt(18) < 20) { + if (itemfood.p() && this.datawatcher.getInt(18) < 20) { --itemstack.count; - this.c(itemfood.k(), RegainReason.EATING); // Craftbukkit + this.d(itemfood.n(), RegainReason.EATING); // Craftbukkit if (itemstack.count <= 0) { entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); } @@ -396,7 +399,7 @@ public class EntityWolf extends EntityAnimal { if (entityhuman.name.equalsIgnoreCase(this.getOwnerName())) { if (!this.world.isStatic) { this.setSitting(!this.isSitting()); - this.aS = false; + this.aW = false; this.setPathEntity((PathEntity) null); } @@ -404,10 +407,10 @@ public class EntityWolf extends EntityAnimal { } } - return false; + return super.b(entityhuman); } - void b(boolean flag) { + void a(boolean flag) { String s = "heart"; if (!flag) { @@ -423,7 +426,7 @@ public class EntityWolf extends EntityAnimal { } } - public int m() { + public int p() { return 8; } @@ -476,4 +479,8 @@ public class EntityWolf extends EntityAnimal { this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -5))); } } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + return new EntityWolf(this.world); + } } diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 92eb6d85..4a2f5136 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -7,13 +7,21 @@ public class EntityZombie extends EntityMonster { public EntityZombie(World world) { super(world); this.texture = "/mob/zombie.png"; - this.aU = 0.5F; - this.damage = 5; + this.aY = 0.5F; + this.damage = 4; } - public void s() { - if (this.world.d() && !this.world.isStatic) { - float f = this.a_(1.0F); + public int getMaxHealth() { + return 20; + } + + protected int O() { + return 2; + } + + public void d() { + if (this.world.e() && !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 @@ -21,28 +29,32 @@ public class EntityZombie extends EntityMonster { this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.fireTicks = 300; + this.j(8); } // CraftBukkit end } } - super.s(); + super.d(); } - protected String h() { + protected String c_() { return "mob.zombie"; } - protected String i() { + protected String m() { return "mob.zombiehurt"; } - protected String j() { + protected String n() { return "mob.zombiedeath"; } - protected int k() { + protected int e() { return Item.ROTTEN_FLESH.id; } + + public EnchantmentDamage t() { + return EnchantmentDamage.b; + } } diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index 8ebb573d..491f9375 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -154,20 +154,6 @@ public class Explosion { ArrayList arraylist = new ArrayList(); arraylist.addAll(this.blocks); - if (this.a) { - for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) { - ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2); - int i3 = chunkposition.x; - int j3 = chunkposition.y; - int k3 = chunkposition.z; - int l3 = this.world.getTypeId(i3, j3, k3); - int i4 = this.world.getTypeId(i3, j3 - 1, k3); - - if (l3 == 0 && Block.o[i4] && this.h.nextInt(3) == 0) { - this.world.setTypeId(i3, j3, k3, Block.FIRE.id); - } - } - } } public void a(boolean flag) { @@ -193,10 +179,10 @@ public class Explosion { EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList); this.world.getServer().getPluginManager().callEvent(event); - + arraylist.clear(); blocks.clear(); - + for (org.bukkit.block.Block block : event.blockList()) { ChunkPosition coords = new ChunkPosition(block.getX(), block.getY(), block.getZ()); arraylist.add(coords); @@ -209,13 +195,19 @@ public class Explosion { } // CraftBukkit end - for (int i = arraylist.size() - 1; i >= 0; --i) { - ChunkPosition chunkposition = (ChunkPosition) arraylist.get(i); - int j = chunkposition.x; - int k = chunkposition.y; - int l = chunkposition.z; - int i1 = this.world.getTypeId(j, k, l); - + int i; + ChunkPosition chunkposition; + int j; + int k; + int l; + int i1; + + for (i = arraylist.size() - 1; i >= 0; --i) { + chunkposition = (ChunkPosition) arraylist.get(i); + j = chunkposition.x; + k = chunkposition.y; + l = chunkposition.z; + i1 = this.world.getTypeId(j, k, l); if (flag) { double d0 = (double) ((float) j + this.world.random.nextFloat()); double d1 = (double) ((float) k + this.world.random.nextFloat()); @@ -241,10 +233,25 @@ public class Explosion { // CraftBukkit - stop explosions from putting out fire if (i1 > 0 && i1 != Block.FIRE.id) { // CraftBukkit - Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield()); + Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield(), 0); this.world.setTypeId(j, k, l, 0); Block.byId[i1].a_(this.world, j, k, l); } } + + if (this.a) { + for (i = arraylist.size() - 1; i >= 0; --i) { + chunkposition = (ChunkPosition) arraylist.get(i); + j = chunkposition.x; + k = chunkposition.y; + l = chunkposition.z; + i1 = this.world.getTypeId(j, k, l); + int j1 = this.world.getTypeId(j, k - 1, l); + + if (i1 == 0 && Block.o[j1] && this.h.nextInt(3) == 0) { + this.world.setTypeId(j, k, l, Block.FIRE.id); + } + } + } } } diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java index c07c921a..854b79cb 100644 --- a/src/main/java/net/minecraft/server/FoodMetaData.java +++ b/src/main/java/net/minecraft/server/FoodMetaData.java @@ -23,7 +23,7 @@ public class FoodMetaData { } public void a(ItemFood itemfood) { - this.a(itemfood.k(), itemfood.l()); + this.a(itemfood.n(), itemfood.o()); } public void a(EntityHuman entityhuman) { @@ -46,17 +46,17 @@ public class FoodMetaData { } } - if (this.foodLevel >= 18 && entityhuman.W()) { + if (this.foodLevel >= 18 && entityhuman.ab()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { // CraftBukkit - added RegainReason. - entityhuman.c(1, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); + entityhuman.d(1, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); this.foodTickTimer = 0; } } else if (this.foodLevel <= 0) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - if (entityhuman.health > 10 || i >= 3 || entityhuman.health > 1 && i >= 2) { + if (entityhuman.getHealth() > 10 || i >= 3 || entityhuman.getHealth() > 1 && i >= 2) { // CraftBukkit start EntityDamageEvent event = new EntityDamageEvent(entityhuman.getBukkitEntity(), EntityDamageEvent.DamageCause.STARVATION, 1); entityhuman.world.getServer().getPluginManager().callEvent(event); @@ -76,10 +76,10 @@ public class FoodMetaData { public void a(NBTTagCompound nbttagcompound) { if (nbttagcompound.hasKey("foodLevel")) { - this.foodLevel = nbttagcompound.e("foodLevel"); - this.foodTickTimer = nbttagcompound.e("foodTickTimer"); - this.saturationLevel = nbttagcompound.g("foodSaturationLevel"); - this.exhaustionLevel = nbttagcompound.g("foodExhaustionLevel"); + this.foodLevel = nbttagcompound.f("foodLevel"); + this.foodTickTimer = nbttagcompound.f("foodTickTimer"); + this.saturationLevel = nbttagcompound.h("foodSaturationLevel"); + this.exhaustionLevel = nbttagcompound.h("foodExhaustionLevel"); } } diff --git a/src/main/java/net/minecraft/server/IInventory.java b/src/main/java/net/minecraft/server/IInventory.java index 80a84b4d..b94ab24a 100644 --- a/src/main/java/net/minecraft/server/IInventory.java +++ b/src/main/java/net/minecraft/server/IInventory.java @@ -18,9 +18,9 @@ public interface IInventory { boolean a(EntityHuman entityhuman); - void e(); + void f(); - void t_(); + void g(); 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 b5065677..154b603a 100644 --- a/src/main/java/net/minecraft/server/InventoryCraftResult.java +++ b/src/main/java/net/minecraft/server/InventoryCraftResult.java @@ -49,7 +49,7 @@ public class InventoryCraftResult implements IInventory { return true; } - public void e() {} + public void f() {} - public void t_() {} + public void g() {} } diff --git a/src/main/java/net/minecraft/server/InventoryCrafting.java b/src/main/java/net/minecraft/server/InventoryCrafting.java index a64f65a5..1ed97d79 100644 --- a/src/main/java/net/minecraft/server/InventoryCrafting.java +++ b/src/main/java/net/minecraft/server/InventoryCrafting.java @@ -80,7 +80,7 @@ public class InventoryCrafting implements IInventory { return true; } - public void e() {} + public void f() {} - public void t_() {} + public void g() {} } diff --git a/src/main/java/net/minecraft/server/InventoryLargeChest.java b/src/main/java/net/minecraft/server/InventoryLargeChest.java index 023f2751..5090563f 100644 --- a/src/main/java/net/minecraft/server/InventoryLargeChest.java +++ b/src/main/java/net/minecraft/server/InventoryLargeChest.java @@ -67,13 +67,13 @@ public class InventoryLargeChest implements IInventory { return this.b.a(entityhuman) && this.c.a(entityhuman); } - public void e() { - this.b.e(); - this.c.e(); + public void f() { + this.b.f(); + this.c.f(); } - public void t_() { - this.b.t_(); - this.c.t_(); + public void g() { + this.b.g(); + this.c.g(); } } diff --git a/src/main/java/net/minecraft/server/InventoryPlayer.java b/src/main/java/net/minecraft/server/InventoryPlayer.java index 27c5c3ff..ef395e3a 100644 --- a/src/main/java/net/minecraft/server/InventoryPlayer.java +++ b/src/main/java/net/minecraft/server/InventoryPlayer.java @@ -27,7 +27,7 @@ public class InventoryPlayer implements IInventory { return this.itemInHandIndex < 9 && this.itemInHandIndex >= 0 ? this.items[this.itemInHandIndex] : null; } - public static int g() { + public static int h() { return 9; } @@ -80,41 +80,55 @@ public class InventoryPlayer implements IInventory { private int e(ItemStack itemstack) { int i = itemstack.id; int j = itemstack.count; - int k = this.firstPartial(itemstack); + int k; - if (k < 0) { + if (itemstack.getMaxStackSize() == 1) { k = this.m(); - } + if (k < 0) { + return j; + } else { + if (this.items[k] == null) { + this.items[k] = ItemStack.b(itemstack); + } - if (k < 0) { - return j; + return 0; + } } else { - if (this.items[k] == null) { - this.items[k] = new ItemStack(i, 0, itemstack.getData()); + k = this.firstPartial(itemstack); + if (k < 0) { + k = this.m(); } - int l = j; + if (k < 0) { + return j; + } else { + if (this.items[k] == null) { + this.items[k] = new ItemStack(i, 0, itemstack.getData()); + } - if (j > this.items[k].getMaxStackSize() - this.items[k].count) { - l = this.items[k].getMaxStackSize() - this.items[k].count; - } + int l = j; - if (l > this.getMaxStackSize() - this.items[k].count) { - l = this.getMaxStackSize() - this.items[k].count; - } + if (j > this.items[k].getMaxStackSize() - this.items[k].count) { + l = this.items[k].getMaxStackSize() - this.items[k].count; + } - if (l == 0) { - return j; - } else { - j -= l; - this.items[k].count += l; - this.items[k].b = 5; - return j; + if (l > this.getMaxStackSize() - this.items[k].count) { + l = this.getMaxStackSize() - this.items[k].count; + } + + if (l == 0) { + return j; + } else { + j -= l; + this.items[k].count += l; + this.items[k].b = 5; + return j; + } } } } - public void h() { + public void i() { 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); @@ -152,6 +166,9 @@ public class InventoryPlayer implements IInventory { this.items[i].b = 5; itemstack.count = 0; return true; + } else if (this.d.abilities.canInstantlyBuild) { + itemstack.count = 0; + return true; } else { return false; } @@ -161,7 +178,12 @@ public class InventoryPlayer implements IInventory { itemstack.count = this.e(itemstack); } while (itemstack.count > 0 && itemstack.count < i); - return itemstack.count < i; + if (itemstack.count == i && this.d.abilities.canInstantlyBuild) { + itemstack.count = 0; + return true; + } else { + return itemstack.count < i; + } } } @@ -243,9 +265,9 @@ public class InventoryPlayer implements IInventory { this.items = new ItemStack[36]; this.armor = new ItemStack[4]; - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.a(i); - int j = nbttagcompound.c("Slot") & 255; + int j = nbttagcompound.d("Slot") & 255; ItemStack itemstack = ItemStack.a(nbttagcompound); if (itemstack != null) { @@ -299,33 +321,26 @@ public class InventoryPlayer implements IInventory { } } - public int i() { + public int j() { int i = 0; - int j = 0; - int k = 0; - for (int l = 0; l < this.armor.length; ++l) { - if (this.armor[l] != null && this.armor[l].getItem() instanceof ItemArmor) { - int i1 = this.armor[l].i(); - int j1 = this.armor[l].g(); - int k1 = i1 - j1; - - j += k1; - k += i1; - int l1 = ((ItemArmor) this.armor[l].getItem()).bu; + for (int j = 0; j < this.armor.length; ++j) { + if (this.armor[j] != null && this.armor[j].getItem() instanceof ItemArmor) { + int k = ((ItemArmor) this.armor[j].getItem()).b; - i += l1; + i += k; } } - if (k == 0) { - return 0; - } else { - return (i - 1) * j / k + 1; - } + return i; } public void d(int i) { + i /= 4; + if (i < 1) { + i = 1; + } + 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); @@ -337,7 +352,7 @@ public class InventoryPlayer implements IInventory { } } - public void j() { + public void k() { int i; for (i = 0; i < this.items.length; ++i) { @@ -369,7 +384,7 @@ public class InventoryPlayer implements IInventory { } public boolean a(EntityHuman entityhuman) { - return this.d.dead ? false : entityhuman.h(this.d) <= 64.0D; + return this.d.dead ? false : entityhuman.i(this.d) <= 64.0D; } public boolean c(ItemStack itemstack) { @@ -390,7 +405,19 @@ public class InventoryPlayer implements IInventory { return false; } - public void e() {} + public void f() {} - public void t_() {} + public void g() {} + + public void a(InventoryPlayer inventoryplayer) { + int i; + + for (i = 0; i < this.items.length; ++i) { + this.items[i] = ItemStack.b(inventoryplayer.items[i]); + } + + for (i = 0; i < this.armor.length; ++i) { + this.armor[i] = ItemStack.b(inventoryplayer.armor[i]); + } + } } diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index f78467c0..d0d284b9 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -40,7 +40,7 @@ public class ItemBed extends Item { b0 = 1; } - if (entityhuman.c(i, j, k) && entityhuman.c(i + b0, j, k + b1)) { + if (entityhuman.d(i, j, k) && entityhuman.d(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 @@ -55,7 +55,10 @@ public class ItemBed extends Item { } // CraftBukkit end - world.setTypeIdAndData(i + b0, j, k + b1, blockbed.id, i1 + 8); + if (world.getTypeId(i, j, k) == blockbed.id) { + world.setTypeIdAndData(i + b0, j, k + b1, blockbed.id, i1 + 8); + } + --itemstack.count; return true; } else { diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index 172e9ad6..6d8c2006 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -13,7 +13,7 @@ public class ItemBlock extends Item { public ItemBlock(int i) { super(i); this.id = i + 256; - this.b(Block.byId[i + 256].a(2)); + this.d(Block.byId[i + 256].a(2)); } public int a() { @@ -54,87 +54,84 @@ public class ItemBlock extends Item { if (itemstack.count == 0) { return false; - } else if (!entityhuman.c(i, j, k)) { + } else if (!entityhuman.d(i, j, k)) { return false; - } else { - 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; - } + } else if (j == world.height - 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()); + /** + * @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); } - return true; + world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); } - world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) + return true; - // CraftBukkit end + } + world.update(i, j, k, this.id); // <-- world.setTypeIdAndData does this on success (tell the world) - if (world.getTypeId(i, j, k) == this.id) { - Block.byId[this.id].postPlace(world, i, j, k, l); - Block.byId[this.id].postPlace(world, i, j, k, entityhuman); - } + // CraftBukkit end - 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; + if (world.getTypeId(i, j, k) == this.id) { + Block.byId[this.id].postPlace(world, i, j, k, l); + Block.byId[this.id].postPlace(world, i, j, k, entityhuman); } - return true; - } else { - return false; + 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(ItemStack itemstack) { - return Block.byId[this.id].l(); + return Block.byId[this.id].n(); } public String b() { - return Block.byId[this.id].l(); + return Block.byId[this.id].n(); } } diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java index b84d6656..1bb99704 100644 --- a/src/main/java/net/minecraft/server/ItemBoat.java +++ b/src/main/java/net/minecraft/server/ItemBoat.java @@ -1,5 +1,7 @@ package net.minecraft.server; +import java.util.List; + // CraftBukkit start import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.block.Action; @@ -34,31 +36,55 @@ public class ItemBoat extends Item { if (movingobjectposition == null) { return itemstack; } else { - if (movingobjectposition.type == EnumMovingObjectType.TILE) { - int i = movingobjectposition.b; - int j = movingobjectposition.c; - int k = movingobjectposition.d; + Vec3D vec3d2 = entityhuman.d(f); + boolean flag = false; + float f9 = 1.0F; + List list = world.b((Entity) entityhuman, entityhuman.boundingBox.a(vec3d2.a * d3, vec3d2.b * d3, vec3d2.c * d3).b((double) f9, (double) f9, (double) f9)); + + for (int i = 0; i < list.size(); ++i) { + Entity entity = (Entity) list.get(i); - if (!world.isStatic) { - // CraftBukkit start - Boat placement - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, movingobjectposition.face, itemstack); + if (entity.e_()) { + float f10 = entity.j_(); + AxisAlignedBB axisalignedbb = entity.boundingBox.b((double) f10, (double) f10, (double) f10); - if (event.isCancelled()) { - return itemstack; + if (axisalignedbb.a(vec3d)) { + flag = true; } - // CraftBukkit end + } + } + + if (flag) { + return itemstack; + } else { + if (movingobjectposition.type == EnumMovingObjectType.TILE) { + int j = movingobjectposition.b; + int k = movingobjectposition.c; + int l = movingobjectposition.d; + + if (!world.isStatic) { + // CraftBukkit start - Boat placement + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, j, k, l, movingobjectposition.face, itemstack); - if (world.getTypeId(i, j, k) == Block.SNOW.id) { - --j; + if (event.isCancelled()) { + return itemstack; + } + // CraftBukkit end + + if (world.getTypeId(j, k, l) == Block.SNOW.id) { + --k; + } + + world.addEntity(new EntityBoat(world, (double) ((float) j + 0.5F), (double) ((float) k + 1.0F), (double) ((float) l + 0.5F))); } - world.addEntity(new EntityBoat(world, (double) ((float) i + 0.5F), (double) ((float) j + 1.0F), (double) ((float) k + 0.5F))); + if (!entityhuman.abilities.canInstantlyBuild) { + --itemstack.count; + } } - --itemstack.count; + return itemstack; } - - return itemstack; } } } diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index ee348ac9..2eb6104d 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -20,21 +20,11 @@ public class ItemBucket extends Item { public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { float f = 1.0F; - float f1 = entityhuman.lastPitch + (entityhuman.pitch - entityhuman.lastPitch) * f; - float f2 = entityhuman.lastYaw + (entityhuman.yaw - entityhuman.lastYaw) * f; double d0 = entityhuman.lastX + (entityhuman.locX - entityhuman.lastX) * (double) f; double d1 = entityhuman.lastY + (entityhuman.locY - entityhuman.lastY) * (double) f + 1.62D - (double) entityhuman.height; double d2 = entityhuman.lastZ + (entityhuman.locZ - entityhuman.lastZ) * (double) f; - Vec3D vec3d = Vec3D.create(d0, d1, d2); - float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); - float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); - float f5 = -MathHelper.cos(-f1 * 0.017453292F); - float f6 = MathHelper.sin(-f1 * 0.017453292F); - float f7 = f4 * f5; - float f8 = f3 * f5; - double d3 = 5.0D; - Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); - MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, this.a == 0); + boolean flag = this.a == 0; + MovingObjectPosition movingobjectposition = this.a(world, entityhuman, flag); if (movingobjectposition == null) { return itemstack; @@ -49,7 +39,7 @@ public class ItemBucket extends Item { } if (this.a == 0) { - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return itemstack; } @@ -61,6 +51,10 @@ public class ItemBucket extends Item { return itemstack; } + if (entityhuman.abilities.canInstantlyBuild) { + return itemstack; + } + CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); // CraftBukkit end @@ -77,6 +71,10 @@ public class ItemBucket extends Item { return itemstack; } + if (entityhuman.abilities.canInstantlyBuild) { + return itemstack; + } + CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); // CraftBukkit end @@ -125,7 +123,7 @@ public class ItemBucket extends Item { ++i; } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return itemstack; } diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index 31940e2e..fc3dd9c9 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -29,7 +29,7 @@ public class ItemDoor extends Item { block = Block.IRON_DOOR_BLOCK; } - if (entityhuman.c(i, j, k) && entityhuman.c(i, j + 1, k)) { + if (entityhuman.d(i, j, k) && entityhuman.d(i, j + 1, k)) { if (!block.canPlace(world, i, j, k)) { return false; } else { @@ -39,9 +39,8 @@ public class ItemDoor extends Item { if (a(world, i, j, k, i1, block, entityhuman)) { --itemstack.count; return true; - } else { - return false; } + return false; // CraftBukkit end } } else { diff --git a/src/main/java/net/minecraft/server/ItemFishingRod.java b/src/main/java/net/minecraft/server/ItemFishingRod.java index cf5715a4..33fa84bf 100644 --- a/src/main/java/net/minecraft/server/ItemFishingRod.java +++ b/src/main/java/net/minecraft/server/ItemFishingRod.java @@ -6,16 +6,16 @@ public class ItemFishingRod extends Item { public ItemFishingRod(int i) { super(i); - this.d(64); - this.c(1); + this.f(64); + this.e(1); } public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { if (entityhuman.hookedFish != null) { - int i = entityhuman.hookedFish.i(); + int i = entityhuman.hookedFish.j(); itemstack.damage(i, entityhuman); - entityhuman.v(); + entityhuman.r_(); } else { // CraftBukkit start PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null,PlayerFishEvent.State.FISHING); @@ -25,12 +25,13 @@ public class ItemFishingRod extends Item { return itemstack; } // CraftBukkit end - world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (b.nextFloat() * 0.4F + 0.8F)); + + world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (c.nextFloat() * 0.4F + 0.8F)); if (!world.isStatic) { world.addEntity(new EntityFishingHook(world, entityhuman)); } - entityhuman.v(); + entityhuman.r_(); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 56646bbb..1405b08c 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -13,7 +13,7 @@ public class ItemFlintAndSteel extends Item { public ItemFlintAndSteel(int i) { super(i); this.maxStackSize = 1; - this.d(64); + this.f(64); } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { @@ -43,7 +43,7 @@ public class ItemFlintAndSteel extends Item { ++i; } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else { int i1 = world.getTypeId(i, j, k); @@ -64,7 +64,7 @@ public class ItemFlintAndSteel extends Item { 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.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, c.nextFloat() * 0.4F + 0.8F); world.setTypeId(i, j, k, Block.FIRE.id); // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/ItemFood.java b/src/main/java/net/minecraft/server/ItemFood.java index de922f2c..755e13c8 100644 --- a/src/main/java/net/minecraft/server/ItemFood.java +++ b/src/main/java/net/minecraft/server/ItemFood.java @@ -5,21 +5,21 @@ import org.bukkit.event.entity.FoodLevelChangeEvent; // CraftBukkit public class ItemFood extends Item { public final int a; - private final int bt; - private final float bu; - private final boolean bv; - private boolean bw; - private int bx; - private int by; - private int bz; - private float bA; + private final int b; + private final float bR; + private final boolean bS; + private boolean bT; + private int bU; + private int bV; + private int bW; + private float bX; public ItemFood(int i, int j, float f, boolean flag) { super(i); this.a = 32; - this.bt = j; - this.bv = flag; - this.bu = f; + this.b = j; + this.bS = flag; + this.bR = f; } public ItemFood(int i, int j, boolean flag) { @@ -31,16 +31,16 @@ public class ItemFood extends Item { // CraftBukkit start int oldFoodLevel = entityhuman.getFoodData().foodLevel; - FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.k() + entityhuman.getFoodData().foodLevel, 20)); + FoodLevelChangeEvent event = new FoodLevelChangeEvent(entityhuman.getBukkitEntity(), Math.min(this.n() + entityhuman.getFoodData().foodLevel, 20)); entityhuman.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - entityhuman.getFoodData().a(event.getFoodLevel() - oldFoodLevel, this.l()); + entityhuman.getFoodData().a(event.getFoodLevel() - oldFoodLevel, this.o()); } // CraftBukkit end - if (!world.isStatic && this.bx > 0 && world.random.nextFloat() < this.bA) { - entityhuman.addEffect(new MobEffect(this.bx, this.by * 20, this.bz)); + if (!world.isStatic && this.bU > 0 && world.random.nextFloat() < this.bX) { + entityhuman.addEffect(new MobEffect(this.bU, this.bV * 20, this.bW)); } return itemstack; @@ -50,40 +50,40 @@ public class ItemFood extends Item { return 32; } - public EnumAnimation b(ItemStack itemstack) { + public EnumAnimation d(ItemStack itemstack) { return EnumAnimation.b; } public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (entityhuman.c(this.bw)) { + if (entityhuman.b(this.bT)) { entityhuman.a(itemstack, this.c(itemstack)); } return itemstack; } - public int k() { - return this.bt; + public int n() { + return this.b; } - public float l() { - return this.bu; + public float o() { + return this.bR; } - public boolean m() { - return this.bv; + public boolean p() { + return this.bS; } public ItemFood a(int i, int j, int k, float f) { - this.bx = i; - this.by = j; - this.bz = k; - this.bA = f; + this.bU = i; + this.bV = j; + this.bW = k; + this.bX = f; return this; } - public ItemFood n() { - this.bw = true; + public ItemFood q() { + this.bT = true; return this; } diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index 318fcd75..6286cd9b 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -11,11 +11,11 @@ public class ItemHoe extends Item { public ItemHoe(int i, EnumToolMaterial enumtoolmaterial) { super(i); this.maxStackSize = 1; - this.d(enumtoolmaterial.a()); + this.f(enumtoolmaterial.a()); } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else { int i1 = world.getTypeId(i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index e88f63c3..bc560e09 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -215,17 +215,18 @@ public class ItemInWorldManager { if (this.b()) { ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); } else { - ItemStack itemstack = this.player.K(); + ItemStack itemstack = this.player.P(); + boolean flag1 = this.player.b(Block.byId[l]); if (itemstack != null) { itemstack.a(l, i, j, k, this.player); if (itemstack.count == 0) { itemstack.a(this.player); - this.player.L(); + this.player.Q(); } } - if (flag && this.player.b(Block.byId[l])) { + if (flag && flag1) { Block.byId[l].a(this.world, this.player, i, j, k, i1); } } diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java index 5e83b1ad..dd73f3b5 100644 --- a/src/main/java/net/minecraft/server/ItemMinecart.java +++ b/src/main/java/net/minecraft/server/ItemMinecart.java @@ -19,7 +19,7 @@ public class ItemMinecart 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); - if (BlockMinecartTrack.c(i1)) { + if (BlockMinecartTrack.d(i1)) { if (!world.isStatic) { // CraftBukkit start - Minecarts PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, i, j, k, l, itemstack); diff --git a/src/main/java/net/minecraft/server/ItemPainting.java b/src/main/java/net/minecraft/server/ItemPainting.java index 5985a6b4..445f53e2 100644 --- a/src/main/java/net/minecraft/server/ItemPainting.java +++ b/src/main/java/net/minecraft/server/ItemPainting.java @@ -32,12 +32,12 @@ public class ItemPainting extends Item { b0 = 3; } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else { EntityPainting entitypainting = new EntityPainting(world, i, j, k, b0); - if (entitypainting.i()) { + if (entitypainting.j()) { if (!world.isStatic) { // CraftBukkit start Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index 7f22ce18..53f668d9 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -45,7 +45,7 @@ public class ItemRedstone extends Item { } } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else { if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { diff --git a/src/main/java/net/minecraft/server/ItemReed.java b/src/main/java/net/minecraft/server/ItemReed.java index b0bd521b..b5c62849 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -47,7 +47,7 @@ public class ItemReed extends Item { } } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else if (itemstack.count == 0) { return false; diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java index 0fb19e91..8033d6d0 100644 --- a/src/main/java/net/minecraft/server/ItemSeeds.java +++ b/src/main/java/net/minecraft/server/ItemSeeds.java @@ -9,19 +9,21 @@ import org.bukkit.event.block.BlockPlaceEvent; public class ItemSeeds extends Item { private int id; + private int b; - public ItemSeeds(int i, int j) { + public ItemSeeds(int i, int j, int k) { super(i); this.id = j; + this.b = k; } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { if (l != 1) { return false; - } else if (entityhuman.c(i, j, k) && entityhuman.c(i, j + 1, k)) { + } else if (entityhuman.d(i, j, k) && entityhuman.d(i, j + 1, k)) { int i1 = world.getTypeId(i, j, k); - if (i1 == Block.SOIL.id && world.isEmpty(i, j + 1, k)) { + if (i1 == this.b && world.isEmpty(i, j + 1, k)) { CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit world.setTypeId(i, j + 1, k, this.id); diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index 7aeaaff6..fc603c11 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -41,7 +41,7 @@ public class ItemSign extends Item { ++i; } - if (!entityhuman.c(i, j, k)) { + if (!entityhuman.d(i, j, k)) { return false; } else if (!Block.SIGN_POST.canPlace(world, i, j, k)) { return false; diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index a624e7fc..fedb9d39 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -5,6 +5,7 @@ public final class ItemStack { public int count; public int b; public int id; + public NBTTagCompound tag; private int damage; public ItemStack(Block block) { @@ -50,8 +51,14 @@ public final class ItemStack { } public ItemStack a(int i) { + ItemStack itemstack = new ItemStack(this.id, i, this.damage); + + if (this.tag != null) { + itemstack.tag = (NBTTagCompound) this.tag.b(); + } + this.count -= i; - return new ItemStack(this.id, i, this.damage); + return itemstack; } public Item getItem() { @@ -84,13 +91,20 @@ public final class ItemStack { nbttagcompound.a("id", (short) this.id); nbttagcompound.a("Count", (byte) this.count); nbttagcompound.a("Damage", (short) this.damage); + if (this.tag != null) { + nbttagcompound.a("tag", (NBTBase) this.tag); + } + return nbttagcompound; } public void c(NBTTagCompound nbttagcompound) { - this.id = nbttagcompound.d("id"); - this.count = nbttagcompound.c("Count"); - this.damage = nbttagcompound.d("Damage"); + this.id = nbttagcompound.e("id"); + this.count = nbttagcompound.d("Count"); + this.damage = nbttagcompound.e("Damage"); + if (nbttagcompound.hasKey("tag")) { + this.tag = nbttagcompound.l("tag"); + } } public int getMaxStackSize() { @@ -106,7 +120,7 @@ public final class ItemStack { } public boolean usesData() { - return Item.byId[this.id].d(); + return Item.byId[this.id].e(); } public boolean f() { @@ -129,12 +143,21 @@ public final class ItemStack { return Item.byId[this.id].getMaxDurability(); } - public void damage(int i, Entity entity) { + public void damage(int i, EntityLiving entityliving) { if (this.d()) { + if (i > 0 && entityliving instanceof EntityHuman) { + int j = EnchantmentManager.c(((EntityHuman) entityliving).inventory); + + if (j > 0 && entityliving.world.random.nextInt(j + 1) > 0) { + return; + } + } + this.damage += i; if (this.damage > this.i()) { - if (entity instanceof EntityHuman) { - ((EntityHuman) entity).a(StatisticList.F[this.id], 1); + entityliving.c(this); + if (entityliving instanceof EntityHuman) { + ((EntityHuman) entityliving).a(StatisticList.F[this.id], 1); } --this.count; @@ -178,7 +201,16 @@ public final class ItemStack { } public ItemStack cloneItemStack() { - return new ItemStack(this.id, this.count, this.damage); + ItemStack itemstack = new ItemStack(this.id, this.count, this.damage); + + if (this.tag != null) { + itemstack.tag = (NBTTagCompound) this.tag.b(); + if (!itemstack.tag.equals(this.tag)) { + return itemstack; + } + } + + return itemstack; } public static boolean equals(ItemStack itemstack, ItemStack itemstack1) { @@ -186,7 +218,7 @@ public final class ItemStack { } private boolean d(ItemStack itemstack) { - return this.count != itemstack.count ? false : (this.id != itemstack.id ? false : this.damage == itemstack.damage); + return this.count != itemstack.count ? false : (this.id != itemstack.id ? false : (this.damage != itemstack.damage ? false : (this.tag == null && itemstack.tag != null ? false : this.tag == null || this.tag.equals(itemstack.tag)))); } public boolean doMaterialsMatch(ItemStack itemstack) { @@ -227,10 +259,55 @@ public final class ItemStack { } public EnumAnimation m() { - return this.getItem().b(this); + return this.getItem().d(this); } public void a(World world, EntityHuman entityhuman, int i) { this.getItem().a(this, world, entityhuman, i); } + + public boolean n() { + return this.tag != null; + } + + public NBTTagCompound o() { + return this.tag; + } + + public NBTTagList p() { + return this.tag == null ? null : (NBTTagList) this.tag.b("ench"); + } + + public void d(NBTTagCompound nbttagcompound) { + if (Item.byId[this.id].getMaxStackSize() != 1) { + throw new IllegalArgumentException("Cannot add tag data to a stackable item"); + } else { + this.tag = nbttagcompound; + } + } + + public boolean q() { + return !this.getItem().e(this) ? false : !this.r(); + } + + public void a(Enchantment enchantment, int i) { + if (this.tag == null) { + this.d(new NBTTagCompound()); + } + + if (!this.tag.hasKey("ench")) { + this.tag.a("ench", (NBTBase) (new NBTTagList("ench"))); + } + + NBTTagList nbttaglist = (NBTTagList) this.tag.b("ench"); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + nbttagcompound.a("id", (short) enchantment.id); + nbttagcompound.a("lvl", (short) ((byte) i)); + nbttaglist.a((NBTBase) nbttagcompound); + } + + public boolean r() { + return this.tag != null && this.tag.hasKey("ench"); + } } diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java index 8e7ac204..558a1851 100644 --- a/src/main/java/net/minecraft/server/ItemWorldMap.java +++ b/src/main/java/net/minecraft/server/ItemWorldMap.java @@ -9,7 +9,7 @@ public class ItemWorldMap extends ItemWorldMapBase { protected ItemWorldMap(int i) { super(i); - this.c(1); + this.e(1); } public WorldMap a(ItemStack itemstack, World world) { @@ -21,8 +21,8 @@ public class ItemWorldMap extends ItemWorldMapBase { String s = "map_" + itemstack.getData(); worldmap = new WorldMap(s); - worldmap.b = world.p().c(); - worldmap.c = world.p().e(); + worldmap.b = world.r().c(); + worldmap.c = world.r().e(); worldmap.e = 3; worldmap.map = (byte) world.worldProvider.dimension; worldmap.a(); @@ -105,18 +105,17 @@ 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.D == MaterialMapColor.b) { + } else if (k4 > 0 && j5 > 0 && Block.byId[j5].material.E == MaterialMapColor.b) { flag1 = false; } if (!flag1) { --k4; - if (k4 <= 0) break; // CraftBukkit j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3); } - } while (!flag1); + } while (k4 > 0 && !flag1); - if (j5 != 0 && Block.byId[j5].material.isLiquid()) { + if (k4 > 0 && j5 != 0 && Block.byId[j5].material.isLiquid()) { i5 = k4 - 1; boolean flag2 = false; @@ -163,7 +162,7 @@ public class ItemWorldMap extends ItemWorldMapBase { i5 = 0; if (j4 > 0) { - MaterialMapColor materialmapcolor = Block.byId[j4].material.D; + MaterialMapColor materialmapcolor = Block.byId[j4].material.E; if (materialmapcolor == MaterialMapColor.n) { d2 = (double) i4 * 0.1D + (double) (k1 + j2 & 1) * 0.2D; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 347262e8..f4c2fb5b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -32,28 +32,34 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.PluginLoadOrder; // CraftBukkit end -public class MinecraftServer implements Runnable, ICommandListener { +public class MinecraftServer implements Runnable, ICommandListener, IMinecraftServer { public static Logger log = Logger.getLogger("Minecraft"); public static HashMap trackerList = new HashMap(); + private String s; + private int t; public NetworkListenThread networkListenThread; public PropertyManager propertyManager; // public WorldServer[] worldServer; // CraftBukkit - removed! + public long[] f = new long[100]; + public long[][] g; public ServerConfigurationManager serverConfigurationManager; public ConsoleCommandHandler consoleCommandHandler; // CraftBukkit - made public private boolean isRunning = true; public boolean isStopped = false; int ticks = 0; - public String i; - public int j; - private List s = new ArrayList(); - private List t = Collections.synchronizedList(new ArrayList()); - // public EntityTracker[] tracker = new EntityTracker[2]; // CraftBukkit - removed! + public String k; + public int l; + private List w = new ArrayList(); + private List x = Collections.synchronizedList(new ArrayList()); + // public EntityTracker[] tracker = new EntityTracker[3]; // CraftBukkit - removed! public boolean onlineMode; public boolean spawnAnimals; public boolean pvpMode; public boolean allowFlight; - public String p; + public String r; + private RemoteStatusListener y; + private RemoteControlListener z; // CraftBukkit start public List<WorldServer> worlds = new ArrayList<WorldServer>(); @@ -91,7 +97,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.8.1"); + log.info("Starting minecraft server version 1.0.0"); 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\""); @@ -99,26 +105,24 @@ public class MinecraftServer implements Runnable, ICommandListener { log.info("Loading properties"); this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support - String s = this.propertyManager.getString("server-ip", ""); - + this.s = this.propertyManager.getString("server-ip", ""); this.onlineMode = this.propertyManager.getBoolean("online-mode", true); 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', '$'); + this.r = this.propertyManager.getString("motd", "A Minecraft Server"); + this.r.replace('\u00a7', '$'); InetAddress inetaddress = null; - if (s.length() > 0) { - inetaddress = InetAddress.getByName(s); + if (this.s.length() > 0) { + inetaddress = InetAddress.getByName(this.s); } - int i = this.propertyManager.getInt("server-port", 25565); - - log.info("Starting Minecraft server on " + (s.length() == 0 ? "*" : s) + ":" + i); + this.t = this.propertyManager.getInt("server-port", 25565); + log.info("Starting Minecraft server on " + (this.s.length() == 0 ? "*" : this.s) + ":" + this.t); try { - this.networkListenThread = new NetworkListenThread(this, inetaddress, i); + this.networkListenThread = new NetworkListenThread(this, inetaddress, this.t); } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable log.warning("**** FAILED TO BIND TO PORT!"); log.log(Level.WARNING, "The exception was: " + ioexception.toString()); @@ -135,33 +139,53 @@ public class MinecraftServer implements Runnable, ICommandListener { this.serverConfigurationManager = new ServerConfigurationManager(this); // CraftBukkit - removed trackers - long j = System.nanoTime(); - String s1 = this.propertyManager.getString("level-name", "world"); - String s2 = this.propertyManager.getString("level-seed", ""); - long k = (new Random()).nextLong(); + long i = System.nanoTime(); + String s = this.propertyManager.getString("level-name", "world"); + String s1 = this.propertyManager.getString("level-seed", ""); + long j = (new Random()).nextLong(); - if (s2.length() > 0) { + if (s1.length() > 0) { try { - k = Long.parseLong(s2); + long k = Long.parseLong(s1); + + if (k != 0L) { + j = k; + } } catch (NumberFormatException numberformatexception) { - k = (long) s2.hashCode(); + j = (long) s1.hashCode(); } } - log.info("Preparing level \"" + s1 + "\""); - this.a(new WorldLoaderServer(new File(".")), s1, k); + log.info("Preparing level \"" + s + "\""); + this.a(new WorldLoaderServer(new File(".")), s, j); // CraftBukkit start - long elapsed = System.nanoTime() - j; + long elapsed = System.nanoTime() - i; String time = String.format("%.3fs", elapsed / 10000000000.0D); log.info("Done (" + time + ")! For help, type \"help\" or \"?\""); + // CratBukkit end + if (this.propertyManager.getBoolean("enable-query", false)) { + log.info("Starting GS4 status listener"); + this.y = new RemoteStatusListener(this); + this.y.a(); + } + + if (this.propertyManager.getBoolean("enable-rcon", false)) { + log.info("Starting remote control listener"); + this.z = new RemoteControlListener(this); + this.z.a(); + } + + // CraftBukkit start if (this.propertyManager.properties.containsKey("spawn-protection")) { log.info("'spawn-protection' in server.properties has been moved to 'settings.spawn-radius' in bukkit.yml. I will move your config for you."); this.server.setSpawnRadius(this.propertyManager.getInt("spawn-protection", 16)); this.propertyManager.properties.remove("spawn-protection"); this.propertyManager.savePropertiesFile(); } + // CratBukkit end + return true; } @@ -171,21 +195,36 @@ public class MinecraftServer implements Runnable, ICommandListener { convertable.convert(s, new ConvertProgressUpdater(this)); } - // CraftBukkit - removed world array + // CraftBukkit - removed world and ticktime arrays 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) { + int worldCount = 2; + + if (this.propertyManager.getBoolean("allow-nether", true)) { + worldCount++; + } + + for (int k = 0; k < worldCount; ++k) { WorldServer world; - int dimension = k == 0 ? 0 : -1; + int dimension = 0; + + if (k == 1) { + dimension = -1; + } + + if (k == 2) { + dimension = 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); + WorldSettings settings = new WorldSettings(i, j, true, false); if (k == 0) { world = new WorldServer(this, new ServerNBTManager(server.getWorldContainer(), s, true), s, dimension, settings, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit @@ -231,7 +270,7 @@ public class MinecraftServer implements Runnable, ICommandListener { world.addIWorldAccess(new WorldManager(this, world)); world.difficulty = this.propertyManager.getInt("difficulty", 1); world.setSpawnFlags(this.propertyManager.getBoolean("spawn-monsters", true), this.spawnAnimals); - world.p().setGameType(j); + world.r().setGameType(j); this.worlds.add(world); this.serverConfigurationManager.setPlayerFileData(this.worlds.toArray(new WorldServer[0])); } @@ -261,13 +300,13 @@ public class MinecraftServer implements Runnable, ICommandListener { int i2 = (short1 * 2 + 1) * (short1 * 2 + 1); int j2 = (j1 + short1) * (short1 * 2 + 1) + k1 + 1; - this.a("Preparing spawn area", j2 * 100 / i2); + this.b("Preparing spawn area", j2 * 100 / i2); l = l1; } worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + j1 >> 4, chunkcoordinates.z + k1 >> 4); - while (worldserver.v() && this.isRunning) { + while (worldserver.x() && this.isRunning) { ; } } @@ -281,18 +320,18 @@ public class MinecraftServer implements Runnable, ICommandListener { } // CraftBukkit end - this.e(); + this.t(); } - private void a(String s, int i) { - this.i = s; - this.j = i; + private void b(String s, int i) { + this.k = s; + this.l = i; log.info(s + ": " + i + "%"); } - private void e() { - this.i = null; - this.j = 0; + private void t() { + this.k = null; + this.l = 0; this.server.enablePlugins(PluginLoadOrder.POSTWORLD); // CraftBukkit } @@ -365,13 +404,13 @@ public class MinecraftServer implements Runnable, ICommandListener { j += l; i = k; if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit - this.h(); + this.w(); j = 0L; } else { while (j > 50L) { MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit j -= 50L; - this.h(); + this.w(); } } } @@ -411,25 +450,26 @@ public class MinecraftServer implements Runnable, ICommandListener { } } - private void h() { + private void w() { + long i = System.nanoTime(); ArrayList arraylist = new ArrayList(); Iterator iterator = trackerList.keySet().iterator(); while (iterator.hasNext()) { String s = (String) iterator.next(); - int i = ((Integer) trackerList.get(s)).intValue(); + int j = ((Integer) trackerList.get(s)).intValue(); - if (i > 0) { - trackerList.put(s, Integer.valueOf(i - 1)); + if (j > 0) { + trackerList.put(s, Integer.valueOf(j - 1)); } else { arraylist.add(s); } } - int j; + int k; - for (j = 0; j < arraylist.size(); ++j) { - trackerList.remove(arraylist.get(j)); + for (k = 0; k < arraylist.size(); ++k) { + trackerList.remove(arraylist.get(k)); } AxisAlignedBB.a(); @@ -442,15 +482,16 @@ public class MinecraftServer implements Runnable, ICommandListener { // Send timeupdates to everyone, it will get the right time from the world the player is in. if (this.ticks % 20 == 0) { - for (int i = 0; i < this.serverConfigurationManager.players.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(i); + for ( k = 0; k < this.serverConfigurationManager.players.size(); ++k) { + EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k); entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time } } - for (j = 0; j < this.worlds.size(); ++j) { - // if (j == 0 || this.propertyManager.getBoolean("allow-nether", true)) { - WorldServer worldserver = this.worlds.get(j); + for (k = 0; k < this.worlds.size(); ++k) { + long l = System.nanoTime(); + // if (k == 0 || this.propertyManager.getBoolean("allow-nether", true)) { + WorldServer worldserver = this.worlds.get(k); /* Drop global timeupdates if (this.ticks % 20 == 0) { @@ -460,25 +501,28 @@ public class MinecraftServer implements Runnable, ICommandListener { worldserver.doTick(); - while (worldserver.v()) { - ; + while (true) { + if (!worldserver.x()) { + worldserver.tickEntities(); + break; + } } - - worldserver.tickEntities(); } + + // this.g[k][this.ticks % 100] = System.nanoTime() - l; // CraftBukkit // } // CraftBukkit this.networkListenThread.a(); this.serverConfigurationManager.b(); // CraftBukkit start - for (j = 0; j < this.worlds.size(); ++j) { - this.worlds.get(j).tracker.updatePlayers(); + for (k = 0; k < this.worlds.size(); ++k) { + this.worlds.get(k).tracker.updatePlayers(); } // CraftBukkit end - for (j = 0; j < this.s.size(); ++j) { - ((IUpdatePlayerListBox) this.s.get(j)).a(); + for (k = 0; k < this.w.size(); ++k) { + ((IUpdatePlayerListBox) this.w.get(k)).a(); } try { @@ -486,15 +530,17 @@ public class MinecraftServer implements Runnable, ICommandListener { } catch (Exception exception) { log.log(Level.WARNING, "Unexpected exception while parsing console command", exception); } + + this.f[this.ticks % 100] = System.nanoTime() - i; } public void issueCommand(String s, ICommandListener icommandlistener) { - this.t.add(new ServerCommand(s, icommandlistener)); + this.x.add(new ServerCommand(s, icommandlistener)); } public void b() { - while (this.t.size() > 0) { - ServerCommand servercommand = (ServerCommand) this.t.remove(0); + while (this.x.size() > 0) { + ServerCommand servercommand = (ServerCommand) this.x.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); @@ -508,7 +554,7 @@ public class MinecraftServer implements Runnable, ICommandListener { } public void a(IUpdatePlayerListBox iupdateplayerlistbox) { - this.s.add(iupdateplayerlistbox); + this.w.add(iupdateplayerlistbox); } public static void main(final OptionSet options) { // CraftBukkit - replaces main(String args[]) @@ -533,7 +579,7 @@ public class MinecraftServer implements Runnable, ICommandListener { log.info(s); } - public void c(String s) { + public void warning(String s) { log.warning(s); } @@ -557,6 +603,94 @@ public class MinecraftServer implements Runnable, ICommandListener { return this.getWorldServer(i).tracker; // CraftBukkit } + public int getProperty(String s, int i) { + return this.propertyManager.getInt(s, i); + } + + public String a(String s, String s1) { + return this.propertyManager.getString(s, s1); + } + + public void a(String s, Object object) { + this.propertyManager.a(s, object); + } + + public void c() { + this.propertyManager.savePropertiesFile(); + } + + public String getPropertiesFile() { + File file1 = this.propertyManager.c(); + + return file1 != null ? file1.getAbsolutePath() : "No settings file"; + } + + public String getMotd() { + return this.s; + } + + public int getPort() { + return this.t; + } + + public String getServerAddress() { + return this.r; + } + + public String getVersion() { + return "1.0.0"; + } + + public int getPlayerCount() { + return this.serverConfigurationManager.j(); + } + + public int getMaxPlayers() { + return this.serverConfigurationManager.k(); + } + + public String[] getPlayers() { + return this.serverConfigurationManager.d(); + } + + public String getWorldName() { + return this.propertyManager.getString("level-name", "world"); + } + + public String getPlugins() { + return ""; + } + + public void o() {} + + public String d(String s) { + RemoteControlCommandListener.a.a(); + this.consoleCommandHandler.handle(new ServerCommand(s, RemoteControlCommandListener.a)); + return RemoteControlCommandListener.a.b(); + } + + public boolean isDebugging() { + return false; + } + + public void severe(String s) { + log.log(Level.SEVERE, s); + } + + public void debug(String s) { + if (this.isDebugging()) { + log.log(Level.INFO, s); + } + } + + public String[] q() { + return (String[]) this.serverConfigurationManager.f().toArray(new String[0]); + } + + public String[] r() { + return (String[]) this.serverConfigurationManager.e().toArray(new String[0]); + } + public static boolean isRunning(MinecraftServer minecraftserver) { return minecraftserver.isRunning; } diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index e7d6d6e2..1b00ff40 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -20,7 +20,7 @@ public class NetLoginHandler extends NetHandler { private int f = 0; private String g = null; private Packet1Login h = null; - private String i = Long.toHexString(d.nextLong()); + private String i = Long.toString(d.nextLong(), 16); // CraftBukkit -- Thanks Jens! :D public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) { this.server = minecraftserver; @@ -69,8 +69,8 @@ public class NetLoginHandler extends NetHandler { public void a(Packet1Login packet1login) { this.g = packet1login.name; - if (packet1login.a != 17) { - if (packet1login.a > 17) { + if (packet1login.a != 22) { + if (packet1login.a > 22) { this.disconnect("Outdated server!"); } else { this.disconnect("Outdated client!"); @@ -90,31 +90,23 @@ public class NetLoginHandler extends NetHandler { if (entityplayer != null) { 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); + // CraftBukkit - add world and location to 'logged in' message. 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().getGameType()); + entityplayer.itemInWorldManager.b(worldserver.r().getGameType()); NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); - int i = entityplayer.id; - long j = worldserver.getSeed(); - int k = entityplayer.itemInWorldManager.a(); - byte b0 = (byte) worldserver.worldProvider.dimension; - byte b1 = (byte) worldserver.difficulty; - - worldserver.getClass(); // CraftBukkit start -- Don't send a higher than 60 MaxPlayer size, otherwise the PlayerInfo window won't render correctly. - int maxPlayers = this.server.serverConfigurationManager.h(); + int maxPlayers = this.server.serverConfigurationManager.k(); if (maxPlayers > 60) { maxPlayers = 60; } - Packet1Login packet1login1 = new Packet1Login("", i, j, k, b0, b1, (byte) -128, (byte) maxPlayers); + netserverhandler.sendPacket(new Packet1Login("", entityplayer.id, worldserver.getSeed(), entityplayer.itemInWorldManager.a(), (byte) worldserver.worldProvider.dimension, (byte) worldserver.difficulty, (byte) worldserver.height, (byte) maxPlayers)); // CraftBukkit end - 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 @@ -145,8 +137,8 @@ public class NetLoginHandler extends NetHandler { if (this.networkManager.f() == null) return; // CraftBukkit - fix NPE when a client queries a server that is unable to handle it. try { // CraftBukkit start - ServerListPingEvent pingEvent = CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.p, this.server.serverConfigurationManager.g(), this.server.serverConfigurationManager.h()); - String s = pingEvent.getMotd() + "\u00A7" + this.server.serverConfigurationManager.g() + "\u00A7" + pingEvent.getMaxPlayers(); + ServerListPingEvent pingEvent = CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.r, this.server.serverConfigurationManager.j(), this.server.serverConfigurationManager.k()); + String s = pingEvent.getMotd() + "\u00A7" + this.server.serverConfigurationManager.j() + "\u00A7" + pingEvent.getMaxPlayers(); // CraftBukkit end this.networkManager.queue(new Packet255KickDisconnect(s)); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index d688b93c..81b541bb 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -113,7 +113,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { s = event.getReason(); // CraftBukkit end - this.player.A(); + this.player.E(); this.sendPacket(new Packet255KickDisconnect(s)); this.networkManager.d(); @@ -136,244 +136,248 @@ public class NetServerHandler extends NetHandler implements ICommandListener { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); this.h = true; - double d0; + if (!this.player.j) { + double d0; - if (!this.checkMovement) { - d0 = packet10flying.y - this.y; - if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) { - this.checkMovement = true; + if (!this.checkMovement) { + d0 = packet10flying.y - this.y; + if (packet10flying.x == this.x && d0 * d0 < 0.01D && packet10flying.z == this.z) { + this.checkMovement = true; + } } - } - - // CraftBukkit start - Player player = this.getPlayer(); - Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. - Location to = player.getLocation().clone(); // Start off the To location as the Players current location. - - // If the packet contains movement information then we update the To location with the correct XYZ. - if (packet10flying.h && !(packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D)) { - to.setX(packet10flying.x); - to.setY(packet10flying.y); - to.setZ(packet10flying.z); - } - // If the packet contains look information then we update the To location with the correct Yaw & Pitch. - if (packet10flying.hasLook) { - to.setYaw(packet10flying.yaw); - to.setPitch(packet10flying.pitch); - } - - // Prevent 40 event-calls for less than a single pixel of movement >.> - double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); - float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); - - if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) { - this.lastPosX = to.getX(); - this.lastPosY = to.getY(); - this.lastPosZ = to.getZ(); - this.lastYaw = to.getYaw(); - this.lastPitch = to.getPitch(); + // CraftBukkit start + Player player = this.getPlayer(); + Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location. + Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + + // If the packet contains movement information then we update the To location with the correct XYZ. + if (packet10flying.h && !(packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D)) { + to.setX(packet10flying.x); + to.setY(packet10flying.y); + to.setZ(packet10flying.z); + } - // Skip the first time we do this - if (from.getX() != Double.MAX_VALUE) { - PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); - this.server.getPluginManager().callEvent(event); + // If the packet contains look information then we update the To location with the correct Yaw & Pitch. + if (packet10flying.hasLook) { + to.setYaw(packet10flying.yaw); + to.setPitch(packet10flying.pitch); + } - // If the event is cancelled we move the player back to their old location. - if (event.isCancelled()) { - this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(from.getX(), from.getY() + 1.6200000047683716D, from.getY(), from.getZ(), from.getYaw(), from.getPitch(), false)); - return; - } + // Prevent 40 event-calls for less than a single pixel of movement >.> + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + + if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); + this.lastYaw = to.getYaw(); + this.lastPitch = to.getPitch(); + + // Skip the first time we do this + if (from.getX() != Double.MAX_VALUE) { + PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); + this.server.getPluginManager().callEvent(event); + + // If the event is cancelled we move the player back to their old location. + if (event.isCancelled()) { + this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(from.getX(), from.getY() + 1.6200000047683716D, from.getY(), from.getZ(), from.getYaw(), from.getPitch(), false)); + return; + } - /* If a Plugin has changed the To destination then we teleport the Player - there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. - We only do this if the Event was not cancelled. */ - if (!to.equals(event.getTo()) && !event.isCancelled()) { - this.player.getBukkitEntity().teleport(event.getTo()); - return; - } + /* If a Plugin has changed the To destination then we teleport the Player + there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. + We only do this if the Event was not cancelled. */ + if (!to.equals(event.getTo()) && !event.isCancelled()) { + this.player.getBukkitEntity().teleport(event.getTo()); + return; + } - /* Check to see if the Players Location has some how changed during the call of the event. - This can happen due to a plugin teleporting the player instead of using .setTo() */ - if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { - this.justTeleported = false; - return; + /* Check to see if the Players Location has some how changed during the call of the event. + This can happen due to a plugin teleporting the player instead of using .setTo() */ + if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { + this.justTeleported = false; + return; + } } } - } - if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) { - player.teleport(player.getWorld().getSpawnLocation()); - System.err.println(player.getName() + " was caught trying to crash the server with an invalid position."); - player.kickPlayer("Nope!"); - return; - } + if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z) || Double.isNaN(packet10flying.stance)) { + player.teleport(player.getWorld().getSpawnLocation()); + System.err.println(player.getName() + " was caught trying to crash the server with an invalid position."); + player.kickPlayer("Nope!"); + return; + } - if (this.checkMovement && !this.player.dead) { - // CraftBukkit end - double d1; - double d2; - double d3; - double d4; + if (this.checkMovement && !this.player.dead) { + // CraftBukkit end + double d1; + double d2; + double d3; + double d4; - if (this.player.vehicle != null) { - float f = this.player.yaw; - float f1 = this.player.pitch; + if (this.player.vehicle != null) { + float f = this.player.yaw; + float f1 = this.player.pitch; + + this.player.vehicle.i(); + d1 = this.player.locX; + d2 = this.player.locY; + d3 = this.player.locZ; + double d5 = 0.0D; + + d4 = 0.0D; + if (packet10flying.hasLook) { + f = packet10flying.yaw; + f1 = packet10flying.pitch; + } - this.player.vehicle.g_(); - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - double d5 = 0.0D; + if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) { + d5 = packet10flying.x; + d4 = packet10flying.z; + } - d4 = 0.0D; - if (packet10flying.hasLook) { - f = packet10flying.yaw; - f1 = packet10flying.pitch; - } + this.player.onGround = packet10flying.g; + this.player.a(true); + this.player.move(d5, 0.0D, d4); + this.player.setLocation(d1, d2, d3, f, f1); + this.player.motX = d5; + this.player.motZ = d4; + if (this.player.vehicle != null) { + worldserver.vehicleEnteredWorld(this.player.vehicle, true); + } - if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) { - d5 = packet10flying.x; - d4 = packet10flying.z; - } + if (this.player.vehicle != null) { + this.player.vehicle.i(); + } - this.player.onGround = packet10flying.g; - this.player.b(true); - this.player.move(d5, 0.0D, d4); - this.player.setLocation(d1, d2, d3, f, f1); - this.player.motX = d5; - this.player.motZ = d4; - if (this.player.vehicle != null) { - worldserver.vehicleEnteredWorld(this.player.vehicle, true); + this.minecraftServer.serverConfigurationManager.d(this.player); + this.x = this.player.locX; + this.y = this.player.locY; + this.z = this.player.locZ; + worldserver.playerJoinedWorld(this.player); + return; } - if (this.player.vehicle != null) { - this.player.vehicle.g_(); + if (this.player.isSleeping()) { + this.player.a(true); + this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch); + worldserver.playerJoinedWorld(this.player); + return; } - this.minecraftServer.serverConfigurationManager.d(this.player); + d0 = this.player.locY; this.x = this.player.locX; this.y = this.player.locY; this.z = this.player.locZ; - worldserver.playerJoinedWorld(this.player); - return; - } + d1 = this.player.locX; + d2 = this.player.locY; + d3 = this.player.locZ; + float f2 = this.player.yaw; + float f3 = this.player.pitch; - if (this.player.isSleeping()) { - this.player.b(true); - this.player.setLocation(this.x, this.y, this.z, this.player.yaw, this.player.pitch); - worldserver.playerJoinedWorld(this.player); - return; - } + if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) { + packet10flying.h = false; + } - d0 = this.player.locY; - this.x = this.player.locX; - this.y = this.player.locY; - this.z = this.player.locZ; - d1 = this.player.locX; - d2 = this.player.locY; - d3 = this.player.locZ; - float f2 = this.player.yaw; - float f3 = this.player.pitch; - - if (packet10flying.h && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) { - packet10flying.h = false; - } + if (packet10flying.h) { + d1 = packet10flying.x; + d2 = packet10flying.y; + d3 = packet10flying.z; + d4 = packet10flying.stance - packet10flying.y; + if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) { + this.disconnect("Illegal stance"); + a.warning(this.player.name + " had an illegal stance: " + d4); + return; + } - if (packet10flying.h) { - d1 = packet10flying.x; - d2 = packet10flying.y; - d3 = packet10flying.z; - d4 = packet10flying.stance - packet10flying.y; - if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) { - this.disconnect("Illegal stance"); - a.warning(this.player.name + " had an illegal stance: " + d4); - return; + if (Math.abs(packet10flying.x) > 3.2E7D || Math.abs(packet10flying.z) > 3.2E7D) { + this.disconnect("Illegal position"); + return; + } } - if (Math.abs(packet10flying.x) > 3.2E7D || Math.abs(packet10flying.z) > 3.2E7D) { - this.disconnect("Illegal position"); - return; + if (packet10flying.hasLook) { + f2 = packet10flying.yaw; + f3 = packet10flying.pitch; } - } - if (packet10flying.hasLook) { - f2 = packet10flying.yaw; - f3 = packet10flying.pitch; - } + this.player.a(true); + this.player.bL = 0.0F; + this.player.setLocation(this.x, this.y, this.z, f2, f3); + if (!this.checkMovement) { + return; + } - this.player.b(true); - this.player.bH = 0.0F; - this.player.setLocation(this.x, this.y, this.z, f2, f3); - if (!this.checkMovement) { - return; - } + d4 = d1 - this.player.locX; + double d6 = d2 - this.player.locY; + double d7 = d3 - this.player.locZ; + double d8 = d4 * d4 + d6 * d6 + d7 * d7; - d4 = d1 - this.player.locX; - double d6 = d2 - this.player.locY; - double d7 = d3 - this.player.locZ; - double d8 = d4 * d4 + d6 * d6 + d7 * d7; + 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; + } - 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; - } + float f4 = 0.0625F; + boolean flag = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0; - 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.c(0.2F); + } - 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.b(d4, d6, d7); + double d9 = d6; - 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) { - d6 = 0.0D; - } + d4 = d1 - this.player.locX; + d6 = d2 - this.player.locY; + if (d6 > -0.5D || d6 < 0.5D) { + d6 = 0.0D; + } - d7 = d3 - this.player.locZ; - d8 = d4 * d4 + d6 * d6 + d7 * d7; - boolean flag1 = false; + d7 = d3 - this.player.locZ; + d8 = d4 * d4 + d6 * d6 + d7 * d7; + boolean flag1 = false; - 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); - System.out.println("Expected " + this.player.locX + ", " + this.player.locY + ", " + this.player.locZ); - } + 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); + System.out.println("Expected " + this.player.locX + ", " + this.player.locY + ", " + this.player.locZ); + } - this.player.setLocation(d1, d2, d3, f2, f3); - boolean flag2 = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0; + this.player.setLocation(d1, d2, d3, f2, f3); + boolean flag2 = worldserver.getEntities(this.player, this.player.boundingBox.clone().shrink((double) f4, (double) f4, (double) f4)).size() == 0; - if (flag && (flag1 || !flag2) && !this.player.isSleeping()) { - this.a(this.x, this.y, this.z, f2, f3); - return; - } + if (flag && (flag1 || !flag2) && !this.player.isSleeping()) { + this.a(this.x, this.y, this.z, f2, f3); + return; + } - AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().b((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D); + AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().b((double) f4, (double) f4, (double) f4).a(0.0D, -0.55D, 0.0D); - if (!this.minecraftServer.allowFlight && !this.player.itemInWorldManager.b() && !worldserver.b(axisalignedbb)) { - if (d6 >= -0.03125D) { - ++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; + if (!this.minecraftServer.allowFlight && !this.player.itemInWorldManager.b() && !worldserver.b(axisalignedbb)) { + if (d9 >= -0.03125D) { + ++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.g = 0; } - } else { - this.g = 0; - } - this.player.onGround = packet10flying.g; - this.minecraftServer.serverConfigurationManager.d(this.player); - if (this.player.itemInWorldManager.b()) return; // CraftBukkit - fixed fall distance accumulating while being in Creative mode. - this.player.b(this.player.locY - d0, packet10flying.g); + this.player.onGround = packet10flying.g; + this.minecraftServer.serverConfigurationManager.d(this.player); + if (this.player.itemInWorldManager.b()) return; // CraftBukkit - fixed fall distance accumulating while being in Creative mode. + this.player.b(this.player.locY - d0, packet10flying.g); + } } } @@ -447,9 +451,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } // CraftBukkit end - this.player.J(); + this.player.N(); } else if (packet14blockdig.e == 5) { - this.player.E(); + this.player.I(); } else { boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit boolean flag1 = false; @@ -462,17 +466,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener { flag1 = true; } - if (this.player.itemInWorldManager.b()) { - flag1 = true; // CraftBukkit - false -> true - } - int i = packet14blockdig.a; int j = packet14blockdig.b; int k = packet14blockdig.c; if (flag1) { double d0 = this.player.locX - ((double) i + 0.5D); - double d1 = this.player.locY - ((double) j + 0.5D); + double d1 = this.player.locY - ((double) j + 0.5D) + 1.5D; double d2 = this.player.locZ - ((double) k + 0.5D); double d3 = d0 * d0 + d1 * d1 + d2 * d2; @@ -629,13 +629,13 @@ public class NetServerHandler extends NetHandler implements ICommandListener { 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); + Slot slot = this.player.activeContainer.a((IInventory) this.player.inventory, this.player.inventory.itemInHandIndex); 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())); + this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.c, this.player.inventory.getItemInHand())); } } @@ -671,7 +671,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.networkManager.queue(new Packet3Chat(line)); } packet = null; - } else if (packet.k == true) { + } else if (packet.l == true) { // Reroute all low-priority packets through to compression thread. ChunkCompressionThread.sendPacket(this.player, packet); packet = null; @@ -684,8 +684,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // CraftBukkit start if (this.player.dead) return; - // Changed <= to < - if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < InventoryPlayer.g()) { + if (packet16blockitemswitch.itemInHandIndex >= 0 && packet16blockitemswitch.itemInHandIndex < InventoryPlayer.h()) { PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex); this.server.getPluginManager().callEvent(event); // CraftBukkit end @@ -832,7 +831,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (event.isCancelled()) return; // CraftBukkit end - this.player.v(); + this.player.r_(); } } @@ -895,7 +894,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = worldserver.getEntity(packet7useentity.target); - if (entity != null && this.player.f(entity) && this.player.h(entity) < 36.0D) { + if (entity != null && this.player.g(entity) && this.player.i(entity) < 36.0D) { ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit if (packet7useentity.c == 0) { // CraftBukkit start @@ -906,14 +905,14 @@ public class NetServerHandler extends NetHandler implements ICommandListener { return; } // CraftBukkit end - this.player.c(entity); + this.player.e(entity); // CraftBukkit start - update the client if the item is an infinite one if (itemInHand != null && itemInHand.count <= -1) { this.player.updateInventory(this.player.activeContainer); } // CraftBukkit end } else if (packet7useentity.c == 1) { - this.player.d(entity); + this.player.f(entity); // CraftBukkit start - update the client if the item is an infinite one if (itemInHand != null && itemInHand.count <= -1) { this.player.updateInventory(this.player.activeContainer); @@ -924,17 +923,22 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void a(Packet9Respawn packet9respawn) { - if (this.player.health <= 0) { - this.player = this.minecraftServer.serverConfigurationManager.moveToWorld(this.player, 0); + if (this.player.j) { + this.player = this.minecraftServer.serverConfigurationManager.moveToWorld(this.player, 0, true); + } else { + if (this.player.getHealth() > 0) { + return; + } - this.getPlayer().setHandle(this.player); // CraftBukkit + this.player = this.minecraftServer.serverConfigurationManager.moveToWorld(this.player, 0, false); } + this.getPlayer().setHandle(this.player); // CraftBukkit } public void a(Packet101CloseWindow packet101closewindow) { if (this.player.dead) return; // CraftBukkit - this.player.z(); + this.player.D(); } public void a(Packet102WindowClick packet102windowclick) { @@ -947,7 +951,7 @@ 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.y(); + this.player.C(); this.player.h = false; } else { this.q.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d)); @@ -964,22 +968,31 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } } + public void a(Packet108 packet108) { + if (this.player.activeContainer.windowId == packet108.a && this.player.activeContainer.c(this.player)) { + this.player.activeContainer.a((EntityHuman) this.player, packet108.b); + this.player.activeContainer.a(); + } + } + 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) { + boolean flag = packet107setcreativeslot.a < 0; + ItemStack itemstack = packet107setcreativeslot.b; + boolean flag1 = packet107setcreativeslot.a >= 36 && packet107setcreativeslot.a < 36 + InventoryPlayer.h(); + boolean flag2 = itemstack == null || itemstack.id < Item.byId.length && itemstack.id >= 0 && Item.byId[itemstack.id] != null; + boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0; + + if (flag1 && flag2 && flag3) { + if (itemstack == null) { 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(packet107setcreativeslot.a, itemstack); } 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)); + } else if (flag && flag2 && flag3) { + this.player.b(itemstack); } } } @@ -1004,8 +1017,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign) tileentity; - if (!tileentitysign.a()) { - this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign"); + if (!tileentitysign.c()) { + this.minecraftServer.warning("Player " + this.player.name + " just tried to change non-editable sign"); // CraftBukkit this.sendPacket(new Packet130UpdateSign(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z, tileentitysign.lines)); return; diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index f7b56f74..f953dd5a 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -79,7 +79,7 @@ public class NetworkManager { synchronized (this.g) { this.x += packet.a() + 1; - if (packet.k) { + if (packet.l) { this.lowPriorityQueue.add(packet); } else { this.highPriorityQueue.add(packet); diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java index 06475164..3746fb0d 100644 --- a/src/main/java/net/minecraft/server/Packet.java +++ b/src/main/java/net/minecraft/server/Packet.java @@ -11,38 +11,36 @@ import java.util.Set; public abstract class Packet { - private static EntityList a = new EntityList(); - private static Map b = new HashMap(); + public static EntityList j = new EntityList(); + private static Map a = new HashMap(); + private static Set b = new HashSet(); private static Set c = new HashSet(); - private static Set d = new HashSet(); public final long timestamp = System.currentTimeMillis(); - public boolean k = false; - private static EntityList e; - private static int f; + public boolean l = false; public Packet() {} static void a(int i, boolean flag, boolean flag1, Class oclass) { - if (a.b(i)) { + if (j.b(i)) { throw new IllegalArgumentException("Duplicate packet id:" + i); - } else if (b.containsKey(oclass)) { + } else if (a.containsKey(oclass)) { throw new IllegalArgumentException("Duplicate packet class:" + oclass); } else { - a.a(i, oclass); - b.put(oclass, Integer.valueOf(i)); + j.a(i, oclass); + a.put(oclass, Integer.valueOf(i)); if (flag) { - c.add(Integer.valueOf(i)); + b.add(Integer.valueOf(i)); } if (flag1) { - d.add(Integer.valueOf(i)); + c.add(Integer.valueOf(i)); } } } public static Packet a(int i) { try { - Class oclass = (Class) a.a(i); + Class oclass = (Class) j.a(i); return oclass == null ? null : (Packet) oclass.newInstance(); } catch (Exception exception) { @@ -53,7 +51,7 @@ public abstract class Packet { } public final int b() { - return ((Integer) b.get(this.getClass())).intValue(); + return ((Integer) a.get(this.getClass())).intValue(); } // CraftBukkit - throws IOException @@ -69,7 +67,7 @@ public abstract class Packet { return null; } - if (flag && !d.contains(Integer.valueOf(i)) || !flag && !c.contains(Integer.valueOf(i))) { + if (flag && !c.contains(Integer.valueOf(i)) || !flag && !b.contains(Integer.valueOf(i))) { throw new IOException("Bad packet id " + i); } @@ -94,19 +92,7 @@ public abstract class Packet { } // CraftBukkit end - PacketCounter packetcounter = (PacketCounter) e.a(i); - - if (packetcounter == null) { - packetcounter = new PacketCounter((EmptyClass1) null); - e.a(i, packetcounter); - } - - packetcounter.a(packet.a()); - ++f; - if (f % 1000 == 0) { - ; - } - + PacketCounter.a(i, (long) packet.a()); return packet; } @@ -153,6 +139,60 @@ public abstract class Packet { public abstract int a(); + protected ItemStack b(DataInputStream datainputstream) throws IOException { // CraftBukkit + ItemStack itemstack = null; + short short1 = datainputstream.readShort(); + + if (short1 >= 0) { + byte b0 = datainputstream.readByte(); + short short2 = datainputstream.readShort(); + + itemstack = new ItemStack(short1, b0, short2); + if (Item.byId[short1].g()) { + itemstack.tag = this.c(datainputstream); + } + } + + return itemstack; + } + + protected void a(ItemStack itemstack, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit + if (itemstack == null) { + dataoutputstream.writeShort(-1); + } else { + dataoutputstream.writeShort(itemstack.id); + dataoutputstream.writeByte(itemstack.count); + dataoutputstream.writeShort(itemstack.getData()); + if (itemstack.getItem().g()) { + this.a(itemstack.tag, dataoutputstream); + } + } + } + + protected NBTTagCompound c(DataInputStream datainputstream) throws IOException { // CraftBukkit + short short1 = datainputstream.readShort(); + + if (short1 < 0) { + return null; + } else { + byte[] abyte = new byte[short1]; + + datainputstream.readFully(abyte); + return CompressedStreamTools.a(abyte); + } + } + + protected void a(NBTTagCompound nbttagcompound, DataOutputStream dataoutputstream) throws IOException { // CraftBukkit + if (nbttagcompound == null) { + dataoutputstream.writeShort(-1); + } else { + byte[] abyte = CompressedStreamTools.a(nbttagcompound); + + dataoutputstream.writeShort((short) abyte.length); + dataoutputstream.write(abyte); + } + } + static { a(0, true, true, Packet0KeepAlive.class); a(1, true, true, Packet1Login.class); @@ -212,13 +252,12 @@ public abstract class Packet { a(105, true, false, Packet105CraftProgressBar.class); a(106, true, true, Packet106Transaction.class); a(107, true, true, Packet107SetCreativeSlot.class); + a(108, false, true, Packet108.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 EntityList(); - f = 0; } } diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java index 3bf163f6..5bfd2fe5 100644 --- a/src/main/java/net/minecraft/server/Packet51MapChunk.java +++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java @@ -20,7 +20,7 @@ public class Packet51MapChunk extends Packet { public byte[] rawData; // CraftBukkit public Packet51MapChunk() { - this.k = true; + this.l = true; } // CraftBukkit start @@ -30,7 +30,7 @@ public class Packet51MapChunk extends Packet { public Packet51MapChunk(int i, int j, int k, int l, int i1, int j1, byte[] data) { // CraftBukkit end - this.k = true; + this.l = true; this.a = i; this.b = j; this.c = k; diff --git a/src/main/java/net/minecraft/server/PacketCounter.java b/src/main/java/net/minecraft/server/PacketCounter.java deleted file mode 100644 index 38239ab3..00000000 --- a/src/main/java/net/minecraft/server/PacketCounter.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.minecraft.server; - -class PacketCounter { - - private int a; - private long b; - - private PacketCounter() {} - - public void a(int i) { - ++this.a; - this.b += (long) i; - } - - PacketCounter(EmptyClass1 emptyclass1) { - this(); - } -} diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index 04dad1c0..c7cfcb54 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -182,7 +182,7 @@ class PlayerInstance { private void sendTileEntity(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.l(); + Packet packet = tileentity.k(); if (packet != null) { this.sendAll(packet); diff --git a/src/main/java/net/minecraft/server/PlayerNBTManager.java b/src/main/java/net/minecraft/server/PlayerNBTManager.java index df762836..284ff886 100644 --- a/src/main/java/net/minecraft/server/PlayerNBTManager.java +++ b/src/main/java/net/minecraft/server/PlayerNBTManager.java @@ -20,6 +20,7 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { private final File c; private final File d; private final long e = System.currentTimeMillis(); + private final String f; private UUID uuid = null; // CraftBukkit public PlayerNBTManager(File file1, String s, boolean flag) { @@ -28,6 +29,7 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { this.c = new File(this.b, "players"); this.d = new File(this.b, "data"); this.d.mkdirs(); + this.f = s; if (flag) { this.c.mkdirs(); } @@ -73,9 +75,14 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { } public IChunkLoader a(WorldProvider worldprovider) { - if (worldprovider instanceof WorldProviderHell) { - File file1 = new File(this.b, "DIM-1"); + File file1; + if (worldprovider instanceof WorldProviderHell) { + file1 = new File(this.b, "DIM-1"); + file1.mkdirs(); + return new ChunkLoader(file1, true); + } else if (worldprovider instanceof WorldProviderSky) { + file1 = new File(this.b, "DIM1"); file1.mkdirs(); return new ChunkLoader(file1, true); } else { @@ -91,7 +98,7 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { if (file1.exists()) { try { nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - nbttagcompound1 = nbttagcompound.k("Data"); + nbttagcompound1 = nbttagcompound.l("Data"); return new WorldData(nbttagcompound1); } catch (Exception exception) { exception.printStackTrace(); @@ -102,7 +109,7 @@ public class PlayerNBTManager implements PlayerFileData, IDataManager { if (file1.exists()) { try { nbttagcompound = CompressedStreamTools.a((InputStream) (new FileInputStream(file1))); - nbttagcompound1 = nbttagcompound.k("Data"); + nbttagcompound1 = nbttagcompound.l("Data"); return new WorldData(nbttagcompound1); } catch (Exception exception1) { exception1.printStackTrace(); diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java index 5d8c833c..e7864ea0 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -14,9 +14,33 @@ public class PortalTravelAgent { public PortalTravelAgent() {} public void a(World world, Entity entity) { - if (!this.b(world, entity)) { - this.c(world, entity); - this.b(world, entity); + if (world.worldProvider.dimension != 1) { + if (!this.b(world, entity)) { + this.c(world, entity); + this.b(world, entity); + } + } else { + int i = MathHelper.floor(entity.locX); + int j = MathHelper.floor(entity.locY) - 1; + int k = MathHelper.floor(entity.locZ); + byte b0 = 1; + byte b1 = 0; + + for (int l = -2; l <= 2; ++l) { + for (int i1 = -2; i1 <= 2; ++i1) { + for (int j1 = -1; j1 < 3; ++j1) { + int k1 = i + i1 * b0 + l * b1; + int l1 = j + j1; + int i2 = k + i1 * b1 - l * b0; + boolean flag = j1 < 0; + + world.setTypeId(k1, l1, i2, flag ? Block.OBSIDIAN.id : 0); + } + } + } + + entity.setPositionRotation((double) i, (double) j, (double) k, entity.yaw, 0.0F); + entity.motX = entity.motY = entity.motZ = 0.0D; } } @@ -37,9 +61,7 @@ public class PortalTravelAgent { for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { double d3 = (double) k1 + 0.5D - entity.locZ; - world.getClass(); - - for (int l1 = 128 - 1; l1 >= 0; --l1) { + for (int l1 = world.height - 1; l1 >= 0; --l1) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { --l1; @@ -121,10 +143,9 @@ public class PortalTravelAgent { for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - entity.locZ; - world.getClass(); label274: - for (l2 = 128 - 1; l2 >= 0; --l2) { + for (l2 = world.height - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -173,10 +194,9 @@ public class PortalTravelAgent { for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - entity.locZ; - world.getClass(); label222: - for (l2 = 128 - 1; l2 >= 0; --l2) { + for (l2 = world.height - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -237,8 +257,8 @@ public class PortalTravelAgent { i1 = 70; } - if (i1 > 118) { - i1 = 118; + if (i1 > world.height - 10) { + i1 = world.height - 10; } j5 = i1; @@ -279,10 +299,8 @@ public class PortalTravelAgent { i1 = 70; } - world.getClass(); - if (i1 > 128 - 10) { - world.getClass(); - i1 = 128 - 10; + if (i1 > world.height - 10) { + i1 = world.height - 10; } j5 = i1; diff --git a/src/main/java/net/minecraft/server/PropertyManager.java b/src/main/java/net/minecraft/server/PropertyManager.java index 5108b1cf..ae0feee2 100644 --- a/src/main/java/net/minecraft/server/PropertyManager.java +++ b/src/main/java/net/minecraft/server/PropertyManager.java @@ -60,6 +60,10 @@ public class PropertyManager { } } + public File c() { + return this.c; + } + public String getString(String s, String s1) { if (!this.properties.containsKey(s)) { s1 = this.getOverride(s, s1); // CraftBukkit @@ -90,6 +94,10 @@ public class PropertyManager { } } + public void a(String s, Object object) { + this.properties.setProperty(s, "" + object); + } + public void setBoolean(String s, boolean flag) { this.properties.setProperty(s, "" + flag); this.savePropertiesFile(); diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index c87cba3d..fb3ec79c 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -31,7 +31,7 @@ public class ServerConfigurationManager { public static Logger a = Logger.getLogger("Minecraft"); public List players = new ArrayList(); public MinecraftServer server; // CraftBukkit - private -> public - // private PlayerManager[] d = new PlayerManager[2]; // CraftBukkit - removed + // private PlayerManager[] d = new PlayerManager[3]; // CraftBukkit - removed public int maxPlayers; // CraftBukkit - private -> public public Set banByName = new HashSet(); // CraftBukkit - private -> public public Set banByIP = new HashSet(); // CraftBukkit - private -> public @@ -64,19 +64,19 @@ public class ServerConfigurationManager { // CraftBukkit - removed playermanagers this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20); this.hasWhitelist = minecraftserver.propertyManager.getBoolean("white-list", false); - this.i(); - this.k(); - this.m(); - this.o(); - this.j(); this.l(); this.n(); this.p(); + this.r(); + this.m(); + this.o(); + this.q(); + this.s(); } public void setPlayerFileData(WorldServer[] aworldserver) { if (this.playerFileData != null) return; // CraftBukkit - this.playerFileData = aworldserver[0].o().d(); + this.playerFileData = aworldserver[0].q().d(); } public void a(EntityPlayer entityplayer) { @@ -216,7 +216,7 @@ public class ServerConfigurationManager { } // CraftBukkit start - public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i) { + public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag) { return this.moveToWorld(entityplayer, i, null); } @@ -279,7 +279,7 @@ public class ServerConfigurationManager { // CraftBukkit start byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId()); - entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension, (byte) worldserver.difficulty, worldserver.getSeed(), 128, entityplayer1.itemInWorldManager.a())); + entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension, (byte) worldserver.difficulty, worldserver.getSeed(), worldserver.height, 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)); @@ -289,7 +289,7 @@ public class ServerConfigurationManager { worldserver.addEntity(entityplayer1); this.players.add(entityplayer1); this.updateClient(entityplayer1); // CraftBukkit - entityplayer1.w(); + entityplayer1.A(); // CraftBukkit start - don't fire on respawn if (fromWorld != location.getWorld()) { org.bukkit.event.player.PlayerChangedWorldEvent event = new org.bukkit.event.player.PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld); @@ -299,15 +299,14 @@ public class ServerConfigurationManager { return entityplayer1; } - public void f(EntityPlayer entityplayer) { + public void a(EntityPlayer entityplayer, int i) { // CraftBukkit start -- Replaced the standard handling of portals with a more customised method. int dimension = entityplayer.dimension; WorldServer fromWorld = this.server.getWorldServer(dimension); WorldServer toWorld = null; if (dimension < 10) { - int toDimension = dimension == -1 ? 0 : -1; for (WorldServer world : this.server.worlds) { - if (world.dimension == toDimension) { + if (world.dimension == i) { toWorld = world; } } @@ -334,20 +333,19 @@ public class ServerConfigurationManager { } public void b() { - int i; + if (++this.p > 200) { + this.p = 0; + } /* CraftBukkit start -- remove updating of lag to players -- it spams way to much on big servers. - if (this.p-- <= 0) { - for (i = 0; i < this.players.size(); ++i) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); + if (this.p < this.players.size()) { + EntityPlayer entityplayer = (EntityPlayer) this.players.get(this.p); - this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.i)); - } - this.p = 200; // <-- this resetting of flushtime is missing! though whole code is commented out now :) + this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.i)); } */ - for (i = 0; i < this.server.worlds.size(); ++i) { + for (int i = 0; i < this.server.worlds.size(); ++i) { this.server.worlds.get(i).manager.flush(); // CraftBukkit end } @@ -389,17 +387,27 @@ public class ServerConfigurationManager { return s; } + public String[] d() { + String[] astring = new String[this.players.size()]; + + for (int i = 0; i < this.players.size(); ++i) { + astring[i] = ((EntityPlayer) this.players.get(i)).name; + } + + return astring; + } + public void addUserBan(String s) { this.banByName.add(s.toLowerCase()); - this.j(); + this.m(); } public void removeUserBan(String s) { this.banByName.remove(s.toLowerCase()); - this.j(); + this.m(); } - private void i() { + private void l() { try { this.banByName.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j)); @@ -415,7 +423,7 @@ public class ServerConfigurationManager { } } - private void j() { + private void m() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false)); Iterator iterator = this.banByName.iterator(); @@ -432,17 +440,25 @@ public class ServerConfigurationManager { } } + public Set e() { + return this.banByName; + } + + public Set f() { + return this.banByIP; + } + public void addIpBan(String s) { this.banByIP.add(s.toLowerCase()); - this.l(); + this.o(); } public void removeIpBan(String s) { this.banByIP.remove(s.toLowerCase()); - this.l(); + this.o(); } - private void k() { + private void n() { try { this.banByIP.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k)); @@ -458,7 +474,7 @@ public class ServerConfigurationManager { } } - private void l() { + private void o() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false)); Iterator iterator = this.banByIP.iterator(); @@ -477,7 +493,7 @@ public class ServerConfigurationManager { public void addOp(String s) { this.operators.add(s.toLowerCase()); - this.n(); + this.q(); // Craftbukkit start Player player = server.server.getPlayer(s); @@ -489,7 +505,7 @@ public class ServerConfigurationManager { public void removeOp(String s) { this.operators.remove(s.toLowerCase()); - this.n(); + this.q(); // Craftbukkit start Player player = server.server.getPlayer(s); @@ -499,7 +515,7 @@ public class ServerConfigurationManager { // Craftbukkit end } - private void m() { + private void p() { try { this.operators.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.l)); @@ -511,12 +527,11 @@ public class ServerConfigurationManager { bufferedreader.close(); } catch (Exception exception) { - // CraftBukkit - corrected text - a.warning("Failed to load ops: " + exception); + a.warning("Failed to load operators list: " + exception); } } - private void n() { + private void q() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.l, false)); Iterator iterator = this.operators.iterator(); @@ -529,12 +544,11 @@ public class ServerConfigurationManager { printwriter.close(); } catch (Exception exception) { - // CraftBukkit - corrected text - a.warning("Failed to save ops: " + exception); + a.warning("Failed to save operators list: " + exception); } } - private void o() { + private void r() { try { this.whitelist.clear(); BufferedReader bufferedreader = new BufferedReader(new FileReader(this.m)); @@ -550,7 +564,7 @@ public class ServerConfigurationManager { } } - private void p() { + private void s() { try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.m, false)); Iterator iterator = this.whitelist.iterator(); @@ -649,12 +663,12 @@ public class ServerConfigurationManager { public void addWhitelist(String s) { this.whitelist.add(s); - this.p(); + this.s(); } public void removeWhitelist(String s) { this.whitelist.remove(s); - this.p(); + this.s(); } public Set getWhitelisted() { @@ -662,26 +676,26 @@ public class ServerConfigurationManager { } public void reloadWhitelist() { - this.o(); + this.r(); } public void a(EntityPlayer entityplayer, WorldServer worldserver) { entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(worldserver.getTime())); - if (worldserver.u()) { + if (worldserver.w()) { entityplayer.netServerHandler.sendPacket(new Packet70Bed(1, 0)); } } public void updateClient(EntityPlayer entityplayer) { entityplayer.updateInventory(entityplayer.defaultContainer); - entityplayer.B(); + entityplayer.s_(); } - public int g() { + public int j() { return this.players.size(); } - public int h() { + public int k() { return this.maxPlayers; } } diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java index 58849856..5b56279a 100644 --- a/src/main/java/net/minecraft/server/Slot.java +++ b/src/main/java/net/minecraft/server/Slot.java @@ -4,19 +4,19 @@ public class Slot { public final int index; // CraftBukkit - private -> public public final IInventory inventory; - public int b; public int c; public int d; + public int e; public Slot(IInventory iinventory, int i, int j, int k) { this.inventory = iinventory; this.index = i; - this.c = j; - this.d = k; + this.d = j; + this.e = k; } - public void a(ItemStack itemstack) { - this.c(); + public void b(ItemStack itemstack) { + this.d(); } public boolean isAllowed(ItemStack itemstack) { @@ -27,20 +27,20 @@ public class Slot { return this.inventory.getItem(this.index); } - public boolean b() { + public boolean c() { return this.getItem() != null; } public void c(ItemStack itemstack) { this.inventory.setItem(this.index, itemstack); - this.c(); + this.d(); } - public void c() { + public void d() { this.inventory.update(); } - public int d() { + public int a() { return this.inventory.getMaxStackSize(); } diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java index 69234367..25369365 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -1,28 +1,24 @@ package net.minecraft.server; import java.util.Collection; -import java.util.HashSet; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Random; -import java.util.Set; // CraftBukkit import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; public final class SpawnerCreature { - private static Set b = new HashSet(); + private static HashMap b = new HashMap(); protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class}; public SpawnerCreature() {} protected static ChunkPosition a(World world, int i, int j) { int k = i + world.random.nextInt(16); - Random random = world.random; - - world.getClass(); - int l = random.nextInt(128); + int l = world.random.nextInt(world.height); int i1 = j + world.random.nextInt(16); return new ChunkPosition(k, l, i1); @@ -46,7 +42,14 @@ public final class SpawnerCreature { for (int l = -b0; l <= b0; ++l) { for (int i1 = -b0; i1 <= b0; ++i1) { - b.add(new ChunkCoordIntPair(l + k, i1 + j)); + boolean flag2 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0; + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(l + k, i1 + j); + + if (!flag2) { + b.put(chunkcoordintpair, Boolean.valueOf(false)); + } else if (!b.containsKey(chunkcoordintpair)) { + b.put(chunkcoordintpair, Boolean.valueOf(true)); + } } } } @@ -61,70 +64,87 @@ public final class SpawnerCreature { EnumCreatureType enumcreaturetype = aenumcreaturetype[j1]; if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= enumcreaturetype.b() * b.size() / 256) { - Iterator iterator = b.iterator(); + Iterator iterator = b.keySet().iterator(); - label91: + label108: while (iterator.hasNext()) { - ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); - BiomeBase biomebase = world.getWorldChunkManager().a(chunkcoordintpair); - List list = biomebase.a(enumcreaturetype); + ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator.next(); - if (list != null && !list.isEmpty()) { - BiomeMeta biomemeta = (BiomeMeta) WeightedRandom.a(world.random, (Collection) list); - ChunkPosition chunkposition = a(world, chunkcoordintpair.x * 16, chunkcoordintpair.z * 16); + if (!((Boolean) b.get(chunkcoordintpair1)).booleanValue()) { + ChunkPosition chunkposition = a(world, chunkcoordintpair1.x * 16, chunkcoordintpair1.z * 16); int k1 = chunkposition.x; int l1 = chunkposition.y; int i2 = chunkposition.z; if (!world.e(k1, l1, i2) && world.getMaterial(k1, l1, i2) == enumcreaturetype.c()) { int j2 = 0; + int k2 = 0; - for (int k2 = 0; k2 < 3; ++k2) { + while (k2 < 3) { int l2 = k1; int i3 = l1; int j3 = i2; byte b1 = 6; - - 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); - 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; - float f4 = f1 - (float) chunkcoordinates.y; - float f5 = f2 - (float) chunkcoordinates.z; - float f6 = f3 * f3 + f4 * f4 + f5 * f5; - - if (f6 >= 576.0F) { - EntityLiving entityliving; - - try { - entityliving = (EntityLiving) biomemeta.a.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); - } catch (Exception exception) { - exception.printStackTrace(); - return i; - } - - entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F); - if (entityliving.d()) { - ++j2; - // CraftBukkit - added a reason for spawning this creature - world.addEntity(entityliving, SpawnReason.NATURAL); - a(entityliving, world, f, f1, f2); - if (j2 >= entityliving.m()) { - continue label91; + BiomeMeta biomemeta = null; + int k3 = 0; + + while (true) { + if (k3 < 4) { + label101: { + 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); + 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; + float f4 = f1 - (float) chunkcoordinates.y; + float f5 = f2 - (float) chunkcoordinates.z; + float f6 = f3 * f3 + f4 * f4 + f5 * f5; + + if (f6 >= 576.0F) { + if (biomemeta == null) { + biomemeta = world.a(enumcreaturetype, l2, i3, j3); + if (biomemeta == null) { + break label101; + } + } + + EntityLiving entityliving; + + try { + entityliving = (EntityLiving) biomemeta.a.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world}); + } catch (Exception exception) { + exception.printStackTrace(); + return i; + } + + entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F); + if (entityliving.g()) { + ++j2; + // CraftBukkit - added a reason for spawning this creature + world.addEntity(entityliving, SpawnReason.NATURAL); + a(entityliving, world, f, f1, f2); + if (j2 >= entityliving.p()) { + continue label108; + } + } + + i += j2; } } - - i += j2; } + + ++k3; + continue; } } + + ++k2; + break; } } } @@ -154,101 +174,6 @@ public final class SpawnerCreature { } } - public static boolean a(World world, List list) { - boolean flag = false; - Pathfinder pathfinder = new Pathfinder(world); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (entityhuman.fauxSleeping) continue; // CraftBukkit - Do not generate nightmares for humans ignoring sleep - Class[] aclass = a; - - if (aclass != null && aclass.length != 0) { - boolean flag1 = false; - - for (int i = 0; i < 20 && !flag1; ++i) { - int j = MathHelper.floor(entityhuman.locX) + world.random.nextInt(32) - world.random.nextInt(32); - int k = MathHelper.floor(entityhuman.locZ) + world.random.nextInt(32) - world.random.nextInt(32); - int l = MathHelper.floor(entityhuman.locY) + world.random.nextInt(16) - world.random.nextInt(16); - - if (l < 1) { - l = 1; - } else { - world.getClass(); - if (l > 128) { - world.getClass(); - l = 128; - } - } - - int i1 = world.random.nextInt(aclass.length); - - int j1; - - for (j1 = l; j1 > 2 && !world.e(j, j1 - 1, k); --j1) { - ; - } - - while (!a(EnumCreatureType.MONSTER, world, j, j1, k) && j1 < l + 16) { - world.getClass(); - if (j1 >= 128) { - break; - } - - ++j1; - } - - 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; - - 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); - - 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 (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; - } - } - } - } - } - } - } - } - - return flag; - } - public static void a(World world, BiomeBase biomebase, int i, int j, int k, int l, Random random) { List list = biomebase.a(EnumCreatureType.CREATURE); diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java index bf16c5c2..a81d7dd4 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -11,7 +11,7 @@ public class TileEntityChest extends TileEntity implements IInventory { public float f; public float g; public int h; - private int q; + private int j; // CraftBukkit start public ItemStack[] getContents() { @@ -67,13 +67,13 @@ public class TileEntityChest extends TileEntity implements IInventory { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.l("Items"); + NBTTagList nbttaglist = nbttagcompound.m("Items"); this.items = new ItemStack[this.getSize()]; - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); - int j = nbttagcompound1.c("Slot") & 255; + int j = nbttagcompound1.d("Slot") & 255; if (j >= 0 && j < this.items.length) { this.items[j] = ItemStack.a(nbttagcompound1); @@ -107,8 +107,8 @@ public class TileEntityChest extends TileEntity implements IInventory { 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(); + public void d() { + super.d(); this.a = false; } @@ -136,19 +136,19 @@ public class TileEntityChest extends TileEntity implements IInventory { } if (this.b != null) { - this.b.g(); + this.b.d(); } if (this.e != null) { - this.e.g(); + this.e.d(); } if (this.c != null) { - this.c.g(); + this.c.d(); } if (this.d != null) { - this.d.g(); + this.d.d(); } } } @@ -171,34 +171,36 @@ public class TileEntityChest extends TileEntity implements IInventory { } // CraftBukkit end - public void h_() { - super.h_(); + public void l_() { + super.l_(); if (this.world == null) return; // CraftBukkit this.h(); - if (++this.q % (20 * 4) == 0) { // CraftBukkit + if (++this.j % (20 * 4) == 0) { // CraftBukkit 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; + double d1 = (double) this.x + 0.5D; + + d0 = (double) this.z + 0.5D; if (this.e != null) { - d1 += 0.5D; + d0 += 0.5D; } if (this.c != null) { - d0 += 0.5D; + d1 += 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); + this.world.makeSound(d1, (double) this.y + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); } if (this.h == 0 && this.f > 0.0F || this.h > 0 && this.f < 1.0F) { + float f1 = this.f; + if (this.h > 0) { this.f += f; } else { @@ -209,21 +211,25 @@ public class TileEntityChest extends TileEntity implements IInventory { this.f = 1.0F; } + float f2 = 0.5F; + + if (this.f < f2 && f1 >= f2 && this.b == null && this.d == null) { + d0 = (double) this.x + 0.5D; + double d2 = (double) this.z + 0.5D; + + if (this.e != null) { + d2 += 0.5D; + } + + if (this.c != null) { + d0 += 0.5D; + } + + this.world.makeSound(d0, (double) this.y + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); + } + 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); - } } } } @@ -234,20 +240,20 @@ public class TileEntityChest extends TileEntity implements IInventory { } } - public void e() { + public void f() { ++this.h; if (this.world == null) return; // CraftBukkit this.world.playNote(this.x, this.y, this.z, 1, this.h); } - public void t_() { + public void g() { --this.h; if (this.world == null) return; // CraftBukkit this.world.playNote(this.x, this.y, this.z, 1, this.h); } public void i() { - this.g(); + this.d(); 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 61ac3078..3748e060 100644 --- a/src/main/java/net/minecraft/server/TileEntityDispenser.java +++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java @@ -62,7 +62,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory { return i; } - public ItemStack b() { + public ItemStack k_() { int i = this.findDispenseSlot(); // CraftBukkit end @@ -88,13 +88,13 @@ public class TileEntityDispenser extends TileEntity implements IInventory { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.l("Items"); + NBTTagList nbttaglist = nbttagcompound.m("Items"); this.items = new ItemStack[this.getSize()]; - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); - int j = nbttagcompound1.c("Slot") & 255; + int j = nbttagcompound1.d("Slot") & 255; if (j >= 0 && j < this.items.length) { this.items[j] = ItemStack.a(nbttagcompound1); @@ -127,7 +127,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory { 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 f() {} - public void t_() {} + public void g() {} } diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index f583e1d7..0eda7df8 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -64,21 +64,21 @@ public class TileEntityFurnace extends TileEntity implements IInventory { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - NBTTagList nbttaglist = nbttagcompound.l("Items"); + NBTTagList nbttaglist = nbttagcompound.m("Items"); this.items = new ItemStack[this.getSize()]; - for (int i = 0; i < nbttaglist.c(); ++i) { + for (int i = 0; i < nbttaglist.d(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.a(i); - byte b0 = nbttagcompound1.c("Slot"); + byte b0 = nbttagcompound1.d("Slot"); if (b0 >= 0 && b0 < this.items.length) { this.items[b0] = ItemStack.a(nbttagcompound1); } } - this.burnTime = nbttagcompound.d("BurnTime"); - this.cookTime = nbttagcompound.d("CookTime"); + this.burnTime = nbttagcompound.e("BurnTime"); + this.cookTime = nbttagcompound.e("CookTime"); this.ticksForCurrentFuel = this.fuelTime(this.items[1]); } @@ -109,7 +109,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { return this.burnTime > 0; } - public void h_() { + public void l_() { boolean flag = this.burnTime > 0; boolean flag1 = false; @@ -162,7 +162,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { } /* CraftBukkit start - moved up - if (this.f() && this.process()) { + if (this.isBurning() && this.canBurn()) { ++this.cookTime; if (this.cookTime == 200) { this.cookTime = 0; @@ -238,7 +238,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { } else { int i = itemstack.getItem().id; - return i < 256 && Block.byId[i].material == Material.WOOD ? 300 : (i == Item.STICK.id ? 100 : (i == Item.COAL.id ? 1600 : (i == Item.LAVA_BUCKET.id ? 20000 : (i == Block.SAPLING.id ? 100 : 0)))); + return i < 256 && Block.byId[i].material == Material.WOOD ? 300 : (i == Item.STICK.id ? 100 : (i == Item.COAL.id ? 1600 : (i == Item.LAVA_BUCKET.id ? 20000 : (i == Block.SAPLING.id ? 100 : (i == Item.BLAZE_ROD.id ? 2400 : 0))))); } } @@ -246,7 +246,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { 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 f() {} - public void t_() {} + public void g() {} } diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java index b98f60bc..1cfb838f 100644 --- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java +++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java @@ -17,7 +17,7 @@ public class TileEntityMobSpawner extends TileEntity { this.mobName = s; } - public boolean a() { + public boolean c() { return this.world.a((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D, 16.0D) != null; } @@ -37,9 +37,9 @@ public class TileEntityMobSpawner extends TileEntity { } // CraftBukkit end - public void h_() { + public void l_() { this.c = this.b; - if (this.a()) { + if (this.c()) { double d0 = (double) ((float) this.x + this.world.random.nextFloat()); double d1 = (double) ((float) this.y + this.world.random.nextFloat()); double d2 = (double) ((float) this.z + this.world.random.nextFloat()); @@ -53,7 +53,7 @@ public class TileEntityMobSpawner extends TileEntity { if (!this.world.isStatic) { if (this.spawnDelay == -1) { - this.c(); + this.e(); } if (this.spawnDelay > 0) { @@ -64,8 +64,7 @@ public class TileEntityMobSpawner extends TileEntity { byte b0 = 4; for (int i = 0; i < b0; ++i) { - // CraftBukkit start - Entity entityliving = EntityTypes.a(this.mobName, this.world); + Entity entityliving = EntityTypes.a(this.mobName, this.world); // CraftBukkit if (entityliving == null) { return; @@ -74,7 +73,7 @@ public class TileEntityMobSpawner extends TileEntity { int j = this.world.a(entityliving.getClass(), AxisAlignedBB.b((double) this.x, (double) this.y, (double) this.z, (double) (this.x + 1), (double) (this.y + 1), (double) (this.z + 1)).b(8.0D, 4.0D, 8.0D)).size(); if (j >= 6) { - this.c(); + this.e(); return; } @@ -84,39 +83,32 @@ public class TileEntityMobSpawner extends TileEntity { double d5 = (double) this.z + (this.world.random.nextDouble() - this.world.random.nextDouble()) * 4.0D; entityliving.setPositionRotation(d3, d4, d5, this.world.random.nextFloat() * 360.0F, 0.0F); - if ((entityliving instanceof EntityLiving && ((EntityLiving)entityliving).d()) || + // CraftBukkit start + if ((entityliving instanceof EntityLiving && ((EntityLiving) entityliving).g()) || (!(entityliving instanceof EntityLiving) && entityliving.world.containsEntity(entityliving.boundingBox) && entityliving.world.getEntities(entityliving, entityliving.boundingBox).size() == 0 && !entityliving.world.c(entityliving.boundingBox))) { - // CraftBukkit end - // CraftBukkit - added a reason for spawning this creature this.world.addEntity(entityliving, SpawnReason.SPAWNER); + // CraftBukkit end - for (int k = 0; k < 20; ++k) { - d0 = (double) this.x + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D; - d1 = (double) this.y + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D; - d2 = (double) this.z + 0.5D + ((double) this.world.random.nextFloat() - 0.5D) * 2.0D; - this.world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); - this.world.a("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - - // entity.ab(); // CraftBukkit - client side code, and not available in entity - this.c(); + this.world.f(2004, this.x, this.y, this.z, 0); + // entityliving.ah(); // CraftBukkit -- only avail on clientside + this.e(); } } } } - super.h_(); + super.l_(); } } - private void c() { + private void e() { this.spawnDelay = 200 + this.world.random.nextInt(600); } public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.mobName = nbttagcompound.getString("EntityId"); - this.spawnDelay = nbttagcompound.d("Delay"); + this.spawnDelay = nbttagcompound.e("Delay"); } public void b(NBTTagCompound nbttagcompound) { diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java index cc8b12f0..7467f11f 100644 --- a/src/main/java/net/minecraft/server/TileEntityPiston.java +++ b/src/main/java/net/minecraft/server/TileEntityPiston.java @@ -25,7 +25,7 @@ public class TileEntityPiston extends TileEntity { this.e = flag1; } - public int a() { + public int c() { return this.a; } @@ -33,11 +33,11 @@ public class TileEntityPiston extends TileEntity { return this.b; } - public boolean c() { + public boolean e() { return this.d; } - public int d() { + public int f() { return this.c; } @@ -56,7 +56,7 @@ public class TileEntityPiston extends TileEntity { f = 1.0F - f; } - AxisAlignedBB axisalignedbb = Block.PISTON_MOVING.a(this.world, this.x, this.y, this.z, this.a, f, this.c); + AxisAlignedBB axisalignedbb = Block.PISTON_MOVING.b(this.world, this.x, this.y, this.z, this.a, f, this.c); if (axisalignedbb != null) { List list = this.world.b((Entity) null, axisalignedbb); @@ -76,8 +76,8 @@ public class TileEntityPiston extends TileEntity { } } - public void e() { - if (this.g < 1.0F) { + public void g() { + if (this.g < 1.0F && this.world != null) { this.g = this.f = 1.0F; this.world.n(this.x, this.y, this.z); this.i(); @@ -87,7 +87,7 @@ public class TileEntityPiston extends TileEntity { } } - public void h_() { + public void l_() { if (this.world == null) return; // CraftBukkit this.g = this.f; @@ -112,11 +112,11 @@ public class TileEntityPiston extends TileEntity { public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.a = nbttagcompound.e("blockId"); - this.b = nbttagcompound.e("blockData"); - this.c = nbttagcompound.e("facing"); - this.g = this.f = nbttagcompound.g("progress"); - this.d = nbttagcompound.m("extending"); + this.a = nbttagcompound.f("blockId"); + this.b = nbttagcompound.f("blockData"); + this.c = nbttagcompound.f("facing"); + this.g = this.f = nbttagcompound.h("progress"); + this.d = nbttagcompound.n("extending"); } public void b(NBTTagCompound nbttagcompound) { diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java index 2bc3f202..ac62335f 100644 --- a/src/main/java/net/minecraft/server/TileEntitySign.java +++ b/src/main/java/net/minecraft/server/TileEntitySign.java @@ -28,7 +28,7 @@ public class TileEntitySign extends TileEntity { } } - public Packet l() { + public Packet k() { String[] astring = new String[4]; for (int i = 0; i < 4; ++i) { @@ -44,7 +44,7 @@ public class TileEntitySign extends TileEntity { return new Packet130UpdateSign(this.x, this.y, this.z, astring); } - public boolean a() { + public boolean c() { return this.isEditable; } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 1872cd94..cebf2c18 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -31,57 +31,54 @@ import org.bukkit.block.BlockState; public class World implements IBlockAccess { - public final int heightBits = 7; - public final int heightBitsPlusFour = 11; - public final int height = 128; - public final int heightMinusOne = 127; - public final int seaLevel = 63; - public boolean f = false; - public List entityList = 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 j = new ArrayList(); - private long R = 16777215L; - public int k = 0; - protected int l = (new Random()).nextInt(); - protected final int m = 1013904223; + public int heightBits = 7; + public int heightBitsPlusFour; + public int height; + public int heightMinusOne; + public int seaLevel; + public boolean f; + public List entityList; + private List J; + private TreeSet K; + private Set L; + public List h; + private List M; + private List N; + public List players; + public List j; + private long O; + public int k; + protected int l; + protected final int m; 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 S = System.currentTimeMillis(); - protected int u = 40; + protected int r; + public int s; + public boolean suppressPhysics; + private long P; + protected int u; public int difficulty; - public Random random = new Random(); - public boolean x = false; + public Random random; + public boolean x; public WorldProvider worldProvider; // CraftBukkit - remove final - protected List z = new ArrayList(); + protected List z; public IChunkProvider chunkProvider; // CraftBukkit - protected -> public protected final IDataManager B; public WorldData worldData; // CraftBukkit - protected -> public public boolean isLoading; - private boolean T; + private boolean Q; public WorldMapCollection worldMaps; - private ArrayList U = new ArrayList(); - private boolean V; - public boolean allowMonsters = true; // CraftBukkit - private -> public - public boolean allowAnimals = true; // CraftBukkit - private -> public - private Set W = new HashSet(); - private int X; + private ArrayList R; + private boolean S; + public boolean allowMonsters; // CraftBukkit - private -> public + public boolean allowAnimals; // CraftBukkit - private -> public + private Set T; + private int U; int[] H; - private List Y; + private List V; public boolean isStatic; - public double J; - public double K; - public double L; public WorldChunkManager getWorldChunkManager() { return this.worldProvider.b; @@ -119,9 +116,39 @@ public class World implements IBlockAccess { this.world = new CraftWorld((WorldServer) this, gen, env); // CraftBukkit end - this.X = this.random.nextInt(12000); + this.heightBitsPlusFour = this.heightBits + 4; + this.height = 1 << this.heightBits; + this.heightMinusOne = this.height - 1; + this.seaLevel = this.height / 2 - 1; + this.f = false; + this.entityList = new ArrayList(); + this.J = new ArrayList(); + this.K = new TreeSet(); + this.L = new HashSet(); + this.h = new ArrayList(); + this.M = new ArrayList(); + this.N = new ArrayList(); + this.players = new ArrayList(); + this.j = new ArrayList(); + this.O = 16777215L; + this.k = 0; + this.l = (new Random()).nextInt(); + this.m = 1013904223; + this.r = 0; + this.s = 0; + this.suppressPhysics = false; + this.P = System.currentTimeMillis(); + this.u = 40; + this.random = new Random(); + this.x = false; + this.z = new ArrayList(); + this.R = new ArrayList(); + this.allowMonsters = true; + this.allowAnimals = true; + this.T = new HashSet(); + this.U = this.random.nextInt(12000); this.H = new int['\u8000']; - this.Y = new ArrayList(); + this.V = new ArrayList(); this.isStatic = false; this.B = idatamanager; this.worldMaps = new WorldMapCollection(idatamanager); @@ -129,8 +156,8 @@ public class World implements IBlockAccess { this.x = this.worldData == null; if (worldprovider != null) { this.worldProvider = worldprovider; - } else if (this.worldData != null && this.worldData.h() == -1) { - this.worldProvider = WorldProvider.byDimension(-1); + } else if (this.worldData != null && this.worldData.h() != 0) { + this.worldProvider = WorldProvider.byDimension(this.worldData.h()); } else { this.worldProvider = WorldProvider.byDimension(0); } @@ -150,8 +177,8 @@ public class World implements IBlockAccess { this.c(); } - this.f(); - this.x(); + this.g(); + this.z(); this.getServer().addWorld(this.world); // CraftBukkit } @@ -169,8 +196,8 @@ public class World implements IBlockAccess { Random random = new Random(this.getSeed()); ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random); int i = 0; - byte b0 = 64; - int j = 0; + int j = this.height / 2; + int k = 0; // CraftBukkit start if (this.generator != null) { @@ -191,31 +218,35 @@ public class World implements IBlockAccess { if (chunkposition != null) { i = chunkposition.x; - j = chunkposition.z; + k = chunkposition.z; } else { System.out.println("Unable to find spawn biome"); } - int k = 0; + int l = 0; // CraftBukkit - use out own canSpawn - while (!canSpawn(i, j)) { + while (!this.canSpawn(i, k)) { i += random.nextInt(64) - random.nextInt(64); - j += random.nextInt(64) - random.nextInt(64); - ++k; - if (k == 1000) { + k += random.nextInt(64) - random.nextInt(64); + ++l; + if (l == 1000) { break; } } - this.worldData.setSpawn(i, b0, j); + this.worldData.setSpawn(i, j, k); this.isLoading = false; } + public ChunkCoordinates d() { + return this.worldProvider.d(); + } + public int a(int i, int j) { int k; - for (k = 63; !this.isEmpty(i, k + 1, j); ++k) { + for (k = this.seaLevel; !this.isEmpty(i, k + 1, j); ++k) { ; } @@ -228,7 +259,7 @@ public class World implements IBlockAccess { iprogressupdate.a("Saving level"); } - this.w(); + this.y(); if (iprogressupdate != null) { iprogressupdate.b("Saving chunks"); } @@ -237,14 +268,14 @@ public class World implements IBlockAccess { } } - private void w() { - this.j(); + private void y() { + this.l(); this.B.a(this.worldData, this.players); this.worldMaps.a(); } public int getTypeId(int i, int j, int k) { - 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; + return i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 ? (j < 0 ? 0 : (j >= this.height ? 0 : this.getChunkAt(i >> 4, k >> 4).getTypeId(i & 15, j, k & 15))) : 0; } public boolean isEmpty(int i, int j, int k) { @@ -252,7 +283,7 @@ public class World implements IBlockAccess { } public boolean isLoaded(int i, int j, int k) { - return j >= 0 && j < 128 ? this.isChunkLoaded(i >> 4, k >> 4) : false; + return j >= 0 && j < this.height ? this.isChunkLoaded(i >> 4, k >> 4) : false; } public boolean areChunksLoaded(int i, int j, int k, int l) { @@ -260,7 +291,7 @@ public class World implements IBlockAccess { } public boolean a(int i, int j, int k, int l, int i1, int j1) { - if (i1 >= 0 && j < 128) { + if (i1 >= 0 && j < this.height) { i >>= 4; j >>= 4; k >>= 4; @@ -309,13 +340,13 @@ public class World implements IBlockAccess { if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; - } else if (j >= 128) { + } else if (j >= this.height) { return false; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); boolean flag = chunk.a(i & 15, j, k & 15, l, i1); - this.p(i, j, k); + this.s(i, j, k); return flag; } } else { @@ -327,13 +358,13 @@ public class World implements IBlockAccess { if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; - } else if (j >= 128) { + } else if (j >= this.height) { return false; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); boolean flag = chunk.a(i & 15, j, k & 15, l); - this.p(i, j, k); + this.s(i, j, k); return flag; } } else { @@ -351,7 +382,7 @@ public class World implements IBlockAccess { if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return 0; - } else if (j >= 128) { + } else if (j >= this.height) { return 0; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); @@ -381,15 +412,14 @@ public class World implements IBlockAccess { if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { if (j < 0) { return false; - } else if (j >= 128) { + } else if (j >= this.height) { return false; } else { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); i &= 15; k &= 15; - chunk.b(i, j, k, l); - return true; + return chunk.b(i, j, k, l); } } else { return false; @@ -440,8 +470,10 @@ public class World implements IBlockAccess { k = i1; } - for (i1 = k; i1 <= l; ++i1) { - this.b(EnumSkyBlock.SKY, i, i1, j); + if (!this.worldProvider.e) { + for (i1 = k; i1 <= l; ++i1) { + this.b(EnumSkyBlock.SKY, i, i1, j); + } } this.b(i, k, j, i, l, j); @@ -498,8 +530,8 @@ public class World implements IBlockAccess { if (j < 0) { return 0; } else { - if (j >= 128) { - j = 127; + if (j >= this.height) { + j = this.height - 1; } return this.getChunkAt(i >> 4, k >> 4).c(i & 15, j, k & 15, 0); @@ -545,8 +577,8 @@ public class World implements IBlockAccess { if (j < 0) { return 0; } else { - if (j >= 128) { - j = 127; + if (j >= this.height) { + j = this.height - 1; } Chunk chunk = this.getChunkAt(i >> 4, k >> 4); @@ -579,11 +611,11 @@ public class World implements IBlockAccess { j = 0; } - if (j >= 128) { - j = 127; + if (j >= this.height) { + j = this.height - 1; } - if (j >= 0 && j < 128 && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { + if (j >= 0 && j < this.height && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { int l = i >> 4; int i1 = k >> 4; @@ -602,7 +634,7 @@ public class World implements IBlockAccess { 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 (j < this.height) { if (this.isChunkLoaded(i >> 4, k >> 4)) { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); @@ -621,7 +653,7 @@ public class World implements IBlockAccess { return this.worldProvider.f[this.getLightLevel(i, j, k)]; } - public boolean d() { + public boolean e() { return this.k < 4; } @@ -911,10 +943,10 @@ public class World implements IBlockAccess { this.everyoneSleeping(); } - int i = entity.bW; - int j = entity.bY; + int i = entity.bX; + int j = entity.bZ; - if (entity.bV && this.isChunkLoaded(i, j)) { + if (entity.bW && this.isChunkLoaded(i, j)) { this.getChunkAt(i, j).b(entity); } @@ -927,7 +959,7 @@ public class World implements IBlockAccess { } public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { - this.U.clear(); + this.R.clear(); int i = MathHelper.floor(axisalignedbb.a); int j = MathHelper.floor(axisalignedbb.d + 1.0D); int k = MathHelper.floor(axisalignedbb.b); @@ -937,12 +969,12 @@ public class World implements IBlockAccess { for (int k1 = i; k1 < j; ++k1) { for (int l1 = i1; l1 < j1; ++l1) { - if (this.isLoaded(k1, 64, l1)) { + if (this.isLoaded(k1, this.height / 2, l1)) { for (int i2 = k - 1; i2 < l; ++i2) { Block block = Block.byId[this.getTypeId(k1, i2, l1)]; if (block != null) { - block.a(this, k1, i2, l1, axisalignedbb, this.U); + block.a(this, k1, i2, l1, axisalignedbb, this.R); } } } @@ -953,19 +985,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)).f(); + AxisAlignedBB axisalignedbb1 = ((Entity) list.get(j2)).h_(); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.U.add(axisalignedbb1); + this.R.add(axisalignedbb1); } - axisalignedbb1 = entity.b((Entity) list.get(j2)); + axisalignedbb1 = entity.a_((Entity) list.get(j2)); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.U.add(axisalignedbb1); + this.R.add(axisalignedbb1); } } - return this.U; + return this.R; } public int a(float f) { @@ -988,7 +1020,7 @@ public class World implements IBlockAccess { } public float b(float f) { - return this.worldProvider.a(this.worldData.f(), f) + (float) (this.J + (this.K - this.J) * (double) f); + return this.worldProvider.a(this.worldData.f(), f); } public int e(int i, int j) { @@ -997,7 +1029,7 @@ public class World implements IBlockAccess { public int f(int i, int j) { Chunk chunk = this.getChunkAtWorldCoords(i, j); - int k = 127; + int k = this.height - 1; i &= 15; @@ -1030,15 +1062,31 @@ public class World implements IBlockAccess { nextticklistentry.a((long) i1 + this.worldData.f()); } - if (!this.O.contains(nextticklistentry)) { - this.O.add(nextticklistentry); - this.N.add(nextticklistentry); + if (!this.L.contains(nextticklistentry)) { + this.L.add(nextticklistentry); + this.K.add(nextticklistentry); } } } } + public void d(int i, int j, int k, int l, int i1) { + NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l); + + if (l > 0) { + nextticklistentry.a((long) i1 + this.worldData.f()); + } + + if (!this.L.contains(nextticklistentry)) { + this.L.add(nextticklistentry); + this.K.add(nextticklistentry); + } + } + public void tickEntities() { + MethodProfiler.a("entities"); + MethodProfiler.a("global"); + int i; Entity entity; @@ -1049,31 +1097,33 @@ public class World implements IBlockAccess { continue; } // CraftBukkit end - entity.s_(); + entity.w_(); if (entity.dead) { this.j.remove(i--); } } - this.entityList.removeAll(this.M); + MethodProfiler.b("remove"); + this.entityList.removeAll(this.J); int j; int 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)) { + for (i = 0; i < this.J.size(); ++i) { + entity = (Entity) this.J.get(i); + j = entity.bX; + k = entity.bZ; + if (entity.bW && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } } - for (i = 0; i < this.M.size(); ++i) { - this.d((Entity) this.M.get(i)); + for (i = 0; i < this.J.size(); ++i) { + this.d((Entity) this.J.get(i)); } - this.M.clear(); + this.J.clear(); + MethodProfiler.b("regular"); for (i = 0; i < this.entityList.size(); ++i) { entity = (Entity) this.entityList.get(i); @@ -1090,29 +1140,33 @@ public class World implements IBlockAccess { this.playerJoinedWorld(entity); } + MethodProfiler.a("remove"); if (entity.dead) { - j = entity.bW; - k = entity.bY; - if (entity.bV && this.isChunkLoaded(j, k)) { + j = entity.bX; + k = entity.bZ; + if (entity.bW && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } this.entityList.remove(i--); this.d(entity); } + + MethodProfiler.a(); } - this.V = true; + MethodProfiler.b("tileEntities"); + this.S = true; Iterator iterator = this.h.iterator(); while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); - if (!tileentity.m() && tileentity.world != null) { - tileentity.h_(); + if (!tileentity.l() && tileentity.world != null && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { + tileentity.l_(); } - if (tileentity.m()) { + if (tileentity.l()) { iterator.remove(); if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) { Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); @@ -1124,19 +1178,20 @@ public class World implements IBlockAccess { } } - this.V = false; - if (!this.Q.isEmpty()) { - this.h.removeAll(this.Q); - this.Q.clear(); + this.S = false; + if (!this.N.isEmpty()) { + this.h.removeAll(this.N); + this.N.clear(); } - if (!this.P.isEmpty()) { - Iterator iterator1 = this.P.iterator(); + MethodProfiler.b("pendingTileEntities"); + if (!this.M.isEmpty()) { + Iterator iterator1 = this.M.iterator(); while (iterator1.hasNext()) { TileEntity tileentity1 = (TileEntity) iterator1.next(); - if (!tileentity1.m()) { + if (!tileentity1.l()) { // CraftBukkit - order matters, moved down /* if (!this.h.contains(tileentity1)) { this.h.add(tileentity1); @@ -1159,13 +1214,16 @@ public class World implements IBlockAccess { } } - this.P.clear(); + this.M.clear(); } + + MethodProfiler.a(); + MethodProfiler.a(); } public void a(Collection collection) { - if (this.V) { - this.P.addAll(collection); + if (this.S) { + this.M.addAll(collection); } else { this.h.addAll(collection); } @@ -1180,30 +1238,31 @@ public class World implements IBlockAccess { int j = MathHelper.floor(entity.locZ); byte b0 = 32; - if (!flag || this.a(i - b0, 0, j - b0, i + b0, 128, j + b0)) { - entity.bE = entity.locX; - entity.bF = entity.locY; - entity.bG = entity.locZ; + if (!flag || this.a(i - b0, 0, j - b0, i + b0, this.height, j + b0)) { + entity.bI = entity.locX; + entity.bJ = entity.locY; + entity.bK = entity.locZ; entity.lastYaw = entity.yaw; entity.lastPitch = entity.pitch; - if (flag && entity.bV) { + if (flag && entity.bW) { if (entity.vehicle != null) { - entity.I(); + entity.M(); } else { - entity.s_(); + entity.w_(); } } + MethodProfiler.a("chunkCheck"); if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) { - entity.locX = entity.bE; + entity.locX = entity.bI; } if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) { - entity.locY = entity.bF; + entity.locY = entity.bJ; } if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) { - entity.locZ = entity.bG; + entity.locZ = entity.bK; } if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) { @@ -1218,20 +1277,21 @@ public class World implements IBlockAccess { int l = MathHelper.floor(entity.locY / 16.0D); int i1 = MathHelper.floor(entity.locZ / 16.0D); - 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 (!entity.bW || entity.bX != k || entity.bY != l || entity.bZ != i1) { + if (entity.bW && this.isChunkLoaded(entity.bX, entity.bZ)) { + this.getChunkAt(entity.bX, entity.bZ).a(entity, entity.bY); } if (this.isChunkLoaded(k, i1)) { - entity.bV = true; + entity.bW = true; this.getChunkAt(k, i1).a(entity); } else { - entity.bV = false; + entity.bW = false; } } - if (flag && entity.bV && entity.passenger != null) { + MethodProfiler.a(); + if (flag && entity.bW && entity.passenger != null) { if (!entity.passenger.dead && entity.passenger.vehicle == entity) { this.playerJoinedWorld(entity.passenger); } else { @@ -1248,7 +1308,7 @@ public class World implements IBlockAccess { for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity) list.get(i); - if (!entity.dead && entity.aY) { + if (!entity.dead && entity.bc) { return false; } } @@ -1371,7 +1431,7 @@ public class World implements IBlockAccess { Block block = Block.byId[this.getTypeId(k1, l1, i2)]; if (block != null && block.material == material) { - double d0 = (double) ((float) (l1 + 1) - BlockFluids.c(this.getData(k1, l1, i2))); + double d0 = (double) ((float) (l1 + 1) - BlockFluids.d(this.getData(k1, l1, i2))); if ((double) l >= d0) { flag = true; @@ -1523,16 +1583,35 @@ public class World implements IBlockAccess { public TileEntity getTileEntity(int i, int j, int k) { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); - return chunk != null ? chunk.d(i & 15, j, k & 15) : null; + if (chunk == null) { + return null; + } else { + TileEntity tileentity = chunk.d(i & 15, j, k & 15); + + if (tileentity == null) { + Iterator iterator = this.M.iterator(); + + while (iterator.hasNext()) { + TileEntity tileentity1 = (TileEntity) iterator.next(); + + if (!tileentity1.l() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { + tileentity = tileentity1; + break; + } + } + } + + return tileentity; + } } public void setTileEntity(int i, int j, int k, TileEntity tileentity) { - if (tileentity != null && !tileentity.m()) { - if (this.V) { + if (tileentity != null && !tileentity.l()) { + if (this.S) { tileentity.x = i; tileentity.y = j; tileentity.z = k; - this.P.add(tileentity); + this.M.add(tileentity); } else { // CraftBukkit - order matters, moved down // this.h.add(tileentity); @@ -1549,10 +1628,12 @@ public class World implements IBlockAccess { public void n(int i, int j, int k) { TileEntity tileentity = this.getTileEntity(i, j, k); - if (tileentity != null && this.V) { + if (tileentity != null && this.S) { tileentity.i(); + this.M.remove(tileentity); } else { if (tileentity != null) { + this.M.remove(tileentity); this.h.remove(tileentity); } @@ -1565,7 +1646,7 @@ public class World implements IBlockAccess { } public void a(TileEntity tileentity) { - this.Q.add(tileentity); + this.N.add(tileentity); } public boolean o(int i, int j, int k) { @@ -1580,7 +1661,23 @@ public class World implements IBlockAccess { return block == null ? false : block.material.j() && block.b(); } - public void f() { + public boolean b(int i, int j, int k, boolean flag) { + if (i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000) { + Chunk chunk = this.chunkProvider.getOrCreateChunk(i >> 4, k >> 4); + + if (chunk != null && !chunk.isEmpty()) { + Block block = Block.byId[this.getTypeId(i, j, k)]; + + return block == null ? false : block.material.j() && block.b(); + } else { + return flag; + } + } else { + return flag; + } + } + + public void g() { int i = this.a(1.0F); if (i != this.k) { @@ -1594,33 +1691,35 @@ public class World implements IBlockAccess { } public void doTick() { - this.J = this.K; - this.K += this.L; - this.L *= 0.98D; + if (this.r().isHardcore() && this.difficulty < 3) { + this.difficulty = 3; + } + this.getWorldChunkManager().b(); - this.h(); + this.i(); long i; if (this.everyoneDeeplySleeping()) { boolean flag = false; if (this.allowMonsters && this.difficulty >= 1) { - flag = SpawnerCreature.a(this, this.players); + ; } if (!flag) { i = this.worldData.f() + 24000L; this.worldData.a(i - i % 24000L); - this.r(); + this.t(); } } + MethodProfiler.a("mobSpawner"); // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals if ((this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.getServer().getHandle().players.size() > 0)) { SpawnerCreature.spawnEntities(this, this.allowMonsters, this.allowAnimals && this.worldData.f() % 400L == 0L); } // CraftBukkit end - + MethodProfiler.b("chunkSource"); this.chunkProvider.unloadChunks(); int j = this.a(1.0F); @@ -1630,15 +1729,19 @@ public class World implements IBlockAccess { i = this.worldData.f() + 1L; if (i % (long) this.u == 0L) { + MethodProfiler.b("save"); this.save(false, (IProgressUpdate) null); } this.worldData.a(i); + MethodProfiler.b("tickPending"); this.a(false); - this.i(); + MethodProfiler.b("tickTiles"); + this.k(); + MethodProfiler.a(); } - private void x() { + private void z() { if (this.worldData.hasStorm()) { this.o = 1.0F; if (this.worldData.isThundering()) { @@ -1647,7 +1750,7 @@ public class World implements IBlockAccess { } } - protected void h() { + protected void i() { if (!this.worldProvider.e) { if (this.r > 0) { --this.r; @@ -1730,7 +1833,7 @@ public class World implements IBlockAccess { } } - private void y() { + private void A() { // CraftBukkit start WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false); this.getServer().getPluginManager().callEvent(weather); @@ -1748,154 +1851,218 @@ public class World implements IBlockAccess { // CraftBukkit end } - protected void i() { - this.W.clear(); + public void j() { + this.worldData.setWeatherDuration(1); + } + + protected void k() { + this.T.clear(); + MethodProfiler.a("buildList"); int i; int j; - int k; - int l; - for (int i1 = 0; i1 < this.players.size(); ++i1) { - EntityHuman entityhuman = (EntityHuman) this.players.get(i1); + for (i = 0; i < this.players.size(); ++i) { + EntityHuman entityhuman = (EntityHuman) this.players.get(i); + int k = MathHelper.floor(entityhuman.locX / 16.0D); + int l = MathHelper.floor(entityhuman.locZ / 16.0D); + byte b0 = 7; - i = MathHelper.floor(entityhuman.locX / 16.0D); - j = MathHelper.floor(entityhuman.locZ / 16.0D); - byte b0 = 9; - - for (k = -b0; k <= b0; ++k) { - for (l = -b0; l <= b0; ++l) { - this.W.add(new ChunkCoordIntPair(k + i, l + j)); + for (j = -b0; j <= b0; ++j) { + for (int i1 = -b0; i1 <= b0; ++i1) { + this.T.add(new ChunkCoordIntPair(j + k, i1 + l)); } } } - if (this.X > 0) { - --this.X; + if (this.U > 0) { + --this.U; } - Iterator iterator = this.W.iterator(); + i = 0; + int j1 = 0; + + MethodProfiler.a(); + Iterator iterator = this.T.iterator(); while (iterator.hasNext()) { ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next(); + int k1 = chunkcoordintpair.x * 16; - i = chunkcoordintpair.x * 16; j = chunkcoordintpair.z * 16; + MethodProfiler.a("getChunk"); Chunk chunk = this.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z); - chunk.h(); - int j1; - int k1; + MethodProfiler.b("tickChunk"); + chunk.i(); + MethodProfiler.b("moodSound"); int l1; + int i2; + int j2; + int k2; + int l2; - if (this.X == 0) { + if (this.U == 0) { this.l = this.l * 3 + 1013904223; - k = this.l >> 2; - l = k & 15; - j1 = k >> 8 & 15; - k1 = k >> 16 & 127; - l1 = chunk.getTypeId(l, k1, j1); - l += i; - j1 += j; - if (l1 == 0 && this.k(l, k1, j1) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, l, k1, j1) <= 0) { - EntityHuman entityhuman1 = this.a((double) l + 0.5D, (double) k1 + 0.5D, (double) j1 + 0.5D, 8.0D); - - 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.X = this.random.nextInt(12000) + 6000; + l1 = this.l >> 2; + i2 = l1 & 15; + j2 = l1 >> 8 & 15; + k2 = l1 >> 16 & this.heightMinusOne; + l2 = chunk.getTypeId(i2, k2, j2); + i2 += k1; + j2 += j; + if (l2 == 0 && this.k(i2, k2, j2) <= this.random.nextInt(8) && this.a(EnumSkyBlock.SKY, i2, k2, j2) <= 0) { + EntityHuman entityhuman1 = this.a((double) i2 + 0.5D, (double) k2 + 0.5D, (double) j2 + 0.5D, 8.0D); + + if (entityhuman1 != null && entityhuman1.e((double) i2 + 0.5D, (double) k2 + 0.5D, (double) j2 + 0.5D) > 4.0D) { + this.makeSound((double) i2 + 0.5D, (double) k2 + 0.5D, (double) j2 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F); + this.U = this.random.nextInt(12000) + 6000; } } } - if (this.random.nextInt(100000) == 0 && this.u() && this.t()) { + MethodProfiler.b("thunder"); + if (this.random.nextInt(100000) == 0 && this.w() && this.v()) { 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)); + l1 = this.l >> 2; + i2 = k1 + (l1 & 15); + j2 = j + (l1 >> 8 & 15); + k2 = this.e(i2, j2); + if (this.v(i2, k2, j2)) { + this.strikeLightning(new EntityWeatherStorm(this, (double) i2, (double) k2, (double) j2)); this.r = 2; } } - int i2; + MethodProfiler.b("iceandsnow"); + this.l = this.l * 3 + 1013904223; + l1 = this.l >> 2; + i2 = l1 & 15; + j2 = l1 >> 8 & 15; + k2 = this.e(i2 + k1, j2 + j); + if (this.q(i2 + k1, k2 - 1, j2 + j)) { + // CraftBukkit start + BlockState blockState = this.getWorld().getBlockAt(i2 + k1, k2 - 1, j2 + j).getState(); + blockState.setTypeId(Block.ICE.id); + + BlockFormEvent iceBlockForm = new BlockFormEvent(blockState.getBlock(), blockState); + this.getServer().getPluginManager().callEvent(iceBlockForm); + if (!iceBlockForm.isCancelled()) { + blockState.update(true); + } + // CraftBukkit end + } + + if (this.w() && this.r(i2 + k1, k2, j2 + j)) { + // CraftBukkit start + BlockState blockState = this.getWorld().getBlockAt(i2 + k1, k2, j2 + j).getState(); + blockState.setTypeId(Block.SNOW.id); - if (this.random.nextInt(16) == 0) { + BlockFormEvent snow = new BlockFormEvent(blockState.getBlock(), blockState); + this.getServer().getPluginManager().callEvent(snow); + if (!snow.isCancelled()) { + blockState.update(true); + } + // CraftBukkit end + } + + MethodProfiler.b("checkLight"); + this.s(k1 + this.random.nextInt(16), this.random.nextInt(this.height), j + this.random.nextInt(16)); + MethodProfiler.b("tickTiles"); + + for (l1 = 0; l1 < 20; ++l1) { 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).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.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); - - BlockFormEvent snow = new BlockFormEvent(blockState.getBlock(), blockState); - this.getServer().getPluginManager().callEvent(snow); - if (!snow.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } + i2 = this.l >> 2; + j2 = i2 & 15; + k2 = i2 >> 8 & 15; + l2 = i2 >> 16 & this.heightMinusOne; + int i3 = chunk.b[j2 << this.heightBitsPlusFour | k2 << this.heightBits | l2] & 255; + + ++j1; + if (Block.n[i3]) { + ++i; + Block.byId[i3].a(this, j2 + k1, l2, k2 + j, this.random); + } + } + + MethodProfiler.a(); + } + } - if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) { - boolean flag = true; + public boolean p(int i, int j, int k) { + return this.c(i, j, k, false); + } - if (flag && this.getMaterial(l + i - 1, k1 - 1, j1 + j) != Material.WATER) { - flag = false; - } + public boolean q(int i, int j, int k) { + return this.c(i, j, k, true); + } - if (flag && this.getMaterial(l + i + 1, k1 - 1, j1 + j) != Material.WATER) { - flag = false; - } + public boolean c(int i, int j, int k, boolean flag) { + float f = this.getWorldChunkManager().a(i, j, k); - if (flag && this.getMaterial(l + i, k1 - 1, j1 + j - 1) != Material.WATER) { - flag = false; - } + if (f > 0.15F) { + return false; + } else { + if (j >= 0 && j < this.height && this.a(EnumSkyBlock.BLOCK, i, j, k) < 10) { + int l = this.getTypeId(i, j, k); - if (flag && this.getMaterial(l + i, k1 - 1, j1 + j + 1) != Material.WATER) { - flag = false; - } + if ((l == Block.STATIONARY_WATER.id || l == Block.WATER.id) && this.getData(i, j, k) == 0) { + if (!flag) { + return true; + } - if (!flag) { - // CraftBukkit start - BlockState blockState = this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j).getState(); - blockState.setTypeId(Block.ICE.id); + boolean flag1 = true; - BlockFormEvent iceBlockForm = new BlockFormEvent(blockState.getBlock(), blockState); - this.getServer().getPluginManager().callEvent(iceBlockForm); - if (!iceBlockForm.isCancelled()) { - blockState.update(true); - } - // CraftBukkit end - } + if (flag1 && this.getMaterial(i - 1, j, k) != Material.WATER) { + flag1 = false; + } + + if (flag1 && this.getMaterial(i + 1, j, k) != Material.WATER) { + flag1 = false; + } + + if (flag1 && this.getMaterial(i, j, k - 1) != Material.WATER) { + flag1 = false; + } + + if (flag1 && this.getMaterial(i, j, k + 1) != Material.WATER) { + flag1 = false; + } + + if (!flag1) { + return true; } } } - this.p(i + this.random.nextInt(16), this.random.nextInt(128), j + this.random.nextInt(16)); + return false; + } + } + + public boolean r(int i, int j, int k) { + float f = this.getWorldChunkManager().a(i, j, k); - for (k = 0; k < 80; ++k) { - this.l = this.l * 3 + 1013904223; - l = this.l >> 2; - j1 = l & 15; - k1 = l >> 8 & 15; - l1 = l >> 16 & 127; - i2 = chunk.b[j1 << 11 | k1 << 7 | l1] & 255; - if (Block.n[i2]) { - Block.byId[i2].a(this, j1 + i, l1, k1 + j, this.random); + if (f > 0.15F) { + return false; + } else { + if (j >= 0 && j < this.height && this.a(EnumSkyBlock.BLOCK, i, j, k) < 10) { + int l = this.getTypeId(i, j - 1, k); + int i1 = this.getTypeId(i, j, k); + + if (i1 == 0 && Block.SNOW.canPlace(this, i, j, k) && l != 0 && l != Block.ICE.id && Block.byId[l].material.isSolid()) { + return true; } } + + return false; } } - public void p(int i, int j, int k) { - this.b(EnumSkyBlock.SKY, i, j, k); + public void s(int i, int j, int k) { + if (!this.worldProvider.e) { + this.b(EnumSkyBlock.SKY, i, j, k); + } + this.b(EnumSkyBlock.BLOCK, i, j, k); } @@ -2008,7 +2175,6 @@ public class World implements IBlockAccess { 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; @@ -2033,8 +2199,14 @@ public class World implements IBlockAccess { 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); + int i5 = Block.q[this.getTypeId(j4, k4, l4)]; + + if (i5 == 0) { + i5 = 1; + } + + if (l2 == k2 - i5) { + this.H[i1++] = j4 - i + 32 + (k4 - j + 32 << 6) + (l4 - k + 32 << 12) + (k2 - i5 << 18); } } } @@ -2047,12 +2219,12 @@ public class World implements IBlockAccess { while (l < i1) { j1 = this.H[l++]; - int i5 = (j1 & 63) - 32 + i; + int j5 = (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); + l1 = this.a(enumskyblock, j5, j2, k1); + i2 = this.getTypeId(j5, j2, k1); k2 = Block.q[i2]; if (k2 == 0) { k2 = 1; @@ -2061,15 +2233,15 @@ public class World implements IBlockAccess { boolean flag2 = false; if (enumskyblock == EnumSkyBlock.SKY) { - l2 = this.d(l1, i5, j2, k1, i2, k2); + l2 = this.d(l1, j5, j2, k1, i2, k2); } else { - l2 = this.e(l1, i5, j2, k1, i2, k2); + l2 = this.e(l1, j5, j2, k1, i2, k2); } if (l2 != l1) { - this.a(enumskyblock, i5, j2, k1, l2); + this.a(enumskyblock, j5, j2, k1, l2); if (l2 > l1) { - i3 = i5 - i; + i3 = j5 - i; k3 = j2 - j; j3 = k1 - k; if (i3 < 0) { @@ -2085,28 +2257,28 @@ public class World implements IBlockAccess { } 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, j5 - 1, j2, k1) < l2) { + this.H[i1++] = j5 - 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, j5 + 1, j2, k1) < l2) { + this.H[i1++] = j5 + 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, j5, j2 - 1, k1) < l2) { + this.H[i1++] = j5 - 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, j5, j2 + 1, k1) < l2) { + this.H[i1++] = j5 - 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, j5, j2, k1 - 1) < l2) { + this.H[i1++] = j5 - 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); + if (this.a(enumskyblock, j5, j2, k1 + 1) < l2) { + this.H[i1++] = j5 - i + 32 + (j2 - j + 32 << 6) + (k1 + 1 - k + 32 << 12); } } } @@ -2116,9 +2288,9 @@ public class World implements IBlockAccess { } public boolean a(boolean flag) { - int i = this.N.size(); + int i = this.K.size(); - if (i != this.O.size()) { + if (i != this.L.size()) { throw new IllegalStateException("TickNextTick list out of synch"); } else { if (i > 1000) { @@ -2126,14 +2298,14 @@ public class World implements IBlockAccess { } for (int j = 0; j < i; ++j) { - NextTickListEntry nextticklistentry = (NextTickListEntry) this.N.first(); + NextTickListEntry nextticklistentry = (NextTickListEntry) this.K.first(); if (!flag && nextticklistentry.e > this.worldData.f()) { break; } - this.N.remove(nextticklistentry); - this.O.remove(nextticklistentry); + this.K.remove(nextticklistentry); + this.L.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)) { @@ -2145,12 +2317,41 @@ public class World implements IBlockAccess { } } - return this.N.size() != 0; + return this.K.size() != 0; } } + public List a(Chunk chunk, boolean flag) { + ArrayList arraylist = null; + ChunkCoordIntPair chunkcoordintpair = chunk.j(); + int i = chunkcoordintpair.x << 4; + int j = i + 16; + int k = chunkcoordintpair.z << 4; + int l = k + 16; + Iterator iterator = this.L.iterator(); + + while (iterator.hasNext()) { + NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); + + if (nextticklistentry.a >= i && nextticklistentry.a < j && nextticklistentry.c >= k && nextticklistentry.c < l) { + if (flag) { + this.K.remove(nextticklistentry); + iterator.remove(); + } + + if (arraylist == null) { + arraylist = new ArrayList(); + } + + arraylist.add(nextticklistentry); + } + } + + return arraylist; + } + public List b(Entity entity, AxisAlignedBB axisalignedbb) { - this.Y.clear(); + this.V.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); @@ -2159,12 +2360,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.Y); + this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.V); } } } - return this.Y; + return this.V; } public List a(Class oclass, AxisAlignedBB axisalignedbb) { @@ -2226,7 +2427,7 @@ public class World implements IBlockAccess { } public void b(List list) { - this.M.addAll(list); + this.J.addAll(list); } public boolean a(int i, int j, int k, int l, boolean flag, int i1) { @@ -2260,6 +2461,7 @@ public class World implements IBlockAccess { } public PathEntity findPath(Entity entity, Entity entity1, float f) { + MethodProfiler.a("pathfind"); int i = MathHelper.floor(entity.locX); int j = MathHelper.floor(entity.locY); int k = MathHelper.floor(entity.locZ); @@ -2271,11 +2473,14 @@ public class World implements IBlockAccess { int i2 = j + l; int j2 = k + l; ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2); + PathEntity pathentity = (new Pathfinder(chunkcache)).a(entity, entity1, f); - return (new Pathfinder(chunkcache)).a(entity, entity1, f); + MethodProfiler.a(); + return pathentity; } public PathEntity a(Entity entity, int i, int j, int k, float f) { + MethodProfiler.a("pathfind"); int l = MathHelper.floor(entity.locX); int i1 = MathHelper.floor(entity.locY); int j1 = MathHelper.floor(entity.locZ); @@ -2287,8 +2492,10 @@ public class World implements IBlockAccess { int l2 = i1 + k1; int i3 = j1 + k1; ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3); + PathEntity pathentity = (new Pathfinder(chunkcache)).a(entity, i, j, k, f); - return (new Pathfinder(chunkcache)).a(entity, i, j, k, f); + MethodProfiler.a(); + return pathentity; } public boolean isBlockFacePowered(int i, int j, int k, int l) { @@ -2341,6 +2548,30 @@ public class World implements IBlockAccess { return entityhuman; } + public EntityHuman b(Entity entity, double d0) { + return this.b(entity.locX, entity.locY, entity.locZ, d0); + } + + public EntityHuman b(double d0, double d1, double d2, double d3) { + double d4 = -1.0D; + EntityHuman entityhuman = null; + + for (int i = 0; i < this.players.size(); ++i) { + EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); + + if (!entityhuman1.abilities.isInvulnerable) { + double d5 = entityhuman1.e(d0, d1, d2); + + if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { + d4 = d5; + entityhuman = entityhuman1; + } + } + } + + return entityhuman; + } + public EntityHuman a(String s) { for (int i = 0; i < this.players.size(); ++i) { if (s.equals(((EntityHuman) this.players.get(i)).name)) { @@ -2365,8 +2596,8 @@ public class World implements IBlockAccess { l2 = 0; } - if (i3 > 128) { - i3 = 128; + if (i3 > this.height) { + i3 = this.height; } for (int j3 = k1; j3 <= i2; ++j3) { @@ -2400,7 +2631,7 @@ public class World implements IBlockAccess { return abyte; } - public void j() { + public void l() { this.B.b(); } @@ -2413,7 +2644,7 @@ public class World implements IBlockAccess { NextTickListEntry nextticklistentry; - for (Iterator iterator = this.O.iterator(); iterator.hasNext(); nextticklistentry.e += j) { + for (Iterator iterator = this.L.iterator(); iterator.hasNext(); nextticklistentry.e += j) { nextticklistentry = (NextTickListEntry) iterator.next(); } @@ -2438,7 +2669,7 @@ public class World implements IBlockAccess { public void a(Entity entity, byte b0) {} - public IChunkProvider n() { + public IChunkProvider p() { return this.chunkProvider; } @@ -2450,16 +2681,16 @@ public class World implements IBlockAccess { } } - public IDataManager o() { + public IDataManager q() { return this.B; } - public WorldData p() { + public WorldData r() { return this.worldData; } public void everyoneSleeping() { - this.T = !this.players.isEmpty(); + this.Q = !this.players.isEmpty(); Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2467,7 +2698,7 @@ public class World implements IBlockAccess { // CraftBukkit if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) { - this.T = false; + this.Q = false; break; } } @@ -2483,8 +2714,8 @@ public class World implements IBlockAccess { } // CraftBukkit end - protected void r() { - this.T = false; + protected void t() { + this.Q = false; Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -2495,11 +2726,11 @@ public class World implements IBlockAccess { } } - this.y(); + this.A(); } public boolean everyoneDeeplySleeping() { - if (this.T && !this.isStatic) { + if (this.Q && !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 @@ -2535,16 +2766,16 @@ public class World implements IBlockAccess { return this.n + (this.o - this.n) * f; } - public boolean t() { + public boolean v() { return (double) this.c(1.0F) > 0.9D; } - public boolean u() { + public boolean w() { return (double) this.d(1.0F) > 0.2D; } - public boolean s(int i, int j, int k) { - if (!this.u()) { + public boolean v(int i, int j, int k) { + if (!this.w()) { return false; } else if (!this.isChunkLoaded(i, j, k)) { return false; @@ -2569,7 +2800,7 @@ public class World implements IBlockAccess { return this.worldMaps.a(s); } - public void e(int i, int j, int k, int l, int i1) { + public void f(int i, int j, int k, int l, int i1) { this.a((EntityHuman) null, i, j, k, l, i1); } @@ -2579,19 +2810,29 @@ public class World implements IBlockAccess { } } - public Random t(int i, int j, int k) { - long l = (long) i * 341873128712L + (long) j * 132897987541L + this.p().getSeed() + (long) k; + public Random w(int i, int j, int k) { + long l = (long) i * 341873128712L + (long) j * 132897987541L + this.r().getSeed() + (long) k; this.random.setSeed(l); return this.random; } - public boolean v() { + public boolean x() { return false; } public void a(EnumSkyBlock enumskyblock, int i, int j, int k, int l, int i1, int j1) {} + public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) { + List list = this.p().a(enumcreaturetype, i, j, k); + + return list != null && !list.isEmpty() ? (BiomeMeta) WeightedRandom.a(this.random, (Collection) list) : null; + } + + public ChunkPosition b(String s, int i, int j, int k) { + return this.p().a(this, s, i, j, k); + } + // CraftBukkit start public UUID getUUID() { return this.B.getUUID(); diff --git a/src/main/java/net/minecraft/server/WorldData.java b/src/main/java/net/minecraft/server/WorldData.java index c824df21..c6b2e03a 100644 --- a/src/main/java/net/minecraft/server/WorldData.java +++ b/src/main/java/net/minecraft/server/WorldData.java @@ -21,39 +21,42 @@ public class WorldData { private int thunderTicks; private int gameType; private boolean useMapFeatures; + private boolean hardcore = false; public WorldData(NBTTagCompound nbttagcompound) { this.seed = nbttagcompound.getLong("RandomSeed"); - this.gameType = nbttagcompound.e("GameType"); + this.gameType = nbttagcompound.f("GameType"); if (nbttagcompound.hasKey("MapFeatures")) { - this.useMapFeatures = nbttagcompound.m("MapFeatures"); + this.useMapFeatures = nbttagcompound.n("MapFeatures"); } else { this.useMapFeatures = true; } - this.spawnX = nbttagcompound.e("SpawnX"); - this.spawnY = nbttagcompound.e("SpawnY"); - this.spawnZ = nbttagcompound.e("SpawnZ"); + this.spawnX = nbttagcompound.f("SpawnX"); + this.spawnY = nbttagcompound.f("SpawnY"); + this.spawnZ = nbttagcompound.f("SpawnZ"); this.time = nbttagcompound.getLong("Time"); this.lastPlayed = nbttagcompound.getLong("LastPlayed"); this.sizeOnDisk = nbttagcompound.getLong("SizeOnDisk"); this.name = nbttagcompound.getString("LevelName"); - this.version = nbttagcompound.e("version"); - this.rainTicks = nbttagcompound.e("rainTime"); - this.isRaining = nbttagcompound.m("raining"); - this.thunderTicks = nbttagcompound.e("thunderTime"); - this.isThundering = nbttagcompound.m("thundering"); + this.version = nbttagcompound.f("version"); + this.rainTicks = nbttagcompound.f("rainTime"); + this.isRaining = nbttagcompound.n("raining"); + this.thunderTicks = nbttagcompound.f("thunderTime"); + this.isThundering = nbttagcompound.n("thundering"); + this.hardcore = nbttagcompound.n("hardcore"); if (nbttagcompound.hasKey("Player")) { - this.playerData = nbttagcompound.k("Player"); - this.dimension = this.playerData.e("Dimension"); + this.playerData = nbttagcompound.l("Player"); + this.dimension = this.playerData.f("Dimension"); } } public WorldData(WorldSettings worldsettings, String s) { this.seed = worldsettings.a(); this.gameType = worldsettings.b(); - this.useMapFeatures = worldsettings.c(); + this.useMapFeatures = worldsettings.d(); this.name = s; + this.hardcore = worldsettings.c(); } public WorldData(WorldData worlddata) { @@ -74,6 +77,7 @@ public class WorldData { this.isRaining = worlddata.isRaining; this.thunderTicks = worlddata.thunderTicks; this.isThundering = worlddata.isThundering; + this.hardcore = worlddata.hardcore; } public NBTTagCompound a() { @@ -117,6 +121,7 @@ public class WorldData { nbttagcompound.a("raining", this.isRaining); nbttagcompound.a("thunderTime", this.thunderTicks); nbttagcompound.a("thundering", this.isThundering); + nbttagcompound.a("hardcore", this.hardcore); if (nbttagcompound1 != null) { nbttagcompound.a("Player", nbttagcompound1); } @@ -219,4 +224,8 @@ public class WorldData { public void setGameType(int i) { this.gameType = i; } + + public boolean isHardcore() { + return this.hardcore; + } } diff --git a/src/main/java/net/minecraft/server/WorldGenBigTree.java b/src/main/java/net/minecraft/server/WorldGenBigTree.java index 372d6059..17ad9294 100644 --- a/src/main/java/net/minecraft/server/WorldGenBigTree.java +++ b/src/main/java/net/minecraft/server/WorldGenBigTree.java @@ -22,7 +22,9 @@ public class WorldGenBigTree extends WorldGenerator { int n = 4; int[][] o; - public WorldGenBigTree() {} + public WorldGenBigTree(boolean flag) { + super(flag); + } void a() { this.f = (int) ((double) this.e * this.g); @@ -119,7 +121,7 @@ public class WorldGenBigTree extends WorldGenerator { if (l1 != 0 && l1 != 18) { ++k1; } else { - this.c.setRawTypeId(aint1[0], aint1[1], aint1[2], l); + this.a(this.c, aint1[0], aint1[1], aint1[2], l, 0); ++k1; } } @@ -195,7 +197,7 @@ public class WorldGenBigTree extends WorldGenerator { aint3[b1] = MathHelper.floor((double) (aint[b1] + j) + 0.5D); aint3[b2] = MathHelper.floor((double) aint[b2] + (double) j * d0 + 0.5D); aint3[b3] = MathHelper.floor((double) aint[b3] + (double) j * d1 + 0.5D); - this.c.setRawTypeId(aint3[0], aint3[1], aint3[2], i); + this.a(this.c, aint3[0], aint3[1], aint3[2], i, 0); } } } diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java index 319fea48..5903c906 100644 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ b/src/main/java/net/minecraft/server/WorldGenForest.java @@ -6,7 +6,9 @@ import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenForest extends WorldGenerator { - public WorldGenForest() {} + public WorldGenForest(boolean flag) { + super(flag); + } public boolean a(World world, Random random, int i, int j, int k) { // CraftBukkit start @@ -22,89 +24,77 @@ public class WorldGenForest extends WorldGenerator { int l = random.nextInt(3) + 5; boolean flag = true; - if (j >= 1) { - int k1000 = j + l + 1; - - world.getClass(); - if (k1000 <= 128) { - int j1; - int k1; - int l1; - int i2; + if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit + int i1; + int j1; + int k1; + int l1; - for (j1 = j; j1 <= j + 1 + l; ++j1) { - byte b0 = 1; + for (i1 = j; i1 <= j + 1 + l; ++i1) { + byte b0 = 1; - if (j1 == j) { - b0 = 0; - } + if (i1 == j) { + b0 = 0; + } - if (j1 >= j + 1 + l - 2) { - b0 = 2; - } + if (i1 >= 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; - } + for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { + for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < world.getHeight()) { // CraftBukkit + l1 = world.getTypeId(j1, i1, k1); + if (l1 != 0 && l1 != Block.LEAVES.id) { + flag = false; } - + } else { flag = false; } } } + } - if (!flag) { - return false; - } - - 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); + if (!flag) { + return false; + } else { + i1 = world.getTypeId(i, j - 1, k); + if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - int j2; + int i2; - for (j2 = j - 3 + l; j2 <= j + l; ++j2) { - k1 = j2 - (j + l); - l1 = 1 - k1 / 2; + for (i2 = j - 3 + l; i2 <= j + l; ++i2) { + j1 = i2 - (j + l); + k1 = 1 - j1 / 2; - for (i2 = i - l1; i2 <= i + l1; ++i2) { - int k2 = i2 - i; + for (l1 = i - k1; l1 <= i + k1; ++l1) { + int j2 = l1 - i; - for (int l2 = k - l1; l2 <= k + l1; ++l2) { - int i3 = l2 - k; + for (int k2 = k - k1; k2 <= k + k1; ++k2) { + int l2 = k2 - 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); - } + if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { + this.a(world, l1, i2, k2, Block.LEAVES.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); - } + for (i2 = 0; i2 < l; ++i2) { + j1 = world.getTypeId(i, j + i2, k); + if (j1 == 0 || j1 == Block.LEAVES.id) { + this.a(world, i, j + i2, k, Block.LOG.id, 2); } - - return true; } - } - return false; + return true; + } else { + 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 79015933..237bc99d 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga1.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga1.java @@ -25,90 +25,78 @@ public class WorldGenTaiga1 extends WorldGenerator { int k1 = 1 + random.nextInt(j1 + 1); boolean flag = true; - if (j >= 1) { - int l1 = j + l + 1; - - world.getClass(); - if (l1 <= 128) { - int i2; - int j2; - int k2; - int l2; - int i3; - - for (i2 = j; i2 <= j + 1 + l && flag; ++i2) { - boolean flag1 = true; - - if (i2 - j < i1) { - i3 = 0; - } else { - i3 = k1; - } + if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit + int l1; + int i2; + int j2; + int k2; + int l2; + + for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { + boolean flag1 = true; + + if (l1 - j < i1) { + l2 = 0; + } else { + l2 = 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; - } + for (i2 = i - l2; i2 <= i + l2 && flag; ++i2) { + for (j2 = k - l2; j2 <= k + l2 && flag; ++j2) { + if (l1 >= 0 && l1 < world.getHeight()) { // CraftBukkit + k2 = world.getTypeId(i2, l1, j2); + if (k2 != 0 && k2 != Block.LEAVES.id) { + flag = false; } - + } else { flag = false; } } } + } - 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); - i3 = 0; + if (!flag) { + return false; + } else { + l1 = world.getTypeId(i, j - 1, k); + if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + l2 = 0; - for (j2 = j + l; j2 >= j + i1; --j2) { - for (k2 = i - i3; k2 <= i + i3; ++k2) { - l2 = k2 - i; + for (i2 = j + l; i2 >= j + i1; --i2) { + for (j2 = i - l2; j2 <= i + l2; ++j2) { + k2 = j2 - i; - for (int j3 = k - i3; j3 <= k + i3; ++j3) { - int k3 = j3 - k; + for (int i3 = k - l2; i3 <= k + l2; ++i3) { + int j3 = i3 - 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 ((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); } } - - if (i3 >= 1 && j2 == j + i1 + 1) { - --i3; - } else if (i3 < k1) { - ++i3; - } } - 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); - } + if (l2 >= 1 && i2 == j + i1 + 1) { + --l2; + } else if (l2 < k1) { + ++l2; } + } - return true; + 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 false; + return true; + } else { + 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 61947368..b6cf4555 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -6,7 +6,9 @@ import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenTaiga2 extends WorldGenerator { - public WorldGenTaiga2() {} + public WorldGenTaiga2(boolean flag) { + super(flag); + } public boolean a(World world, Random random, int i, int j, int k) { // CraftBukkit start @@ -25,103 +27,91 @@ public class WorldGenTaiga2 extends WorldGenerator { int k1 = 2 + random.nextInt(2); boolean flag = true; - if (j >= 1) { - int l1 = j + l + 1; - - world.getClass(); - if (l1 <= 128) { - int i2; - int j2; - int k2; - int l2; + if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit + int l1; + int i2; + int j2; + int k2; - for (i2 = j; i2 <= j + 1 + l && flag; ++i2) { - boolean flag1 = true; + for (l1 = j; l1 <= j + 1 + l && flag; ++l1) { + boolean flag1 = true; - if (i2 - j < i1) { - l2 = 0; - } else { - l2 = k1; - } + if (l1 - j < i1) { + k2 = 0; + } else { + k2 = 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; - } + for (i2 = i - k2; i2 <= i + k2 && flag; ++i2) { + for (int l2 = k - k2; l2 <= k + k2 && flag; ++l2) { + if (l1 >= 0 && l1 < world.getHeight()) { // CraftBukkit + j2 = world.getTypeId(i2, l1, l2); + if (j2 != 0 && j2 != Block.LEAVES.id) { + flag = false; } - + } else { flag = false; } } } + } - 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; + if (!flag) { + return false; + } else { + l1 = world.getTypeId(i, j - 1, k); + if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); + k2 = random.nextInt(2); + i2 = 1; + byte b0 = 0; - int j3; - int k3; + int i3; + int j3; - for (k2 = 0; k2 <= j1; ++k2) { - k3 = j + l - k2; + for (j2 = 0; j2 <= j1; ++j2) { + j3 = j + l - j2; - for (j3 = i - l2; j3 <= i + l2; ++j3) { - int l3 = j3 - i; + for (i3 = i - k2; i3 <= i + k2; ++i3) { + int k3 = i3 - i; - for (int i4 = k - l2; i4 <= k + l2; ++i4) { - int j4 = i4 - k; + for (int l3 = k - k2; l3 <= k + k2; ++l3) { + int i4 = l3 - 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 ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.o[world.getTypeId(i3, j3, l3)]) { + this.a(world, i3, j3, l3, Block.LEAVES.id, 1); } } + } - if (l2 >= j2) { - l2 = b0; - b0 = 1; - ++j2; - if (j2 > k1) { - j2 = k1; - } - } else { - ++l2; + if (k2 >= i2) { + k2 = b0; + b0 = 1; + ++i2; + if (i2 > k1) { + i2 = k1; } + } else { + ++k2; } + } - k2 = random.nextInt(3); + j2 = 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); - } + for (j3 = 0; j3 < l - j2; ++j3) { + i3 = world.getTypeId(i, j + j3, k); + if (i3 == 0 || i3 == Block.LEAVES.id) { + this.a(world, i, j + j3, k, Block.LOG.id, 1); } - - return true; } - } - return false; + return true; + } else { + 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 021560fc..15450e41 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -6,7 +6,9 @@ import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenTrees extends WorldGenerator { - public WorldGenTrees() {} + public WorldGenTrees(boolean flag) { + super(flag); + } public boolean a(World world, Random random, int i, int j, int k) { // CraftBukkit start @@ -22,89 +24,77 @@ public class WorldGenTrees extends WorldGenerator { int l = random.nextInt(3) + 4; boolean flag = true; - if (j >= 1) { - int k1000 = j + l + 1; - - world.getClass(); - if (k1000 <= 128) { - int j1; - int k1; - int l1; - int i2; + if (j >= 1 && j + l + 1 <= world.getHeight()) { // CraftBukkit + int i1; + int j1; + int k1; + int l1; - for (j1 = j; j1 <= j + 1 + l; ++j1) { - byte b0 = 1; + for (i1 = j; i1 <= j + 1 + l; ++i1) { + byte b0 = 1; - if (j1 == j) { - b0 = 0; - } + if (i1 == j) { + b0 = 0; + } - if (j1 >= j + 1 + l - 2) { - b0 = 2; - } + if (i1 >= 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; - } + for (j1 = i - b0; j1 <= i + b0 && flag; ++j1) { + for (k1 = k - b0; k1 <= k + b0 && flag; ++k1) { + if (i1 >= 0 && i1 < world.getHeight()) { // CraftBukkit + l1 = world.getTypeId(j1, i1, k1); + if (l1 != 0 && l1 != Block.LEAVES.id) { + flag = false; } - + } else { flag = false; } } } + } - if (!flag) { - return false; - } - - 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); + if (!flag) { + return false; + } else { + i1 = world.getTypeId(i, j - 1, k); + if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < world.getHeight() - l - 1) { // CraftBukkit + world.setRawTypeId(i, j - 1, k, Block.DIRT.id); - int j2; + int i2; - for (j2 = j - 3 + l; j2 <= j + l; ++j2) { - k1 = j2 - (j + l); - l1 = 1 - k1 / 2; + for (i2 = j - 3 + l; i2 <= j + l; ++i2) { + j1 = i2 - (j + l); + k1 = 1 - j1 / 2; - for (i2 = i - l1; i2 <= i + l1; ++i2) { - int k2 = i2 - i; + for (l1 = i - k1; l1 <= i + k1; ++l1) { + int j2 = l1 - i; - for (int l2 = k - l1; l2 <= k + l1; ++l2) { - int i3 = l2 - k; + for (int k2 = k - k1; k2 <= k + k1; ++k2) { + int l2 = k2 - 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); - } + if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.o[world.getTypeId(l1, i2, k2)]) { + this.a(world, l1, i2, k2, Block.LEAVES.id, 0); } } } + } - 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); - } + for (i2 = 0; i2 < l; ++i2) { + j1 = world.getTypeId(i, j + i2, k); + if (j1 == 0 || j1 == Block.LEAVES.id) { + this.a(world, i, j + i2, k, Block.LOG.id, 0); } - - return true; } - } - return false; + return true; + } else { + return false; + } } + } else { + return false; } - - return false; } } diff --git a/src/main/java/net/minecraft/server/WorldGenerator.java b/src/main/java/net/minecraft/server/WorldGenerator.java new file mode 100644 index 00000000..7ed5f7e8 --- /dev/null +++ b/src/main/java/net/minecraft/server/WorldGenerator.java @@ -0,0 +1,31 @@ +package net.minecraft.server; + +import java.util.Random; + +import org.bukkit.BlockChangeDelegate; // CraftBukkit + +public abstract class WorldGenerator { + + private final boolean a; + + public WorldGenerator() { + this.a = false; + } + + public WorldGenerator(boolean flag) { + this.a = flag; + } + + public abstract boolean a(World world, Random random, int i, int j, int k); + + public void a(double d0, double d1, double d2) {} + + // CraftBukkit -- change signature + protected void a(BlockChangeDelegate world, int i, int j, int k, int l, int i1) { + if (this.a) { + ((World) world).setTypeIdAndData(i, j, k, l, i1); // CraftBukkit -- force-cast to world to get it working + } else { + world.setRawTypeIdAndData(i, j, k, l, i1); + } + } +} diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index 4e93ed3a..344f954a 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -42,7 +42,7 @@ public class WorldMap extends WorldMapBase { public void a(NBTTagCompound nbttagcompound) { // CraftBukkit start - byte dimension = nbttagcompound.c("dimension"); + byte dimension = nbttagcompound.d("dimension"); if (dimension >= 10) { long least = nbttagcompound.getLong("UUIDLeast"); @@ -65,9 +65,9 @@ public class WorldMap extends WorldMapBase { this.map = dimension; // CraftBukkit end - this.b = nbttagcompound.e("xCenter"); - this.c = nbttagcompound.e("zCenter"); - this.e = nbttagcompound.c("scale"); + this.b = nbttagcompound.f("xCenter"); + this.c = nbttagcompound.f("zCenter"); + this.e = nbttagcompound.d("scale"); if (this.e < 0) { this.e = 0; } @@ -76,13 +76,13 @@ public class WorldMap extends WorldMapBase { this.e = 4; } - short short1 = nbttagcompound.d("width"); - short short2 = nbttagcompound.d("height"); + short short1 = nbttagcompound.e("width"); + short short2 = nbttagcompound.e("height"); if (short1 == 128 && short2 == 128) { - this.f = nbttagcompound.j("colors"); + this.f = nbttagcompound.k("colors"); } else { - byte[] abyte = nbttagcompound.j("colors"); + byte[] abyte = nbttagcompound.k("colors"); this.f = new byte[16384]; int i = (128 - short1) / 2; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index add4647d..66b1cb38 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -20,7 +20,7 @@ public class WorldServer extends World implements BlockChangeDelegate { public boolean weirdIsOpCache = false; public boolean savingDisabled; public final MinecraftServer server; // CraftBukkit - private -> public final - private EntityList Q = new EntityList(); + private EntityList N = new EntityList(); // CraftBukkit start - change signature public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, WorldSettings worldsettings, org.bukkit.World.Environment env, ChunkGenerator gen) { @@ -159,16 +159,30 @@ public class WorldServer extends World implements BlockChangeDelegate { protected void c(Entity entity) { super.c(entity); - this.Q.a(entity.id, entity); + this.N.a(entity.id, entity); + Entity[] aentity = entity.aG(); + + if (aentity != null) { + for (int i = 0; i < aentity.length; ++i) { + this.N.a(aentity[i].id, aentity[i]); + } + } } protected void d(Entity entity) { super.d(entity); - this.Q.d(entity.id); + this.N.d(entity.id); + Entity[] aentity = entity.aG(); + + if (aentity != null) { + for (int i = 0; i < aentity.length; ++i) { + this.N.d(aentity[i].id); + } + } } public Entity getEntity(int i) { - return (Entity) this.Q.a(i); + return (Entity) this.N.a(i); } public boolean strikeLightning(Entity entity) { @@ -224,11 +238,11 @@ public class WorldServer extends World implements BlockChangeDelegate { this.B.e(); } - protected void h() { - boolean flag = this.u(); + protected void i() { + boolean flag = this.w(); - super.h(); - if (flag != this.u()) { + super.i(); + if (flag != this.w()) { // 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) { |