diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-24 22:53:23 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-10-27 22:19:03 -0400 |
commit | 60819c6693daf19dde68b04af38a4fee8c7da988 (patch) | |
tree | e7bd96a07f0e9d9f1f6b2721ddd1bb5dd71eaf48 | |
parent | b9a72531b6e2ccc84bd021bca421255a957d96f7 (diff) | |
download | craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.gz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.lz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.tar.xz craftbukkit-60819c6693daf19dde68b04af38a4fee8c7da988.zip |
Update CraftBukkit to Minecraft 1.4(.2).
237 files changed, 10055 insertions, 4814 deletions
@@ -4,7 +4,7 @@ <groupId>org.bukkit</groupId> <artifactId>craftbukkit</artifactId> <packaging>jar</packaging> - <version>1.3.2-R3.0</version> + <version>1.4.2-R0.1-SNAPSHOT</version> <name>CraftBukkit</name> <url>http://www.bukkit.org</url> @@ -51,14 +51,14 @@ <dependency> <groupId>org.bukkit</groupId> <artifactId>bukkit</artifactId> - <version>1.3.2-R3.0</version> + <version>1.4.2-R0.1-SNAPSHOT</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.bukkit</groupId> <artifactId>minecraft-server</artifactId> - <version>1.3.2</version> + <version>1.4.2</version> <type>jar</type> <scope>compile</scope> </dependency> diff --git a/src/main/java/net/minecraft/server/AABBPool.java b/src/main/java/net/minecraft/server/AABBPool.java index 8262e5c1..0815fbd1 100644 --- a/src/main/java/net/minecraft/server/AABBPool.java +++ b/src/main/java/net/minecraft/server/AABBPool.java @@ -7,10 +7,10 @@ public class AABBPool { private final int a; private final int b; - private final List c = new ArrayList(); + private final List pool = new ArrayList(); private int d = 0; - private int e = 0; - private int f = 0; + private int largestSize = 0; + private int resizeTime = 0; public AABBPool(int i, int j) { this.a = i; @@ -18,15 +18,15 @@ public class AABBPool { } public AxisAlignedBB a(double d0, double d1, double d2, double d3, double d4, double d5) { - if (this.f == 0) return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract - + // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract + if (this.resizeTime == 0) return new AxisAlignedBB(d0, d1, d2, d3, d4, d5); AxisAlignedBB axisalignedbb; - if (this.d >= this.c.size()) { + if (this.d >= this.pool.size()) { axisalignedbb = new AxisAlignedBB(d0, d1, d2, d3, d4, d5); - this.c.add(axisalignedbb); + this.pool.add(axisalignedbb); } else { - axisalignedbb = (AxisAlignedBB) this.c.get(this.d); + axisalignedbb = (AxisAlignedBB) this.pool.get(this.d); axisalignedbb.b(d0, d1, d2, d3, d4, d5); } @@ -35,24 +35,34 @@ public class AABBPool { } public void a() { - if (this.d > this.e) { - this.e = this.d; + if (this.d > this.largestSize) { + this.largestSize = this.d; } // CraftBukkit start - intelligent cache - if ((this.f++ & 0xff) == 0) { - int newSize = this.c.size() - (this.c.size() >> 3); - if (newSize > this.e) { // newSize will be 87.5%, but if we were not in that range, we clear some of the cache - for (int i = this.c.size() - 1; i > newSize; i--) { // Work down from size() to prevent insane array copies - this.c.remove(i); + if ((this.resizeTime++ & 0xff) == 0) { + int newSize = this.pool.size() - (this.pool.size() >> 3); + // newSize will be 87.5%, but if we were not in that range, we clear some of the cache + if (newSize > this.largestSize) { + // Work down from size() to prevent insane array copies + for (int i = this.pool.size() - 1; i > newSize; i--) { + this.pool.remove(i); } } - this.e = 0; - // this.f = 0; // We do not reset to zero; it doubles for a flag + this.largestSize = 0; + // this.resizeTime = 0; // We do not reset to zero; it doubles for a flag } // CraftBukkit end this.d = 0; } + + public int c() { + return this.pool.size(); + } + + public int d() { + return this.d; + } } diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java index d5880a4b..6893134e 100644 --- a/src/main/java/net/minecraft/server/Block.java +++ b/src/main/java/net/minecraft/server/Block.java @@ -14,49 +14,52 @@ public class Block { public static final StepSound i = new StepSound("stone", 1.0F, 1.5F); public static final StepSound j = new StepSoundStone("stone", 1.0F, 1.0F); public static final StepSound k = new StepSound("cloth", 1.0F, 1.0F); - public static final StepSound l = new StepSoundSand("sand", 1.0F, 1.0F); + public static final StepSound l = new StepSound("sand", 1.0F, 1.0F); + public static final StepSound m = new StepSound("snow", 1.0F, 1.0F); + public static final StepSound n = new StepSoundLadder("ladder", 1.0F, 1.0F); + public static final StepSound o = new StepSoundAnvil("anvil", 0.3F, 1.0F); public static final Block[] byId = new Block[4096]; - public static final boolean[] n = new boolean[4096]; + public static final boolean[] q = new boolean[4096]; public static final int[] lightBlock = new int[4096]; - public static final boolean[] p = new boolean[4096]; + public static final boolean[] s = new boolean[4096]; public static final int[] lightEmission = new int[4096]; - public static final boolean[] r = new boolean[4096]; - public static boolean[] s = new boolean[4096]; + public static final boolean[] u = new boolean[4096]; + public static boolean[] v = new boolean[4096]; public static final Block STONE = (new BlockStone(1, 1)).c(1.5F).b(10.0F).a(h).b("stone"); public static final BlockGrass GRASS = (BlockGrass) (new BlockGrass(2)).c(0.6F).a(g).b("grass"); public static final Block DIRT = (new BlockDirt(3, 2)).c(0.5F).a(f).b("dirt"); public static final Block COBBLESTONE = (new Block(4, 16, Material.STONE)).c(2.0F).b(10.0F).a(h).b("stonebrick").a(CreativeModeTab.b); - public static final Block WOOD = (new BlockWood(5)).c(2.0F).b(5.0F).a(e).b("wood").p(); - public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(g).b("sapling").p(); - public static final Block BEDROCK = (new Block(7, 17, Material.STONE)).q().b(6000000.0F).a(h).b("bedrock").v().a(CreativeModeTab.b); - public static final Block WATER = (new BlockFlowing(8, Material.WATER)).c(100.0F).h(3).b("water").v().p(); - public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.WATER)).c(100.0F).h(3).b("water").v().p(); - public static final Block LAVA = (new BlockFlowing(10, Material.LAVA)).c(0.0F).a(1.0F).h(255).b("lava").v().p(); - public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.LAVA)).c(100.0F).a(1.0F).h(255).b("lava").v().p(); + public static final Block WOOD = (new BlockWood(5)).c(2.0F).b(5.0F).a(e).b("wood").r(); + public static final Block SAPLING = (new BlockSapling(6, 15)).c(0.0F).a(g).b("sapling").r(); + public static final Block BEDROCK = (new Block(7, 17, Material.STONE)).s().b(6000000.0F).a(h).b("bedrock").D().a(CreativeModeTab.b); + public static final Block WATER = (new BlockFlowing(8, Material.WATER)).c(100.0F).h(3).b("water").D().r(); + public static final Block STATIONARY_WATER = (new BlockStationary(9, Material.WATER)).c(100.0F).h(3).b("water").D().r(); + public static final Block LAVA = (new BlockFlowing(10, Material.LAVA)).c(0.0F).a(1.0F).h(255).b("lava").D().r(); + public static final Block STATIONARY_LAVA = (new BlockStationary(11, Material.LAVA)).c(100.0F).a(1.0F).h(255).b("lava").D().r(); public static final Block SAND = (new BlockSand(12, 18)).c(0.5F).a(l).b("sand"); public static final Block GRAVEL = (new BlockGravel(13, 19)).c(0.6F).a(f).b("gravel"); public static final Block GOLD_ORE = (new BlockOre(14, 32)).c(3.0F).b(5.0F).a(h).b("oreGold"); public static final Block IRON_ORE = (new BlockOre(15, 33)).c(3.0F).b(5.0F).a(h).b("oreIron"); public static final Block COAL_ORE = (new BlockOre(16, 34)).c(3.0F).b(5.0F).a(h).b("oreCoal"); - public static final Block LOG = (new BlockLog(17)).c(2.0F).a(e).b("log").p(); - public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).h(1).a(g).b("leaves").p(); + public static final Block LOG = (new BlockLog(17)).c(2.0F).a(e).b("log").r(); + public static final BlockLeaves LEAVES = (BlockLeaves) (new BlockLeaves(18, 52)).c(0.2F).h(1).a(g).b("leaves").r(); public static final Block SPONGE = (new BlockSponge(19)).c(0.6F).a(g).b("sponge"); public static final Block GLASS = (new BlockGlass(20, 49, Material.SHATTERABLE, false)).c(0.3F).a(j).b("glass"); public static final Block LAPIS_ORE = (new BlockOre(21, 160)).c(3.0F).b(5.0F).a(h).b("oreLapis"); public static final Block LAPIS_BLOCK = (new Block(22, 144, Material.STONE)).c(3.0F).b(5.0F).a(h).b("blockLapis").a(CreativeModeTab.b); - public static final Block DISPENSER = (new BlockDispenser(23)).c(3.5F).a(h).b("dispenser").p(); - public static final Block SANDSTONE = (new BlockSandStone(24)).a(h).c(0.8F).b("sandStone").p(); - public static final Block NOTE_BLOCK = (new BlockNote(25)).c(0.8F).b("musicBlock").p(); - public static final Block BED = (new BlockBed(26)).c(0.2F).b("bed").v().p(); - public static final Block GOLDEN_RAIL = (new BlockMinecartTrack(27, 179, true)).c(0.7F).a(i).b("goldenRail").p(); - public static final Block DETECTOR_RAIL = (new BlockMinecartDetector(28, 195)).c(0.7F).a(i).b("detectorRail").p(); - public static final Block PISTON_STICKY = (new BlockPiston(29, 106, true)).b("pistonStickyBase").p(); + public static final Block DISPENSER = (new BlockDispenser(23)).c(3.5F).a(h).b("dispenser").r(); + public static final Block SANDSTONE = (new BlockSandStone(24)).a(h).c(0.8F).b("sandStone").r(); + public static final Block NOTE_BLOCK = (new BlockNote(25)).c(0.8F).b("musicBlock").r(); + public static final Block BED = (new BlockBed(26)).c(0.2F).b("bed").D().r(); + public static final Block GOLDEN_RAIL = (new BlockMinecartTrack(27, 179, true)).c(0.7F).a(i).b("goldenRail").r(); + public static final Block DETECTOR_RAIL = (new BlockMinecartDetector(28, 195)).c(0.7F).a(i).b("detectorRail").r(); + public static final Block PISTON_STICKY = (new BlockPiston(29, 106, true)).b("pistonStickyBase").r(); public static final Block WEB = (new BlockWeb(30, 11)).h(1).c(4.0F).b("web"); public static final BlockLongGrass LONG_GRASS = (BlockLongGrass) (new BlockLongGrass(31, 39)).c(0.0F).a(g).b("tallgrass"); public static final BlockDeadBush DEAD_BUSH = (BlockDeadBush) (new BlockDeadBush(32, 55)).c(0.0F).a(g).b("deadbush"); - public static final Block PISTON = (new BlockPiston(33, 107, false)).b("pistonBase").p(); - public static final BlockPistonExtension PISTON_EXTENSION = (BlockPistonExtension) (new BlockPistonExtension(34, 107)).p(); - public static final Block WOOL = (new BlockCloth()).c(0.8F).a(k).b("cloth").p(); + public static final Block PISTON = (new BlockPiston(33, 107, false)).b("pistonBase").r(); + public static final BlockPistonExtension PISTON_EXTENSION = (BlockPistonExtension) (new BlockPistonExtension(34, 107)).r(); + public static final Block WOOL = (new BlockCloth()).c(0.8F).a(k).b("cloth").r(); 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).b("flower"); public static final BlockFlower RED_ROSE = (BlockFlower) (new BlockFlower(38, 12)).c(0.0F).a(g).b("rose"); @@ -71,118 +74,127 @@ public class Block { public static final Block BOOKSHELF = (new BlockBookshelf(47, 35)).c(1.5F).a(e).b("bookshelf"); public static final Block MOSSY_COBBLESTONE = (new Block(48, 36, Material.STONE)).c(2.0F).b(10.0F).a(h).b("stoneMoss").a(CreativeModeTab.b); public static final Block OBSIDIAN = (new BlockObsidian(49, 37)).c(50.0F).b(2000.0F).a(h).b("obsidian"); - public static final Block TORCH = (new BlockTorch(50, 80)).c(0.0F).a(0.9375F).a(e).b("torch").p(); - public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).b("fire").v(); - public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(i).b("mobSpawner").v(); - public static final Block WOOD_STAIRS = (new BlockStairs(53, WOOD, 0)).b("stairsWood").p(); - public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(e).b("chest").p(); - public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 164)).c(0.0F).a(d).b("redstoneDust").v().p(); + public static final Block TORCH = (new BlockTorch(50, 80)).c(0.0F).a(0.9375F).a(e).b("torch").r(); + public static final BlockFire FIRE = (BlockFire) (new BlockFire(51, 31)).c(0.0F).a(1.0F).a(e).b("fire").D(); + public static final Block MOB_SPAWNER = (new BlockMobSpawner(52, 65)).c(5.0F).a(i).b("mobSpawner").D(); + public static final Block WOOD_STAIRS = (new BlockStairs(53, WOOD, 0)).b("stairsWood").r(); + public static final Block CHEST = (new BlockChest(54)).c(2.5F).a(e).b("chest").r(); + public static final Block REDSTONE_WIRE = (new BlockRedstoneWire(55, 164)).c(0.0F).a(d).b("redstoneDust").D().r(); public static final Block DIAMOND_ORE = (new BlockOre(56, 50)).c(3.0F).b(5.0F).a(h).b("oreDiamond"); public static final Block DIAMOND_BLOCK = (new BlockOreBlock(57, 24)).c(5.0F).b(10.0F).a(i).b("blockDiamond"); public static final Block WORKBENCH = (new BlockWorkbench(58)).c(2.5F).a(e).b("workbench"); - public static final Block CROPS = (new BlockCrops(59, 88)).c(0.0F).a(g).b("crops").v().p(); - public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).b("farmland").p(); - public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(h).b("furnace").p().a(CreativeModeTab.c); - public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(h).a(0.875F).b("furnace").p(); - public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(e).b("sign").v().p(); - public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.WOOD)).c(3.0F).a(e).b("doorWood").v().p(); - public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(e).b("ladder").p(); - public static final Block RAILS = (new BlockMinecartTrack(66, 128, false)).c(0.7F).a(i).b("rail").p(); - public static final Block COBBLESTONE_STAIRS = (new BlockStairs(67, COBBLESTONE, 0)).b("stairsStone").p(); - public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(e).b("sign").v().p(); - public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(e).b("lever").p(); - public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.textureId, EnumMobType.MOBS, Material.STONE)).c(0.5F).a(h).b("pressurePlate").p(); - public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.ORE)).c(5.0F).a(i).b("doorIron").v().p(); - public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.textureId, EnumMobType.EVERYTHING, Material.WOOD)).c(0.5F).a(e).b("pressurePlate").p(); - public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(h).b("oreRedstone").p().a(CreativeModeTab.b); - public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(h).b("oreRedstone").p(); - public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(e).b("notGate").p(); - public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(e).b("notGate").p().a(CreativeModeTab.d); - public static final Block STONE_BUTTON = (new BlockButton(77, STONE.textureId)).c(0.5F).a(h).b("button").p(); - public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(k).b("snow").p().h(0); + public static final Block CROPS = (new BlockCrops(59, 88)).b("crops"); + public static final Block SOIL = (new BlockSoil(60)).c(0.6F).a(f).b("farmland").r(); + public static final Block FURNACE = (new BlockFurnace(61, false)).c(3.5F).a(h).b("furnace").r().a(CreativeModeTab.c); + public static final Block BURNING_FURNACE = (new BlockFurnace(62, true)).c(3.5F).a(h).a(0.875F).b("furnace").r(); + public static final Block SIGN_POST = (new BlockSign(63, TileEntitySign.class, true)).c(1.0F).a(e).b("sign").D().r(); + public static final Block WOODEN_DOOR = (new BlockDoor(64, Material.WOOD)).c(3.0F).a(e).b("doorWood").D().r(); + public static final Block LADDER = (new BlockLadder(65, 83)).c(0.4F).a(n).b("ladder").r(); + public static final Block RAILS = (new BlockMinecartTrack(66, 128, false)).c(0.7F).a(i).b("rail").r(); + public static final Block COBBLESTONE_STAIRS = (new BlockStairs(67, COBBLESTONE, 0)).b("stairsStone").r(); + public static final Block WALL_SIGN = (new BlockSign(68, TileEntitySign.class, false)).c(1.0F).a(e).b("sign").D().r(); + public static final Block LEVER = (new BlockLever(69, 96)).c(0.5F).a(e).b("lever").r(); + public static final Block STONE_PLATE = (new BlockPressurePlate(70, STONE.textureId, EnumMobType.MOBS, Material.STONE)).c(0.5F).a(h).b("pressurePlate").r(); + public static final Block IRON_DOOR_BLOCK = (new BlockDoor(71, Material.ORE)).c(5.0F).a(i).b("doorIron").D().r(); + public static final Block WOOD_PLATE = (new BlockPressurePlate(72, WOOD.textureId, EnumMobType.EVERYTHING, Material.WOOD)).c(0.5F).a(e).b("pressurePlate").r(); + public static final Block REDSTONE_ORE = (new BlockRedstoneOre(73, 51, false)).c(3.0F).b(5.0F).a(h).b("oreRedstone").r().a(CreativeModeTab.b); + public static final Block GLOWING_REDSTONE_ORE = (new BlockRedstoneOre(74, 51, true)).a(0.625F).c(3.0F).b(5.0F).a(h).b("oreRedstone").r(); + public static final Block REDSTONE_TORCH_OFF = (new BlockRedstoneTorch(75, 115, false)).c(0.0F).a(e).b("notGate").r(); + public static final Block REDSTONE_TORCH_ON = (new BlockRedstoneTorch(76, 99, true)).c(0.0F).a(0.5F).a(e).b("notGate").r().a(CreativeModeTab.d); + public static final Block STONE_BUTTON = (new BlockButton(77, STONE.textureId, false)).c(0.5F).a(h).b("button").r(); + public static final Block SNOW = (new BlockSnow(78, 66)).c(0.1F).a(m).b("snow").r().h(0); public static final Block ICE = (new BlockIce(79, 67)).c(0.5F).h(3).a(j).b("ice"); - public static final Block SNOW_BLOCK = (new BlockSnowBlock(80, 66)).c(0.2F).a(k).b("snow"); + public static final Block SNOW_BLOCK = (new BlockSnowBlock(80, 66)).c(0.2F).a(m).b("snow"); public static final Block CACTUS = (new BlockCactus(81, 70)).c(0.4F).a(k).b("cactus"); public static final Block CLAY = (new BlockClay(82, 72)).c(0.6F).a(f).b("clay"); - public static final Block SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(g).b("reeds").v(); - public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(h).b("jukebox").p(); + public static final Block SUGAR_CANE_BLOCK = (new BlockReed(83, 73)).c(0.0F).a(g).b("reeds").D(); + public static final Block JUKEBOX = (new BlockJukeBox(84, 74)).c(2.0F).b(10.0F).a(h).b("jukebox").r(); public static final Block FENCE = (new BlockFence(85, 4)).c(2.0F).b(5.0F).a(e).b("fence"); - public static final Block PUMPKIN = (new BlockPumpkin(86, 102, false)).c(1.0F).a(e).b("pumpkin").p(); + public static final Block PUMPKIN = (new BlockPumpkin(86, 102, false)).c(1.0F).a(e).b("pumpkin").r(); public static final Block NETHERRACK = (new BlockBloodStone(87, 103)).c(0.4F).a(h).b("hellrock"); public static final Block SOUL_SAND = (new BlockSlowSand(88, 104)).c(0.5F).a(l).b("hellsand"); public static final Block GLOWSTONE = (new BlockLightStone(89, 105, Material.SHATTERABLE)).c(0.3F).a(j).a(1.0F).b("lightgem"); public static final BlockPortal PORTAL = (BlockPortal) (new BlockPortal(90, 14)).c(-1.0F).a(j).a(0.75F).b("portal"); - public static final Block JACK_O_LANTERN = (new BlockPumpkin(91, 102, true)).c(1.0F).a(e).a(1.0F).b("litpumpkin").p(); - public static final Block CAKE_BLOCK = (new BlockCake(92, 121)).c(0.5F).a(k).b("cake").v().p(); - public static final Block DIODE_OFF = (new BlockDiode(93, false)).c(0.0F).a(e).b("diode").v().p(); - public static final Block DIODE_ON = (new BlockDiode(94, true)).c(0.0F).a(0.625F).a(e).b("diode").v().p(); - public static final Block LOCKED_CHEST = (new BlockLockedChest(95)).c(0.0F).a(1.0F).a(e).b("lockedchest").b(true).p(); - public static final Block TRAP_DOOR = (new BlockTrapdoor(96, Material.WOOD)).c(3.0F).a(e).b("trapdoor").v().p(); + public static final Block JACK_O_LANTERN = (new BlockPumpkin(91, 102, true)).c(1.0F).a(e).a(1.0F).b("litpumpkin").r(); + public static final Block CAKE_BLOCK = (new BlockCake(92, 121)).c(0.5F).a(k).b("cake").D().r(); + public static final Block DIODE_OFF = (new BlockDiode(93, false)).c(0.0F).a(e).b("diode").D().r(); + public static final Block DIODE_ON = (new BlockDiode(94, true)).c(0.0F).a(0.625F).a(e).b("diode").D().r(); + public static final Block LOCKED_CHEST = (new BlockLockedChest(95)).c(0.0F).a(1.0F).a(e).b("lockedchest").b(true).r(); + public static final Block TRAP_DOOR = (new BlockTrapdoor(96, Material.WOOD)).c(3.0F).a(e).b("trapdoor").D().r(); public static final Block MONSTER_EGGS = (new BlockMonsterEggs(97)).c(0.75F).b("monsterStoneEgg"); public static final Block SMOOTH_BRICK = (new BlockSmoothBrick(98)).c(1.5F).b(10.0F).a(h).b("stonebricksmooth"); - public static final Block BIG_MUSHROOM_1 = (new BlockHugeMushroom(99, Material.WOOD, 142, 0)).c(0.2F).a(e).b("mushroom").p(); - public static final Block BIG_MUSHROOM_2 = (new BlockHugeMushroom(100, Material.WOOD, 142, 1)).c(0.2F).a(e).b("mushroom").p(); + public static final Block BIG_MUSHROOM_1 = (new BlockHugeMushroom(99, Material.WOOD, 142, 0)).c(0.2F).a(e).b("mushroom").r(); + public static final Block BIG_MUSHROOM_2 = (new BlockHugeMushroom(100, Material.WOOD, 142, 1)).c(0.2F).a(e).b("mushroom").r(); public static final Block IRON_FENCE = (new BlockThinFence(101, 85, 85, Material.ORE, true)).c(5.0F).b(10.0F).a(i).b("fenceIron"); public static final Block THIN_GLASS = (new BlockThinFence(102, 49, 148, Material.SHATTERABLE, false)).c(0.3F).a(j).b("thinGlass"); public static final Block MELON = (new BlockMelon(103)).c(1.0F).a(e).b("melon"); - public static final Block PUMPKIN_STEM = (new BlockStem(104, PUMPKIN)).c(0.0F).a(e).b("pumpkinStem").p(); - public static final Block MELON_STEM = (new BlockStem(105, MELON)).c(0.0F).a(e).b("pumpkinStem").p(); - public static final Block VINE = (new BlockVine(106)).c(0.2F).a(g).b("vine").p(); - public static final Block FENCE_GATE = (new BlockFenceGate(107, 4)).c(2.0F).b(5.0F).a(e).b("fenceGate").p(); - public static final Block BRICK_STAIRS = (new BlockStairs(108, BRICK, 0)).b("stairsBrick").p(); - public static final Block STONE_STAIRS = (new BlockStairs(109, SMOOTH_BRICK, 0)).b("stairsStoneBrickSmooth").p(); + public static final Block PUMPKIN_STEM = (new BlockStem(104, PUMPKIN)).c(0.0F).a(e).b("pumpkinStem").r(); + public static final Block MELON_STEM = (new BlockStem(105, MELON)).c(0.0F).a(e).b("pumpkinStem").r(); + public static final Block VINE = (new BlockVine(106)).c(0.2F).a(g).b("vine").r(); + public static final Block FENCE_GATE = (new BlockFenceGate(107, 4)).c(2.0F).b(5.0F).a(e).b("fenceGate").r(); + public static final Block BRICK_STAIRS = (new BlockStairs(108, BRICK, 0)).b("stairsBrick").r(); + public static final Block STONE_STAIRS = (new BlockStairs(109, SMOOTH_BRICK, 0)).b("stairsStoneBrickSmooth").r(); public static final BlockMycel MYCEL = (BlockMycel) (new BlockMycel(110)).c(0.6F).a(g).b("mycel"); public static final Block WATER_LILY = (new BlockWaterLily(111, 76)).c(0.0F).a(g).b("waterlily"); public static final Block NETHER_BRICK = (new Block(112, 224, Material.STONE)).c(2.0F).b(10.0F).a(h).b("netherBrick").a(CreativeModeTab.b); public static final Block NETHER_FENCE = (new BlockFence(113, 224, Material.STONE)).c(2.0F).b(10.0F).a(h).b("netherFence"); - public static final Block NETHER_BRICK_STAIRS = (new BlockStairs(114, NETHER_BRICK, 0)).b("stairsNetherBrick").p(); - public static final Block NETHER_WART = (new BlockNetherWart(115)).b("netherStalk").p(); + public static final Block NETHER_BRICK_STAIRS = (new BlockStairs(114, NETHER_BRICK, 0)).b("stairsNetherBrick").r(); + public static final Block NETHER_WART = (new BlockNetherWart(115)).b("netherStalk").r(); public static final Block ENCHANTMENT_TABLE = (new BlockEnchantmentTable(116)).c(5.0F).b(2000.0F).b("enchantmentTable"); - public static final Block BREWING_STAND = (new BlockBrewingStand(117)).c(0.5F).a(0.125F).b("brewingStand").p(); - public static final Block CAULDRON = (new BlockCauldron(118)).c(2.0F).b("cauldron").p(); + public static final Block BREWING_STAND = (new BlockBrewingStand(117)).c(0.5F).a(0.125F).b("brewingStand").r(); + public static final Block CAULDRON = (new BlockCauldron(118)).c(2.0F).b("cauldron").r(); 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).b("endPortalFrame").p().b(6000000.0F).a(CreativeModeTab.c); + public static final Block ENDER_PORTAL_FRAME = (new BlockEnderPortalFrame(120)).a(j).a(0.125F).c(-1.0F).b("endPortalFrame").r().b(6000000.0F).a(CreativeModeTab.c); public static final Block WHITESTONE = (new Block(121, 175, Material.STONE)).c(3.0F).b(15.0F).a(h).b("whiteStone").a(CreativeModeTab.b); public static final Block DRAGON_EGG = (new BlockDragonEgg(122, 167)).c(3.0F).b(15.0F).a(h).a(0.125F).b("dragonEgg"); public static final Block REDSTONE_LAMP_OFF = (new BlockRedstoneLamp(123, false)).c(0.3F).a(j).b("redstoneLight").a(CreativeModeTab.d); public static final Block REDSTONE_LAMP_ON = (new BlockRedstoneLamp(124, true)).c(0.3F).a(j).b("redstoneLight"); public static final BlockStepAbstract WOOD_DOUBLE_STEP = (BlockStepAbstract) (new BlockWoodStep(125, true)).c(2.0F).b(5.0F).a(e).b("woodSlab"); public static final BlockStepAbstract WOOD_STEP = (BlockStepAbstract) (new BlockWoodStep(126, false)).c(2.0F).b(5.0F).a(e).b("woodSlab"); - public static final Block COCOA = (new BlockCocoa(127)).c(0.2F).b(5.0F).a(e).b("cocoa").p(); - public static final Block SANDSTONE_STAIRS = (new BlockStairs(128, SANDSTONE, 0)).b("stairsSandStone").p(); + public static final Block COCOA = (new BlockCocoa(127)).c(0.2F).b(5.0F).a(e).b("cocoa").r(); + public static final Block SANDSTONE_STAIRS = (new BlockStairs(128, SANDSTONE, 0)).b("stairsSandStone").r(); public static final Block EMERALD_ORE = (new BlockOre(129, 171)).c(3.0F).b(5.0F).a(h).b("oreEmerald"); - public static final Block ENDER_CHEST = (new BlockEnderChest(130)).c(22.5F).b(1000.0F).a(h).b("enderChest").p().a(0.5F); - public static final BlockTripwireHook TRIPWIRE_SOURCE = (BlockTripwireHook) (new BlockTripwireHook(131)).b("tripWireSource").p(); - public static final Block TRIPWIRE = (new BlockTripwire(132)).b("tripWire").p(); + public static final Block ENDER_CHEST = (new BlockEnderChest(130)).c(22.5F).b(1000.0F).a(h).b("enderChest").r().a(0.5F); + public static final BlockTripwireHook TRIPWIRE_SOURCE = (BlockTripwireHook) (new BlockTripwireHook(131)).b("tripWireSource").r(); + public static final Block TRIPWIRE = (new BlockTripwire(132)).b("tripWire").r(); public static final Block EMERALD_BLOCK = (new BlockOreBlock(133, 25)).c(5.0F).b(10.0F).a(i).b("blockEmerald"); - public static final Block SPRUCE_WOOD_STAIRS = (new BlockStairs(134, WOOD, 1)).b("stairsWoodSpruce").p(); - public static final Block BIRCH_WOOD_STAIRS = (new BlockStairs(135, WOOD, 2)).b("stairsWoodBirch").p(); - public static final Block JUNGLE_WOOD_STAIRS = (new BlockStairs(136, WOOD, 3)).b("stairsWoodJungle").p(); + public static final Block SPRUCE_WOOD_STAIRS = (new BlockStairs(134, WOOD, 1)).b("stairsWoodSpruce").r(); + public static final Block BIRCH_WOOD_STAIRS = (new BlockStairs(135, WOOD, 2)).b("stairsWoodBirch").r(); + public static final Block JUNGLE_WOOD_STAIRS = (new BlockStairs(136, WOOD, 3)).b("stairsWoodJungle").r(); + public static final Block COMMAND = (new BlockCommand(137)).b("commandBlock"); + public static final Block BEACON = (new BlockBeacon(138)).b("beacon").a(1.0F); + public static final Block COBBLE_WALL = (new BlockCobbleWall(139, COBBLESTONE)).b("cobbleWall"); + public static final Block FLOWER_POT = (new BlockFlowerPot(140)).c(0.0F).a(d).b("flowerPot"); + public static final Block CARROTS = (new BlockCarrots(141)).b("carrots"); + public static final Block POTATOES = (new BlockPotatoes(142)).b("potatoes"); + public static final Block WOOD_BUTTON = (new BlockButton(143, WOOD.textureId, true)).c(0.5F).a(e).b("button").r(); + public static final Block SKULL = (new BlockSkull(144)).c(1.0F).a(h).b("skull").r(); + public static final Block ANVIL = (new BlockAnvil(145)).c(5.0F).a(o).b(2000.0F).b("anvil").r(); public int textureId; public final int id; protected float strength; protected float durability; - protected boolean cd; - protected boolean ce; - protected boolean cf; + protected boolean cp; + protected boolean cq; + protected boolean cr; protected boolean isTileEntity; - public double minX; - public double minY; - public double minZ; - public double maxX; - public double maxY; - public double maxZ; + protected double minX; + protected double minY; + protected double minZ; + protected double maxX; + protected double maxY; + protected double maxZ; public StepSound stepSound; - public float co; + public float cA; public final Material material; public float frictionFactor; private String name; protected Block(int i, Material material) { - this.cd = true; - this.ce = true; + this.cp = true; + this.cq = true; this.stepSound = d; - this.co = 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); @@ -191,18 +203,18 @@ public class Block { byId[i] = this; this.id = i; this.a(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - n[i] = this.d(); - lightBlock[i] = this.d() ? 255 : 0; - p[i] = !material.blocksLight(); + q[i] = this.c(); + lightBlock[i] = this.c() ? 255 : 0; + s[i] = !material.blocksLight(); } } - protected Block p() { - r[this.id] = true; + protected Block r() { + u[this.id] = true; return this; } - protected void r_() {} + protected void t_() {} protected Block(int i, int j, Material material) { this(i, material); @@ -232,10 +244,10 @@ public class Block { public static boolean i(int i) { Block block = byId[i]; - return block == null ? false : block.material.k() && block.c(); + return block == null ? false : block.material.k() && block.b(); } - public boolean c() { + public boolean b() { return true; } @@ -243,7 +255,7 @@ public class Block { return !this.material.isSolid(); } - public int b() { + public int d() { return 0; } @@ -256,7 +268,7 @@ public class Block { return this; } - protected Block q() { + protected Block s() { this.c(-1.0F); return this; } @@ -266,19 +278,19 @@ public class Block { } protected Block b(boolean flag) { - this.cf = flag; + this.cr = flag; return this; } - public boolean r() { - return this.cf; + public boolean isTicking() { + return this.cr; } - public boolean s() { + public boolean u() { return this.isTileEntity; } - public void a(float f, float f1, float f2, float f3, float f4, float f5) { + protected final void a(float f, float f1, float f2, float f3, float f4, float f5) { this.minX = (double) f; this.minY = (double) f1; this.minZ = (double) f2; @@ -287,7 +299,7 @@ public class Block { this.maxZ = (double) f5; } - public boolean d(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean a_(IBlockAccess iblockaccess, int i, int j, int k, int l) { return iblockaccess.getMaterial(i, j, k).isBuildable(); } @@ -311,15 +323,15 @@ public class Block { return AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) j + this.maxY, (double) k + this.maxZ); } - public boolean d() { + public boolean c() { return true; } public boolean a(int i, boolean flag) { - return this.l(); + return this.m(); } - public boolean l() { + public boolean m() { return true; } @@ -329,7 +341,7 @@ public class Block { public void doPhysics(World world, int i, int j, int k, int l) {} - public int p_() { + public int r_() { return 10; } @@ -373,7 +385,7 @@ public class Block { } protected void a(World world, int i, int j, int k, ItemStack itemstack) { - if (!world.isStatic) { + if (!world.isStatic && world.getGameRules().getBoolean("doTileDrops")) { float f = 0.7F; double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; @@ -385,7 +397,7 @@ public class Block { } } - protected void g(World world, int i, int j, int k, int l) { + protected void f(World world, int i, int j, int k, int l) { if (!world.isStatic) { while (l > 0) { int i1 = EntityExperienceOrb.getOrbValue(l); @@ -396,7 +408,7 @@ public class Block { } } - protected int getDropData(int i) { + public int getDropData(int i) { return 0; } @@ -499,15 +511,15 @@ public class Block { } private boolean a(Vec3D vec3d) { - return vec3d == null ? false : vec3d.b >= this.minY && vec3d.b <= this.maxY && vec3d.c >= this.minZ && vec3d.c <= this.maxZ; + return vec3d == null ? false : vec3d.d >= this.minY && vec3d.d <= this.maxY && vec3d.e >= this.minZ && vec3d.e <= this.maxZ; } private boolean b(Vec3D vec3d) { - return vec3d == null ? false : vec3d.a >= this.minX && vec3d.a <= this.maxX && vec3d.c >= this.minZ && vec3d.c <= this.maxZ; + return vec3d == null ? false : vec3d.c >= this.minX && vec3d.c <= this.maxX && vec3d.e >= this.minZ && vec3d.e <= this.maxZ; } private boolean c(Vec3D vec3d) { - return vec3d == null ? false : vec3d.a >= this.minX && vec3d.a <= this.maxX && vec3d.b >= this.minY && vec3d.b <= this.maxY; + return vec3d == null ? false : vec3d.c >= this.minX && vec3d.c <= this.maxX && vec3d.d >= this.minY && vec3d.d <= this.maxY; } public void wasExploded(World world, int i, int j, int k) {} @@ -536,7 +548,31 @@ public class Block { public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) {} - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public final double v() { + return this.minX; + } + + public final double w() { + return this.maxX; + } + + public final double x() { + return this.minY; + } + + public final double y() { + return this.maxY; + } + + public final double z() { + return this.minZ; + } + + public final double A() { + return this.maxZ; + } + + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return false; } @@ -546,7 +582,7 @@ public class Block { public void a(World world, int i, int j, int k, Entity entity) {} - public boolean c(World world, int i, int j, int k, int l) { + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { return false; } @@ -555,27 +591,27 @@ public class Block { public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { entityhuman.a(StatisticList.C[this.id], 1); entityhuman.j(0.025F); - if (this.q_() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) { - ItemStack itemstack = this.c_(l); + if (this.s_() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman)) { + ItemStack itemstack = this.f_(l); if (itemstack != null) { this.a(world, i, j, k, itemstack); } } else { - int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman.inventory); + int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman); this.c(world, i, j, k, l, i1); } } - protected boolean q_() { - return this.c() && !this.isTileEntity; + protected boolean s_() { + return this.b() && !this.isTileEntity; } - protected ItemStack c_(int i) { + protected ItemStack f_(int i) { int j = 0; - if (this.id >= 0 && this.id < Item.byId.length && Item.byId[this.id].k()) { + if (this.id >= 0 && this.id < Item.byId.length && Item.byId[this.id].l()) { j = i; } @@ -607,21 +643,25 @@ public class Block { public void b(World world, int i, int j, int k, int l, int i1) {} - public boolean u() { - return this.ce; + public boolean C() { + return this.cq; } - protected Block v() { - this.ce = false; + protected Block D() { + this.cq = false; return this; } - public int e() { + public int q_() { return this.material.getPushReaction(); } public void a(World world, int i, int j, int k, Entity entity, float f) {} + public int getDropData(World world, int i, int j, int k) { + return this.getDropData(world.getData(i, j, k)); + } + public Block a(CreativeModeTab creativemodetab) { this.creativeTab = creativemodetab; return this; @@ -629,30 +669,34 @@ public class Block { public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) {} - public void h(World world, int i, int j, int k, int l) {} + public void g(World world, int i, int j, int k, int l) {} public void f(World world, int i, int j, int k) {} - public void a(World world, long i, long j) {} + public boolean l() { + return true; + } static { Item.byId[WOOL.id] = (new ItemCloth(WOOL.id - 256)).b("cloth"); - Item.byId[LOG.id] = (new ItemLog(LOG.id - 256, LOG)).b("log"); - Item.byId[WOOD.id] = (new ItemWood(WOOD.id - 256, WOOD)).b("wood"); - Item.byId[MONSTER_EGGS.id] = (new ItemMonsterEggs(MONSTER_EGGS.id - 256)).b("monsterStoneEgg"); - Item.byId[SMOOTH_BRICK.id] = (new ItemSmoothStone(SMOOTH_BRICK.id - 256, SMOOTH_BRICK)).b("stonebricksmooth"); - Item.byId[SANDSTONE.id] = (new ItemSandStone(SANDSTONE.id - 256, SANDSTONE)).b("sandStone"); + Item.byId[LOG.id] = (new ItemMultiTexture(LOG.id - 256, LOG, BlockLog.a)).b("log"); + Item.byId[WOOD.id] = (new ItemMultiTexture(WOOD.id - 256, WOOD, BlockWood.a)).b("wood"); + Item.byId[MONSTER_EGGS.id] = (new ItemMultiTexture(MONSTER_EGGS.id - 256, MONSTER_EGGS, BlockMonsterEggs.a)).b("monsterStoneEgg"); + Item.byId[SMOOTH_BRICK.id] = (new ItemMultiTexture(SMOOTH_BRICK.id - 256, SMOOTH_BRICK, BlockSmoothBrick.a)).b("stonebricksmooth"); + Item.byId[SANDSTONE.id] = (new ItemMultiTexture(SANDSTONE.id - 256, SANDSTONE, BlockSandStone.a)).b("sandStone"); Item.byId[STEP.id] = (new ItemStep(STEP.id - 256, STEP, DOUBLE_STEP, false)).b("stoneSlab"); Item.byId[DOUBLE_STEP.id] = (new ItemStep(DOUBLE_STEP.id - 256, STEP, DOUBLE_STEP, true)).b("stoneSlab"); Item.byId[WOOD_STEP.id] = (new ItemStep(WOOD_STEP.id - 256, WOOD_STEP, WOOD_DOUBLE_STEP, false)).b("woodSlab"); Item.byId[WOOD_DOUBLE_STEP.id] = (new ItemStep(WOOD_DOUBLE_STEP.id - 256, WOOD_STEP, WOOD_DOUBLE_STEP, true)).b("woodSlab"); - Item.byId[SAPLING.id] = (new ItemSapling(SAPLING.id - 256)).b("sapling"); + Item.byId[SAPLING.id] = (new ItemMultiTexture(SAPLING.id - 256, SAPLING, BlockSapling.a)).b("sapling"); Item.byId[LEAVES.id] = (new ItemLeaves(LEAVES.id - 256)).b("leaves"); Item.byId[VINE.id] = new ItemWithAuxData(VINE.id - 256, false); Item.byId[LONG_GRASS.id] = (new ItemWithAuxData(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[COBBLE_WALL.id] = (new ItemMultiTexture(COBBLE_WALL.id - 256, COBBLE_WALL, BlockCobbleWall.a)).b("cobbleWall"); + Item.byId[ANVIL.id] = (new ItemAnvil(ANVIL)).b("anvil"); // CraftBukkit start Item.byId[BIG_MUSHROOM_1.id] = new ItemWithAuxData(BIG_MUSHROOM_1.id - 256, true); Item.byId[BIG_MUSHROOM_2.id] = new ItemWithAuxData(BIG_MUSHROOM_2.id - 256, true); @@ -663,12 +707,12 @@ public class Block { if (byId[i] != null) { if (Item.byId[i] == null) { Item.byId[i] = new ItemBlock(i - 256); - byId[i].r_(); + byId[i].t_(); } boolean flag = false; - if (i > 0 && byId[i].b() == 10) { + if (i > 0 && byId[i].d() == 10) { flag = true; } @@ -680,7 +724,7 @@ public class Block { flag = true; } - if (p[i]) { + if (s[i]) { flag = true; } @@ -688,19 +732,15 @@ public class Block { flag = true; } - s[i] = flag; + v[i] = flag; } } - p[0] = true; + s[0] = true; StatisticList.b(); } - // CraftBukkit start - getDropData(int) is protected - public static int getDropData(Block block, int data) { - return block.getDropData(data); - } - + // CraftBukkit start public int getExpDrop(World world, int data, int enchantmentLevel) { return 0; } diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java index 43d95f72..59fa1b51 100644 --- a/src/main/java/net/minecraft/server/BlockButton.java +++ b/src/main/java/net/minecraft/server/BlockButton.java @@ -1,30 +1,34 @@ package net.minecraft.server; +import java.util.List; import java.util.Random; import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit public class BlockButton extends Block { - protected BlockButton(int i, int j) { + private final boolean a; + + protected BlockButton(int i, int j, boolean flag) { super(i, j, Material.ORIENTABLE); this.b(true); this.a(CreativeModeTab.d); + this.a = flag; } public AxisAlignedBB e(World world, int i, int j, int k) { return null; } - public int p_() { - return 20; + public int r_() { + return this.a ? 30 : 20; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } @@ -100,8 +104,13 @@ public class BlockButton extends Block { public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { int l = iblockaccess.getData(i, j, k); - int i1 = l & 7; - boolean flag = (l & 8) > 0; + + this.e(l); + } + + private void e(int i) { + int j = i & 7; + boolean flag = (i & 8) > 0; float f = 0.375F; float f1 = 0.625F; float f2 = 0.1875F; @@ -111,20 +120,18 @@ public class BlockButton extends Block { f3 = 0.0625F; } - if (i1 == 1) { + if (j == 1) { this.a(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); - } else if (i1 == 2) { + } else if (j == 2) { this.a(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); - } else if (i1 == 3) { + } else if (j == 3) { this.a(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); - } else if (i1 == 4) { + } else if (j == 4) { this.a(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); } } - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.interact(world, i, j, k, entityhuman, 0, 0.0F, 0.0F, 0.0F); - } + public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {} public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { int i1 = world.getData(i, j, k); @@ -148,53 +155,30 @@ public class BlockButton extends Block { // CraftBukkit end world.setData(i, j, k, j1 + k1); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); - world.applyPhysics(i, j, k, this.id); - if (j1 == 1) { - world.applyPhysics(i - 1, j, k, this.id); - } else if (j1 == 2) { - world.applyPhysics(i + 1, j, k, this.id); - } else if (j1 == 3) { - world.applyPhysics(i, j, k - 1, this.id); - } else if (j1 == 4) { - world.applyPhysics(i, j, k + 1, this.id); - } else { - world.applyPhysics(i, j - 1, k, this.id); - } - - world.a(i, j, k, this.id, this.p_()); + this.d(world, i, j, k, j1); + world.a(i, j, k, this.id, this.r_()); return true; } } public void remove(World world, int i, int j, int k, int l, int i1) { if ((i1 & 8) > 0) { - world.applyPhysics(i, j, k, this.id); int j1 = i1 & 7; - if (j1 == 1) { - world.applyPhysics(i - 1, j, k, this.id); - } else if (j1 == 2) { - world.applyPhysics(i + 1, j, k, this.id); - } else if (j1 == 3) { - world.applyPhysics(i, j, k - 1, this.id); - } else if (j1 == 4) { - world.applyPhysics(i, j, k + 1, this.id); - } else { - world.applyPhysics(i, j - 1, k, this.id); - } + this.d(world, i, j, k, j1); } super.remove(world, i, j, k, l, i1); } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return (iblockaccess.getData(i, j, k) & 8) > 0; } - public boolean c(World world, int i, int j, int k, int l) { - int i1 = world.getData(i, j, k); + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + int i1 = iblockaccess.getData(i, j, k); if ((i1 & 8) == 0) { return false; @@ -225,24 +209,16 @@ public class BlockButton extends Block { } // CraftBukkit end - world.setData(i, j, k, l & 7); - world.applyPhysics(i, j, k, this.id); - int i1 = l & 7; - - if (i1 == 1) { - world.applyPhysics(i - 1, j, k, this.id); - } else if (i1 == 2) { - world.applyPhysics(i + 1, j, k, this.id); - } else if (i1 == 3) { - world.applyPhysics(i, j, k - 1, this.id); - } else if (i1 == 4) { - world.applyPhysics(i, j, k + 1, this.id); + if (this.a) { + this.o(world, i, j, k); } else { - world.applyPhysics(i, j - 1, k, this.id); - } + world.setData(i, j, k, l & 7); + int i1 = l & 7; - world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); - world.d(i, j, k, i, j, k); + this.d(world, i, j, k, i1); + world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + world.e(i, j, k, i, j, k); + } } } } @@ -254,4 +230,57 @@ public class BlockButton extends Block { this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); } + + public void a(World world, int i, int j, int k, Entity entity) { + if (!world.isStatic) { + if (this.a) { + if ((world.getData(i, j, k) & 8) == 0) { + this.o(world, i, j, k); + } + } + } + } + + private void o(World world, int i, int j, int k) { + int l = world.getData(i, j, k); + int i1 = l & 7; + boolean flag = (l & 8) != 0; + + this.e(l); + List list = world.a(EntityArrow.class, AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) j + this.maxY, (double) k + this.maxZ)); + boolean flag1 = !list.isEmpty(); + + if (flag1 && !flag) { + world.setData(i, j, k, i1 | 8); + this.d(world, i, j, k, i1); + world.e(i, j, k, i, j, k); + world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); + } + + if (!flag1 && flag) { + world.setData(i, j, k, i1); + this.d(world, i, j, k, i1); + world.e(i, j, k, i, j, k); + world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); + } + + if (flag1) { + world.a(i, j, k, this.id, this.r_()); + } + } + + private void d(World world, int i, int j, int k, int l) { + world.applyPhysics(i, j, k, this.id); + if (l == 1) { + world.applyPhysics(i - 1, j, k, this.id); + } else if (l == 2) { + world.applyPhysics(i + 1, j, k, this.id); + } else if (l == 3) { + world.applyPhysics(i, j, k - 1, this.id); + } else if (l == 4) { + world.applyPhysics(i, j, k + 1, this.id); + } else { + world.applyPhysics(i, j - 1, k, this.id); + } + } } diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java index 87f2b369..dd680201 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java @@ -43,15 +43,15 @@ public class BlockCactus extends Block { return i == 1 ? this.textureId - 1 : (i == 0 ? this.textureId + 1 : this.textureId); } - public boolean c() { + public boolean b() { return false; } - public boolean d() { + public boolean c() { return false; } - public int b() { + public int d() { return 13; } @@ -83,7 +83,7 @@ public class BlockCactus extends Block { } public void a(World world, int i, int j, int k, Entity entity) { - // CraftBukkit start - ENTITY_DAMAGEBY_BLOCK event + // CraftBukkit start - EntityDamageByBlock event if (entity instanceof EntityLiving) { org.bukkit.block.Block damager = world.getWorld().getBlockAt(i, j, k); org.bukkit.entity.Entity damagee = (entity == null) ? null : entity.getBukkitEntity(); diff --git a/src/main/java/net/minecraft/server/BlockCommand.java b/src/main/java/net/minecraft/server/BlockCommand.java new file mode 100644 index 00000000..c43ba944 --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockCommand.java @@ -0,0 +1,53 @@ +package net.minecraft.server; + +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + +public class BlockCommand extends BlockContainer { + + public BlockCommand(int i) { + super(i, 184, Material.ORE); + } + + public TileEntity a(World world) { + return new TileEntityCommand(); + } + + public void doPhysics(World world, int i, int j, int k, int l) { + if (!world.isStatic) { + boolean flag = world.isBlockIndirectlyPowered(i, j, k); + int i1 = world.getData(i, j, k); + boolean flag1 = (i1 & 1) != 0; + + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); + int old = flag1 ? 1 : 0; + int current = flag ? 1 : 0; + + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); + world.getServer().getPluginManager().callEvent(eventRedstone); + // CraftBukkit end + + if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit + TileEntity tileentity = world.getTileEntity(i, j, k); + + if (tileentity != null && tileentity instanceof TileEntityCommand) { + ((TileEntityCommand) tileentity).a(world); + } + + world.setRawData(i, j, k, i1 | 1); + } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit + world.setRawData(i, j, k, i1 & -2); + } + } + } + + public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { + TileEntityCommand tileentitycommand = (TileEntityCommand) world.getTileEntity(i, j, k); + + if (tileentitycommand != null) { + entityhuman.a((TileEntity) tileentitycommand); + } + + return true; + } +} diff --git a/src/main/java/net/minecraft/server/BlockCrops.java b/src/main/java/net/minecraft/server/BlockCrops.java index 58d31cc9..ca45aded 100644 --- a/src/main/java/net/minecraft/server/BlockCrops.java +++ b/src/main/java/net/minecraft/server/BlockCrops.java @@ -12,6 +12,10 @@ public class BlockCrops extends BlockFlower { this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); this.a((CreativeModeTab) null); + this.c(0.0F); + this.a(g); + this.D(); + this.r(); } protected boolean d_(int i) { @@ -86,32 +90,35 @@ public class BlockCrops extends BlockFlower { return this.textureId + j; } - public int b() { + public int d() { return 6; } + protected int h() { + return Item.SEEDS.id; + } + + protected int j() { + return Item.WHEAT.id; + } + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) { super.dropNaturally(world, i, j, k, l, f, 0); if (!world.isStatic) { - int j1 = 3 + i1; - - for (int k1 = 0; k1 < j1; ++k1) { - if (world.random.nextInt(15) <= l) { - float f1 = 0.7F; - float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - EntityItem entityitem = new EntityItem(world, (double) ((float) i + f2), (double) ((float) j + f3), (double) ((float) k + f4), new ItemStack(Item.SEEDS)); - - entityitem.pickupDelay = 10; - world.addEntity(entityitem); + if (l >= 7) { + int j1 = 3 + i1; + + for (int k1 = 0; k1 < j1; ++k1) { + if (world.random.nextInt(15) <= l) { + this.a(world, i, j, k, new ItemStack(this.h(), 1, 0)); + } } } } } public int getDropType(int i, Random random, int j) { - return i == 7 ? Item.WHEAT.id : -1; + return i == 7 ? this.j() : this.h(); } public int a(Random random) { diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index bb1928a2..68483094 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -2,14 +2,11 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.block.BlockDispenseEvent; -// CraftBukkit end - public class BlockDispenser extends BlockContainer { - private Random a = new Random(); + public static final IRegistry a = new RegistryDefault(new DispenseBehaviorItem()); + private Random b = new Random(); + public static boolean eventFired = false; // CraftBukkit protected BlockDispenser(int i) { super(i, Material.STONE); @@ -17,7 +14,7 @@ public class BlockDispenser extends BlockContainer { this.a(CreativeModeTab.d); } - public int p_() { + public int r_() { return 4; } @@ -38,19 +35,19 @@ public class BlockDispenser extends BlockContainer { int k1 = world.getTypeId(i + 1, j, k); byte b0 = 3; - if (Block.n[l] && !Block.n[i1]) { + if (Block.q[l] && !Block.q[i1]) { b0 = 3; } - if (Block.n[i1] && !Block.n[l]) { + if (Block.q[i1] && !Block.q[l]) { b0 = 2; } - if (Block.n[j1] && !Block.n[k1]) { + if (Block.q[j1] && !Block.q[k1]) { b0 = 5; } - if (Block.n[k1] && !Block.n[j1]) { + if (Block.q[k1] && !Block.q[j1]) { b0 = 4; } @@ -76,104 +73,26 @@ public class BlockDispenser extends BlockContainer { } } - // CraftBukkit - private to public - public void dispense(World world, int i, int j, int k, Random random) { - int l = world.getData(i, j, k); - byte b0 = 0; - byte b1 = 0; - - if (l == 3) { - b1 = 1; - } else if (l == 2) { - b1 = -1; - } else if (l == 5) { - b0 = 1; - } else { - b0 = -1; - } - - TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k); + // CraftBukkit - private -> public + public void dispense(World world, int i, int j, int k) { + SourceBlock sourceblock = new SourceBlock(world, i, j, k); + TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity(); if (tileentitydispenser != null) { - int i1 = tileentitydispenser.i(); + int l = tileentitydispenser.i(); - if (i1 < 0) { + if (l < 0) { world.triggerEffect(1001, i, j, k, 0); } else { - double d0 = (double) i + (double) b0 * 0.6D + 0.5D; - double d1 = (double) j + 0.5D; - double d2 = (double) k + (double) b1 * 0.6D + 0.5D; - ItemStack itemstack = tileentitydispenser.getItem(i1); - - // CraftBukkit start - // Clone item stack, then set the count to 1 - itemstack = itemstack.cloneItemStack(); - itemstack.count = 1; - - double d3 = random.nextDouble() * 0.1D + 0.2D; - double motX = (double) b0 * d3; - double motY = 0.20000000298023224D; - double motZ = (double) b1 * d3; - motX += random.nextGaussian() * 0.007499999832361937D * 6.0D; - motY += random.nextGaussian() * 0.007499999832361937D * 6.0D; - motZ += random.nextGaussian() * 0.007499999832361937D * 6.0D; - - org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); - - BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(motX, motY, motZ)); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return; - } + ItemStack itemstack = tileentitydispenser.getItem(l); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) a.a(itemstack.getItem()); - itemstack = CraftItemStack.createNMSItemStack(event.getItem()); - // CraftBukkit end + if (idispensebehavior != IDispenseBehavior.a) { + ItemStack itemstack1 = idispensebehavior.a(sourceblock, itemstack); + eventFired = false; // CraftBukkit - reset event status - int j1 = a(tileentitydispenser, world, itemstack, random, i, j, k, b0, b1, d0, d1, d2); - - if (j1 == 1) { - // CraftBukkit start - if (event.getItem().equals(bukkitItem)) { - // Actually remove the item - tileentitydispenser.splitStack(i1, 1); - } - // CraftBukkit end - } else if (j1 == 0) { - // CraftBukkit start - motX = event.getVelocity().getX(); - motY = event.getVelocity().getY(); - motZ = event.getVelocity().getZ(); - - if (event.getItem().equals(bukkitItem)) { - // Actually remove the item - tileentitydispenser.splitStack(i1, 1); - } - - EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); - entityitem.motX = event.getVelocity().getX(); - entityitem.motY = event.getVelocity().getY(); - entityitem.motZ = event.getVelocity().getZ(); - world.addEntity(entityitem); - // CraftBukkit end - - world.triggerEffect(1000, i, j, k, 0); - // CraftBukkit start - new condition - } else if (j1 == 2) { - ItemStack old = tileentitydispenser.getItem(i1); - if (old.id == Item.BUCKET.id && old.count > 1) { - old.count--; - if (tileentitydispenser.a(itemstack) < 0) { - a(world, itemstack, random, 6, l, i1, d0, d1, d2); - } - } else { - tileentitydispenser.setItem(i1, itemstack); - } - // CraftBukkit end + tileentitydispenser.setItem(l, itemstack1.count == 0 ? null : itemstack1); } - - world.triggerEffect(2000, i, j, k, b0 + 1 + (b1 + 1) * 3); } } } @@ -183,14 +102,14 @@ public class BlockDispenser extends BlockContainer { boolean flag = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k); if (flag) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } } } public void b(World world, int i, int j, int k, Random random) { if (!world.isStatic && (world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k))) { - this.dispense(world, i, j, k, random); + this.dispense(world, i, j, k); } } @@ -226,12 +145,12 @@ public class BlockDispenser extends BlockContainer { ItemStack itemstack = tileentitydispenser.getItem(j1); if (itemstack != null) { - float f = this.a.nextFloat() * 0.8F + 0.1F; - float f1 = this.a.nextFloat() * 0.8F + 0.1F; - float f2 = this.a.nextFloat() * 0.8F + 0.1F; + float f = this.b.nextFloat() * 0.8F + 0.1F; + float f1 = this.b.nextFloat() * 0.8F + 0.1F; + float f2 = this.b.nextFloat() * 0.8F + 0.1F; while (itemstack.count > 0) { - int k1 = this.a.nextInt(21) + 10; + int k1 = this.b.nextInt(21) + 10; if (k1 > itemstack.count) { k1 = itemstack.count; @@ -246,9 +165,9 @@ public class BlockDispenser extends BlockContainer { float f3 = 0.05F; - entityitem.motX = (double) ((float) this.a.nextGaussian() * f3); - entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F); - entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3); + entityitem.motX = (double) ((float) this.b.nextGaussian() * f3); + entityitem.motY = (double) ((float) this.b.nextGaussian() * f3 + 0.2F); + entityitem.motZ = (double) ((float) this.b.nextGaussian() * f3); world.addEntity(entityitem); } } @@ -258,148 +177,12 @@ public class BlockDispenser extends BlockContainer { super.remove(world, i, j, k, l, i1); } - private static void a(World world, ItemStack itemstack, Random random, int i, int j, int k, double d0, double d1, double d2) { - EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); - double d3 = random.nextDouble() * 0.1D + 0.2D; - - entityitem.motX = (double) j * d3; - entityitem.motY = 0.20000000298023224D; - entityitem.motZ = (double) k * d3; - entityitem.motX += random.nextGaussian() * 0.007499999832361937D * (double) i; - entityitem.motY += random.nextGaussian() * 0.007499999832361937D * (double) i; - entityitem.motZ += random.nextGaussian() * 0.007499999832361937D * (double) i; - world.addEntity(entityitem); - } - - private static int a(TileEntityDispenser tileentitydispenser, World world, ItemStack itemstack, Random random, int i, int j, int k, int l, int i1, double d0, double d1, double d2) { - float f = 1.1F; - byte b0 = 6; - - if (itemstack.id == Item.ARROW.id) { - EntityArrow entityarrow = new EntityArrow(world, d0, d1, d2); - - entityarrow.shoot((double) l, 0.10000000149011612D, (double) i1, f, (float) b0); - entityarrow.fromPlayer = 1; - world.addEntity(entityarrow); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.EGG.id) { - EntityEgg entityegg = new EntityEgg(world, d0, d1, d2); - - entityegg.c((double) l, 0.10000000149011612D, (double) i1, f, (float) b0); - world.addEntity(entityegg); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.SNOW_BALL.id) { - EntitySnowball entitysnowball = new EntitySnowball(world, d0, d1, d2); - - entitysnowball.c((double) l, 0.10000000149011612D, (double) i1, f, (float) b0); - world.addEntity(entitysnowball); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.POTION.id && ItemPotion.g(itemstack.getData())) { - EntityPotion entitypotion = new EntityPotion(world, d0, d1, d2, itemstack.getData()); - - entitypotion.c((double) l, 0.10000000149011612D, (double) i1, f * 1.25F, (float) b0 * 0.5F); - world.addEntity(entitypotion); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.EXP_BOTTLE.id) { - EntityThrownExpBottle entitythrownexpbottle = new EntityThrownExpBottle(world, d0, d1, d2); - - entitythrownexpbottle.c((double) l, 0.10000000149011612D, (double) i1, f * 1.25F, (float) b0 * 0.5F); - world.addEntity(entitythrownexpbottle); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.MONSTER_EGG.id) { - ItemMonsterEgg.a(world, itemstack.getData(), d0 + (double) l * 0.3D, d1 - 0.3D, d2 + (double) i1 * 0.3D); - world.triggerEffect(1002, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.FIREBALL.id) { - EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0 + (double) l * 0.3D, d1, d2 + (double) i1 * 0.3D, (double) l + random.nextGaussian() * 0.05D, random.nextGaussian() * 0.05D, (double) i1 + random.nextGaussian() * 0.05D); - - world.addEntity(entitysmallfireball); - world.triggerEffect(1009, i, j, k, 0); - return 1; - } else if (itemstack.id != Item.LAVA_BUCKET.id && itemstack.id != Item.WATER_BUCKET.id) { - if (itemstack.id == Item.BUCKET.id) { - int j1 = i + l; - int k1 = k + i1; - Material material = world.getMaterial(j1, j, k1); - int l1 = world.getData(j1, j, k1); - - if (material == Material.WATER && l1 == 0) { - world.setTypeId(j1, j, k1, 0); - if (--itemstack.count == 0) { - itemstack.id = Item.WATER_BUCKET.id; - itemstack.count = 1; - } else if (tileentitydispenser.a(new ItemStack(Item.WATER_BUCKET)) < 0) { - a(world, new ItemStack(Item.WATER_BUCKET), random, 6, l, i1, d0, d1, d2); - } + public static IPosition a(ISourceBlock isourceblock) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + double d0 = isourceblock.getX() + 0.6D * (double) enumfacing.c(); + double d1 = isourceblock.getY(); + double d2 = isourceblock.getZ() + 0.6D * (double) enumfacing.e(); - return 2; - } else if (material == Material.LAVA && l1 == 0) { - world.setTypeId(j1, j, k1, 0); - if (--itemstack.count == 0) { - itemstack.id = Item.LAVA_BUCKET.id; - itemstack.count = 1; - } else if (tileentitydispenser.a(new ItemStack(Item.LAVA_BUCKET)) < 0) { - a(world, new ItemStack(Item.LAVA_BUCKET), random, 6, l, i1, d0, d1, d2); - } - - return 2; - } else { - return 0; - } - } else if (itemstack.getItem() instanceof ItemMinecart) { - d0 = (double) i + (l < 0 ? (double) l * 0.8D : (double) ((float) l * 1.8F)) + (double) ((float) Math.abs(i1) * 0.5F); - d2 = (double) k + (i1 < 0 ? (double) i1 * 0.8D : (double) ((float) i1 * 1.8F)) + (double) ((float) Math.abs(l) * 0.5F); - if (BlockMinecartTrack.d_(world, i + l, j, k + i1)) { - d1 = (double) ((float) j + 0.5F); - } else { - if (!world.isEmpty(i + l, j, k + i1) || !BlockMinecartTrack.d_(world, i + l, j - 1, k + i1)) { - return 0; - } - - d1 = (double) ((float) j - 0.5F); - } - - EntityMinecart entityminecart = new EntityMinecart(world, d0, d1, d2, ((ItemMinecart) itemstack.getItem()).a); - - world.addEntity(entityminecart); - world.triggerEffect(1000, i, j, k, 0); - return 1; - } else if (itemstack.id == Item.BOAT.id) { - d0 = (double) i + (l < 0 ? (double) l * 0.8D : (double) ((float) l * 1.8F)) + (double) ((float) Math.abs(i1) * 0.5F); - d2 = (double) k + (i1 < 0 ? (double) i1 * 0.8D : (double) ((float) i1 * 1.8F)) + (double) ((float) Math.abs(l) * 0.5F); - if (world.getMaterial(i + l, j, k + i1) == Material.WATER) { - d1 = (double) ((float) j + 1.0F); - } else { - if (!world.isEmpty(i + l, j, k + i1) || world.getMaterial(i + l, j - 1, k + i1) != Material.WATER) { - return 0; - } - - d1 = (double) j; - } - - EntityBoat entityboat = new EntityBoat(world, d0, d1, d2); - - world.addEntity(entityboat); - world.triggerEffect(1000, i, j, k, 0); - return 1; - } else { - return 0; - } - } else { - ItemBucket itembucket = (ItemBucket) itemstack.getItem(); - - if (itembucket.a(world, (double) i, (double) j, (double) k, i + l, j, k + i1)) { - itemstack.id = Item.BUCKET.id; - itemstack.count = 1; - return 2; - } else { - return 0; - } - } + return new Position(d0, d1, d2); } } diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 933e2755..d87582d6 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -19,7 +19,7 @@ public class BlockDoor extends Block { this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); } - public boolean d() { + public boolean c() { return false; } @@ -29,11 +29,11 @@ public class BlockDoor extends Block { return (l & 4) != 0; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 7; } @@ -105,9 +105,7 @@ public class BlockDoor extends Block { } } - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.interact(world, i, j, k, entityhuman, 0, 0.0F, 0.0F, 0.0F); - } + public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {} public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { if (this.material == Material.ORE) { @@ -119,10 +117,10 @@ public class BlockDoor extends Block { j1 ^= 4; if ((i1 & 8) == 0) { world.setData(i, j, k, j1); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); } else { world.setData(i, j - 1, k, j1); - world.d(i, j - 1, k, i, j, k); + world.e(i, j - 1, k, i, j, k); } world.a(entityhuman, 1003, i, j, k, 0); @@ -140,10 +138,10 @@ public class BlockDoor extends Block { i1 ^= 4; if ((l & 8) == 0) { world.setData(i, j, k, i1); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); } else { world.setData(i, j - 1, k, i1); - world.d(i, j - 1, k, i, j, k); + world.e(i, j - 1, k, i, j, k); } world.a((EntityHuman) null, 1003, i, j, k, 0); @@ -215,7 +213,7 @@ public class BlockDoor extends Block { return j >= 255 ? false : world.t(i, j - 1, k) && super.canPlace(world, i, j, k) && super.canPlace(world, i, j + 1, k); } - public int e() { + public int q_() { return 1; } diff --git a/src/main/java/net/minecraft/server/BlockDragonEgg.java b/src/main/java/net/minecraft/server/BlockDragonEgg.java index 9c0ec846..2b4257c9 100644 --- a/src/main/java/net/minecraft/server/BlockDragonEgg.java +++ b/src/main/java/net/minecraft/server/BlockDragonEgg.java @@ -11,11 +11,11 @@ public class BlockDragonEgg extends Block { } public void onPlace(World world, int i, int j, int k) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } public void doPhysics(World world, int i, int j, int k, int l) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } public void b(World world, int i, int j, int k, Random random) { @@ -26,7 +26,7 @@ public class BlockDragonEgg extends Block { if (BlockSand.canFall(world, i, j - 1, k) && j >= 0) { byte b0 = 32; - if (!BlockSand.instaFall && world.c(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { + if (!BlockSand.instaFall && world.d(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { // CraftBukkit - added data EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k)); @@ -91,7 +91,7 @@ public class BlockDragonEgg extends Block { double d2 = (double) j1 + (double) (j - j1) * d0 + world.random.nextDouble() * 1.0D - 0.5D; double d3 = (double) k1 + (double) (k - k1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D; - world.a("portal", d1, d2, d3, (double) f, (double) f1, (double) f2); + world.addParticle("portal", d1, d2, d3, (double) f, (double) f1, (double) f2); } return; @@ -101,19 +101,19 @@ public class BlockDragonEgg extends Block { } } - public int p_() { + public int r_() { return 3; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 27; } } diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java index 5d1ebab6..41954799 100644 --- a/src/main/java/net/minecraft/server/BlockFire.java +++ b/src/main/java/net/minecraft/server/BlockFire.java @@ -18,7 +18,7 @@ public class BlockFire extends Block { this.b(true); } - public void r_() { + public void t_() { this.a(Block.WOOD.id, 5, 20); this.a(Block.WOOD_DOUBLE_STEP.id, 5, 20); this.a(Block.WOOD_STEP.id, 5, 20); @@ -45,15 +45,15 @@ public class BlockFire extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 3; } @@ -61,109 +61,111 @@ public class BlockFire extends Block { return 0; } - public int p_() { + public int r_() { return 30; } public void b(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 WorldProviderTheEnd && world.getTypeId(i, j - 1, k) == Block.BEDROCK.id) { - flag = true; - } + if (world.getGameRules().getBoolean("doFireTick")) { + boolean flag = world.getTypeId(i, j - 1, k) == Block.NETHERRACK.id; - if (!this.canPlace(world, i, j, k)) { - fireExtinguished(world, i, j, k); // CraftBukkit - invalid place location - } - - if (!flag && world.J() && (world.B(i, j, k) || world.B(i - 1, j, k) || world.B(i + 1, j, k) || world.B(i, j, k - 1) || world.B(i, j, k + 1))) { - fireExtinguished(world, i, j, k); // CraftBukkit - extinguished by rain - } else { - int l = world.getData(i, j, k); + if (world.worldProvider instanceof WorldProviderTheEnd && world.getTypeId(i, j - 1, k) == Block.BEDROCK.id) { + flag = true; + } - if (l < 15) { - world.setRawData(i, j, k, l + random.nextInt(3) / 2); + if (!this.canPlace(world, i, j, k)) { + fireExtinguished(world, i, j, k); // CraftBukkit - invalid place location } - world.a(i, j, k, this.id, this.p_() + random.nextInt(10)); - if (!flag && !this.l(world, i, j, k)) { - if (!world.t(i, j - 1, k) || l > 3) { - fireExtinguished(world, i, j, k); // CraftBukkit - burn out - } - } else if (!flag && !this.d((IBlockAccess) world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { - fireExtinguished(world, i, j, k); // CraftBukkit - burn out + if (!flag && world.M() && (world.B(i, j, k) || world.B(i - 1, j, k) || world.B(i + 1, j, k) || world.B(i, j, k - 1) || world.B(i, j, k + 1))) { + fireExtinguished(world, i, j, k); // CraftBukkit - extinguished by rain } else { - boolean flag1 = world.C(i, j, k); - byte b0 = 0; + int l = world.getData(i, j, k); - if (flag1) { - b0 = -50; + if (l < 15) { + world.setRawData(i, j, k, l + random.nextInt(3) / 2); } - this.a(world, i + 1, j, k, 300 + b0, random, l); - this.a(world, i - 1, j, k, 300 + b0, random, l); - this.a(world, i, j - 1, k, 250 + b0, random, l); - this.a(world, i, j + 1, k, 250 + b0, random, l); - this.a(world, i, j, k - 1, 300 + b0, random, l); - this.a(world, i, j, k + 1, 300 + b0, random, l); - - // CraftBukkit start - call to stop spread of fire - org.bukkit.Server server = world.getServer(); - org.bukkit.World bworld = world.getWorld(); - - BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD; - org.bukkit.block.Block fromBlock = bworld.getBlockAt(i, j, k); - // CraftBukkit end - - for (int i1 = i - 1; i1 <= i + 1; ++i1) { - for (int j1 = k - 1; j1 <= k + 1; ++j1) { - for (int k1 = j - 1; k1 <= j + 4; ++k1) { - if (i1 != i || k1 != j || j1 != k) { - int l1 = 100; - - if (k1 > j + 1) { - l1 += (k1 - (j + 1)) * 100; - } - - int i2 = this.n(world, i1, k1, j1); + world.a(i, j, k, this.id, this.r_() + random.nextInt(10)); + if (!flag && !this.l(world, i, j, k)) { + if (!world.t(i, j - 1, k) || l > 3) { + world.setTypeId(i, j, k, 0); + } + } else if (!flag && !this.d((IBlockAccess) world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) { + fireExtinguished(world, i, j, k); // CraftBukkit - burn out + } else { + boolean flag1 = world.C(i, j, k); + byte b0 = 0; - if (i2 > 0) { - int j2 = (i2 + 40) / (l + 30); + if (flag1) { + b0 = -50; + } - if (flag1) { - j2 /= 2; + this.a(world, i + 1, j, k, 300 + b0, random, l); + this.a(world, i - 1, j, k, 300 + b0, random, l); + this.a(world, i, j - 1, k, 250 + b0, random, l); + this.a(world, i, j + 1, k, 250 + b0, random, l); + this.a(world, i, j, k - 1, 300 + b0, random, l); + this.a(world, i, j, k + 1, 300 + b0, random, l); + + // CraftBukkit start - call to stop spread of fire + org.bukkit.Server server = world.getServer(); + org.bukkit.World bworld = world.getWorld(); + + BlockIgniteEvent.IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.SPREAD; + org.bukkit.block.Block fromBlock = bworld.getBlockAt(i, j, k); + // CraftBukkit end + + for (int i1 = i - 1; i1 <= i + 1; ++i1) { + for (int j1 = k - 1; j1 <= k + 1; ++j1) { + for (int k1 = j - 1; k1 <= j + 4; ++k1) { + if (i1 != i || k1 != j || j1 != k) { + int l1 = 100; + + if (k1 > j + 1) { + l1 += (k1 - (j + 1)) * 100; } - if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.J() || !world.B(i1, k1, j1)) && !world.B(i1 - 1, k1, k) && !world.B(i1 + 1, k1, j1) && !world.B(i1, k1, j1 - 1) && !world.B(i1, k1, j1 + 1)) { - int k2 = l + random.nextInt(5) / 4; + int i2 = this.n(world, i1, k1, j1); - if (k2 > 15) { - k2 = 15; - } + if (i2 > 0) { + int j2 = (i2 + 40 + world.difficulty * 7) / (l + 30); - // CraftBukkit start - call to stop spread of fire - org.bukkit.block.Block block = bworld.getBlockAt(i1, k1, j1); + if (flag1) { + j2 /= 2; + } - if (block.getTypeId() != Block.FIRE.id) { - BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null); - server.getPluginManager().callEvent(event); + if (j2 > 0 && random.nextInt(l1) <= j2 && (!world.M() || !world.B(i1, k1, j1)) && !world.B(i1 - 1, k1, k) && !world.B(i1 + 1, k1, j1) && !world.B(i1, k1, j1 - 1) && !world.B(i1, k1, j1 + 1)) { + int k2 = l + random.nextInt(5) / 4; - if (event.isCancelled()) { - continue; + if (k2 > 15) { + k2 = 15; } - org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState(); - blockState.setTypeId(this.id); - blockState.setData(new org.bukkit.material.MaterialData(this.id, (byte) k2)); + // CraftBukkit start - call to stop spread of fire + org.bukkit.block.Block block = bworld.getBlockAt(i1, k1, j1); + + if (block.getTypeId() != Block.FIRE.id) { + BlockIgniteEvent event = new BlockIgniteEvent(block, igniteCause, null); + server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + continue; + } - BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), fromBlock, blockState); - server.getPluginManager().callEvent(spreadEvent); + org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState(); + blockState.setTypeId(this.id); + blockState.setData(new org.bukkit.material.MaterialData(this.id, (byte) k2)); - if (!spreadEvent.isCancelled()) { - blockState.update(true); + BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), fromBlock, blockState); + server.getPluginManager().callEvent(spreadEvent); + + if (!spreadEvent.isCancelled()) { + blockState.update(true); + } } + // CraftBukkit end } - // CraftBukkit end } } } @@ -174,6 +176,10 @@ public class BlockFire extends Block { } } + public boolean l() { + return false; + } + private void a(World world, int i, int j, int k, int l, Random random, int i1) { int j1 = this.b[world.getTypeId(i, j, k)]; @@ -219,18 +225,18 @@ public class BlockFire extends Block { if (!world.isEmpty(i, j, k)) { return 0; } else { - int l = this.e(world, i + 1, j, k, b0); + int l = this.d(world, i + 1, j, k, b0); - l = this.e(world, i - 1, j, k, l); - l = this.e(world, i, j - 1, k, l); - l = this.e(world, i, j + 1, k, l); - l = this.e(world, i, j, k - 1, l); - l = this.e(world, i, j, k + 1, l); + l = this.d(world, i - 1, j, k, l); + l = this.d(world, i, j - 1, k, l); + l = this.d(world, i, j + 1, k, l); + l = this.d(world, i, j, k - 1, l); + l = this.d(world, i, j, k + 1, l); return l; } } - public boolean l() { + public boolean m() { return false; } @@ -238,7 +244,7 @@ public class BlockFire extends Block { return this.a[iblockaccess.getTypeId(i, j, k)] > 0; } - public int e(World world, int i, int j, int k, int l) { + public int d(World world, int i, int j, int k, int l) { int i1 = this.a[world.getTypeId(i, j, k)]; return i1 > l ? i1 : l; @@ -259,7 +265,7 @@ public class BlockFire extends Block { if (!world.t(i, j - 1, k) && !this.l(world, i, j, k)) { fireExtinguished(world, i, j, k); // CraftBukkit - fuel block broke } else { - world.a(i, j, k, this.id, this.p_() + world.random.nextInt(10)); + world.a(i, j, k, this.id, this.r_() + world.random.nextInt(10)); } } } diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index e5f44a90..7a2cea99 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -21,7 +21,7 @@ public class BlockFlowing extends BlockFluids { int l = world.getData(i, j, k); world.setRawTypeIdAndData(i, j, k, this.id + 1, l); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); } public boolean c(IBlockAccess iblockaccess, int i, int j, int k) { @@ -38,7 +38,7 @@ public class BlockFlowing extends BlockFluids { int l = this.f_(world, i, j, k); byte b0 = 1; - if (this.material == Material.LAVA && !world.worldProvider.d) { + if (this.material == Material.LAVA && !world.worldProvider.e) { b0 = 2; } @@ -49,11 +49,11 @@ public class BlockFlowing extends BlockFluids { byte b1 = -100; this.a = 0; - int j1 = this.e(world, i - 1, j, k, b1); + int j1 = this.d(world, i - 1, j, k, b1); - j1 = this.e(world, i + 1, j, k, j1); - j1 = this.e(world, i, j, k - 1, j1); - j1 = this.e(world, i, j, k + 1, j1); + j1 = this.d(world, i + 1, j, k, j1); + j1 = this.d(world, i, j, k - 1, j1); + j1 = this.d(world, i, j, k + 1, j1); i1 = j1 + b0; if (i1 >= 8 || j1 < 0) { i1 = -1; @@ -92,7 +92,7 @@ public class BlockFlowing extends BlockFluids { world.setTypeId(i, j, k, 0); } else { world.setData(i, j, k, i1); - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); world.applyPhysics(i, j, k, this.id); } } @@ -279,7 +279,7 @@ public class BlockFlowing extends BlockFluids { } } - protected int e(World world, int i, int j, int k, int l) { + protected int d(World world, int i, int j, int k, int l) { int i1 = this.f_(world, i, j, k); if (i1 < 0) { @@ -306,7 +306,11 @@ public class BlockFlowing extends BlockFluids { public void onPlace(World world, int i, int j, int k) { super.onPlace(world, i, j, k); if (world.getTypeId(i, j, k) == this.id) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } } + + public boolean l() { + return false; + } } diff --git a/src/main/java/net/minecraft/server/BlockGravel.java b/src/main/java/net/minecraft/server/BlockGravel.java deleted file mode 100644 index 7da42695..00000000 --- a/src/main/java/net/minecraft/server/BlockGravel.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.minecraft.server; - -import java.util.Random; - -public class BlockGravel extends BlockSand { - - public BlockGravel(int i, int j) { - super(i, j); - } - - public int getDropType(int i, Random random, int j) { - j = Math.min(j, 3); // CraftBukkit - added to fix crash when j > 3 - return random.nextInt(10 - j * 3) == 0 ? Item.FLINT.id : this.id; - } -} diff --git a/src/main/java/net/minecraft/server/BlockIce.java b/src/main/java/net/minecraft/server/BlockIce.java index b6791ce9..b6097938 100644 --- a/src/main/java/net/minecraft/server/BlockIce.java +++ b/src/main/java/net/minecraft/server/BlockIce.java @@ -14,19 +14,19 @@ public class BlockIce extends BlockHalfTransparant { public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { entityhuman.a(StatisticList.C[this.id], 1); entityhuman.j(0.025F); - if (this.q_() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) { - ItemStack itemstack = this.c_(l); + if (this.s_() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman)) { + ItemStack itemstack = this.f_(l); if (itemstack != null) { this.a(world, i, j, k, itemstack); } } else { - if (world.worldProvider.d) { + if (world.worldProvider.e) { world.setTypeId(i, j, k, 0); return; } - int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman.inventory); + int i1 = EnchantmentManager.getBonusBlockLootEnchantmentLevel(entityhuman); this.c(world, i, j, k, l, i1); Material material = world.getMaterial(i, j - 1, k); @@ -49,7 +49,7 @@ public class BlockIce extends BlockHalfTransparant { } // CraftBukkit end - if (world.worldProvider.d) { + if (world.worldProvider.e) { world.setTypeId(i, j, k, 0); return; } @@ -59,7 +59,7 @@ public class BlockIce extends BlockHalfTransparant { } } - public int e() { + public int q_() { return 0; } } diff --git a/src/main/java/net/minecraft/server/BlockLeaves.java b/src/main/java/net/minecraft/server/BlockLeaves.java index 7f7066b5..a2bd362f 100644 --- a/src/main/java/net/minecraft/server/BlockLeaves.java +++ b/src/main/java/net/minecraft/server/BlockLeaves.java @@ -6,13 +6,13 @@ import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit public class BlockLeaves extends BlockTransparant { - private int cr; + private int cD; public static final String[] a = new String[] { "oak", "spruce", "birch", "jungle"}; int[] b; protected BlockLeaves(int i, int j) { super(i, j, Material.LEAVES, false); - this.cr = j; + this.cD = j; this.b(true); this.a(CreativeModeTab.c); } @@ -21,7 +21,7 @@ public class BlockLeaves extends BlockTransparant { byte b0 = 1; int j1 = b0 + 1; - if (world.c(i - j1, j - j1, k - j1, i + j1, j + j1, k + j1)) { + if (world.d(i - j1, j - j1, k - j1, i + j1, j + j1, k + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { @@ -55,7 +55,7 @@ public class BlockLeaves extends BlockTransparant { int l1; - if (world.c(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { + if (world.d(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { int i2; int j2; int k2; @@ -163,7 +163,7 @@ public class BlockLeaves extends BlockTransparant { } public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { - if (!world.isStatic && entityhuman.bC() != null && entityhuman.bC().id == Item.SHEARS.id) { + if (!world.isStatic && entityhuman.bP() != null && entityhuman.bP().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 { @@ -171,11 +171,11 @@ public class BlockLeaves extends BlockTransparant { } } - protected int getDropData(int i) { + public int getDropData(int i) { return i & 3; } - public boolean d() { + public boolean c() { return !this.c; } diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java index df25656d..13a61688 100644 --- a/src/main/java/net/minecraft/server/BlockLever.java +++ b/src/main/java/net/minecraft/server/BlockLever.java @@ -13,15 +13,15 @@ public class BlockLever extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 12; } @@ -173,9 +173,7 @@ public class BlockLever extends Block { } } - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.interact(world, i, j, k, entityhuman, 0, 0.0F, 0.0F, 0.0F); - } + public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {} public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { if (world.isStatic) { @@ -199,7 +197,7 @@ public class BlockLever extends Block { // CraftBukkit end world.setData(i, j, k, j1 + k1); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "random.click", 0.3F, k1 > 0 ? 0.6F : 0.5F); world.applyPhysics(i, j, k, this.id); if (j1 == 1) { @@ -247,12 +245,12 @@ public class BlockLever extends Block { super.remove(world, i, j, k, l, i1); } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return (iblockaccess.getData(i, j, k) & 8) > 0; } - public boolean c(World world, int i, int j, int k, int l) { - int i1 = world.getData(i, j, k); + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + int i1 = iblockaccess.getData(i, j, k); if ((i1 & 8) == 0) { return false; diff --git a/src/main/java/net/minecraft/server/BlockMinecartDetector.java b/src/main/java/net/minecraft/server/BlockMinecartDetector.java index b5689bfa..93d13625 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.b(true); } - public int p_() { + public int r_() { return 20; } @@ -25,7 +25,7 @@ public class BlockMinecartDetector extends BlockMinecartTrack { int l = world.getData(i, j, k); if ((l & 8) == 0) { - this.e(world, i, j, k, l); + this.d(world, i, j, k, l); } } } @@ -35,20 +35,20 @@ public class BlockMinecartDetector extends BlockMinecartTrack { int l = world.getData(i, j, k); if ((l & 8) != 0) { - this.e(world, i, j, k, l); + this.d(world, i, j, k, l); } } } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return (iblockaccess.getData(i, j, k) & 8) != 0; } - public boolean c(World world, int i, int j, int k, int l) { - return (world.getData(i, j, k) & 8) == 0 ? false : l == 1; + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return (iblockaccess.getData(i, j, k) & 8) == 0 ? false : l == 1; } - private void e(World world, int i, int j, int k, int l) { + private void d(World world, int i, int j, int k, int l) { boolean flag = (l & 8) != 0; boolean flag1 = false; float f = 0.125F; @@ -73,18 +73,18 @@ public class BlockMinecartDetector extends BlockMinecartTrack { world.setData(i, j, k, l | 8); world.applyPhysics(i, j, k, this.id); world.applyPhysics(i, j - 1, k, this.id); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); } if (!flag1 && flag) { world.setData(i, j, k, l & 7); world.applyPhysics(i, j, k, this.id); world.applyPhysics(i, j - 1, k, this.id); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); } if (flag1) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } } } diff --git a/src/main/java/net/minecraft/server/BlockMobSpawner.java b/src/main/java/net/minecraft/server/BlockMobSpawner.java index 50e41b62..fdedbad9 100644 --- a/src/main/java/net/minecraft/server/BlockMobSpawner.java +++ b/src/main/java/net/minecraft/server/BlockMobSpawner.java @@ -25,7 +25,7 @@ public class BlockMobSpawner extends BlockContainer { /* CraftBukkit start - delegate to getExpDrop int j1 = 15 + world.random.nextInt(15) + world.random.nextInt(15); - this.g(world, i, j, k, j1); */ + this.f(world, i, j, k, j1);*/ } public int getExpDrop(World world, int data, int enchantmentLevel) { @@ -35,7 +35,7 @@ public class BlockMobSpawner extends BlockContainer { // CraftBukkit end } - public boolean d() { + public boolean c() { return false; } } diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java index 177cfaf3..a9df9501 100644 --- a/src/main/java/net/minecraft/server/BlockMushroom.java +++ b/src/main/java/net/minecraft/server/BlockMushroom.java @@ -82,7 +82,7 @@ public class BlockMushroom extends BlockFlower { } protected boolean d_(int i) { - return Block.n[i]; + return Block.q[i]; } public boolean d(World world, int i, int j, int k) { diff --git a/src/main/java/net/minecraft/server/BlockNetherWart.java b/src/main/java/net/minecraft/server/BlockNetherWart.java index 9c4b7761..514abd29 100644 --- a/src/main/java/net/minecraft/server/BlockNetherWart.java +++ b/src/main/java/net/minecraft/server/BlockNetherWart.java @@ -35,7 +35,7 @@ public class BlockNetherWart extends BlockFlower { return j >= 3 ? this.textureId + 2 : (j > 0 ? this.textureId + 1 : this.textureId); } - public int b() { + public int d() { return 6; } diff --git a/src/main/java/net/minecraft/server/BlockOre.java b/src/main/java/net/minecraft/server/BlockOre.java index f679e3ee..7448d166 100644 --- a/src/main/java/net/minecraft/server/BlockOre.java +++ b/src/main/java/net/minecraft/server/BlockOre.java @@ -38,16 +38,16 @@ public class BlockOre extends Block { int j1 = 0; if (this.id == Block.COAL_ORE.id) { - j1 = MathHelper.a(world.random, 0, 2); + j1 = MathHelper.nextInt(world.random, 0, 2); } else if (this.id == Block.DIAMOND_ORE.id) { - j1 = MathHelper.a(world.random, 3, 7); + j1 = MathHelper.nextInt(world.random, 3, 7); } else if (this.id == Block.EMERALD_ORE.id) { - j1 = MathHelper.a(world.random, 3, 7); + j1 = MathHelper.nextInt(world.random, 3, 7); } else if (this.id == Block.LAPIS_ORE.id) { - j1 = MathHelper.a(world.random, 2, 5); + j1 = MathHelper.nextInt(world.random, 2, 5); } - this.g(world, i, j, k, j1); + this.f(world, i, j, k, j1); } */ } @@ -56,13 +56,13 @@ public class BlockOre extends Block { int j1 = 0; if (this.id == Block.COAL_ORE.id) { - j1 = MathHelper.a(world.random, 0, 2); + j1 = MathHelper.nextInt(world.random, 0, 2); } else if (this.id == Block.DIAMOND_ORE.id) { - j1 = MathHelper.a(world.random, 3, 7); + j1 = MathHelper.nextInt(world.random, 3, 7); } else if (this.id == Block.EMERALD_ORE.id) { - j1 = MathHelper.a(world.random, 3, 7); + j1 = MathHelper.nextInt(world.random, 3, 7); } else if (this.id == Block.LAPIS_ORE.id) { - j1 = MathHelper.a(world.random, 2, 5); + j1 = MathHelper.nextInt(world.random, 2, 5); } return j1; @@ -72,7 +72,7 @@ public class BlockOre extends Block { // CraftBukkit end } - protected int getDropData(int i) { + public int getDropData(int i) { return this.id == Block.LAPIS_ORE.id ? 4 : 0; } } diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java index 2944eca7..ed73f32b 100644 --- a/src/main/java/net/minecraft/server/BlockPiston.java +++ b/src/main/java/net/minecraft/server/BlockPiston.java @@ -26,11 +26,11 @@ public class BlockPiston extends Block { return k > 5 ? this.textureId : (i == k ? (!f(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 == Facing.OPPOSITE_FACING[k] ? 109 : 108)); } - public int b() { + public int d() { return 16; } - public boolean d() { + public boolean c() { return false; } @@ -64,14 +64,13 @@ public class BlockPiston extends Block { int i1 = e(l); if (i1 != 7) { - boolean flag = this.e(world, i, j, k, i1); + boolean flag = this.d(world, i, j, k, i1); if (flag && !f(l)) { // CraftBukkit start - int length = i(world, i, j, k, i1); + int length = h(world, i, j, k, i1); if (length >= 0) { org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - BlockPistonExtendEvent event = new BlockPistonExtendEvent(block, length, CraftBlock.notchToBlockFace(i1)); world.getServer().getPluginManager().callEvent(event); @@ -85,7 +84,6 @@ public class BlockPiston extends Block { } else if (!flag && f(l)) { // CraftBukkit start org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); - BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, CraftBlock.notchToBlockFace(i1)); world.getServer().getPluginManager().callEvent(event); @@ -99,7 +97,7 @@ public class BlockPiston extends Block { } } - private boolean e(World world, int i, int j, int k, int l) { + private boolean d(World world, int i, int j, int k, int l) { return l != 0 && world.isBlockFaceIndirectlyPowered(i, j - 1, k, 0) ? true : (l != 1 && world.isBlockFaceIndirectlyPowered(i, j + 1, k, 1) ? true : (l != 2 && world.isBlockFaceIndirectlyPowered(i, j, k - 1, 2) ? true : (l != 3 && world.isBlockFaceIndirectlyPowered(i, j, k + 1, 3) ? true : (l != 5 && world.isBlockFaceIndirectlyPowered(i + 1, j, k, 5) ? true : (l != 4 && world.isBlockFaceIndirectlyPowered(i - 1, j, k, 4) ? true : (world.isBlockFaceIndirectlyPowered(i, j, k, 0) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 2, k, 1) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 1, k - 1, 2) ? true : (world.isBlockFaceIndirectlyPowered(i, j + 1, k + 1, 3) ? true : (world.isBlockFaceIndirectlyPowered(i - 1, j + 1, k, 4) ? true : world.isBlockFaceIndirectlyPowered(i + 1, j + 1, k, 5))))))))))); } @@ -111,7 +109,7 @@ public class BlockPiston extends Block { } if (l == 0) { - if (this.j(world, i, j, k, i1)) { + if (this.i(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 { @@ -121,7 +119,7 @@ public class BlockPiston extends Block { TileEntity tileentity = world.getTileEntity(i + Facing.b[i1], j + Facing.c[i1], k + Facing.d[i1]); if (tileentity instanceof TileEntityPiston) { - ((TileEntityPiston) tileentity).i(); + ((TileEntityPiston) tileentity).f(); } world.setRawTypeIdAndData(i, j, k, Block.PISTON_MOVING.id, i1); @@ -141,15 +139,15 @@ public class BlockPiston extends Block { TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1; if (tileentitypiston.c() == i1 && tileentitypiston.b()) { - tileentitypiston.i(); + tileentitypiston.f(); i2 = tileentitypiston.a(); - j2 = tileentitypiston.n(); + j2 = tileentitypiston.p(); 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)) { + if (!flag && i2 > 0 && a(i2, world, j1, k1, l1, false) && (Block.byId[i2].q_() == 0 || i2 == Block.PISTON.id || i2 == Block.PISTON_STICKY.id)) { i += Facing.b[i1]; j += Facing.c[i1]; k += Facing.d[i1]; @@ -214,7 +212,7 @@ public class BlockPiston extends Block { return super.e(world, i, j, k); } - public boolean c() { + public boolean b() { return false; } @@ -254,11 +252,11 @@ public class BlockPiston extends Block { return false; } - if (Block.byId[i].e() == 2) { + if (Block.byId[i].q_() == 2) { return false; } - if (!flag && Block.byId[i].e() == 1) { + if (!flag && Block.byId[i].q_() == 1) { return false; } } else if (f(world.getData(j, k, l))) { @@ -269,8 +267,8 @@ public class BlockPiston extends Block { } } - // CraftBukkit - change return from boolean to int - private static int i(World world, int i, int j, int k, int l) { + // CraftBukkit - boolean -> int return + private static int h(World world, int i, int j, int k, int l) { int i1 = i + Facing.b[l]; int j1 = j + Facing.c[l]; int k1 = k + Facing.d[l]; @@ -289,7 +287,7 @@ public class BlockPiston extends Block { return -1; // CraftBukkit } - if (Block.byId[i2].e() != 1) { + if (Block.byId[i2].q_() != 1) { if (l1 == 12) { return -1; // CraftBukkit } @@ -307,7 +305,7 @@ public class BlockPiston extends Block { } } - private boolean j(World world, int i, int j, int k, int l) { + private boolean i(World world, int i, int j, int k, int l) { int i1 = i + Facing.b[l]; int j1 = j + Facing.c[l]; int k1 = k + Facing.d[l]; @@ -327,7 +325,7 @@ public class BlockPiston extends Block { return false; } - if (Block.byId[i2].e() != 1) { + if (Block.byId[i2].q_() != 1) { if (l1 == 12) { return false; } diff --git a/src/main/java/net/minecraft/server/BlockPistonExtension.java b/src/main/java/net/minecraft/server/BlockPistonExtension.java index 19ec8d5d..b14548a2 100644 --- a/src/main/java/net/minecraft/server/BlockPistonExtension.java +++ b/src/main/java/net/minecraft/server/BlockPistonExtension.java @@ -15,7 +15,7 @@ public class BlockPistonExtension extends Block { public void remove(World world, int i, int j, int k, int l, int i1) { super.remove(world, i, j, k, l, i1); - if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fixed a piston AIOOBE issue + if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue int j1 = Facing.OPPOSITE_FACING[f(i1)]; i += Facing.b[j1]; @@ -38,15 +38,15 @@ public class BlockPistonExtension extends Block { return i == k ? (this.a >= 0 ? this.a : ((j & 8) != 0 ? this.textureId - 1 : this.textureId)) : (k < 6 && i == Facing.OPPOSITE_FACING[k] ? 107 : 108); } - public int b() { + public int d() { return 17; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } @@ -142,7 +142,7 @@ public class BlockPistonExtension extends Block { public void doPhysics(World world, int i, int j, int k, int l) { int i1 = f(world.getData(i, j, k)); - if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fixed a piston AIOOBE issue + if ((i1 & 7) >= Facing.OPPOSITE_FACING.length) return; // CraftBukkit - fix a piston AIOOBE issue int j1 = world.getTypeId(i - Facing.b[i1], j - Facing.c[i1], k - Facing.d[i1]); if (j1 != Block.PISTON.id && j1 != Block.PISTON_STICKY.id) { diff --git a/src/main/java/net/minecraft/server/BlockPortal.java b/src/main/java/net/minecraft/server/BlockPortal.java index c18a9750..7e519f66 100644 --- a/src/main/java/net/minecraft/server/BlockPortal.java +++ b/src/main/java/net/minecraft/server/BlockPortal.java @@ -24,7 +24,11 @@ public class BlockPortal extends BlockHalfTransparant { } if (l > 0 && !world.s(i, l + 1, k)) { - ItemMonsterEgg.a(world, 57, (double) i + 0.5D, (double) l + 1.1D, (double) k + 0.5D); + Entity entity = ItemMonsterEgg.a(world, 57, (double) i + 0.5D, (double) l + 1.1D, (double) k + 0.5D); + + if (entity != null) { + entity.an = entity.ab(); + } } } } @@ -48,11 +52,11 @@ public class BlockPortal extends BlockHalfTransparant { } } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java index d05e6987..1d43560c 100644 --- a/src/main/java/net/minecraft/server/BlockPressurePlate.java +++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import java.util.Iterator; import java.util.List; import java.util.Random; @@ -22,7 +23,7 @@ public class BlockPressurePlate extends Block { this.a(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); } - public int p_() { + public int r_() { return 20; } @@ -30,11 +31,11 @@ public class BlockPressurePlate extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } @@ -94,7 +95,16 @@ public class BlockPressurePlate extends Block { } if (!list.isEmpty()) { - flag1 = true; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + + if (!entity.au()) { + flag1 = true; + break; + } + } } // CraftBukkit start - Interact Pressure Plate @@ -134,7 +144,7 @@ public class BlockPressurePlate extends Block { world.setData(i, j, k, 1); world.applyPhysics(i, j, k, this.id); world.applyPhysics(i, j - 1, k, this.id); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.6F); } @@ -142,12 +152,12 @@ public class BlockPressurePlate extends Block { world.setData(i, j, k, 0); world.applyPhysics(i, j, k, this.id); world.applyPhysics(i, j - 1, k, this.id); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); world.makeSound((double) i + 0.5D, (double) j + 0.1D, (double) k + 0.5D, "random.click", 0.3F, 0.5F); } if (flag1) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } } @@ -171,12 +181,12 @@ public class BlockPressurePlate extends Block { } } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return iblockaccess.getData(i, j, k) > 0; } - public boolean c(World world, int i, int j, int k, int l) { - return world.getData(i, j, k) == 0 ? false : l == 1; + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return iblockaccess.getData(i, j, k) == 0 ? false : l == 1; } public boolean isPowerSource() { @@ -191,7 +201,7 @@ public class BlockPressurePlate extends Block { this.a(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); } - public int e() { + public int q_() { return 1; } } diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java index 86ec54eb..0abaa467 100644 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -60,7 +60,7 @@ public class BlockPumpkin extends BlockDirectional { } 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); + world.addParticle("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); } } else if (world.getTypeId(i, j - 1, k) == Block.IRON_BLOCK.id && world.getTypeId(i, j - 2, k) == Block.IRON_BLOCK.id) { boolean flag = world.getTypeId(i - 1, j - 1, k) == Block.IRON_BLOCK.id && world.getTypeId(i + 1, j - 1, k) == Block.IRON_BLOCK.id; @@ -84,11 +84,11 @@ public class BlockPumpkin extends BlockDirectional { EntityIronGolem entityirongolem = new EntityIronGolem(world); - entityirongolem.f(true); + entityirongolem.setPlayerCreated(true); entityirongolem.setPositionRotation((double) i + 0.5D, (double) j - 1.95D, (double) k + 0.5D, 0.0F, 0.0F); if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { for (int i1 = 0; i1 < 120; ++i1) { - world.a("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); + world.addParticle("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); } blockList.updateList(); diff --git a/src/main/java/net/minecraft/server/BlockRedstoneOre.java b/src/main/java/net/minecraft/server/BlockRedstoneOre.java index b3716bbd..cedc3365 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneOre.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneOre.java @@ -17,7 +17,7 @@ public class BlockRedstoneOre extends Block { this.a = flag; } - public int p_() { + public int r_() { return 30; } @@ -81,7 +81,7 @@ public class BlockRedstoneOre extends Block { if (this.getDropType(l, world.random, i1) != this.id) { int j1 = 1 + world.random.nextInt(5); - this.g(world, i, j, k, j1); + this.f(world, i, j, k, j1); } */ } @@ -130,12 +130,12 @@ public class BlockRedstoneOre extends Block { } if (d1 < (double) i || d1 > (double) (i + 1) || d2 < 0.0D || d2 > (double) (j + 1) || d3 < (double) k || d3 > (double) (k + 1)) { - world.a("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); + world.addParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); } } } - protected ItemStack c_(int i) { + protected ItemStack f_(int i) { return new ItemStack(Block.REDSTONE_ORE); } } diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java index 2904401c..e3056277 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java @@ -51,7 +51,7 @@ public class BlockRedstoneTorch extends BlockTorch { this.a((CreativeModeTab) null); } - public int p_() { + public int r_() { return 2; } @@ -81,7 +81,7 @@ public class BlockRedstoneTorch extends BlockTorch { } } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { if (!this.isOn) { return false; } else { @@ -134,7 +134,7 @@ public class BlockRedstoneTorch extends BlockTorch { double d1 = (double) j + random.nextDouble() * 0.6D + 0.2D; double d2 = (double) k + random.nextDouble() * 0.6D + 0.2D; - world.a("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + world.addParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); } } } @@ -155,11 +155,11 @@ 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.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } - public boolean c(World world, int i, int j, int k, int l) { - return l == 0 ? this.a(world, i, j, k, l) : false; + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return l == 0 ? this.b(iblockaccess, i, j, k, l) : false; } public int getDropType(int i, Random random, int j) { @@ -169,15 +169,4 @@ public class BlockRedstoneTorch extends BlockTorch { public boolean isPowerSource() { return true; } - - public void a(World world, long i, long j) { - List list = (List) b.get(world); - RedstoneUpdateInfo redstoneupdateinfo; - - if (list != null) { - for (Iterator iterator = list.iterator(); iterator.hasNext(); redstoneupdateinfo.d += i) { - redstoneupdateinfo = (RedstoneUpdateInfo) iterator.next(); - } - } - } } diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java index 0b656b53..d3a4bc4a 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java @@ -26,15 +26,15 @@ public class BlockRedstoneWire extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 5; } @@ -122,7 +122,7 @@ public class BlockRedstoneWire extends Block { if (k1 != l1) { world.suppressPhysics = true; world.setData(i, j, k, l1); - world.d(i, j, k, i, j, k); + world.e(i, j, k, i, j, k); world.suppressPhysics = false; for (i2 = 0; i2 < 4; ++i2) { @@ -305,11 +305,11 @@ public class BlockRedstoneWire extends Block { return Item.REDSTONE.id; } - public boolean c(World world, int i, int j, int k, int l) { - return !this.a ? false : this.a(world, i, j, k, l); + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + return !this.a ? false : this.b(iblockaccess, i, j, k, l); } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { if (!this.a) { return false; } else if (iblockaccess.getData(i, j, k) == 0) { @@ -317,25 +317,25 @@ public class BlockRedstoneWire extends Block { } else if (l == 1) { return true; } else { - boolean flag = f(iblockaccess, i - 1, j, k, 1) || !iblockaccess.s(i - 1, j, k) && f(iblockaccess, i - 1, j - 1, k, -1); - boolean flag1 = f(iblockaccess, i + 1, j, k, 3) || !iblockaccess.s(i + 1, j, k) && f(iblockaccess, i + 1, j - 1, k, -1); - boolean flag2 = f(iblockaccess, i, j, k - 1, 2) || !iblockaccess.s(i, j, k - 1) && f(iblockaccess, i, j - 1, k - 1, -1); - boolean flag3 = f(iblockaccess, i, j, k + 1, 0) || !iblockaccess.s(i, j, k + 1) && f(iblockaccess, i, j - 1, k + 1, -1); + boolean flag = g(iblockaccess, i - 1, j, k, 1) || !iblockaccess.s(i - 1, j, k) && g(iblockaccess, i - 1, j - 1, k, -1); + boolean flag1 = g(iblockaccess, i + 1, j, k, 3) || !iblockaccess.s(i + 1, j, k) && g(iblockaccess, i + 1, j - 1, k, -1); + boolean flag2 = g(iblockaccess, i, j, k - 1, 2) || !iblockaccess.s(i, j, k - 1) && g(iblockaccess, i, j - 1, k - 1, -1); + boolean flag3 = g(iblockaccess, i, j, k + 1, 0) || !iblockaccess.s(i, j, k + 1) && g(iblockaccess, i, j - 1, k + 1, -1); if (!iblockaccess.s(i, j + 1, k)) { - if (iblockaccess.s(i - 1, j, k) && f(iblockaccess, i - 1, j + 1, k, -1)) { + if (iblockaccess.s(i - 1, j, k) && g(iblockaccess, i - 1, j + 1, k, -1)) { flag = true; } - if (iblockaccess.s(i + 1, j, k) && f(iblockaccess, i + 1, j + 1, k, -1)) { + if (iblockaccess.s(i + 1, j, k) && g(iblockaccess, i + 1, j + 1, k, -1)) { flag1 = true; } - if (iblockaccess.s(i, j, k - 1) && f(iblockaccess, i, j + 1, k - 1, -1)) { + if (iblockaccess.s(i, j, k - 1) && g(iblockaccess, i, j + 1, k - 1, -1)) { flag2 = true; } - if (iblockaccess.s(i, j, k + 1) && f(iblockaccess, i, j + 1, k + 1, -1)) { + if (iblockaccess.s(i, j, k + 1) && g(iblockaccess, i, j + 1, k + 1, -1)) { flag3 = true; } } @@ -348,7 +348,7 @@ public class BlockRedstoneWire extends Block { return this.a; } - public static boolean e(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public static boolean f(IBlockAccess iblockaccess, int i, int j, int k, int l) { int i1 = iblockaccess.getTypeId(i, j, k); if (i1 == Block.REDSTONE_WIRE.id) { @@ -360,12 +360,12 @@ public class BlockRedstoneWire extends Block { } else { int j1 = iblockaccess.getData(i, j, k); - return l == (j1 & 3) || l == Direction.e[j1 & 3]; + return l == (j1 & 3) || l == Direction.f[j1 & 3]; } } - public static boolean f(IBlockAccess iblockaccess, int i, int j, int k, int l) { - if (e(iblockaccess, i, j, k, l)) { + public static boolean g(IBlockAccess iblockaccess, int i, int j, int k, int l) { + if (f(iblockaccess, i, j, k, l)) { return true; } else { int i1 = iblockaccess.getTypeId(i, j, k); diff --git a/src/main/java/net/minecraft/server/BlockReed.java b/src/main/java/net/minecraft/server/BlockReed.java index 1b459a19..399050ab 100644 --- a/src/main/java/net/minecraft/server/BlockReed.java +++ b/src/main/java/net/minecraft/server/BlockReed.java @@ -63,15 +63,15 @@ public class BlockReed extends Block { return Item.SUGAR_CANE.id; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 1; } } diff --git a/src/main/java/net/minecraft/server/BlockSand.java b/src/main/java/net/minecraft/server/BlockSand.java index 053b75e7..2738f081 100644 --- a/src/main/java/net/minecraft/server/BlockSand.java +++ b/src/main/java/net/minecraft/server/BlockSand.java @@ -11,12 +11,16 @@ public class BlockSand extends Block { this.a(CreativeModeTab.b); } + public BlockSand(int i, int j, Material material) { + super(i, j, material); + } + public void onPlace(World world, int i, int j, int k) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } public void doPhysics(World world, int i, int j, int k, int l) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } public void b(World world, int i, int j, int k, Random random) { @@ -29,11 +33,11 @@ public class BlockSand extends Block { if (canFall(world, i, j - 1, k) && j >= 0) { byte b0 = 32; - if (!instaFall && world.c(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { + if (!instaFall && world.d(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { if (!world.isStatic) { - // CraftBukkit - change call to add data EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k)); + this.a(entityfallingblock); world.addEntity(entityfallingblock); } } else { @@ -50,7 +54,9 @@ public class BlockSand extends Block { } } - public int p_() { + protected void a(EntityFallingBlock entityfallingblock) {} + + public int r_() { return 3; } @@ -67,4 +73,6 @@ public class BlockSand extends Block { return material == Material.WATER ? true : material == Material.LAVA; } } + + public void a_(World world, int i, int j, int k, int l) {} } diff --git a/src/main/java/net/minecraft/server/BlockSapling.java b/src/main/java/net/minecraft/server/BlockSapling.java index 9495da10..9c94399e 100644 --- a/src/main/java/net/minecraft/server/BlockSapling.java +++ b/src/main/java/net/minecraft/server/BlockSapling.java @@ -62,7 +62,7 @@ public class BlockSapling extends BlockFlower { } else if (l == 3) { for (i1 = 0; i1 >= -1; --i1) { for (j1 = 0; j1 >= -1; --j1) { - if (this.e(world, i + i1, j, k + j1, 3) && this.e(world, i + i1 + 1, j, k + j1, 3) && this.e(world, i + i1, j, k + j1 + 1, 3) && this.e(world, i + i1 + 1, j, k + j1 + 1, 3)) { + if (this.d(world, i + i1, j, k + j1, 3) && this.d(world, i + i1 + 1, j, k + j1, 3) && this.d(world, i + i1, j, k + j1 + 1, 3) && this.d(world, i + i1 + 1, j, k + j1 + 1, 3)) { treeType = TreeType.JUNGLE; gen = new WorldGenMegaTree(false, 10 + random.nextInt(20), 3, 3); flag = true; @@ -128,11 +128,11 @@ public class BlockSapling extends BlockFlower { // CraftBukkit end } - public boolean e(World world, int i, int j, int k, int l) { + public boolean d(World world, int i, int j, int k, int l) { return world.getTypeId(i, j, k) == this.id && (world.getData(i, j, k) & 3) == l; } - protected int getDropData(int i) { + public int getDropData(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 329a3d41..5e6ce37e 100644 --- a/src/main/java/net/minecraft/server/BlockSign.java +++ b/src/main/java/net/minecraft/server/BlockSign.java @@ -52,11 +52,11 @@ public class BlockSign extends BlockContainer { } } - public int b() { + public int d() { return -1; } - public boolean c() { + public boolean b() { return false; } @@ -64,7 +64,7 @@ public class BlockSign extends BlockContainer { return true; } - public boolean d() { + public boolean c() { return false; } diff --git a/src/main/java/net/minecraft/server/BlockSkull.java b/src/main/java/net/minecraft/server/BlockSkull.java new file mode 100644 index 00000000..e7520eac --- /dev/null +++ b/src/main/java/net/minecraft/server/BlockSkull.java @@ -0,0 +1,198 @@ +package net.minecraft.server; + +import java.util.Random; + +// CraftBukkit start +import org.bukkit.craftbukkit.util.BlockStateListPopulator; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; +// CraftBukkit end + +public class BlockSkull extends BlockContainer { + + protected BlockSkull(int i) { + super(i, Material.ORIENTABLE); + this.textureId = 104; + this.a(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + } + + public int d() { + return -1; + } + + public boolean c() { + return false; + } + + public boolean b() { + return false; + } + + public void updateShape(IBlockAccess iblockaccess, int i, int j, int k) { + int l = iblockaccess.getData(i, j, k) & 7; + + switch (l) { + case 1: + default: + this.a(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + break; + + case 2: + this.a(0.25F, 0.25F, 0.5F, 0.75F, 0.75F, 1.0F); + break; + + case 3: + this.a(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 0.5F); + break; + + case 4: + this.a(0.5F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); + break; + + case 5: + this.a(0.0F, 0.25F, 0.25F, 0.5F, 0.75F, 0.75F); + } + } + + public AxisAlignedBB e(World world, int i, int j, int k) { + this.updateShape(world, i, j, k); + return super.e(world, i, j, k); + } + + public void postPlace(World world, int i, int j, int k, EntityLiving entityliving) { + int l = MathHelper.floor((double) (entityliving.yaw * 4.0F / 360.0F) + 2.5D) & 3; + + world.setData(i, j, k, l); + } + + public TileEntity a(World world) { + return new TileEntitySkull(); + } + + public int getDropData(World world, int i, int j, int k) { + TileEntity tileentity = world.getTileEntity(i, j, k); + + return tileentity != null && tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).a() : super.getDropData(world, i, j, k); + } + + public int getDropData(int i) { + return i; + } + + public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {} + + public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { + if (entityhuman.abilities.canInstantlyBuild) { + l |= 8; + world.setData(i, j, k, l); + } + + super.a(world, i, j, k, l, entityhuman); + } + + public void remove(World world, int i, int j, int k, int l, int i1) { + if (!world.isStatic) { + if ((i1 & 8) == 0) { + this.a(world, i, j, k, new ItemStack(Item.SKULL.id, 1, this.getDropData(world, i, j, k))); + } + + super.remove(world, i, j, k, l, i1); + } + } + + public int getDropType(int i, Random random, int j) { + return Item.SKULL.id; + } + + public void a(World world, int i, int j, int k, TileEntitySkull tileentityskull) { + if (tileentityskull.a() == 1 && j >= 2) { + int l = Block.SOUL_SAND.id; + + int i1; + EntityWither entitywither; + int j1; + + for (i1 = -2; i1 <= 0; ++i1) { + if (world.getTypeId(i, j - 1, k + i1) == l && world.getTypeId(i, j - 1, k + i1 + 1) == l && world.getTypeId(i, j - 2, k + i1 + 1) == l && world.getTypeId(i, j - 1, k + i1 + 2) == l && this.d(world, i, j, k + i1, 1) && this.d(world, i, j, k + i1 + 1, 1) && this.d(world, i, j, k + i1 + 2, 1)) { + // CraftBukkit start - use BlockStateListPopulator + BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); + + world.setRawData(i, j, k + i1, 8); + world.setRawData(i, j, k + i1 + 1, 8); + world.setRawData(i, j, k + i1 + 2, 8); + + blockList.setTypeId(i, j, k + i1, 0); + blockList.setTypeId(i, j, k + i1 + 1, 0); + blockList.setTypeId(i, j, k + i1 + 2, 0); + blockList.setTypeId(i, j - 1, k + i1, 0); + blockList.setTypeId(i, j - 1, k + i1 + 1, 0); + blockList.setTypeId(i, j - 1, k + i1 + 2, 0); + blockList.setTypeId(i, j - 2, k + i1 + 1, 0); + + if (!world.isStatic) { + entitywither = new EntityWither(world); + entitywither.setPositionRotation((double) i + 0.5D, (double) j - 1.45D, (double) (k + i1) + 1.5D, 90.0F, 0.0F); + entitywither.aw = 90.0F; + entitywither.m(); + + if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { + blockList.updateList(); + } + } + + for (j1 = 0; j1 < 120; ++j1) { + world.addParticle("snowballpoof", (double) i + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) (k + i1 + 1) + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); + } + // CraftBukkit end + + return; + } + } + + for (i1 = -2; i1 <= 0; ++i1) { + if (world.getTypeId(i + i1, j - 1, k) == l && world.getTypeId(i + i1 + 1, j - 1, k) == l && world.getTypeId(i + i1 + 1, j - 2, k) == l && world.getTypeId(i + i1 + 2, j - 1, k) == l && this.d(world, i + i1, j, k, 1) && this.d(world, i + i1 + 1, j, k, 1) && this.d(world, i + i1 + 2, j, k, 1)) { + // CraftBukkit start - use BlockStateListPopulator + BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); + + world.setRawData(i + i1, j, k, 8); + world.setRawData(i + i1 + 1, j, k, 8); + world.setRawData(i + i1 + 2, j, k, 8); + + blockList.setTypeId(i + i1, j, k, 0); + blockList.setTypeId(i + i1 + 1, j, k, 0); + blockList.setTypeId(i + i1 + 2, j, k, 0); + blockList.setTypeId(i + i1, j - 1, k, 0); + blockList.setTypeId(i + i1 + 1, j - 1, k, 0); + blockList.setTypeId(i + i1 + 2, j - 1, k, 0); + blockList.setTypeId(i + i1 + 1, j - 2, k, 0); + + if (!world.isStatic) { + entitywither = new EntityWither(world); + entitywither.setPositionRotation((double) (i + i1) + 1.5D, (double) j - 1.45D, (double) k + 0.5D, 0.0F, 0.0F); + entitywither.m(); + + if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { + blockList.updateList(); + } + } + + for (j1 = 0; j1 < 120; ++j1) { + world.addParticle("snowballpoof", (double) (i + i1 + 1) + world.random.nextDouble(), (double) (j - 2) + world.random.nextDouble() * 3.9D, (double) k + world.random.nextDouble(), 0.0D, 0.0D, 0.0D); + } + // CraftBukkit end + + return; + } + } + } + } + + private boolean d(World world, int i, int j, int k, int l) { + if (world.getTypeId(i, j, k) != this.id) { + return false; + } else { + TileEntity tileentity = world.getTileEntity(i, j, k); + + return tileentity != null && tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).a() == l : false; + } + } +} diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java index ecade8e2..2e11d2f9 100644 --- a/src/main/java/net/minecraft/server/BlockSnow.java +++ b/src/main/java/net/minecraft/server/BlockSnow.java @@ -17,11 +17,11 @@ public class BlockSnow extends Block { return l >= 3 ? AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + 0.5F), (double) k + this.maxZ) : null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } @@ -35,7 +35,7 @@ public class BlockSnow extends Block { public boolean canPlace(World world, int i, int j, int k) { int l = world.getTypeId(i, j - 1, k); - return l != 0 && (l == Block.LEAVES.id || Block.byId[l].d()) ? world.getMaterial(i, j - 1, k).isSolid() : false; + return l != 0 && (l == Block.LEAVES.id || Block.byId[l].c()) ? world.getMaterial(i, j - 1, k).isSolid() : false; } public void doPhysics(World world, int i, int j, int k, int l) { @@ -55,14 +55,8 @@ public class BlockSnow extends Block { public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) { int i1 = Item.SNOW_BALL.id; - float f = 0.7F; - double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D; - EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0)); - - entityitem.pickupDelay = 10; - world.addEntity(entityitem); + + this.a(world, i, j, k, new ItemStack(i1, 1, 0)); world.setTypeId(i, j, k, 0); entityhuman.a(StatisticList.C[this.id], 1); } diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index 6804187a..bdffd555 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -18,11 +18,11 @@ public class BlockSoil extends Block { return AxisAlignedBB.a().a((double) (i + 0), (double) (j + 0), (double) (k + 0), (double) (i + 1), (double) (j + 1), (double) (k + 1)); } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java index d9ef03fe..25695d3f 100644 --- a/src/main/java/net/minecraft/server/BlockStationary.java +++ b/src/main/java/net/minecraft/server/BlockStationary.java @@ -33,8 +33,8 @@ public class BlockStationary extends BlockFluids { world.suppressPhysics = true; world.setRawTypeIdAndData(i, j, k, this.id - 1, l); - world.d(i, j, k, i, j, k); - world.a(i, j, k, this.id - 1, this.p_()); + world.e(i, j, k, i, j, k); + world.a(i, j, k, this.id - 1, this.r_()); world.suppressPhysics = false; } diff --git a/src/main/java/net/minecraft/server/BlockStem.java b/src/main/java/net/minecraft/server/BlockStem.java index d8a2c1d0..50c3760d 100644 --- a/src/main/java/net/minecraft/server/BlockStem.java +++ b/src/main/java/net/minecraft/server/BlockStem.java @@ -142,7 +142,7 @@ public class BlockStem extends BlockFlower { this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float) this.maxY, 0.5F + f); } - public int b() { + public int d() { return 19; } @@ -161,14 +161,7 @@ public class BlockStem extends BlockFlower { for (int j1 = 0; j1 < 3; ++j1) { if (world.random.nextInt(15) <= l) { - float f1 = 0.7F; - float f2 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - float f3 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - float f4 = world.random.nextFloat() * f1 + (1.0F - f1) * 0.5F; - EntityItem entityitem = new EntityItem(world, (double) ((float) i + f2), (double) ((float) j + f3), (double) ((float) k + f4), new ItemStack(item)); - - entityitem.pickupDelay = 10; - world.addEntity(entityitem); + this.a(world, i, j, k, new ItemStack(item)); } } } diff --git a/src/main/java/net/minecraft/server/BlockTNT.java b/src/main/java/net/minecraft/server/BlockTNT.java index df7bb644..8b6a2907 100644 --- a/src/main/java/net/minecraft/server/BlockTNT.java +++ b/src/main/java/net/minecraft/server/BlockTNT.java @@ -53,7 +53,7 @@ public class BlockTNT extends Block { } public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { - if (entityhuman.bC() != null && entityhuman.bC().id == Item.FLINT_AND_STEEL.id) { + if (entityhuman.bP() != null && entityhuman.bP().id == Item.FLINT_AND_STEEL.id) { this.postBreak(world, i, j, k, 1); world.setTypeId(i, j, k, 0); return true; @@ -62,7 +62,14 @@ public class BlockTNT extends Block { } } - protected ItemStack c_(int i) { - return null; + public void a(World world, int i, int j, int k, Entity entity) { + if (entity instanceof EntityArrow && !world.isStatic) { + EntityArrow entityarrow = (EntityArrow) entity; + + if (entityarrow.isBurning()) { + this.postBreak(world, i, j, k, 1); + world.setTypeId(i, j, k, 0); + } + } } } diff --git a/src/main/java/net/minecraft/server/BlockTrapdoor.java b/src/main/java/net/minecraft/server/BlockTrapdoor.java index cd735dc7..7c5719af 100644 --- a/src/main/java/net/minecraft/server/BlockTrapdoor.java +++ b/src/main/java/net/minecraft/server/BlockTrapdoor.java @@ -18,11 +18,11 @@ public class BlockTrapdoor extends Block { this.a(CreativeModeTab.d); } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } @@ -30,7 +30,7 @@ public class BlockTrapdoor extends Block { return !g(iblockaccess.getData(i, j, k)); } - public int b() { + public int d() { return 0; } @@ -52,7 +52,12 @@ public class BlockTrapdoor extends Block { public void e(int i) { float f = 0.1875F; - this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + if ((i & 8) != 0) { + this.a(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F); + } else { + this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + } + if (g(i)) { if ((i & 3) == 0) { this.a(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); @@ -72,9 +77,7 @@ public class BlockTrapdoor extends Block { } } - public void attack(World world, int i, int j, int k, EntityHuman entityhuman) { - this.interact(world, i, j, k, entityhuman, 0, 0.0F, 0.0F, 0.0F); - } + public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {} public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) { if (this.material == Material.ORE) { @@ -150,25 +153,31 @@ public class BlockTrapdoor extends Block { } public void postPlace(World world, int i, int j, int k, int l, float f, float f1, float f2) { - byte b0 = 0; + int i1 = 0; if (l == 2) { - b0 = 0; + i1 = 0; } if (l == 3) { - b0 = 1; + i1 = 1; } if (l == 4) { - b0 = 2; + i1 = 2; } if (l == 5) { - b0 = 3; + i1 = 3; + } + + int j1 = Block.TRAP_DOOR.id; + + if (l != 1 && l != 0 && f1 > 0.5F) { + i1 |= 8; } - world.setData(i, j, k, b0); + world.setTypeIdAndData(i, j, k, j1, i1); doPhysics(world, i, j, k, Block.REDSTONE_WIRE.id); // CraftBukkit } @@ -208,7 +217,7 @@ public class BlockTrapdoor extends Block { } else { Block block = Block.byId[i]; - return block != null && block.material.k() && block.c() || block == Block.GLOWSTONE; + return block != null && block.material.k() && block.b() || block == Block.GLOWSTONE; } } } diff --git a/src/main/java/net/minecraft/server/BlockTripwire.java b/src/main/java/net/minecraft/server/BlockTripwire.java index 00981725..3a4b7e42 100644 --- a/src/main/java/net/minecraft/server/BlockTripwire.java +++ b/src/main/java/net/minecraft/server/BlockTripwire.java @@ -1,5 +1,6 @@ package net.minecraft.server; +import java.util.Iterator; import java.util.List; import java.util.Random; @@ -13,7 +14,7 @@ public class BlockTripwire extends Block { this.b(true); } - public int p_() { + public int r_() { return 10; } @@ -21,15 +22,15 @@ public class BlockTripwire extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 30; } @@ -66,22 +67,22 @@ public class BlockTripwire extends Block { int l = world.t(i, j - 1, k) ? 0 : 2; world.setData(i, j, k, l); - this.e(world, i, j, k, l); + this.d(world, i, j, k, l); } public void remove(World world, int i, int j, int k, int l, int i1) { - this.e(world, i, j, k, i1 | 1); + this.d(world, i, j, k, i1 | 1); } public void a(World world, int i, int j, int k, int l, EntityHuman entityhuman) { if (!world.isStatic) { - if (entityhuman.bC() != null && entityhuman.bC().id == Item.SHEARS.id) { + if (entityhuman.bP() != null && entityhuman.bP().id == Item.SHEARS.id) { world.setData(i, j, k, l | 8); } } } - private void e(World world, int i, int j, int k, int l) { + private void d(World world, int i, int j, int k, int l) { int i1 = 0; while (i1 < 2) { @@ -96,7 +97,7 @@ public class BlockTripwire extends Block { if (i2 == Block.TRIPWIRE_SOURCE.id) { int j2 = world.getData(k1, j, l1) & 3; - if (j2 == Direction.e[i1]) { + if (j2 == Direction.f[i1]) { Block.TRIPWIRE_SOURCE.a(world, k1, j, l1, i2, world.getData(k1, j, l1), true, j1, l); } } else if (i2 == Block.TRIPWIRE.id) { @@ -134,7 +135,16 @@ public class BlockTripwire extends Block { List list = world.getEntities((Entity) null, AxisAlignedBB.a().a((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) j + this.maxY, (double) k + this.maxZ)); if (!list.isEmpty()) { - flag1 = true; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + + if (!entity.au()) { + flag1 = true; + break; + } + } } // CraftBukkit start @@ -175,11 +185,11 @@ public class BlockTripwire extends Block { if (flag1 != flag) { world.setData(i, j, k, l); - this.e(world, i, j, k, l); + this.d(world, i, j, k, l); } if (flag1) { - world.a(i, j, k, this.id, this.p_()); + world.a(i, j, k, this.id, this.r_()); } } } diff --git a/src/main/java/net/minecraft/server/BlockTripwireHook.java b/src/main/java/net/minecraft/server/BlockTripwireHook.java index 6025e8fd..0fe164d6 100644 --- a/src/main/java/net/minecraft/server/BlockTripwireHook.java +++ b/src/main/java/net/minecraft/server/BlockTripwireHook.java @@ -16,19 +16,19 @@ public class BlockTripwireHook extends Block { return null; } - public boolean d() { + public boolean c() { return false; } - public boolean c() { + public boolean b() { return false; } - public int b() { + public int d() { return 29; } - public int p_() { + public int r_() { return 10; } @@ -117,7 +117,7 @@ public class BlockTripwireHook extends Block { j3 = world.getTypeId(l2, j, k3); if (j3 == Block.TRIPWIRE_SOURCE.id) { l3 = world.getData(l2, j, k3); - if ((l3 & 3) == Direction.e[l1]) { + if ((l3 & 3) == Direction.f[l1]) { k2 = i3; } break; @@ -136,7 +136,7 @@ public class BlockTripwireHook extends Block { flag4 |= flag6 && flag7; aint[i3] = l3; if (i3 == j1) { - world.a(i, j, k, l, this.p_()); + world.a(i, j, k, l, this.r_()); flag3 &= flag6; } } @@ -149,9 +149,9 @@ public class BlockTripwireHook extends Block { if (k2 > 0) { l2 = i + i2 * k2; k3 = k + j2 * k2; - j3 = Direction.e[l1]; + j3 = Direction.f[l1]; world.setData(l2, j, k3, j3 | i3); - this.e(world, l2, j, k3, j3); + this.d(world, l2, j, k3, j3); this.a(world, l2, j, k3, flag3, flag4, flag1, flag2); } @@ -170,7 +170,7 @@ public class BlockTripwireHook extends Block { if (l > 0) { world.setData(i, j, k, i1); if (flag) { - this.e(world, i, j, k, l1); + this.d(world, i, j, k, l1); } } @@ -208,7 +208,7 @@ public class BlockTripwireHook extends Block { } } - private void e(World world, int i, int j, int k, int l) { + private void d(World world, int i, int j, int k, int l) { world.applyPhysics(i, j, k, this.id); if (l == 3) { world.applyPhysics(i - 1, j, k, this.id); @@ -272,12 +272,12 @@ public class BlockTripwireHook extends Block { super.remove(world, i, j, k, l, i1); } - public boolean a(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public boolean b(IBlockAccess iblockaccess, int i, int j, int k, int l) { return (iblockaccess.getData(i, j, k) & 8) == 8; } - public boolean c(World world, int i, int j, int k, int l) { - int i1 = world.getData(i, j, k); + public boolean c(IBlockAccess iblockaccess, int i, int j, int k, int l) { + int i1 = iblockaccess.getData(i, j, k); if ((i1 & 8) != 8) { return false; diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index a82773b4..612d6f01 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -17,7 +17,7 @@ public class Chunk { public static boolean a; private ChunkSection[] sections; - private byte[] r; + private byte[] s; public int[] b; public boolean[] c; public boolean d; @@ -25,7 +25,7 @@ public class Chunk { public int[] heightMap; public final int x; public final int z; - private boolean s; + private boolean t; public Map tileEntities; public List[] entitySlices; public boolean done; @@ -33,23 +33,25 @@ public class Chunk { public boolean m; public long n; public boolean seenByPlayer; - private int t; - boolean p; + public int p; + private int u; + boolean q; public Chunk(World world, int i, int j) { this.sections = new ChunkSection[16]; - this.r = new byte[256]; + this.s = new byte[256]; this.b = new int[256]; this.c = new boolean[256]; - this.s = false; + this.t = false; this.tileEntities = new HashMap(); this.done = false; this.l = false; this.m = false; this.n = 0L; this.seenByPlayer = false; - this.t = 4096; - this.p = false; + this.p = 0; + this.u = 4096; + this.q = false; this.entitySlices = new List[16]; this.world = world; this.x = i; @@ -61,7 +63,7 @@ public class Chunk { } Arrays.fill(this.b, -999); - Arrays.fill(this.r, (byte) -1); + Arrays.fill(this.s, (byte) -1); // CraftBukkit start if (!(this instanceof EmptyChunk)) { @@ -121,6 +123,8 @@ public class Chunk { public void initLighting() { int i = this.h(); + this.p = Integer.MAX_VALUE; + int j; int k; @@ -139,9 +143,12 @@ public class Chunk { } this.heightMap[k << 4 | j] = l; + if (l < this.p) { + this.p = l; + } } - if (!this.world.worldProvider.e) { + if (!this.world.worldProvider.f) { l = 15; int i1 = i + 16 - 1; @@ -177,7 +184,7 @@ public class Chunk { private void e(int i, int j) { this.c[i + j * 16] = true; - this.s = true; + this.t = true; } private void q() { @@ -190,10 +197,10 @@ public class Chunk { 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); + int j1 = this.world.g(l - 1, i1); + int k1 = this.world.g(l + 1, i1); + int l1 = this.world.g(l, i1 - 1); + int i2 = this.world.g(l, i1 + 1); if (k1 < j1) { j1 = k1; @@ -216,7 +223,7 @@ public class Chunk { } } - this.s = false; + this.t = false; } this.world.methodProfiler.b(); @@ -262,7 +269,7 @@ public class Chunk { int l1; int i2; - if (!this.world.worldProvider.e) { + if (!this.world.worldProvider.f) { ChunkSection chunksection; if (i1 < l) { @@ -314,7 +321,11 @@ public class Chunk { j2 = l; } - if (!this.world.worldProvider.e) { + if (l1 < this.p) { + this.p = l1; + } + + if (!this.world.worldProvider.f) { this.d(j1 - 1, k1, i2, j2); this.d(j1 + 1, k1, i2, j2); this.d(j1, k1 - 1, i2, j2); @@ -384,7 +395,7 @@ public class Chunk { int k2 = this.z * 16 + k; if (l1 != 0 && !this.world.isStatic) { - Block.byId[l1].h(this.world, j2, j, k2, i2); + Block.byId[l1].g(this.world, j2, j, k2, i2); } chunksection.a(i, j & 15, k, l); @@ -494,7 +505,7 @@ public class Chunk { this.l = true; if (enumskyblock == EnumSkyBlock.SKY) { - if (!this.world.worldProvider.e) { + if (!this.world.worldProvider.f) { chunksection.c(i, j & 15, k, l); } } else if (enumskyblock == EnumSkyBlock.BLOCK) { @@ -506,9 +517,9 @@ public class Chunk { ChunkSection chunksection = this.sections[j >> 4]; if (chunksection == null) { - return !this.world.worldProvider.e && l < EnumSkyBlock.SKY.c ? EnumSkyBlock.SKY.c - l : 0; + return !this.world.worldProvider.f && l < EnumSkyBlock.SKY.c ? EnumSkyBlock.SKY.c - l : 0; } else { - int i1 = this.world.worldProvider.e ? 0 : chunksection.c(i, j & 15, k); + int i1 = this.world.worldProvider.f ? 0 : chunksection.c(i, j & 15, k); if (i1 > 0) { a = true; @@ -548,15 +559,15 @@ public class Chunk { k = this.entitySlices.length - 1; } - entity.ag = true; - entity.ah = this.x; - entity.ai = k; - entity.aj = this.z; + entity.ah = true; + entity.ai = this.x; + entity.aj = k; + entity.ak = this.z; this.entitySlices[k].add(entity); } public void b(Entity entity) { - this.a(entity, entity.ai); + this.a(entity, entity.aj); } public void a(Entity entity, int i) { @@ -582,7 +593,7 @@ public class Chunk { if (tileentity == null) { int l = this.getTypeId(i, j, k); - if (l <= 0 || !Block.byId[l].s()) { + if (l <= 0 || !Block.byId[l].u()) { return null; } @@ -594,7 +605,7 @@ public class Chunk { tileentity = (TileEntity) this.tileEntities.get(chunkposition); } - if (tileentity != null && tileentity.p()) { + if (tileentity != null && tileentity.r()) { this.tileEntities.remove(chunkposition); return null; } else { @@ -616,14 +627,14 @@ public class Chunk { public void a(int i, int j, int k, TileEntity tileentity) { ChunkPosition chunkposition = new ChunkPosition(i, j, k); - tileentity.a(this.world); + tileentity.b(this.world); tileentity.x = this.x * 16 + i; 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.q(); + tileentity.s(); this.tileEntities.put(chunkposition, tileentity); - // CraftBukkit start + // CraftBukkit start } else { 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!"); @@ -640,7 +651,7 @@ public class Chunk { TileEntity tileentity = (TileEntity) this.tileEntities.remove(chunkposition); if (tileentity != null) { - tileentity.j(); + tileentity.w_(); } } } @@ -718,7 +729,7 @@ public class Chunk { if (entity1 != entity && entity1.boundingBox.a(axisalignedbb)) { list.add(entity1); - Entity[] aentity = entity1.al(); + Entity[] aentity = entity1.ao(); if (aentity != null) { for (int l = 0; l < aentity.length; ++l) { @@ -733,7 +744,7 @@ public class Chunk { } } - public void a(Class oclass, AxisAlignedBB axisalignedbb, List list) { + public void a(Class oclass, AxisAlignedBB axisalignedbb, List list, IEntitySelector ientityselector) { int i = MathHelper.floor((axisalignedbb.b - 2.0D) / 16.0D); int j = MathHelper.floor((axisalignedbb.e + 2.0D) / 16.0D); @@ -756,7 +767,7 @@ public class Chunk { while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); - if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.a(axisalignedbb)) { + if (oclass.isAssignableFrom(entity.getClass()) && entity.boundingBox.a(axisalignedbb) && (ientityselector == null || ientityselector.a(entity))) { list.add(entity); } } @@ -828,7 +839,7 @@ public class Chunk { } public void k() { - if (this.s && !this.world.worldProvider.e) { + if (this.t && !this.world.worldProvider.f) { this.q(); } } @@ -862,41 +873,41 @@ public class Chunk { } public BiomeBase a(int i, int j, WorldChunkManager worldchunkmanager) { - int k = this.r[j << 4 | i] & 255; + int k = this.s[j << 4 | i] & 255; if (k == 255) { BiomeBase biomebase = worldchunkmanager.getBiome((this.x << 4) + i, (this.z << 4) + j); k = biomebase.id; - this.r[j << 4 | i] = (byte) (k & 255); + this.s[j << 4 | i] = (byte) (k & 255); } return BiomeBase.biomes[k] == null ? BiomeBase.PLAINS : BiomeBase.biomes[k]; } public byte[] m() { - return this.r; + return this.s; } public void a(byte[] abyte) { - this.r = abyte; + this.s = abyte; } public void n() { - this.t = 0; + this.u = 0; } public void o() { for (int i = 0; i < 8; ++i) { - if (this.t >= 4096) { + if (this.u >= 4096) { return; } - int j = this.t % 16; - int k = this.t / 16 % 16; - int l = this.t / 256; + int j = this.u % 16; + int k = this.u / 16 % 16; + int l = this.u / 256; - ++this.t; + ++this.u; int i1 = (this.x << 4) + k; int j1 = (this.z << 4) + l; diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index a9d0567d..4cdf364c 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -146,6 +146,9 @@ public class ChunkProviderServer implements IChunkProvider { if (chunk != null) { chunk.n = this.world.getTime(); + if (this.chunkProvider != null) { + this.chunkProvider.recreateStructures(i, j); + } } return chunk; @@ -249,7 +252,7 @@ public class ChunkProviderServer implements IChunkProvider { if (!this.world.savingDisabled) { // CraftBukkit start Server server = this.world.getServer(); - for (int i = 0; i < 50 && !this.unloadQueue.isEmpty(); i++) { + for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); i++) { long chunkcoordinates = this.unloadQueue.popFirst(); Chunk chunk = this.chunks.get(chunkcoordinates); if (chunk == null) continue; @@ -293,4 +296,6 @@ public class ChunkProviderServer implements IChunkProvider { public int getLoadedChunks() { return this.chunks.values().size(); // CraftBukkit } + + public void recreateStructures(int i, int j) {} } diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java index 20950e0e..69632491 100644 --- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java +++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java @@ -79,7 +79,7 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader { public void a(World world, Chunk chunk) { // CraftBukkit start - "handle" exception try { - world.B(); + world.C(); } catch (ExceptionWorldConflict ex) { ex.printStackTrace(); } @@ -266,7 +266,7 @@ public class ChunkRegionLoader implements IAsyncChunkSaver, IChunkLoader { chunksection.b(new NibbleArray(nbttagcompound1.getByteArray("Data"), 4)); chunksection.d(new NibbleArray(nbttagcompound1.getByteArray("SkyLight"), 4)); chunksection.c(new NibbleArray(nbttagcompound1.getByteArray("BlockLight"), 4)); - chunksection.e(); + chunksection.recalcBlockCounts(); achunksection[b1] = chunksection; } diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java index 1b0c8e00..60d2a73c 100644 --- a/src/main/java/net/minecraft/server/ChunkSection.java +++ b/src/main/java/net/minecraft/server/ChunkSection.java @@ -2,159 +2,159 @@ package net.minecraft.server; public class ChunkSection { - private int a; - private int b; - private int c; - private byte[] d; - private NibbleArray e; - private NibbleArray f; - private NibbleArray g; - private NibbleArray h; + private int yPos; + private int nonEmptyBlockCount; + private int tickingBlockCount; + private byte[] blockIds; + private NibbleArray extBlockIds; + private NibbleArray blockData; + private NibbleArray blockLight; + private NibbleArray skyLight; public ChunkSection(int i) { - this.a = i; - this.d = new byte[4096]; - this.f = new NibbleArray(this.d.length, 4); - this.h = new NibbleArray(this.d.length, 4); - this.g = new NibbleArray(this.d.length, 4); + this.yPos = i; + this.blockIds = new byte[4096]; + this.blockData = new NibbleArray(this.blockIds.length, 4); + this.skyLight = new NibbleArray(this.blockIds.length, 4); + this.blockLight = new NibbleArray(this.blockIds.length, 4); } // CraftBukkit start - public ChunkSection(int y, byte[] blkData, byte[] extBlkData) { - this.a = y; - this.d = blkData; - if (extBlkData != null) { - this.e = new NibbleArray(extBlkData, 4); + public ChunkSection(int y, byte[] blkIds, byte[] extBlkIds) { + this.yPos = y; + this.blockIds = blkIds; + if (extBlkIds != null) { + this.extBlockIds = new NibbleArray(extBlkIds, 4); } - this.f = new NibbleArray(this.d.length, 4); - this.h = new NibbleArray(this.d.length, 4); - this.g = new NibbleArray(this.d.length, 4); - this.e(); + this.blockData = new NibbleArray(this.blockIds.length, 4); + this.blockLight = new NibbleArray(this.blockIds.length, 4); + this.skyLight = new NibbleArray(this.blockIds.length, 4); + this.recalcBlockCounts(); } // CraftBukkit end public int a(int i, int j, int k) { - int l = this.d[j << 8 | k << 4 | i] & 255; + int l = this.blockIds[j << 8 | k << 4 | i] & 255; - return this.e != null ? this.e.a(i, j, k) << 8 | l : l; + return this.extBlockIds != null ? this.extBlockIds.a(i, j, k) << 8 | l : l; } public void a(int i, int j, int k, int l) { - int i1 = this.d[j << 8 | k << 4 | i] & 255; + int i1 = this.blockIds[j << 8 | k << 4 | i] & 255; - if (this.e != null) { - i1 |= this.e.a(i, j, k) << 8; + if (this.extBlockIds != null) { + i1 |= this.extBlockIds.a(i, j, k) << 8; } if (i1 == 0 && l != 0) { - ++this.b; - if (Block.byId[l] != null && Block.byId[l].r()) { - ++this.c; + ++this.nonEmptyBlockCount; + if (Block.byId[l] != null && Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } } else if (i1 != 0 && l == 0) { - --this.b; - if (Block.byId[i1] != null && Block.byId[i1].r()) { - --this.c; + --this.nonEmptyBlockCount; + if (Block.byId[i1] != null && Block.byId[i1].isTicking()) { + --this.tickingBlockCount; } - } else if (Block.byId[i1] != null && Block.byId[i1].r() && (Block.byId[l] == null || !Block.byId[l].r())) { - --this.c; - } else if ((Block.byId[i1] == null || !Block.byId[i1].r()) && Block.byId[l] != null && Block.byId[l].r()) { - ++this.c; + } else if (Block.byId[i1] != null && Block.byId[i1].isTicking() && (Block.byId[l] == null || !Block.byId[l].isTicking())) { + --this.tickingBlockCount; + } else if ((Block.byId[i1] == null || !Block.byId[i1].isTicking()) && Block.byId[l] != null && Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } - this.d[j << 8 | k << 4 | i] = (byte) (l & 255); + this.blockIds[j << 8 | k << 4 | i] = (byte) (l & 255); if (l > 255) { - if (this.e == null) { - this.e = new NibbleArray(this.d.length, 4); + if (this.extBlockIds == null) { + this.extBlockIds = new NibbleArray(this.blockIds.length, 4); } - this.e.a(i, j, k, (l & 3840) >> 8); - } else if (this.e != null) { - this.e.a(i, j, k, 0); + this.extBlockIds.a(i, j, k, (l & 3840) >> 8); + } else if (this.extBlockIds != null) { + this.extBlockIds.a(i, j, k, 0); } } public int b(int i, int j, int k) { - return this.f.a(i, j, k); + return this.blockData.a(i, j, k); } public void b(int i, int j, int k, int l) { - this.f.a(i, j, k, l); + this.blockData.a(i, j, k, l); } public boolean a() { - return this.b == 0; + return this.nonEmptyBlockCount == 0; } public boolean b() { - return this.c > 0; + return this.tickingBlockCount > 0; } public int d() { - return this.a; + return this.yPos; } public void c(int i, int j, int k, int l) { - this.h.a(i, j, k, l); + this.skyLight.a(i, j, k, l); } public int c(int i, int j, int k) { - return this.h.a(i, j, k); + return this.skyLight.a(i, j, k); } public void d(int i, int j, int k, int l) { - this.g.a(i, j, k, l); + this.blockLight.a(i, j, k, l); } public int d(int i, int j, int k) { - return this.g.a(i, j, k); + return this.blockLight.a(i, j, k); } - public void e() { + public void recalcBlockCounts() { // CraftBukkit start - optimize for speed - byte[] dd = this.d; - int cntb = 0; - int cntc = 0; - if (this.e == null) { // No extended block IDs? Don't waste time messing with them - for (int off = 0; off < dd.length; off++) { - int l = dd[off] & 0xFF; + byte[] blkIds = this.blockIds; + int cntNonEmpty = 0; + int cntTicking = 0; + if (this.extBlockIds == null) { // No extended block IDs? Don't waste time messing with them + for (int off = 0; off < blkIds.length; off++) { + int l = blkIds[off] & 0xFF; if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } } } else { - byte[] ext = this.e.a; - for (int off = 0, off2 = 0; off < dd.length;) { + byte[] ext = this.extBlockIds.a; + for (int off = 0, off2 = 0; off < blkIds.length;) { byte extid = ext[off2]; - int l = (dd[off] & 0xFF) | ((extid & 0xF) << 8); // Even data + int l = (blkIds[off] & 0xFF) | ((extid & 0xF) << 8); // Even data if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; ext[off2] &= 0xF0; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } off++; - l = (dd[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data + l = (blkIds[off] & 0xFF) | ((extid & 0xF0) << 4); // Odd data if (l > 0) { if (Block.byId[l] == null) { - dd[off] = 0; + blkIds[off] = 0; ext[off2] &= 0x0F; } else { - ++cntb; - if (Block.byId[l].r()) { - ++cntc; + ++cntNonEmpty; + if (Block.byId[l].isTicking()) { + ++cntTicking; } } } @@ -162,14 +162,14 @@ public class ChunkSection { off2++; } } - this.b = cntb; - this.c = cntc; + this.nonEmptyBlockCount = cntNonEmpty; + this.tickingBlockCount = cntTicking; } - private void old_e() { + public void old_recalcBlockCounts() { // CraftBukkit end - this.b = 0; - this.c = 0; + this.nonEmptyBlockCount = 0; + this.tickingBlockCount = 0; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { @@ -178,14 +178,14 @@ public class ChunkSection { if (l > 0) { if (Block.byId[l] == null) { - this.d[j << 8 | k << 4 | i] = 0; - if (this.e != null) { - this.e.a(i, j, k, 0); + this.blockIds[j << 8 | k << 4 | i] = 0; + if (this.extBlockIds != null) { + this.extBlockIds.a(i, j, k, 0); } } else { - ++this.b; - if (Block.byId[l].r()) { - ++this.c; + ++this.nonEmptyBlockCount; + if (Block.byId[l].isTicking()) { + ++this.tickingBlockCount; } } } @@ -195,42 +195,42 @@ public class ChunkSection { } public byte[] g() { - return this.d; + return this.blockIds; } public NibbleArray i() { - return this.e; + return this.extBlockIds; } public NibbleArray j() { - return this.f; + return this.blockData; } public NibbleArray k() { - return this.g; + return this.blockLight; } public NibbleArray l() { - return this.h; + return this.skyLight; } public void a(byte[] abyte) { - this.d = abyte; + this.blockIds = abyte; } public void a(NibbleArray nibblearray) { - this.e = nibblearray; + this.extBlockIds = nibblearray; } public void b(NibbleArray nibblearray) { - this.f = nibblearray; + this.blockData = nibblearray; } public void c(NibbleArray nibblearray) { - this.g = nibblearray; + this.blockLight = nibblearray; } public void d(NibbleArray nibblearray) { - this.h = nibblearray; + this.skyLight = nibblearray; } } diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java index dd894fe8..6aed2de4 100644 --- a/src/main/java/net/minecraft/server/Container.java +++ b/src/main/java/net/minecraft/server/Container.java @@ -35,7 +35,7 @@ public abstract class Container { public Container() {} protected Slot a(Slot slot) { - slot.d = this.b.size(); + slot.g = this.b.size(); this.b.add(slot); this.a.add(null); return slot; @@ -107,107 +107,104 @@ public abstract class Container { return (Slot) this.b.get(i); } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { Slot slot = (Slot) this.b.get(i); return slot != null ? slot.getItem() : null; } - public ItemStack clickItem(int i, int j, boolean flag, EntityHuman entityhuman) { + public ItemStack clickItem(int i, int j, int k, EntityHuman entityhuman) { ItemStack itemstack = null; + PlayerInventory playerinventory = entityhuman.inventory; + Slot slot; + ItemStack itemstack1; + int l; + ItemStack itemstack2; + + if ((k == 0 || k == 1) && (j == 0 || j == 1)) { + if (i == -999) { + if (playerinventory.getCarried() != null && i == -999) { + if (j == 0) { + entityhuman.drop(playerinventory.getCarried()); + playerinventory.setCarried((ItemStack) null); + } - if (j > 1) { - return null; - } else { - if (j == 0 || j == 1) { - PlayerInventory playerinventory = entityhuman.inventory; - - if (i == -999) { - if (playerinventory.getCarried() != null && i == -999) { - if (j == 0) { - entityhuman.drop(playerinventory.getCarried()); - playerinventory.setCarried((ItemStack) null); + if (j == 1) { + // CraftBukkit start - store a reference + ItemStack itemstack3 = playerinventory.getCarried(); + if (itemstack3.count > 0) { + entityhuman.drop(itemstack3.a(1)); } - if (j == 1) { - // CraftBukkit start - store a reference - ItemStack itemstack1 = playerinventory.getCarried(); - if (itemstack1.count > 0) { - entityhuman.drop(itemstack1.a(1)); - } - - if (itemstack1.count == 0) { - // CraftBukkit end - playerinventory.setCarried((ItemStack) null); - } + if (itemstack3.count == 0) { + // CraftBukkit end + playerinventory.setCarried((ItemStack) null); } } - } else if (flag) { - ItemStack itemstack1 = this.b(i); - + } + } else if (k == 1) { + slot = (Slot) this.b.get(i); + if (slot != null && slot.a(entityhuman)) { + itemstack1 = this.b(entityhuman, i); if (itemstack1 != null) { - int k = itemstack1.id; + int i1 = itemstack1.id; itemstack = itemstack1.cloneItemStack(); - Slot slot = (Slot) this.b.get(i); - - if (slot != null && slot.getItem() != null && slot.getItem().id == k) { - this.b(i, j, flag, entityhuman); + if (slot != null && slot.getItem() != null && slot.getItem().id == i1) { + this.a(i, j, true, entityhuman); } } - } else { - if (i < 0) { - return null; - } - - Slot slot1 = (Slot) this.b.get(i); - - if (slot1 != null) { - ItemStack itemstack2 = slot1.getItem(); - ItemStack itemstack3 = playerinventory.getCarried(); - - if (itemstack2 != null) { - itemstack = itemstack2.cloneItemStack(); - } + } + } else { + if (i < 0) { + return null; + } - int l; + slot = (Slot) this.b.get(i); + if (slot != null) { + itemstack1 = slot.getItem(); + ItemStack itemstack3 = playerinventory.getCarried(); - if (itemstack2 == null) { - if (itemstack3 != null && slot1.isAllowed(itemstack3)) { - l = j == 0 ? itemstack3.count : 1; - if (l > slot1.a()) { - l = slot1.a(); - } + if (itemstack1 != null) { + itemstack = itemstack1.cloneItemStack(); + } - // CraftBukkit start - if (itemstack3.count >= l) { - slot1.set(itemstack3.a(l)); - } - // CraftBukkit end + if (itemstack1 == null) { + if (itemstack3 != null && slot.isAllowed(itemstack3)) { + l = j == 0 ? itemstack3.count : 1; + if (l > slot.a()) { + l = slot.a(); + } - if (itemstack3.count == 0) { - playerinventory.setCarried((ItemStack) null); - } + // CraftBukkit start + if (itemstack3.count >= l) { + slot.set(itemstack3.a(l)); } - } else if (itemstack3 == null) { - l = j == 0 ? itemstack2.count : (itemstack2.count + 1) / 2; - ItemStack itemstack4 = slot1.a(l); + // CraftBukkit end - playerinventory.setCarried(itemstack4); - if (itemstack2.count == 0) { - slot1.set((ItemStack) null); + if (itemstack3.count == 0) { + playerinventory.setCarried((ItemStack) null); + } + } + } else if (slot.a(entityhuman)) { + if (itemstack3 == null) { + l = j == 0 ? itemstack1.count : (itemstack1.count + 1) / 2; + itemstack2 = slot.a(l); + playerinventory.setCarried(itemstack2); + if (itemstack1.count == 0) { + slot.set((ItemStack) null); } - slot1.b(playerinventory.getCarried()); - } else if (slot1.isAllowed(itemstack3)) { - if (itemstack2.id == itemstack3.id && (!itemstack2.usesData() || itemstack2.getData() == itemstack3.getData()) && ItemStack.equals(itemstack2, itemstack3)) { + slot.a(entityhuman, playerinventory.getCarried()); + } else if (slot.isAllowed(itemstack3)) { + if (itemstack1.id == itemstack3.id && (!itemstack1.usesData() || itemstack1.getData() == itemstack3.getData()) && ItemStack.equals(itemstack1, itemstack3)) { l = j == 0 ? itemstack3.count : 1; - if (l > slot1.a() - itemstack2.count) { - l = slot1.a() - itemstack2.count; + if (l > slot.a() - itemstack1.count) { + l = slot.a() - itemstack1.count; } - if (l > itemstack3.getMaxStackSize() - itemstack2.count) { - l = itemstack3.getMaxStackSize() - itemstack2.count; + if (l > itemstack3.getMaxStackSize() - itemstack1.count) { + l = itemstack3.getMaxStackSize() - itemstack1.count; } itemstack3.a(l); @@ -215,35 +212,72 @@ public abstract class Container { playerinventory.setCarried((ItemStack) null); } - itemstack2.count += l; - } else if (itemstack3.count <= slot1.a()) { - slot1.set(itemstack3); - playerinventory.setCarried(itemstack2); + itemstack1.count += l; + } else if (itemstack3.count <= slot.a()) { + slot.set(itemstack3); + playerinventory.setCarried(itemstack1); } - } else if (itemstack2.id == itemstack3.id && itemstack3.getMaxStackSize() > 1 && (!itemstack2.usesData() || itemstack2.getData() == itemstack3.getData()) && ItemStack.equals(itemstack2, itemstack3)) { - l = itemstack2.count; + } else if (itemstack1.id == itemstack3.id && itemstack3.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack3.getData()) && ItemStack.equals(itemstack1, itemstack3)) { + l = itemstack1.count; if (l > 0 && l + itemstack3.count <= itemstack3.getMaxStackSize()) { itemstack3.count += l; - itemstack2 = slot1.a(l); - if (itemstack2.count == 0) { - slot1.set((ItemStack) null); + itemstack1 = slot.a(l); + if (itemstack1.count == 0) { + slot.set((ItemStack) null); } - slot1.b(playerinventory.getCarried()); + slot.a(entityhuman, playerinventory.getCarried()); } } - - slot1.e(); } + + slot.e(); } } + } else if (k == 2 && j >= 0 && j < 9) { + slot = (Slot) this.b.get(i); + if (slot.a(entityhuman)) { + itemstack1 = playerinventory.getItem(j); + boolean flag = itemstack1 == null || slot.inventory == playerinventory && slot.isAllowed(itemstack1); + + l = -1; + if (!flag) { + l = playerinventory.i(); + flag |= l > -1; + } - return itemstack; + if (slot.d() && flag) { + itemstack2 = slot.getItem(); + playerinventory.setItem(j, itemstack2); + if ((slot.inventory != playerinventory || !slot.isAllowed(itemstack1)) && itemstack1 != null) { + if (l > -1) { + playerinventory.pickup(itemstack1); + slot.set((ItemStack) null); + slot.a(entityhuman, itemstack2); + } + } else { + slot.set(itemstack1); + slot.a(entityhuman, itemstack2); + } + } else if (!slot.d() && itemstack1 != null && slot.isAllowed(itemstack1)) { + playerinventory.setItem(j, (ItemStack) null); + slot.set(itemstack1); + } + } + } else if (k == 3 && entityhuman.abilities.canInstantlyBuild && playerinventory.getCarried() == null && i > 0) { + slot = (Slot) this.b.get(i); + if (slot != null && slot.d()) { + itemstack1 = slot.getItem().cloneItemStack(); + itemstack1.count = itemstack1.getMaxStackSize(); + playerinventory.setCarried(itemstack1); + } } + + return itemstack; } - protected void b(int i, int j, boolean flag, EntityHuman entityhuman) { - this.clickItem(i, j, flag, entityhuman); + protected void a(int i, int j, boolean flag, EntityHuman entityhuman) { + this.clickItem(i, j, 1, entityhuman); } public void a(EntityHuman entityhuman) { diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java new file mode 100644 index 00000000..0a2351f0 --- /dev/null +++ b/src/main/java/net/minecraft/server/ContainerAnvil.java @@ -0,0 +1,370 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.Map; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryAnvil; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + +public class ContainerAnvil extends Container { + + private IInventory f = new InventoryCraftResult(); + private IInventory g = new ContainerAnvilInventory(this, "Repair", 2); + private World h; + private int i; + private int j; + private int k; + public int e = 0; + private int l = 0; + private String m; + private final EntityHuman n; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end + + public ContainerAnvil(PlayerInventory playerinventory, World world, int i, int j, int k, EntityHuman entityhuman) { + this.player = playerinventory; // CraftBukkit + this.h = world; + this.i = i; + this.j = j; + this.k = k; + this.n = entityhuman; + this.a(new Slot(this.g, 0, 27, 47)); + this.a(new Slot(this.g, 1, 76, 47)); + this.a((Slot) (new SlotAnvilResult(this, this.f, 2, 134, 47, world, i, j, k))); + + int l; + + for (l = 0; l < 3; ++l) { + for (int i1 = 0; i1 < 9; ++i1) { + this.a(new Slot(playerinventory, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) { + this.a(new Slot(playerinventory, l, 8 + l * 18, 142)); + } + } + + public void a(IInventory iinventory) { + super.a(iinventory); + if (iinventory == this.g) { + this.d(); + } + } + + public void d() { + ItemStack itemstack = this.g.getItem(0); + + this.e = 0; + int i = 0; + byte b0 = 0; + int j = 0; + + if (itemstack == null) { + this.f.setItem(0, (ItemStack) null); + this.e = 0; + } else { + ItemStack itemstack1 = itemstack.cloneItemStack(); + ItemStack itemstack2 = this.g.getItem(1); + Map map = EnchantmentManager.a(itemstack1); + int k = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost()); + + this.l = 0; + int l; + int i1; + int j1; + int k1; + Enchantment enchantment; + Iterator iterator; + + if (itemstack2 != null) { + if (itemstack1.f() && Item.byId[itemstack1.id].a(itemstack, itemstack2)) { + l = Math.min(itemstack1.i(), itemstack1.k() / 4); + if (l <= 0) { + this.f.setItem(0, (ItemStack) null); + this.e = 0; + return; + } + + for (i1 = 0; l > 0 && i1 < itemstack2.count; ++i1) { + j1 = itemstack1.i() - l; + itemstack1.setData(j1); + i += Math.max(1, l / 100) + map.size(); + l = Math.min(itemstack1.i(), itemstack1.k() / 4); + } + + this.l = i1; + } else { + if (itemstack1.id != itemstack2.id || !itemstack1.f()) { + this.f.setItem(0, (ItemStack) null); + this.e = 0; + return; + } + + if (itemstack1.f()) { + l = itemstack.k() - itemstack.i(); + i1 = itemstack2.k() - itemstack2.i(); + j1 = i1 + itemstack1.k() * 12 / 100; + int l1 = l + j1; + + k1 = itemstack1.k() - l1; + if (k1 < 0) { + k1 = 0; + } + + if (k1 < itemstack1.getData()) { + itemstack1.setData(k1); + i += Math.max(1, j1 / 100); + } + } + + Map map1 = EnchantmentManager.a(itemstack2); + + iterator = map1.keySet().iterator(); + + while (iterator.hasNext()) { + j1 = ((Integer) iterator.next()).intValue(); + enchantment = Enchantment.byId[j1]; + k1 = map.containsKey(Integer.valueOf(j1)) ? ((Integer) map.get(Integer.valueOf(j1))).intValue() : 0; + int i2 = ((Integer) map1.get(Integer.valueOf(j1))).intValue(); + int j2; + + if (k1 == i2) { + ++i2; + j2 = i2; + } else { + j2 = Math.max(i2, k1); + } + + i2 = j2; + int k2 = i2 - k1; + boolean flag = true; + Iterator iterator1 = map.keySet().iterator(); + + while (iterator1.hasNext()) { + int l2 = ((Integer) iterator1.next()).intValue(); + + if (l2 != j1 && !enchantment.a(Enchantment.byId[l2])) { + flag = false; + i += k2; + } + } + + if (flag) { + if (i2 > enchantment.getMaxLevel()) { + i2 = enchantment.getMaxLevel(); + } + + map.put(Integer.valueOf(j1), Integer.valueOf(i2)); + byte b1 = 0; + + switch (enchantment.getRandomWeight()) { + case 1: + b1 = 8; + break; + + case 2: + b1 = 4; + + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + default: + break; + + case 5: + b1 = 2; + break; + + case 10: + b1 = 1; + } + + i += b1 * k2; + } + } + } + } + + if (this.m != null && !this.m.equalsIgnoreCase(itemstack.r()) && this.m.length() > 0) { + j = itemstack.f() ? 7 : itemstack.count * 5; + i += j; + if (itemstack.s()) { + k += j / 2; + } + + itemstack1.c(this.m); + } + + l = 0; + + byte b2; + + for (iterator = map.keySet().iterator(); iterator.hasNext(); k += l + k1 * b2) { + j1 = ((Integer) iterator.next()).intValue(); + enchantment = Enchantment.byId[j1]; + k1 = ((Integer) map.get(Integer.valueOf(j1))).intValue(); + b2 = 0; + ++l; + switch (enchantment.getRandomWeight()) { + case 1: + b2 = 8; + break; + + case 2: + b2 = 4; + + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + default: + break; + + case 5: + b2 = 2; + break; + + case 10: + b2 = 1; + } + } + + this.e = k + i; + if (i <= 0) { + itemstack1 = null; + } + + if (j == i && j > 0 && this.e >= 40) { + System.out.println("Naming an item only, cost too high; giving discount to cap cost to 39 levels"); + this.e = 39; + } + + if (this.e >= 40 && !this.n.abilities.canInstantlyBuild) { + itemstack1 = null; + } + + if (itemstack1 != null) { + i1 = itemstack1.getRepairCost(); + if (itemstack2 != null && i1 < itemstack2.getRepairCost()) { + i1 = itemstack2.getRepairCost(); + } + + if (itemstack1.s()) { + i1 -= 5; + } + + if (i1 < 0) { + i1 = 0; + } + + i1 += 2; + itemstack1.setRepairCost(i1); + EnchantmentManager.a(map, itemstack1); + } + + this.f.setItem(0, itemstack1); + this.b(); + } + } + + public void addSlotListener(ICrafting icrafting) { + super.addSlotListener(icrafting); + icrafting.setContainerData(this, 0, this.e); + } + + public void a(EntityHuman entityhuman) { + super.a(entityhuman); + if (!this.h.isStatic) { + for (int i = 0; i < this.g.getSize(); ++i) { + ItemStack itemstack = this.g.splitWithoutUpdate(i); + + if (itemstack != null) { + entityhuman.drop(itemstack); + } + } + } + } + + public boolean c(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit + return this.h.getTypeId(this.i, this.j, this.k) != Block.ANVIL.id ? false : entityhuman.e((double) this.i + 0.5D, (double) this.j + 0.5D, (double) this.k + 0.5D) <= 64.0D; + } + + public ItemStack b(EntityHuman entityhuman, int i) { + ItemStack itemstack = null; + Slot slot = (Slot) this.b.get(i); + + if (slot != null && slot.d()) { + ItemStack itemstack1 = slot.getItem(); + + itemstack = itemstack1.cloneItemStack(); + if (i == 2) { + if (!this.a(itemstack1, 3, 39, true)) { + return null; + } + + slot.a(itemstack1, itemstack); + } else if (i != 0 && i != 1) { + if (i >= 3 && i < 39 && !this.a(itemstack1, 0, 2, false)) { + return null; + } + } else if (!this.a(itemstack1, 3, 39, false)) { + return null; + } + + if (itemstack1.count == 0) { + slot.set((ItemStack) null); + } else { + slot.e(); + } + + if (itemstack1.count == itemstack.count) { + return null; + } + + slot.a(entityhuman, itemstack1); + } + + return itemstack; + } + + public void a(String s) { + this.m = s; + if (this.getSlot(2).d()) { + this.getSlot(2).getItem().c(this.m); + } + + this.d(); + } + + static IInventory a(ContainerAnvil containeranvil) { + return containeranvil.g; + } + + static int b(ContainerAnvil containeranvil) { + return containeranvil.l; + } + + // CraftBukkit start + public CraftInventoryView getBukkitView() { + if (bukkitEntity != null) { + return bukkitEntity; + } + + CraftInventory inventory = new CraftInventoryAnvil(this.g); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end +} diff --git a/src/main/java/net/minecraft/server/ContainerAnvilInventory.java b/src/main/java/net/minecraft/server/ContainerAnvilInventory.java new file mode 100644 index 00000000..6a24bca3 --- /dev/null +++ b/src/main/java/net/minecraft/server/ContainerAnvilInventory.java @@ -0,0 +1,53 @@ +package net.minecraft.server; + +// CraftBukkit start +import java.util.List; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + +public class ContainerAnvilInventory extends InventorySubcontainer { // CraftBukkit - public + + final ContainerAnvil a; + + // CraftBukkit start + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + public org.bukkit.entity.Player player; + private int maxStack = MAX_STACK; + + public ItemStack[] getContents() { + return this.items; + } + + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + public List<HumanEntity> getViewers() { + return transaction; + } + + public org.bukkit.inventory.InventoryHolder getOwner() { + return this.player; + } + + public void setMaxStackSize(int size) { + maxStack = size; + } + // CraftBukkit end + + ContainerAnvilInventory(ContainerAnvil containeranvil, String s, int i) { + super(s, i); + this.a = containeranvil; + this.setMaxStackSize(1); // CraftBukkit + } + + public void update() { + super.update(); + this.a.a((IInventory) this); + } +} diff --git a/src/main/java/net/minecraft/server/ContainerBeacon.java b/src/main/java/net/minecraft/server/ContainerBeacon.java new file mode 100644 index 00000000..95bb5fcc --- /dev/null +++ b/src/main/java/net/minecraft/server/ContainerBeacon.java @@ -0,0 +1,122 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + +public class ContainerBeacon extends Container { + + private TileEntityBeacon e; + private final SlotBeacon f; + private int g; + private int h; + private int i; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end + + public ContainerBeacon(PlayerInventory playerinventory, TileEntityBeacon tileentitybeacon) { + player = playerinventory; // CraftBukkit + this.e = tileentitybeacon; + this.a(this.f = new SlotBeacon(this, tileentitybeacon, 0, 136, 110)); + byte b0 = 36; + short short1 = 137; + + int i; + + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.a(new Slot(playerinventory, j + i * 9 + 9, b0 + j * 18, short1 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) { + this.a(new Slot(playerinventory, i, b0 + i * 18, 58 + short1)); + } + + this.g = tileentitybeacon.k(); + this.h = tileentitybeacon.i(); + this.i = tileentitybeacon.j(); + } + + public void addSlotListener(ICrafting icrafting) { + super.addSlotListener(icrafting); + icrafting.setContainerData(this, 0, this.g); + icrafting.setContainerData(this, 1, this.h); + icrafting.setContainerData(this, 2, this.i); + } + + public void b() { + super.b(); + } + + public TileEntityBeacon d() { + return this.e; + } + + public boolean c(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit + return this.e.a(entityhuman); + } + + public ItemStack b(EntityHuman entityhuman, int i) { + ItemStack itemstack = null; + Slot slot = (Slot) this.b.get(i); + + if (slot != null && slot.d()) { + ItemStack itemstack1 = slot.getItem(); + + itemstack = itemstack1.cloneItemStack(); + if (i == 0) { + if (!this.a(itemstack1, 1, 37, true)) { + return null; + } + + slot.a(itemstack1, itemstack); + } else if (!this.f.d() && this.f.isAllowed(itemstack1) && itemstack1.count == 1) { + if (!this.a(itemstack1, 0, 1, false)) { + return null; + } + } else if (i >= 1 && i < 28) { + if (!this.a(itemstack1, 28, 37, false)) { + return null; + } + } else if (i >= 28 && i < 37) { + if (!this.a(itemstack1, 1, 28, false)) { + return null; + } + } else if (!this.a(itemstack1, 1, 37, false)) { + return null; + } + + if (itemstack1.count == 0) { + slot.set((ItemStack) null); + } else { + slot.e(); + } + + if (itemstack1.count == itemstack.count) { + return null; + } + + slot.a(entityhuman, itemstack1); + } + + return itemstack; + } + + // CraftBukkit start + public CraftInventoryView getBukkitView() { + if (bukkitEntity != null) { + return bukkitEntity; + } + + CraftInventory inventory = new CraftInventoryBeacon(this.e); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } + // CraftBukkit end +} diff --git a/src/main/java/net/minecraft/server/ContainerBrewingStand.java b/src/main/java/net/minecraft/server/ContainerBrewingStand.java index fa068f6c..0854fdb0 100644 --- a/src/main/java/net/minecraft/server/ContainerBrewingStand.java +++ b/src/main/java/net/minecraft/server/ContainerBrewingStand.java @@ -40,7 +40,7 @@ public class ContainerBrewingStand extends Container { public void addSlotListener(ICrafting icrafting) { super.addSlotListener(icrafting); - icrafting.setContainerData(this, 0, this.brewingStand.t_()); + icrafting.setContainerData(this, 0, this.brewingStand.x_()); } public void b() { @@ -50,12 +50,12 @@ public class ContainerBrewingStand extends Container { while (iterator.hasNext()) { ICrafting icrafting = (ICrafting) iterator.next(); - if (this.g != this.brewingStand.t_()) { - icrafting.setContainerData(this, 0, this.brewingStand.t_()); + if (this.g != this.brewingStand.x_()) { + icrafting.setContainerData(this, 0, this.brewingStand.x_()); } } - this.g = this.brewingStand.t_(); + this.g = this.brewingStand.x_(); } public boolean c(EntityHuman entityhuman) { @@ -63,7 +63,7 @@ public class ContainerBrewingStand extends Container { return this.brewingStand.a(entityhuman); } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -109,7 +109,7 @@ public class ContainerBrewingStand extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerChest.java b/src/main/java/net/minecraft/server/ContainerChest.java index 6f3c93ac..c0e70ead 100644 --- a/src/main/java/net/minecraft/server/ContainerChest.java +++ b/src/main/java/net/minecraft/server/ContainerChest.java @@ -67,7 +67,7 @@ public class ContainerChest extends Container { return this.container.a(entityhuman); } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); diff --git a/src/main/java/net/minecraft/server/ContainerDispenser.java b/src/main/java/net/minecraft/server/ContainerDispenser.java index 93148601..04025026 100644 --- a/src/main/java/net/minecraft/server/ContainerDispenser.java +++ b/src/main/java/net/minecraft/server/ContainerDispenser.java @@ -45,7 +45,7 @@ public class ContainerDispenser extends Container { return this.items.a(entityhuman); } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -71,7 +71,7 @@ public class ContainerDispenser extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java index 3269a218..ded13548 100644 --- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java +++ b/src/main/java/net/minecraft/server/ContainerEnchantTable.java @@ -81,7 +81,7 @@ public class ContainerEnchantTable extends Container { ItemStack itemstack = iinventory.getItem(0); int i; - if (itemstack != null && itemstack.u()) { + if (itemstack != null && itemstack.v()) { this.f = this.l.nextLong(); if (!this.world.isStatic) { i = 0; @@ -171,7 +171,7 @@ public class ContainerEnchantTable extends Container { return false; } - entityhuman.levelDown(level); + entityhuman.levelDown(-level); for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) { try { item.addEnchantment(entry.getKey(), entry.getValue()); @@ -207,7 +207,7 @@ public class ContainerEnchantTable extends Container { return this.world.getTypeId(this.x, this.y, this.z) != Block.ENCHANTMENT_TABLE.id ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -243,7 +243,7 @@ public class ContainerEnchantTable extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerFurnace.java b/src/main/java/net/minecraft/server/ContainerFurnace.java index 1770a676..5952c3b3 100644 --- a/src/main/java/net/minecraft/server/ContainerFurnace.java +++ b/src/main/java/net/minecraft/server/ContainerFurnace.java @@ -86,7 +86,7 @@ public class ContainerFurnace extends Container { return this.furnace.a(entityhuman); } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -130,7 +130,7 @@ public class ContainerFurnace extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerMerchant.java b/src/main/java/net/minecraft/server/ContainerMerchant.java index 1f242ded..925718ff 100644 --- a/src/main/java/net/minecraft/server/ContainerMerchant.java +++ b/src/main/java/net/minecraft/server/ContainerMerchant.java @@ -60,15 +60,15 @@ public class ContainerMerchant extends Container { super.a(iinventory); } - public void c(int i) { + public void b(int i) { this.f.c(i); } public boolean c(EntityHuman entityhuman) { - return this.merchant.l_() == entityhuman; + return this.merchant.m_() == entityhuman; } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -104,7 +104,7 @@ public class ContainerMerchant extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerPlayer.java b/src/main/java/net/minecraft/server/ContainerPlayer.java index 121663fa..707cccb4 100644 --- a/src/main/java/net/minecraft/server/ContainerPlayer.java +++ b/src/main/java/net/minecraft/server/ContainerPlayer.java @@ -7,25 +7,22 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryView; public class ContainerPlayer extends Container { - public InventoryCrafting craftInventory; - public IInventory resultInventory; - public boolean g; + public InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2); + public IInventory resultInventory = new InventoryCraftResult(); + public boolean g = false; + private final EntityHuman h; // CraftBukkit start private CraftInventoryView bukkitEntity = null; private PlayerInventory player; // CraftBukkit end - public ContainerPlayer(PlayerInventory playerinventory) { - this(playerinventory, true); - } - - public ContainerPlayer(PlayerInventory playerinventory, boolean flag) { + public ContainerPlayer(PlayerInventory playerinventory, boolean flag, EntityHuman entityhuman) { + this.g = flag; + this.h = entityhuman; this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot this.player = playerinventory; // CraftBukkit - save player - this.g = false; - this.g = flag; this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 144, 36))); int i; @@ -57,7 +54,7 @@ public class ContainerPlayer extends Container { public void a(IInventory iinventory) { // CraftBukkit start (Note: the following line would cause an error if called during construction) CraftingManager.getInstance().lastCraftView = getBukkitView(); - ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory); + ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.h.world); this.resultInventory.setItem(0, craftResult); if (super.listeners.size() < 1) { return; @@ -86,7 +83,7 @@ public class ContainerPlayer extends Container { return true; } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -136,7 +133,7 @@ public class ContainerPlayer extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java index d1e61170..42f91a9d 100644 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ b/src/main/java/net/minecraft/server/ContainerWorkbench.java @@ -56,7 +56,7 @@ public class ContainerWorkbench extends Container { public void a(IInventory iinventory) { // CraftBukkit start CraftingManager.getInstance().lastCraftView = getBukkitView(); - ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory); + ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.g); this.resultInventory.setItem(0, craftResult); if (super.listeners.size() < 1) { return; @@ -85,7 +85,7 @@ public class ContainerWorkbench extends Container { return this.g.getTypeId(this.h, this.i, this.j) != Block.WORKBENCH.id ? false : entityhuman.e((double) this.h + 0.5D, (double) this.i + 0.5D, (double) this.j + 0.5D) <= 64.0D; } - public ItemStack b(int i) { + public ItemStack b(EntityHuman entityhuman, int i) { ItemStack itemstack = null; Slot slot = (Slot) this.b.get(i); @@ -121,7 +121,7 @@ public class ContainerWorkbench extends Container { return null; } - slot.b(itemstack1); + slot.a(entityhuman, itemstack1); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java index 1f323d7b..52595428 100644 --- a/src/main/java/net/minecraft/server/ControllerLook.java +++ b/src/main/java/net/minecraft/server/ControllerLook.java @@ -53,20 +53,20 @@ public class ControllerLook { // CraftBukkit end this.a.pitch = this.a(this.a.pitch, f1, this.c); - this.a.as = this.a(this.a.as, f, this.b); + this.a.ay = this.a(this.a.ay, f, this.b); } else { - this.a.as = this.a(this.a.as, this.a.aq, 10.0F); + this.a.ay = this.a(this.a.ay, this.a.aw, 10.0F); } - float f2 = MathHelper.g(this.a.as - this.a.aq); + float f2 = MathHelper.g(this.a.ay - this.a.aw); if (!this.a.getNavigation().f()) { if (f2 < -75.0F) { - this.a.as = this.a.aq - 75.0F; + this.a.ay = this.a.aw - 75.0F; } if (f2 > 75.0F) { - this.a.as = this.a.aq + 75.0F; + this.a.ay = this.a.aw + 75.0F; } } } diff --git a/src/main/java/net/minecraft/server/ControllerMove.java b/src/main/java/net/minecraft/server/ControllerMove.java index 15fc0a6d..1fad9432 100644 --- a/src/main/java/net/minecraft/server/ControllerMove.java +++ b/src/main/java/net/minecraft/server/ControllerMove.java @@ -47,7 +47,7 @@ public class ControllerMove { float f = (float) (org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F; this.a.yaw = this.a(this.a.yaw, f, 30.0F); - this.a.e(this.e); + this.a.e(this.e * this.a.by()); if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) { this.a.getControllerJump().a(); } diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java index 72cd878f..aa89ce1b 100644 --- a/src/main/java/net/minecraft/server/CraftingManager.java +++ b/src/main/java/net/minecraft/server/CraftingManager.java @@ -11,8 +11,8 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit public class CraftingManager { private static final CraftingManager a = new CraftingManager(); - public List recipes = new ArrayList(); // CraftBukkit - private -> public // CraftBukkit start + public List recipes = new ArrayList(); // private -> public public IRecipe lastRecipe; public org.bukkit.inventory.InventoryView lastCraftView; // CraftBukkit end @@ -21,7 +21,8 @@ public class CraftingManager { return a; } - public CraftingManager() { // CraftBukkit - private -> public + // CraftBukkit - private -> public + public CraftingManager() { (new RecipesTools()).a(this); (new RecipesWeapons()).a(this); (new RecipeIngots()).a(this); @@ -29,10 +30,15 @@ public class CraftingManager { (new RecipesCrafting()).a(this); (new RecipesArmor()).a(this); (new RecipesDyes()).a(this); + this.recipes.add(new RecipesArmorDye()); + this.recipes.add(new RecipesMapClone()); + this.recipes.add(new RecipesMapExtend()); this.registerShapedRecipe(new ItemStack(Item.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Item.SUGAR_CANE}); this.registerShapelessRecipe(new ItemStack(Item.BOOK, 1), new Object[] { Item.PAPER, Item.PAPER, Item.PAPER, Item.LEATHER}); this.registerShapelessRecipe(new ItemStack(Item.BOOK_AND_QUILL, 1), new Object[] { Item.BOOK, new ItemStack(Item.INK_SACK, 1, 0), Item.FEATHER}); this.registerShapedRecipe(new ItemStack(Block.FENCE, 2), new Object[] { "###", "###", Character.valueOf('#'), Item.STICK}); + this.registerShapedRecipe(new ItemStack(Block.COBBLE_WALL, 6, 0), new Object[] { "###", "###", Character.valueOf('#'), Block.COBBLESTONE}); + this.registerShapedRecipe(new ItemStack(Block.COBBLE_WALL, 6, 1), new Object[] { "###", "###", Character.valueOf('#'), Block.MOSSY_COBBLESTONE}); 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}); @@ -80,6 +86,7 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Item.POWERED_MINECART, 1), new Object[] { "A", "B", Character.valueOf('A'), Block.FURNACE, Character.valueOf('B'), Item.MINECART}); this.registerShapedRecipe(new ItemStack(Item.BOAT, 1), new Object[] { "# #", "###", Character.valueOf('#'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Item.BUCKET, 1), new Object[] { "# #", " # ", Character.valueOf('#'), Item.IRON_INGOT}); + this.registerShapedRecipe(new ItemStack(Item.FLOWER_POT, 1), new Object[] { "# #", " # ", Character.valueOf('#'), Item.CLAY_BRICK}); this.registerShapedRecipe(new ItemStack(Item.FLINT_AND_STEEL, 1), new Object[] { "A ", " B", Character.valueOf('A'), Item.IRON_INGOT, Character.valueOf('B'), Item.FLINT}); this.registerShapedRecipe(new ItemStack(Item.BREAD, 1), new Object[] { "###", Character.valueOf('#'), Item.WHEAT}); this.registerShapedRecipe(new ItemStack(Block.WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Block.WOOD, 1, 0)}); @@ -87,22 +94,26 @@ public class CraftingManager { this.registerShapedRecipe(new ItemStack(Block.SPRUCE_WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Block.WOOD, 1, 1)}); this.registerShapedRecipe(new ItemStack(Block.JUNGLE_WOOD_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), new ItemStack(Block.WOOD, 1, 3)}); this.registerShapedRecipe(new ItemStack(Item.FISHING_ROD, 1), new Object[] { " #", " #X", "# X", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.STRING}); + this.registerShapedRecipe(new ItemStack(Item.CARROT_STICK, 1), new Object[] { "# ", " X", Character.valueOf('#'), Item.FISHING_ROD, Character.valueOf('X'), Item.CARROT}); 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(Block.SANDSTONE_STAIRS, 4), new Object[] { "# ", "## ", "###", Character.valueOf('#'), Block.SANDSTONE}); this.registerShapedRecipe(new ItemStack(Item.PAINTING, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Block.WOOL}); + this.registerShapedRecipe(new ItemStack(Item.ITEM_FRAME, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.LEATHER}); this.registerShapedRecipe(new ItemStack(Item.GOLDEN_APPLE, 1, 0), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.GOLD_NUGGET, Character.valueOf('X'), Item.APPLE}); this.registerShapedRecipe(new ItemStack(Item.GOLDEN_APPLE, 1, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Block.GOLD_BLOCK, Character.valueOf('X'), Item.APPLE}); + this.registerShapedRecipe(new ItemStack(Item.CARROT_GOLDEN, 1, 0), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.GOLD_NUGGET, Character.valueOf('X'), Item.CARROT}); this.registerShapedRecipe(new ItemStack(Block.LEVER, 1), new Object[] { "X", "#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.STICK}); this.registerShapedRecipe(new ItemStack(Block.TRIPWIRE_SOURCE, 2), new Object[] { "I", "S", "#", Character.valueOf('#'), Block.WOOD, Character.valueOf('S'), Item.STICK, Character.valueOf('I'), Item.IRON_INGOT}); this.registerShapedRecipe(new ItemStack(Block.REDSTONE_TORCH_ON, 1), new Object[] { "X", "#", Character.valueOf('#'), Item.STICK, Character.valueOf('X'), Item.REDSTONE}); this.registerShapedRecipe(new ItemStack(Item.DIODE, 1), new Object[] { "#X#", "III", Character.valueOf('#'), Block.REDSTONE_TORCH_ON, Character.valueOf('X'), Item.REDSTONE, Character.valueOf('I'), Block.STONE}); this.registerShapedRecipe(new ItemStack(Item.WATCH, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Item.GOLD_INGOT, Character.valueOf('X'), Item.REDSTONE}); this.registerShapedRecipe(new ItemStack(Item.COMPASS, 1), new Object[] { " # ", "#X#", " # ", Character.valueOf('#'), Item.IRON_INGOT, Character.valueOf('X'), Item.REDSTONE}); - this.registerShapedRecipe(new ItemStack(Item.MAP, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.PAPER, Character.valueOf('X'), Item.COMPASS}); - this.registerShapedRecipe(new ItemStack(Block.STONE_BUTTON, 1), new Object[] { "#", "#", Character.valueOf('#'), Block.STONE}); + this.registerShapedRecipe(new ItemStack(Item.MAP_EMPTY, 1), new Object[] { "###", "#X#", "###", Character.valueOf('#'), Item.PAPER, Character.valueOf('X'), Item.COMPASS}); + this.registerShapedRecipe(new ItemStack(Block.STONE_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Block.STONE}); + this.registerShapedRecipe(new ItemStack(Block.WOOD_BUTTON, 1), new Object[] { "#", Character.valueOf('#'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Block.STONE_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Block.STONE}); this.registerShapedRecipe(new ItemStack(Block.WOOD_PLATE, 1), new Object[] { "##", Character.valueOf('#'), Block.WOOD}); this.registerShapedRecipe(new ItemStack(Block.DISPENSER, 1), new Object[] { "###", "#X#", "#R#", Character.valueOf('#'), Block.COBBLESTONE, Character.valueOf('X'), Item.BOW, Character.valueOf('R'), Item.REDSTONE}); @@ -110,11 +121,12 @@ public class CraftingManager { 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.registerShapedRecipe(new ItemStack(Block.ANVIL, 1), new Object[] { "III", " i ", "iii", Character.valueOf('I'), Block.IRON_BLOCK, Character.valueOf('i'), Item.IRON_INGOT}); this.registerShapelessRecipe(new ItemStack(Item.EYE_OF_ENDER, 1), new Object[] { Item.ENDER_PEARL, Item.BLAZE_POWDER}); this.registerShapelessRecipe(new ItemStack(Item.FIREBALL, 3), new Object[] { Item.SULPHUR, Item.BLAZE_POWDER, Item.COAL}); this.registerShapelessRecipe(new ItemStack(Item.FIREBALL, 3), new Object[] { Item.SULPHUR, Item.BLAZE_POWDER, new ItemStack(Item.COAL, 1, 1)}); - //Collections.sort(this.b, new RecipeSorter(this)); // CraftBukkit - removed; see below - this.sort(); // CraftBukkit - moved sort to a separate method + // Collections.sort(this.recipes, new RecipeSorter(this)); // CraftBukkit - moved below + this.sort(); // CraftBukkit - call new sort method System.out.println(this.recipes.size() + " recipes"); } @@ -124,7 +136,8 @@ public class CraftingManager { } // CraftBukkit end - public void registerShapedRecipe(ItemStack itemstack, Object... aobject) { // CraftBukkit - default -> public + // CraftBukkit - default -> public + public void registerShapedRecipe(ItemStack itemstack, Object... aobject) { String s = ""; int i = 0; int j = 0; @@ -186,7 +199,8 @@ public class CraftingManager { this.recipes.add(new ShapedRecipes(j, k, aitemstack, itemstack)); } - public void registerShapelessRecipe(ItemStack itemstack, Object... aobject) { // CraftBukkit - default -> public + // CraftBukkit - default -> public + public void registerShapelessRecipe(ItemStack itemstack, Object... aobject) { ArrayList arraylist = new ArrayList(); Object[] aobject1 = aobject; int i = aobject.length; @@ -210,7 +224,7 @@ public class CraftingManager { this.recipes.add(new ShapelessRecipes(itemstack, arraylist)); } - public ItemStack craft(InventoryCrafting inventorycrafting) { + public ItemStack craft(InventoryCrafting inventorycrafting, World world) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; @@ -231,11 +245,11 @@ public class CraftingManager { } } - if (i == 2 && itemstack.id == itemstack1.id && itemstack.count == 1 && itemstack1.count == 1 && Item.byId[itemstack.id].m()) { + if (i == 2 && itemstack.id == itemstack1.id && itemstack.count == 1 && itemstack1.count == 1 && Item.byId[itemstack.id].n()) { Item item = Item.byId[itemstack.id]; int k = item.getMaxDurability() - itemstack.i(); int l = item.getMaxDurability() - itemstack1.i(); - int i1 = k + l + item.getMaxDurability() * 10 / 100; + int i1 = k + l + item.getMaxDurability() * 5 / 100; int j1 = item.getMaxDurability() - i1; if (j1 < 0) { @@ -263,11 +277,11 @@ public class CraftingManager { } irecipe = (IRecipe) iterator.next(); - } while (!irecipe.a(inventorycrafting)); + } while (!irecipe.a(inventorycrafting, world)); // CraftBukkit start - INVENTORY_PRE_CRAFT event inventorycrafting.currentRecipe = irecipe; - ItemStack result = irecipe.b(inventorycrafting); + ItemStack result = irecipe.a(inventorycrafting); return CraftEventFactory.callPreCraftEvent(inventorycrafting, result, lastCraftView, false); // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/CrashReport.java b/src/main/java/net/minecraft/server/CrashReport.java index 42110c3a..b5da924c 100644 --- a/src/main/java/net/minecraft/server/CrashReport.java +++ b/src/main/java/net/minecraft/server/CrashReport.java @@ -35,6 +35,7 @@ public class CrashReport { this.a("Java VM Version", (Callable) (new CrashReportJavaVMVersion(this))); this.a("Memory", (Callable) (new CrashReportMemory(this))); this.a("JVM Flags", (Callable) (new CrashReportJVMFlags(this))); + this.a("AABB Pool Size", (Callable) (new CrashReportAABBPoolSize(this))); this.a("CraftBukkit Information", (Callable) (new org.bukkit.craftbukkit.CraftCrashReport())); // CraftBukkit } diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java index 92b4c949..5121cd61 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -47,18 +47,18 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer System.setErr(new PrintStream(new LoggerOutputStream(log, Level.SEVERE), true)); // CraftBukkit end - log.info("Starting minecraft server version 1.3.2"); + log.info("Starting minecraft server version 1.4.2"); if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { log.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } log.info("Loading properties"); this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support - if (this.H()) { - this.e("127.0.0.1"); + if (this.I()) { + this.d("127.0.0.1"); } else { this.setOnlineMode(this.propertyManager.getBoolean("online-mode", true)); - this.e(this.propertyManager.getString("server-ip", "")); + this.d(this.propertyManager.getString("server-ip", "")); } this.setSpawnAnimals(this.propertyManager.getBoolean("spawn-animals", true)); @@ -78,16 +78,16 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer inetaddress = InetAddress.getByName(this.getServerIp()); } - if (this.F() < 0) { + if (this.G() < 0) { this.setPort(this.propertyManager.getInt("server-port", 25565)); } log.info("Generating keypair"); this.a(MinecraftEncryption.b()); - log.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.F()); + log.info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.G()); try { - this.r = new DedicatedServerConnection(this, inetaddress, this.F()); + this.r = new DedicatedServerConnection(this, inetaddress, this.G()); } catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable log.warning("**** FAILED TO BIND TO PORT!"); log.log(Level.WARNING, "The exception was: " + ioexception.toString()); @@ -106,12 +106,13 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor long j = System.nanoTime(); - if (this.I() == null) { - this.m(this.propertyManager.getString("level-name", "world")); + if (this.J() == null) { + this.l(this.propertyManager.getString("level-name", "world")); } String s = this.propertyManager.getString("level-seed", ""); String s1 = this.propertyManager.getString("level-type", "DEFAULT"); + String s2 = this.propertyManager.getString("generator-settings", ""); long k = (new Random()).nextLong(); if (s.length() > 0) { @@ -136,12 +137,12 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.d((this.getMaxBuildHeight() + 8) / 16 * 16); this.d(MathHelper.a(this.getMaxBuildHeight(), 64, 256)); this.propertyManager.a("max-build-height", Integer.valueOf(this.getMaxBuildHeight())); - log.info("Preparing level \"" + this.I() + "\""); - this.a(this.I(), this.I(), k, worldtype); + log.info("Preparing level \"" + this.J() + "\""); + this.a(this.J(), this.J(), k, worldtype, s2); long i1 = System.nanoTime() - j; - String s2 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)}); + String s3 = String.format("%.3fs", new Object[] { Double.valueOf((double) i1 / 1.0E9D)}); - log.info("Done (" + s2 + ")! For help, type \"help\" or \"?\""); + log.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); if (this.propertyManager.getBoolean("enable-query", false)) { log.info("Starting GS4 status listener"); this.m = new RemoteStatusListener(this); @@ -189,7 +190,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer protected void a(CrashReport crashreport) { while (this.isRunning()) { - this.ai(); + this.al(); try { Thread.sleep(10L); @@ -205,13 +206,13 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer return crashreport; } - protected void o() { + protected void p() { System.exit(0); } - public void q() { - super.q(); - this.ai(); + public void r() { + super.r(); + this.al(); } public boolean getAllowNether() { @@ -223,8 +224,8 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { - mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(this.aj().getHasWhitelist())); - mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(this.aj().getWhitelisted().size())); + mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(this.am().getHasWhitelist())); + mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(this.am().getWhitelisted().size())); super.a(mojangstatisticsgenerator); } @@ -236,7 +237,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.l.add(new ServerCommand(s, icommandlistener)); } - public void ai() { + public void al() { while (!this.l.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.l.remove(0); @@ -251,15 +252,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } } - public boolean S() { + public boolean T() { return true; } - public ServerConfigurationManager aj() { + public ServerConfigurationManager am() { return (ServerConfigurationManager) super.getServerConfigurationManager(); } - public ServerConnection ac() { + public ServerConnection ae() { return this.r; } @@ -283,18 +284,18 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer this.propertyManager.savePropertiesFile(); } - public String c() { + public String b_() { File file1 = this.propertyManager.c(); return file1 != null ? file1.getAbsolutePath() : "No settings file"; } - public void ak() { + public void an() { ServerGUI.a(this); this.s = true; } - public boolean ae() { + public boolean ag() { return this.s; } @@ -302,7 +303,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer return ""; } + public boolean getEnableCommandBlock() { + return this.propertyManager.getBoolean("enable-command-block", false); + } + + public int getSpawnProtection() { + return this.propertyManager.getInt("spawn-protection", super.getSpawnProtection()); + } + public ServerConfigurationManagerAbstract getServerConfigurationManager() { - return this.aj(); + return this.am(); } } diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java b/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java new file mode 100644 index 00000000..2cb9e3d0 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorBoat.java @@ -0,0 +1,77 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorBoat extends DispenseBehaviorItem { + + private final DispenseBehaviorItem c; + + final MinecraftServer b; + + public DispenseBehaviorBoat(MinecraftServer minecraftserver) { + this.b = minecraftserver; + this.c = new DispenseBehaviorItem(); + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + World world = isourceblock.k(); + double d0 = isourceblock.getX() + (double) ((float) enumfacing.c() * 1.125F); + double d1 = isourceblock.getY(); + double d2 = isourceblock.getZ() + (double) ((float) enumfacing.e() * 1.125F); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + Material material = world.getMaterial(i, j, k); + double d3; + + if (Material.WATER.equals(material)) { + d3 = 1.0D; + } else { + if (!Material.AIR.equals(material) || !Material.WATER.equals(world.getMaterial(i, j - 1, k))) { + return this.c.a(isourceblock, itemstack); + } + + d3 = 0.0D; + } + + // CraftBukkit start + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack1).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(d0, d1 + d3, d2)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + itemstack.count++; + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end + + world.addEntity(entityboat); + // itemstack.a(1); // CraftBukkit - handled during event processing + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java b/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java new file mode 100644 index 00000000..6e29c260 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorEmptyBucket.java @@ -0,0 +1,72 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorEmptyBucket extends DispenseBehaviorItem { + + private final DispenseBehaviorItem c; + + final MinecraftServer b; + + public DispenseBehaviorEmptyBucket(MinecraftServer minecraftserver) { + this.b = minecraftserver; + this.c = new DispenseBehaviorItem(); + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + World world = isourceblock.k(); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + Material material = world.getMaterial(i, j, k); + int l = world.getData(i, j, k); + Item item; + + if (Material.WATER.equals(material) && l == 0) { + item = Item.WATER_BUCKET; + } else { + if (!Material.LAVA.equals(material) || l != 0) { + return super.b(isourceblock, itemstack); + } + + item = Item.LAVA_BUCKET; + } + + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + // CraftBukkit end + + world.setTypeId(i, j, k, 0); + if (--itemstack.count == 0) { + itemstack.id = item.id; + itemstack.count = 1; + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { + this.c.a(isourceblock, new ItemStack(item)); + } + + return itemstack; + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java b/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java new file mode 100644 index 00000000..28bedc9a --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorFilledBucket.java @@ -0,0 +1,72 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorFilledBucket extends DispenseBehaviorItem { + + private final DispenseBehaviorItem c; + + final MinecraftServer b; + + public DispenseBehaviorFilledBucket(MinecraftServer minecraftserver) { + this.b = minecraftserver; + this.c = new DispenseBehaviorItem(); + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + ItemBucket itembucket = (ItemBucket) itemstack.getItem(); + int i = isourceblock.getBlockX(); + int j = isourceblock.getBlockY(); + int k = isourceblock.getBlockZ(); + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + + // CraftBukkit start + World world = isourceblock.k(); + int i2 = i + enumfacing.c(); + int k2 = k + enumfacing.e(); + if (world.isEmpty(i2, j, k2) || world.getMaterial(i2, j, k2).isBuildable()) { + org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + itembucket = (ItemBucket) CraftItemStack.createNMSItemStack(event.getItem()).getItem(); + } + // CraftBukkit end + + if (itembucket.a(isourceblock.k(), (double) i, (double) j, (double) k, i + enumfacing.c(), j, k + enumfacing.e())) { + // CraftBukkit start - handle stacked buckets + Item item = Item.BUCKET; + if (--itemstack.count == 0) { + itemstack.id = item.id; + itemstack.count = 1; + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { + this.c.a(isourceblock, new ItemStack(item)); + } + // CraftBukkit end + + return itemstack; + } else { + return this.c.a(isourceblock, itemstack); + } + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java b/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java new file mode 100644 index 00000000..0824fc4f --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorFireball.java @@ -0,0 +1,65 @@ +package net.minecraft.server; + +import java.util.Random; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorFireball extends DispenseBehaviorItem { + + final MinecraftServer b; + + public DispenseBehaviorFireball(MinecraftServer minecraftserver) { + this.b = minecraftserver; + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + IPosition iposition = BlockDispenser.a(isourceblock); + double d0 = iposition.getX() + (double) ((float) enumfacing.c() * 0.3F); + double d1 = iposition.getY(); + double d2 = iposition.getZ() + (double) ((float) enumfacing.e() * 0.3F); + World world = isourceblock.k(); + Random random = world.random; + double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.c(); + double d4 = random.nextGaussian() * 0.05D; + double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.e(); + + // CraftBukkit start + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack1).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(d3, d4, d5)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + itemstack.count++; + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + world.addEntity(new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ())); + // itemstack.a(1); // Handled during event processing + // CraftBukkit end + + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1009, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java new file mode 100644 index 00000000..9cf23dd9 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java @@ -0,0 +1,107 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorItem implements IDispenseBehavior { + + public DispenseBehaviorItem() {} + + public final ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + ItemStack itemstack1 = this.b(isourceblock, itemstack); + + this.a(isourceblock); + this.a(isourceblock, EnumFacing.a(isourceblock.h())); + return itemstack1; + } + + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + IPosition iposition = BlockDispenser.a(isourceblock); + ItemStack itemstack1 = itemstack.a(1); + + // CraftBukkit start + if (!a(isourceblock.k(), itemstack1, 6, enumfacing, isourceblock)) { + itemstack.count++; + } + // CraftBukkit end + + return itemstack; + } + + // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument + public static boolean a(World world, ItemStack itemstack, int i, EnumFacing enumfacing, ISourceBlock isourceblock) { + IPosition iposition = BlockDispenser.a(isourceblock); + // CraftBukkit end + double d0 = iposition.getX(); + double d1 = iposition.getY(); + double d2 = iposition.getZ(); + EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); + double d3 = world.random.nextDouble() * 0.1D + 0.2D; + + entityitem.motX = (double) enumfacing.c() * d3; + entityitem.motY = 0.20000000298023224D; + entityitem.motZ = (double) enumfacing.e() * d3; + entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i; + entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i; + entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i; + + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(entityitem.motX, entityitem.motY, entityitem.motZ)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + return false; + } + + entityitem.itemStack = CraftItemStack.createNMSItemStack(event.getItem()); + entityitem.motX = event.getVelocity().getX(); + entityitem.motY = event.getVelocity().getY(); + entityitem.motZ = event.getVelocity().getZ(); + // CraftBukkit end + + world.addEntity(entityitem); + + // CraftBukkit start + if (!event.getItem().equals(bukkitItem)) { + if (event.getItem().getTypeId() == Item.BUCKET.id) { + int x = isourceblock.getBlockX() + enumfacing.c(); + int y = isourceblock.getBlockY(); + int z = isourceblock.getBlockZ() + enumfacing.e(); + Material material = world.getMaterial(x, y, z); + int data = world.getData(x, y, z); + if (!(Material.WATER.equals(material) || Material.LAVA.equals(material)) || data != 0) { + return true; + } + } + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior.getClass() != DispenseBehaviorItem.class) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + } + return false; + } + + return true; + // CraftBukkit end + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } + + protected void a(ISourceBlock isourceblock, EnumFacing enumfacing) { + isourceblock.k().triggerEffect(2000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), this.a(enumfacing)); + } + + private int a(EnumFacing enumfacing) { + return enumfacing.c() + 1 + (enumfacing.e() + 1) * 3; + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java b/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java new file mode 100644 index 00000000..c429abe9 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorMinecart.java @@ -0,0 +1,78 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorMinecart extends DispenseBehaviorItem { + + private final DispenseBehaviorItem c; + + final MinecraftServer b; + + public DispenseBehaviorMinecart(MinecraftServer minecraftserver) { + this.b = minecraftserver; + this.c = new DispenseBehaviorItem(); + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + World world = isourceblock.k(); + double d0 = isourceblock.getX() + (double) ((float) enumfacing.c() * 1.125F); + double d1 = isourceblock.getY(); + double d2 = isourceblock.getZ() + (double) ((float) enumfacing.e() * 1.125F); + int i = isourceblock.getBlockX() + enumfacing.c(); + int j = isourceblock.getBlockY(); + int k = isourceblock.getBlockZ() + enumfacing.e(); + int l = world.getTypeId(i, j, k); + double d3; + + if (BlockMinecartTrack.d(l)) { + d3 = 0.0D; + } else { + if (l != 0 || !BlockMinecartTrack.d(world.getTypeId(i, j - 1, k))) { + return this.c.a(isourceblock, itemstack); + } + + d3 = -1.0D; + } + + // CraftBukkit start + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack1).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(d0, d1 + d3, d2)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + itemstack.count++; + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + itemstack1 = CraftItemStack.createNMSItemStack(event.getItem()); + EntityMinecart entityminecart = new EntityMinecart(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).a); + // CraftBukkit end + + world.addEntity(entityminecart); + // itemstack.a(1); // CraftBukkit - handled during event processing + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1000, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java b/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java new file mode 100644 index 00000000..4895b81c --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorMonsterEgg.java @@ -0,0 +1,58 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public class DispenseBehaviorMonsterEgg extends DispenseBehaviorItem { + + final MinecraftServer b; + + public DispenseBehaviorMonsterEgg(MinecraftServer minecraftserver) { + this.b = minecraftserver; + } + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + double d0 = isourceblock.getX() + (double) enumfacing.c(); + double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F); + double d2 = isourceblock.getZ() + (double) enumfacing.e(); + + // CraftBukkit start + World world = isourceblock.k(); + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack1).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector(d0, d1, d2)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + itemstack.count++; + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + itemstack1 = CraftItemStack.createNMSItemStack(event.getItem()); + ItemMonsterEgg.a(isourceblock.k(), itemstack1.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // itemstack.a(1); // Handled during event processing + // CraftBukkit end + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1002, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } +} diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java b/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java new file mode 100644 index 00000000..ce801b10 --- /dev/null +++ b/src/main/java/net/minecraft/server/DispenseBehaviorProjectile.java @@ -0,0 +1,64 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + +public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem { + + public DispenseBehaviorProjectile() {} + + public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + World world = isourceblock.k(); + IPosition iposition = BlockDispenser.a(isourceblock); + EnumFacing enumfacing = EnumFacing.a(isourceblock.h()); + IProjectile iprojectile = this.a(world, iposition); + + // CraftBukkit start + ItemStack itemstack1 = itemstack.a(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ()); + org.bukkit.inventory.ItemStack bukkitItem = new CraftItemStack(itemstack1).clone(); + + BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new org.bukkit.util.Vector((double) enumfacing.c(), 0.10000000149011612D, (double) enumfacing.e())); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { + itemstack.count++; + return itemstack; + } + + if (!event.getItem().equals(bukkitItem)) { + itemstack.count++; + // Chain to handler for new item + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.a(itemstack.getItem()); + if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) { + idispensebehavior.a(isourceblock, CraftItemStack.createNMSItemStack(event.getItem())); + return itemstack; + } + } + + iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a()); + // CraftBukkit end + + world.addEntity((Entity) iprojectile); + // itemstack.a(1); // CraftBukkit - Handled during event processing + return itemstack; + } + + protected void a(ISourceBlock isourceblock) { + isourceblock.k().triggerEffect(1002, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0); + } + + protected abstract IProjectile a(World world, IPosition iposition); + + protected float a() { + return 6.0F; + } + + protected float b() { + return 1.1F; + } +} diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 8b02cf3a..ddbb9c45 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -63,33 +63,39 @@ public abstract class Entity { public float length; public float P; public float Q; + public float R; public float fallDistance; - private int b; - public double S; + private int c; public double T; public double U; - public float V; + public double V; public float W; - public boolean X; - public float Y; + public float X; + public boolean Y; + public float Z; protected Random random; public int ticksLived; public int maxFireTicks; public int fireTicks; // CraftBukkit - private -> public - protected boolean ac; + protected boolean ad; public int noDamageTicks; private boolean justCreated; protected boolean fireProof; protected DataWatcher datawatcher; - private double e; private double f; - public boolean ag; - public int ah; + private double g; + public boolean ah; public int ai; public int aj; - public boolean ak; + public int ak; public boolean al; - public EnumEntitySize am; + public boolean am; + public int an; + protected boolean ao; + private int h; + public int dimension; + protected int aq; + public EnumEntitySize ar; public UUID uniqueId = UUID.randomUUID(); // CraftBukkit public boolean valid = false; // CraftBukkit @@ -108,25 +114,31 @@ public abstract class Entity { this.length = 1.8F; this.P = 0.0F; this.Q = 0.0F; + this.R = 0.0F; this.fallDistance = 0.0F; - this.b = 1; - this.V = 0.0F; + this.c = 1; this.W = 0.0F; - this.X = false; - this.Y = 0.0F; + this.X = 0.0F; + this.Y = false; + this.Z = 0.0F; this.random = new Random(); this.ticksLived = 0; this.maxFireTicks = 1; this.fireTicks = 0; - this.ac = false; + this.ad = false; this.noDamageTicks = 0; this.justCreated = true; this.fireProof = false; this.datawatcher = new DataWatcher(); - this.ag = false; - this.am = EnumEntitySize.SIZE_2; + this.ah = false; + this.aq = 0; + this.ar = EnumEntitySize.SIZE_2; this.world = world; this.setPosition(0.0D, 0.0D, 0.0D); + if (world != null) { + this.dimension = world.worldProvider.dimension; + } + this.datawatcher.a(0, Byte.valueOf((byte) 0)); this.datawatcher.a(1, Short.valueOf((short) 300)); this.a(); @@ -156,17 +168,17 @@ public abstract class Entity { float f2 = f % 2.0F; if ((double) f2 < 0.375D) { - this.am = EnumEntitySize.SIZE_1; + this.ar = EnumEntitySize.SIZE_1; } else if ((double) f2 < 0.75D) { - this.am = EnumEntitySize.SIZE_2; + this.ar = EnumEntitySize.SIZE_2; } else if ((double) f2 < 1.0D) { - this.am = EnumEntitySize.SIZE_3; + this.ar = EnumEntitySize.SIZE_3; } else if ((double) f2 < 1.375D) { - this.am = EnumEntitySize.SIZE_4; + this.ar = EnumEntitySize.SIZE_4; } else if ((double) f2 < 1.75D) { - this.am = EnumEntitySize.SIZE_5; + this.ar = EnumEntitySize.SIZE_5; } else { - this.am = EnumEntitySize.SIZE_6; + this.ar = EnumEntitySize.SIZE_6; } } @@ -209,14 +221,14 @@ public abstract class Entity { float f = this.width / 2.0F; float f1 = this.length; - this.boundingBox.b(d0 - (double) f, d1 - (double) this.height + (double) this.V, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.V + (double) f1, d2 + (double) f); + this.boundingBox.b(d0 - (double) f, d1 - (double) this.height + (double) this.W, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.W + (double) f1, d2 + (double) f); } - public void h_() { - this.z(); + public void j_() { + this.y(); } - public void z() { + public void y() { this.world.methodProfiler.a("entityBaseTick"); if (this.vehicle != null && this.vehicle.dead) { this.vehicle = null; @@ -231,50 +243,89 @@ public abstract class Entity { this.lastYaw = this.yaw; int i; + if (!this.world.isStatic && this.world instanceof WorldServer) { + MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer(); + + i = this.z(); + if (this.ao) { + // if (minecraftserver.getAllowNether()) { // CraftBukkit + if (this.vehicle == null && this.h++ >= i) { + this.h = i; + this.an = this.ab(); + byte b0; + + if (this.world.worldProvider.dimension == -1) { + b0 = 0; + } else { + b0 = -1; + } + + this.b(b0); + } + + this.ao = false; + // } // CraftBukkit + } else { + if (this.h > 0) { + this.h -= 4; + } + + if (this.h < 0) { + this.h = 0; + } + } + + if (this.an > 0) { + --this.an; + } + } + + int j; + if (this.isSprinting() && !this.H()) { - int j = MathHelper.floor(this.locX); - int k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); + int k = MathHelper.floor(this.locX); - i = MathHelper.floor(this.locZ); - int l = this.world.getTypeId(j, k, i); + i = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); + j = MathHelper.floor(this.locZ); + int l = this.world.getTypeId(k, i, j); if (l > 0) { - this.world.a("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, -this.motX * 4.0D, 1.5D, -this.motZ * 4.0D); + this.world.addParticle("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, -this.motX * 4.0D, 1.5D, -this.motZ * 4.0D); } } if (this.I()) { - if (!this.ac && !this.justCreated) { + if (!this.ad && !this.justCreated) { float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.2F; if (f > 1.0F) { f = 1.0F; } - this.world.makeSound(this, "random.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + this.world.makeSound(this, "liquid.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); float f1 = (float) MathHelper.floor(this.boundingBox.b); float f2; float f3; - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { + for (j = 0; (float) j < 1.0F + this.width * 20.0F; ++j) { f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.a("bubble", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); + this.world.addParticle("bubble", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); } - for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) { + for (j = 0; (float) j < 1.0F + this.width * 20.0F; ++j) { f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.a("splash", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); + this.world.addParticle("splash", this.locX + (double) f3, (double) (f1 + 1.0F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); } } this.fallDistance = 0.0F; - this.ac = true; + this.ad = true; this.fireTicks = 0; } else { - this.ac = false; + this.ad = false; } if (this.world.isStatic) { @@ -324,6 +375,10 @@ public abstract class Entity { this.world.methodProfiler.b(); } + public int z() { + return 0; + } + protected void A() { if (!this.fireProof) { // CraftBukkit start - fallen in lava TODO: this event spams! @@ -387,16 +442,17 @@ public abstract class Entity { } public void move(double d0, double d1, double d2) { - if (this.X) { + if (this.Y) { 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.V; + this.locY = this.boundingBox.b + (double) this.height - (double) this.W; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; } else { this.world.methodProfiler.a("move"); - this.V *= 0.4F; + this.W *= 0.4F; double d3 = this.locX; - double d4 = this.locZ; + double d4 = this.locY; + double d5 = this.locZ; if (this.J) { this.J = false; @@ -408,54 +464,54 @@ public abstract class Entity { this.motZ = 0.0D; } - double d5 = d0; - double d6 = d1; - double d7 = d2; + double d6 = d0; + double d7 = d1; + double d8 = d2; AxisAlignedBB axisalignedbb = this.boundingBox.clone(); boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman; if (flag) { - double d8; + double d9; - for (d8 = 0.05D; d0 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, 0.0D)).isEmpty(); d5 = d0) { - if (d0 < d8 && d0 >= -d8) { + for (d9 = 0.05D; d0 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, 0.0D)).isEmpty(); d6 = d0) { + if (d0 < d9 && d0 >= -d9) { d0 = 0.0D; } else if (d0 > 0.0D) { - d0 -= d8; + d0 -= d9; } else { - d0 += d8; + d0 += d9; } } - for (; d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(0.0D, -1.0D, d2)).isEmpty(); d7 = d2) { - if (d2 < d8 && d2 >= -d8) { + for (; d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(0.0D, -1.0D, d2)).isEmpty(); d8 = d2) { + if (d2 < d9 && d2 >= -d9) { d2 = 0.0D; } else if (d2 > 0.0D) { - d2 -= d8; + d2 -= d9; } else { - d2 += d8; + d2 += d9; } } while (d0 != 0.0D && d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, d2)).isEmpty()) { - if (d0 < d8 && d0 >= -d8) { + if (d0 < d9 && d0 >= -d9) { d0 = 0.0D; } else if (d0 > 0.0D) { - d0 -= d8; + d0 -= d9; } else { - d0 += d8; + d0 += d9; } - if (d2 < d8 && d2 >= -d8) { + if (d2 < d9 && d2 >= -d9) { d2 = 0.0D; } else if (d2 > 0.0D) { - d2 -= d8; + d2 -= d9; } else { - d2 += d8; + d2 += d9; } - d5 = d0; - d7 = d2; + d6 = d0; + d8 = d2; } } @@ -468,13 +524,13 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.K && d6 != d1) { + if (!this.K && d7 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } - boolean flag1 = this.onGround || d6 != d1 && d6 < 0.0D; + boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D; AxisAlignedBB axisalignedbb2; Iterator iterator1; @@ -484,7 +540,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.K && d5 != d0) { + if (!this.K && d6 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -495,27 +551,27 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.K && d7 != d2) { + if (!this.K && d8 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } - double d9; double d10; - - if (this.W > 0.0F && flag1 && (flag || this.V < 0.05F) && (d5 != d0 || d7 != d2)) { - d9 = d0; - d10 = d1; - double d11 = d2; - - d0 = d5; - d1 = (double) this.W; - d2 = d7; + double d11; + double d12; + + if (this.X > 0.0F && flag1 && (flag || this.W < 0.05F) && (d6 != d0 || d8 != d2)) { + d10 = d0; + d11 = d1; + d12 = d2; + d0 = d6; + d1 = (double) this.X; + d2 = d8; AxisAlignedBB axisalignedbb3 = this.boundingBox.clone(); this.boundingBox.c(axisalignedbb); - list = this.world.getCubes(this, this.boundingBox.a(d5, d1, d7)); + list = this.world.getCubes(this, this.boundingBox.a(d6, d1, d8)); Iterator iterator2; AxisAlignedBB axisalignedbb4; @@ -525,7 +581,7 @@ public abstract class Entity { } this.boundingBox.d(0.0D, d1, 0.0D); - if (!this.K && d6 != d1) { + if (!this.K && d7 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -536,7 +592,7 @@ public abstract class Entity { } this.boundingBox.d(d0, 0.0D, 0.0D); - if (!this.K && d5 != d0) { + if (!this.K && d6 != d0) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; @@ -547,18 +603,18 @@ public abstract class Entity { } this.boundingBox.d(0.0D, 0.0D, d2); - if (!this.K && d7 != d2) { + if (!this.K && d8 != d2) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } - if (!this.K && d6 != d1) { + if (!this.K && d7 != d1) { d2 = 0.0D; d1 = 0.0D; d0 = 0.0D; } else { - d1 = (double) (-this.W); + d1 = (double) (-this.X); for (iterator2 = list.iterator(); iterator2.hasNext(); d1 = axisalignedbb4.b(this.boundingBox, d1)) { axisalignedbb4 = (AxisAlignedBB) iterator2.next(); @@ -567,16 +623,16 @@ public abstract class Entity { this.boundingBox.d(0.0D, d1, 0.0D); } - if (d9 * d9 + d11 * d11 >= d0 * d0 + d2 * d2) { - d0 = d9; - d1 = d10; - d2 = d11; + if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) { + d0 = d10; + d1 = d11; + d2 = d12; this.boundingBox.c(axisalignedbb3); } else { - double d12 = this.boundingBox.b - (double) ((int) this.boundingBox.b); + double d13 = this.boundingBox.b - (double) ((int) this.boundingBox.b); - if (d12 > 0.0D) { - this.V = (float) ((double) this.V + d12 + 0.01D); + if (d13 > 0.0D) { + this.W = (float) ((double) this.W + d13 + 0.01D); } } } @@ -584,40 +640,41 @@ public abstract class Entity { this.world.methodProfiler.b(); this.world.methodProfiler.a("rest"); this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D; - this.locY = this.boundingBox.b + (double) this.height - (double) this.V; + this.locY = this.boundingBox.b + (double) this.height - (double) this.W; this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D; - this.positionChanged = d5 != d0 || d7 != d2; - this.G = d6 != d1; - this.onGround = d6 != d1 && d6 < 0.0D; + this.positionChanged = d6 != d0 || d8 != d2; + this.G = d7 != d1; + this.onGround = d7 != d1 && d7 < 0.0D; this.H = this.positionChanged || this.G; this.a(d1, this.onGround); - if (d5 != d0) { + if (d6 != d0) { this.motX = 0.0D; } - if (d6 != d1) { + if (d7 != d1) { this.motY = 0.0D; } - if (d7 != d2) { + if (d8 != d2) { this.motZ = 0.0D; } - d9 = this.locX - d3; - d10 = this.locZ - d4; + d10 = this.locX - d3; + d11 = this.locY - d4; + d12 = this.locZ - d5; // CraftBukkit start if ((this.positionChanged) && (this.getBukkitEntity() instanceof Vehicle)) { Vehicle vehicle = (Vehicle) this.getBukkitEntity(); org.bukkit.block.Block block = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY - (double) this.height), MathHelper.floor(this.locZ)); - if (d5 > d0) { + if (d6 > d0) { block = block.getRelative(BlockFace.SOUTH); - } else if (d5 < d0) { + } else if (d6 < d0) { block = block.getRelative(BlockFace.NORTH); - } else if (d7 > d2) { + } else if (d8 > d2) { block = block.getRelative(BlockFace.WEST); - } else if (d7 < d2) { + } else if (d8 < d2) { block = block.getRelative(BlockFace.EAST); } @@ -626,8 +683,7 @@ public abstract class Entity { } // CraftBukkit end - if (this.e_() && !flag && this.vehicle == null) { - this.Q = (float) ((double) this.Q + (double) MathHelper.sqrt(d9 * d9 + d10 * d10) * 0.6D); + if (this.f_() && !flag && this.vehicle == null) { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); int k = MathHelper.floor(this.locZ); @@ -637,8 +693,24 @@ public abstract class Entity { l = this.world.getTypeId(i, j - 1, k); } - if (this.Q > (float) this.b && l > 0) { - this.b = (int) this.Q + 1; + if (l != Block.LADDER.id) { + d11 = 0.0D; + } + + this.Q = (float) ((double) this.Q + (double) MathHelper.sqrt(d10 * d10 + d12 * d12) * 0.6D); + this.R = (float) ((double) this.R + (double) MathHelper.sqrt(d10 * d10 + d11 * d11 + d12 * d12) * 0.6D); + if (this.R > (float) this.c && l > 0) { + this.c = (int) this.R + 1; + if (this.H()) { + float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.35F; + + if (f > 1.0F) { + f = 1.0F; + } + + this.world.makeSound(this, "liquid.swim", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + } + this.a(i, j, k, l); Block.byId[l].b(this.world, i, j, k, this); } @@ -685,7 +757,7 @@ public abstract class Entity { int i1 = MathHelper.floor(this.boundingBox.e - 0.001D); int j1 = MathHelper.floor(this.boundingBox.f - 0.001D); - if (this.world.c(i, j, k, l, i1, j1)) { + if (this.world.d(i, j, k, l, i1, j1)) { for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { for (int i2 = k; i2 <= j1; ++i2) { @@ -711,28 +783,13 @@ public abstract class Entity { } } - protected boolean e_() { + protected boolean f_() { return true; } protected void a(double d0, boolean flag) { if (flag) { if (this.fallDistance > 0.0F) { - if (this instanceof EntityLiving) { - int i = MathHelper.floor(this.locX); - int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); - int k = MathHelper.floor(this.locZ); - int l = this.world.getTypeId(i, j, k); - - if (l == 0 && this.world.getTypeId(i, j - 1, k) == Block.FENCE.id) { - l = this.world.getTypeId(i, j - 1, k); - } - - if (l > 0) { - Block.byId[l].a(this.world, i, j, k, this, this.fallDistance); - } - } - this.a(this.fallDistance); this.fallDistance = 0.0F; } @@ -776,11 +833,11 @@ public abstract class Entity { } public boolean G() { - return this.ac || this.world.B(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + return this.ad || this.world.B(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); } public boolean H() { - return this.ac; + return this.ad; } public boolean I() { @@ -864,7 +921,7 @@ public abstract class Entity { this.lastZ = this.locZ = d2; this.lastYaw = this.yaw = f; this.lastPitch = this.pitch = f1; - this.V = 0.0F; + this.W = 0.0F; double d3 = (double) (this.lastYaw - f); if (d3 < -180.0D) { @@ -880,9 +937,9 @@ public abstract class Entity { } public void setPositionRotation(double d0, double d1, double d2, float f, float f1) { - this.S = this.lastX = this.locX = d0; - this.T = this.lastY = this.locY = d1 + (double) this.height; - this.U = this.lastZ = this.locZ = d2; + this.T = this.lastX = this.locX = d0; + this.U = this.lastY = this.locY = d1 + (double) this.height; + this.V = this.lastZ = this.locZ = d2; this.yaw = f; this.pitch = f1; this.setPosition(this.locX, this.locY, this.locZ); @@ -942,8 +999,8 @@ public abstract class Entity { d1 *= d3; d0 *= 0.05000000074505806D; d1 *= 0.05000000074505806D; - d0 *= (double) (1.0F - this.Y); - d1 *= (double) (1.0F - this.Y); + d0 *= (double) (1.0F - this.Z); + d1 *= (double) (1.0F - this.Z); this.g(-d0, 0.0D, -d1); entity.g(d0, 0.0D, d1); } @@ -954,7 +1011,7 @@ public abstract class Entity { this.motX += d0; this.motY += d1; this.motZ += d2; - this.al = true; + this.am = true; } protected void K() { @@ -989,7 +1046,7 @@ public abstract class Entity { } public void d(NBTTagCompound nbttagcompound) { - nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.V, this.locZ})); + nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.W, this.locZ})); nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); // CraftBukkit start - checking for NaN pitch/yaw and resetting to zero @@ -1008,6 +1065,7 @@ public abstract class Entity { nbttagcompound.setShort("Fire", (short) this.fireTicks); nbttagcompound.setShort("Air", (short) this.getAirTicks()); nbttagcompound.setBoolean("OnGround", this.onGround); + nbttagcompound.setInt("Dimension", this.dimension); // CraftBukkit start nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits()); nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); @@ -1039,15 +1097,16 @@ public abstract class Entity { } // CraftBukkit end */ - this.lastX = this.S = this.locX = ((NBTTagDouble) nbttaglist.get(0)).data; - this.lastY = this.T = this.locY = ((NBTTagDouble) nbttaglist.get(1)).data; - this.lastZ = this.U = this.locZ = ((NBTTagDouble) nbttaglist.get(2)).data; + this.lastX = this.T = this.locX = ((NBTTagDouble) nbttaglist.get(0)).data; + this.lastY = this.U = this.locY = ((NBTTagDouble) nbttaglist.get(1)).data; + this.lastZ = this.V = this.locZ = ((NBTTagDouble) nbttaglist.get(2)).data; this.lastYaw = this.yaw = ((NBTTagFloat) nbttaglist2.get(0)).data; this.lastPitch = this.pitch = ((NBTTagFloat) nbttaglist2.get(1)).data; this.fallDistance = nbttagcompound.getFloat("FallDistance"); this.fireTicks = nbttagcompound.getShort("Fire"); this.setAirTicks(nbttagcompound.getShort("Air")); this.onGround = nbttagcompound.getBoolean("OnGround"); + this.dimension = nbttagcompound.getInt("Dimension"); this.setPosition(this.locX, this.locY, this.locZ); // CraftBukkit start @@ -1191,29 +1250,29 @@ public abstract class Entity { this.motX = 0.0D; this.motY = 0.0D; this.motZ = 0.0D; - this.h_(); + this.j_(); if (this.vehicle != null) { this.vehicle.V(); - this.f += (double) (this.vehicle.yaw - this.vehicle.lastYaw); + this.g += (double) (this.vehicle.yaw - this.vehicle.lastYaw); - for (this.e += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.f >= 180.0D; this.f -= 360.0D) { + for (this.f += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.g >= 180.0D; this.g -= 360.0D) { ; } - while (this.f < -180.0D) { - this.f += 360.0D; + while (this.g < -180.0D) { + this.g += 360.0D; } - while (this.e >= 180.0D) { - this.e -= 360.0D; + while (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; } - double d0 = this.f * 0.5D; - double d1 = this.e * 0.5D; + double d0 = this.g * 0.5D; + double d1 = this.f * 0.5D; float f = 10.0F; if (d0 > (double) f) { @@ -1232,8 +1291,8 @@ public abstract class Entity { d1 = (double) (-f); } - this.f -= d0; - this.e -= d1; + this.g -= d0; + this.f -= d1; this.yaw = (float) ((double) this.yaw + d0); this.pitch = (float) ((double) this.pitch + d1); } @@ -1241,10 +1300,10 @@ public abstract class Entity { } public void V() { - if (!(this.passenger instanceof EntityHuman) || !((EntityHuman) this.passenger).bF()) { - this.passenger.S = this.passenger.locX; - this.passenger.T = this.passenger.locY; - this.passenger.U = this.passenger.locZ; + if (!(this.passenger instanceof EntityHuman) || !((EntityHuman) this.passenger).bS()) { + this.passenger.T = this.T; + this.passenger.U = this.U + this.X() + this.passenger.W(); + this.passenger.V = this.V; } this.passenger.setPosition(this.locX, this.locY + this.X() + this.passenger.W(), this.locZ); @@ -1279,8 +1338,8 @@ public abstract class Entity { PluginManager pluginManager = Bukkit.getPluginManager(); this.getBukkitEntity(); // make sure bukkitEntity is initialised // CraftBukkit end - this.e = 0.0D; this.f = 0.0D; + this.g = 0.0D; if (entity == null) { if (this.vehicle != null) { // CraftBukkit start @@ -1370,18 +1429,41 @@ public abstract class Entity { return null; } - public void aa() {} + public void aa() { + if (this.an > 0) { + this.an = this.ab(); + } else { + double d0 = this.lastX - this.locX; + double d1 = this.lastZ - this.locZ; + + if (!this.world.isStatic && !this.ao) { + this.aq = Direction.a(d0, d1); + } + + this.ao = true; + } + } + + public int ab() { + return 500; + } public ItemStack[] getEquipment() { return null; } + public void setEquipment(int i, ItemStack itemstack) {} + public boolean isBurning() { - return this.fireTicks > 0 || this.f(0); + return this.fireTicks > 0 || this.e(0); + } + + public boolean ag() { + return this.vehicle != null || this.e(2); } public boolean isSneaking() { - return this.f(1); + return this.e(1); } public void setSneaking(boolean flag) { @@ -1389,18 +1471,26 @@ public abstract class Entity { } public boolean isSprinting() { - return this.f(3); + return this.e(3); } public void setSprinting(boolean flag) { this.a(3, flag); } - public void c(boolean flag) { + public boolean isInvisible() { + return this.e(5); + } + + public void setInvisible(boolean flag) { + this.a(5, flag); + } + + public void d(boolean flag) { this.a(4, flag); } - protected boolean f(int i) { + protected boolean e(int i) { return (this.datawatcher.getByte(0) & 1 << i) != 0; } @@ -1542,7 +1632,7 @@ public abstract class Entity { } } - public void aj() { + public void am() { this.J = true; this.fallDistance = 0.0F; } @@ -1557,7 +1647,7 @@ public abstract class Entity { return LocaleI18n.get("entity." + s + ".name"); } - public Entity[] al() { + public Entity[] ao() { return null; } @@ -1565,15 +1655,68 @@ public abstract class Entity { return this == entity; } - public float am() { + public float ap() { return 0.0F; } - public boolean an() { + public boolean aq() { return true; } public String toString() { return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] { this.getClass().getSimpleName(), this.getLocalizedName(), Integer.valueOf(this.id), this.world == null ? "~NULL~" : this.world.getWorldData().getName(), Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)}); } + + public void j(Entity entity) { + this.setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); + } + + public void a(Entity entity, boolean flag) { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + entity.d(nbttagcompound); + this.e(nbttagcompound); + this.an = entity.an; + this.aq = entity.aq; + } + + public void b(int i) { + if (!this.world.isStatic && !this.dead) { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + int j = this.dimension; + WorldServer worldserver = minecraftserver.getWorldServer(j); + WorldServer worldserver1 = minecraftserver.getWorldServer(i); + + this.dimension = i; + this.world.kill(this); + this.dead = false; + minecraftserver.getServerConfigurationManager().a(this, j, worldserver, worldserver1); + Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1); + + if (entity != null) { + entity.a(this, true); + worldserver1.addEntity(entity); + } + + this.dead = true; + worldserver.i(); + worldserver1.i(); + } + } + + public float a(Explosion explosion, Block block, int i, int j, int k) { + return block.a(this); + } + + public int as() { + return 3; + } + + public int at() { + return this.aq; + } + + public boolean au() { + return false; + } } diff --git a/src/main/java/net/minecraft/server/EntityAgeable.java b/src/main/java/net/minecraft/server/EntityAgeable.java index e8adc0ec..f7421b32 100644 --- a/src/main/java/net/minecraft/server/EntityAgeable.java +++ b/src/main/java/net/minecraft/server/EntityAgeable.java @@ -32,8 +32,8 @@ public abstract class EntityAgeable extends EntityCreature { this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit } - public void d() { - super.d(); + public void c() { + super.c(); int i = this.getAge(); if (ageLocked) return; // CraftBukkit diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 75fdb0e7..af0bcd58 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -10,7 +10,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit end -public class EntityArrow extends Entity { +public class EntityArrow extends Entity implements IProjectile { private int d = -1; private int e = -1; @@ -22,9 +22,9 @@ public class EntityArrow extends Entity { public int shake = 0; public Entity shooter; private int j; - private int an = 0; + private int as = 0; private double damage = 2.0D; - private int ap; + private int au; public EntityArrow(World world) { super(world); @@ -111,8 +111,8 @@ public class EntityArrow extends Entity { this.j = 0; } - public void h_() { - super.h_(); + public void j_() { + super.j_(); if (this.lastPitch == 0.0F && this.lastYaw == 0.0F) { float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); @@ -126,7 +126,7 @@ public class EntityArrow extends Entity { Block.byId[i].updateShape(this.world, this.d, this.e, this.f); AxisAlignedBB axisalignedbb = Block.byId[i].e(this.world, this.d, this.e, this.f); - if (axisalignedbb != null && axisalignedbb.a(Vec3D.a().create(this.locX, this.locY, this.locZ))) { + if (axisalignedbb != null && axisalignedbb.a(this.world.getVec3DPool().create(this.locX, this.locY, this.locZ))) { this.inGround = true; } } @@ -150,18 +150,18 @@ public class EntityArrow extends Entity { this.motY *= (double) (this.random.nextFloat() * 0.2F); this.motZ *= (double) (this.random.nextFloat() * 0.2F); this.j = 0; - this.an = 0; + this.as = 0; } } else { - ++this.an; - Vec3D vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + ++this.as; + Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.rayTrace(vec3d, vec3d1, false, true); - vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); if (movingobjectposition != null) { - vec3d1 = Vec3D.a().create(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); + vec3d1 = this.world.getVec3DPool().create(movingobjectposition.pos.c, movingobjectposition.pos.d, movingobjectposition.pos.e); } Entity entity = null; @@ -174,7 +174,7 @@ public class EntityArrow extends Entity { while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); - if (entity1.L() && (entity1 != this.shooter || this.an >= 5)) { + if (entity1.L() && (entity1 != this.shooter || this.as >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.boundingBox.grow((double) f1, (double) f1, (double) f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); @@ -206,7 +206,7 @@ public class EntityArrow extends Entity { f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); int l = MathHelper.f((double) f2 * this.damage); - if (this.g()) { + if (this.d()) { l += this.random.nextInt(l / 2 + 2); } @@ -232,12 +232,12 @@ public class EntityArrow extends Entity { // if (movingobjectposition.entity.damageEntity(damagesource, l)) { // CraftBukkit - moved up if (movingobjectposition.entity instanceof EntityLiving) { - ++((EntityLiving) movingobjectposition.entity).bd; - if (this.ap > 0) { + ++((EntityLiving) movingobjectposition.entity).bk; + if (this.au > 0) { float f3 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); if (f3 > 0.0F) { - movingobjectposition.entity.g(this.motX * (double) this.ap * 0.6000000238418579D / (double) f3, 0.1D, this.motZ * (double) this.ap * 0.6000000238418579D / (double) f3); + movingobjectposition.entity.g(this.motX * (double) this.au * 0.6000000238418579D / (double) f3, 0.1D, this.motZ * (double) this.au * 0.6000000238418579D / (double) f3); } } } @@ -250,7 +250,7 @@ public class EntityArrow extends Entity { this.motZ *= -0.10000000149011612D; this.yaw += 180.0F; this.lastYaw += 180.0F; - this.an = 0; + this.as = 0; } } else { this.d = movingobjectposition.b; @@ -258,9 +258,9 @@ public class EntityArrow extends Entity { this.f = movingobjectposition.d; this.g = this.world.getTypeId(this.d, this.e, this.f); this.h = this.world.getData(this.d, this.e, this.f); - this.motX = (double) ((float) (movingobjectposition.pos.a - this.locX)); - this.motY = (double) ((float) (movingobjectposition.pos.b - this.locY)); - this.motZ = (double) ((float) (movingobjectposition.pos.c - this.locZ)); + this.motX = (double) ((float) (movingobjectposition.pos.c - this.locX)); + this.motY = (double) ((float) (movingobjectposition.pos.d - this.locY)); + this.motZ = (double) ((float) (movingobjectposition.pos.e - this.locZ)); f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); this.locX -= this.motX / (double) f2 * 0.05000000074505806D; this.locY -= this.motY / (double) f2 * 0.05000000074505806D; @@ -268,13 +268,13 @@ public class EntityArrow extends Entity { 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); + this.e(false); } } - if (this.g()) { + if (this.d()) { for (int i1 = 0; i1 < 4; ++i1) { - this.world.a("crit", this.locX + this.motX * (double) i1 / 4.0D, this.locY + this.motY * (double) i1 / 4.0D, this.locZ + this.motZ * (double) i1 / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ); + this.world.addParticle("crit", this.locX + this.motX * (double) i1 / 4.0D, this.locY + this.motY * (double) i1 / 4.0D, this.locZ + this.motZ * (double) i1 / 4.0D, -this.motX, -this.motY + 0.2D, -this.motZ); } } @@ -309,7 +309,7 @@ public class EntityArrow extends Entity { for (int j1 = 0; j1 < 4; ++j1) { float f5 = 0.25F; - this.world.a("bubble", this.locX - this.motX * (double) f5, this.locY - this.motY * (double) f5, this.locZ - this.motZ * (double) f5, this.motX, this.motY, this.motZ); + this.world.addParticle("bubble", this.locX - this.motX * (double) f5, this.locY - this.motY * (double) f5, this.locZ - this.motZ * (double) f5, this.motX, this.motY, this.motZ); } f4 = 0.8F; @@ -359,7 +359,7 @@ public class EntityArrow extends Entity { if (!this.world.isStatic && this.inGround && this.shake <= 0) { // CraftBukkit start ItemStack itemstack = new ItemStack(Item.ARROW); - if (this.inGround && this.fromPlayer == 1 && this.shake <= 0 && entityhuman.inventory.canHold(itemstack) > 0) { + if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) { EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0); @@ -385,23 +385,27 @@ public class EntityArrow extends Entity { } } + protected boolean f_() { + return false; + } + public void b(double d0) { this.damage = d0; } - public double d() { + public double c() { return this.damage; } public void a(int i) { - this.ap = i; + this.au = i; } - public boolean an() { + public boolean aq() { return false; } - public void d(boolean flag) { + public void e(boolean flag) { byte b0 = this.datawatcher.getByte(16); if (flag) { @@ -411,7 +415,7 @@ public class EntityArrow extends Entity { } } - public boolean g() { + public boolean d() { byte b0 = this.datawatcher.getByte(16); return (b0 & 1) != 0; diff --git a/src/main/java/net/minecraft/server/EntityBlaze.java b/src/main/java/net/minecraft/server/EntityBlaze.java index 3ae97b34..883f52cd 100644 --- a/src/main/java/net/minecraft/server/EntityBlaze.java +++ b/src/main/java/net/minecraft/server/EntityBlaze.java @@ -4,14 +4,13 @@ public class EntityBlaze extends EntityMonster { private float d = 0.5F; private int e; - private int g; + private int f; public EntityBlaze(World world) { super(world); this.texture = "/mob/fire.png"; this.fireProof = true; - this.damage = 6; - this.aV = 10; + this.bc = 10; } public int getMaxHealth() { @@ -23,15 +22,15 @@ public class EntityBlaze extends EntityMonster { this.datawatcher.a(16, new Byte((byte) 0)); } - protected String aQ() { + protected String aW() { return "mob.blaze.breathe"; } - protected String aR() { + protected String aX() { return "mob.blaze.hit"; } - protected String aS() { + protected String aY() { return "mob.blaze.death"; } @@ -39,7 +38,7 @@ public class EntityBlaze extends EntityMonster { return 1.0F; } - public void d() { + public void c() { if (!this.world.isStatic) { if (this.G()) { this.damageEntity(DamageSource.DROWN, 1); @@ -51,7 +50,7 @@ public class EntityBlaze extends EntityMonster { this.d = 0.5F + (float) this.random.nextGaussian() * 3.0F; } - if (this.m() != null && this.m().locY + (double) this.m().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.d) { + if (this.l() != null && this.l().locY + (double) this.l().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.d) { this.motY += (0.30000001192092896D - this.motY) * 0.30000001192092896D; } } @@ -65,35 +64,35 @@ public class EntityBlaze extends EntityMonster { } for (int i = 0; i < 2; ++i) { - this.world.a("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D); + this.world.addParticle("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D); } - super.d(); + super.c(); } 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.k(entity); + this.l(entity); } else if (f < 30.0F) { double d0 = entity.locX - this.locX; double d1 = entity.boundingBox.b + (double) (entity.length / 2.0F) - (this.locY + (double) (this.length / 2.0F)); double d2 = entity.locZ - this.locZ; if (this.attackTicks == 0) { - ++this.g; - if (this.g == 1) { + ++this.f; + if (this.f == 1) { this.attackTicks = 60; - this.e(true); - } else if (this.g <= 4) { + this.f(true); + } else if (this.f <= 4) { this.attackTicks = 6; } else { this.attackTicks = 100; - this.g = 0; - this.e(false); + this.f = 0; + this.f(false); } - if (this.g > 1) { + if (this.f > 1) { float f1 = MathHelper.c(f) * 0.5F; this.world.a((EntityHuman) null, 1009, (int) this.locX, (int) this.locY, (int) this.locZ, 0); @@ -119,7 +118,7 @@ public class EntityBlaze extends EntityMonster { } public boolean isBurning() { - return this.n(); + return this.m(); } protected void dropDeathLoot(boolean flag, int i) { @@ -137,11 +136,11 @@ public class EntityBlaze extends EntityMonster { } } - public boolean n() { + public boolean m() { return (this.datawatcher.getByte(16) & 1) != 0; } - public void e(boolean flag) { + public void f(boolean flag) { byte b0 = this.datawatcher.getByte(16); if (flag) { @@ -153,7 +152,11 @@ public class EntityBlaze extends EntityMonster { this.datawatcher.watch(16, Byte.valueOf(b0)); } - protected boolean o() { + protected boolean i_() { return true; } + + public int c(Entity entity) { + return 6; + } } diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index e2d31354..128db798 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -53,7 +53,7 @@ public class EntityBoat extends Entity { this.height = this.length / 2.0F; } - protected boolean e_() { + protected boolean f_() { return false; } @@ -107,8 +107,8 @@ public class EntityBoat extends Entity { // i = event.getDamage(); // TODO Why don't we do this? // CraftBukkit end - this.c(-this.i()); - this.b(10); + this.h(-this.h()); + this.g(10); this.setDamage(this.getDamage() + i * 10); this.K(); if (damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild) { @@ -144,7 +144,7 @@ public class EntityBoat extends Entity { return !this.dead; } - public void h_() { + public void j_() { // CraftBukkit start double prevX = this.locX; double prevY = this.locY; @@ -153,9 +153,9 @@ public class EntityBoat extends Entity { float prevPitch = this.pitch; // CraftBukkit end - super.h_(); - if (this.h() > 0) { - this.b(this.h() - 1); + super.j_(); + if (this.g() > 0) { + this.g(this.g() - 1); } if (this.getDamage() > 0) { @@ -195,11 +195,11 @@ public class EntityBoat extends Entity { 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); + this.world.addParticle("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); + this.world.addParticle("splash", d8, this.locY - 0.125D, d9, this.motX, this.motY, this.motZ); } } } @@ -428,19 +428,19 @@ public class EntityBoat extends Entity { return this.datawatcher.getInt(19); } - public void b(int i) { + public void g(int i) { this.datawatcher.watch(17, Integer.valueOf(i)); } - public int h() { + public int g() { return this.datawatcher.getInt(17); } - public void c(int i) { + public void h(int i) { this.datawatcher.watch(18, Integer.valueOf(i)); } - public int i() { + public int h() { 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 dbf69a39..75c5c3cf 100644 --- a/src/main/java/net/minecraft/server/EntityChicken.java +++ b/src/main/java/net/minecraft/server/EntityChicken.java @@ -20,14 +20,14 @@ public class EntityChicken extends EntityAnimal { this.goalSelector.a(0, new PathfinderGoalFloat(this)); this.goalSelector.a(1, new PathfinderGoalPanic(this, 0.38F)); this.goalSelector.a(2, new PathfinderGoalBreed(this, f)); - this.goalSelector.a(3, new PathfinderGoalTempt(this, 0.25F, Item.WHEAT.id, false)); + this.goalSelector.a(3, new PathfinderGoalTempt(this, 0.25F, Item.SEEDS.id, false)); this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 0.28F)); this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, f)); this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); } - public boolean aV() { + public boolean bb() { return true; } @@ -35,8 +35,8 @@ public class EntityChicken extends EntityAnimal { return 4; } - public void d() { - super.d(); + public void c() { + super.c(); this.h = this.e; this.g = this.f; this.f = (float) ((double) this.f + (double) (this.onGround ? -1 : 4) * 0.3D); @@ -59,7 +59,7 @@ public class EntityChicken extends EntityAnimal { this.e += this.i * 2.0F; if (!this.isBaby() && !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.world.makeSound(this, "mob.chicken.plop", 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; } @@ -67,16 +67,20 @@ public class EntityChicken extends EntityAnimal { protected void a(float f) {} - protected String aQ() { - return "mob.chicken"; + protected String aW() { + return "mob.chicken.say"; } - protected String aR() { - return "mob.chickenhurt"; + protected String aX() { + return "mob.chicken.hurt"; } - protected String aS() { - return "mob.chickenhurt"; + protected String aY() { + return "mob.chicken.hurt"; + } + + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.chicken.step", 0.15F, 1.0F); } protected int getLootId() { @@ -105,4 +109,8 @@ public class EntityChicken extends EntityAnimal { public EntityAnimal createChild(EntityAnimal entityanimal) { return new EntityChicken(this.world); } + + public boolean c(ItemStack itemstack) { + return itemstack != null && itemstack.getItem() instanceof ItemSeeds; + } } diff --git a/src/main/java/net/minecraft/server/EntityComplex.java b/src/main/java/net/minecraft/server/EntityComplex.java deleted file mode 100644 index e11f6d2b..00000000 --- a/src/main/java/net/minecraft/server/EntityComplex.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.minecraft.server; - -public class EntityComplex extends EntityLiving { - - protected int a = 100; - - public EntityComplex(World world) { - super(world); - } - - public int getMaxHealth() { - return this.a; - } - - public boolean a(EntityComplexPart entitycomplexpart, DamageSource damagesource, int i) { - return this.damageEntity(damagesource, i); - } - - public boolean damageEntity(DamageSource damagesource, int i) { - return false; - } - - public boolean dealDamage(DamageSource damagesource, int i) { // CraftBukkit - protected -> public - return super.damageEntity(damagesource, i); - } -} diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index 136e75b0..c6246d88 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -22,7 +22,7 @@ public class EntityCow extends EntityAnimal { this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); } - public boolean aV() { + public boolean bb() { return true; } @@ -30,19 +30,23 @@ public class EntityCow extends EntityAnimal { return 10; } - protected String aQ() { - return "mob.cow"; + protected String aW() { + return "mob.cow.say"; } - protected String aR() { - return "mob.cowhurt"; + protected String aX() { + return "mob.cow.hurt"; } - protected String aS() { - return "mob.cowhurt"; + protected String aY() { + return "mob.cow.hurt"; } - protected float aP() { + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.cow.step", 0.15F, 1.0F); + } + + protected float aV() { return 0.4F; } diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index a91e55c9..6c63f9c1 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -7,8 +7,8 @@ import org.bukkit.event.entity.EntityTargetEvent; public abstract class EntityCreature extends EntityLiving { - public PathEntity pathEntity; // CraftBukkit - public - public Entity target; // CraftBukkit - public + public PathEntity pathEntity; // CraftBukkit - private -> public + public Entity target; // CraftBukkit - protected -> public protected boolean b = false; protected int c = 0; @@ -16,17 +16,17 @@ public abstract class EntityCreature extends EntityLiving { super(world); } - protected boolean i() { + protected boolean h() { return false; } - protected void be() { + protected void bk() { this.world.methodProfiler.a("ai"); if (this.c > 0) { --this.c; } - this.b = this.i(); + this.b = this.h(); float f = 16.0F; if (this.target == null) { @@ -52,7 +52,7 @@ public abstract class EntityCreature extends EntityLiving { } else if (this.target.isAlive()) { float f1 = this.target.d((Entity) this); - if (this.l(this.target)) { + if (this.m(this.target)) { this.a(this.target, f1); } } else { @@ -73,8 +73,8 @@ public abstract class EntityCreature extends EntityLiving { this.world.methodProfiler.b(); if (!this.b && this.target != null && (this.pathEntity == null || this.random.nextInt(20) == 0)) { this.pathEntity = this.world.findPath(this, this.target, f, true, false, false, true); - } else if (!this.b && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.c > 0) && this.bq < 100) { - this.j(); + } else if (!this.b && (this.pathEntity == null && this.random.nextInt(180) == 0 || this.random.nextInt(120) == 0 || this.c > 0) && this.bC < 100) { + this.i(); } int i = MathHelper.floor(this.boundingBox.b + 0.5D); @@ -87,7 +87,7 @@ public abstract class EntityCreature extends EntityLiving { Vec3D vec3d = this.pathEntity.a((Entity) this); double d0 = (double) (this.width * 2.0F); - while (vec3d != null && vec3d.d(this.locX, vec3d.b, this.locZ) < d0 * d0) { + while (vec3d != null && vec3d.d(this.locX, vec3d.d, this.locZ) < d0 * d0) { this.pathEntity.a(); if (this.pathEntity.b()) { vec3d = null; @@ -97,16 +97,16 @@ public abstract class EntityCreature extends EntityLiving { } } - this.bu = false; + this.bG = false; if (vec3d != null) { - double d1 = vec3d.a - this.locX; - double d2 = vec3d.c - this.locZ; - double d3 = vec3d.b - (double) i; + double d1 = vec3d.c - this.locX; + double d2 = vec3d.e - this.locZ; + double d3 = vec3d.d - (double) i; // CraftBukkit - Math -> TrigMath float f2 = (float) (org.bukkit.craftbukkit.TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; float f3 = MathHelper.g(f2 - this.yaw); - this.bs = this.bw; + this.bE = this.bI; if (f3 > 30.0F) { f3 = 30.0F; } @@ -123,12 +123,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.br = -MathHelper.sin(f3) * this.bs * 1.0F; - this.bs = MathHelper.cos(f3) * this.bs * 1.0F; + this.bD = -MathHelper.sin(f3) * this.bE * 1.0F; + this.bE = MathHelper.cos(f3) * this.bE * 1.0F; } if (d3 > 0.0D) { - this.bu = true; + this.bG = true; } } @@ -136,22 +136,22 @@ public abstract class EntityCreature extends EntityLiving { this.a(this.target, 30.0F, 30.0F); } - if (this.positionChanged && !this.l()) { - this.bu = true; + if (this.positionChanged && !this.k()) { + this.bG = true; } if (this.random.nextFloat() < 0.8F && (flag || flag1)) { - this.bu = true; + this.bG = true; } this.world.methodProfiler.b(); } else { - super.be(); + super.bk(); this.pathEntity = null; } } - protected void j() { + protected void i() { this.world.methodProfiler.a("stroll"); boolean flag = false; int i = -1; @@ -199,7 +199,7 @@ public abstract class EntityCreature extends EntityLiving { return super.canSpawn() && this.a(i, j, k) >= 0.0F; } - public boolean l() { + public boolean k() { return this.pathEntity != null; } @@ -207,7 +207,7 @@ public abstract class EntityCreature extends EntityLiving { this.pathEntity = pathentity; } - public Entity m() { + public Entity l() { return this.target; } @@ -215,17 +215,13 @@ public abstract class EntityCreature extends EntityLiving { this.target = entity; } - protected float bs() { - if (this.aV()) { - return 1.0F; - } else { - float f = super.bs(); - - if (this.c > 0) { - f *= 2.0F; - } + public float by() { + float f = super.by(); - return f; + if (this.c > 0 && !this.bb()) { + f *= 2.0F; } + + return f; } } diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 175be784..025438e9 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -7,8 +7,10 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; public class EntityCreeper extends EntityMonster { - int fuseTicks; - int e; + private int d; + private int fuseTicks; + private int maxFuseTicks = 30; + private int explosionRadius = 3; private int record = -1; // CraftBukkit public EntityCreeper(World world) { @@ -25,10 +27,22 @@ public class EntityCreeper extends EntityMonster { this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false)); } - public boolean aV() { + public boolean bb() { return true; } + public int as() { + return this.aF() == null ? 3 : 3 + (this.health - 1); + } + + protected void a(float f) { + super.a(f); + this.fuseTicks = (int) ((float) this.fuseTicks + f * 1.5F); + if (this.fuseTicks > this.maxFuseTicks - 5) { + this.fuseTicks = this.maxFuseTicks - 5; + } + } + public int getMaxHealth() { return 20; } @@ -44,17 +58,27 @@ public class EntityCreeper extends EntityMonster { if (this.datawatcher.getByte(17) == 1) { nbttagcompound.setBoolean("powered", true); } + + nbttagcompound.setShort("Fuse", (short) this.maxFuseTicks); + nbttagcompound.setByte("ExplosionRadius", (byte) this.explosionRadius); } public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.datawatcher.watch(17, Byte.valueOf((byte) (nbttagcompound.getBoolean("powered") ? 1 : 0))); + if (nbttagcompound.hasKey("Fuse")) { + this.maxFuseTicks = nbttagcompound.getShort("Fuse"); + } + + if (nbttagcompound.hasKey("ExplosionRadius")) { + this.explosionRadius = nbttagcompound.getByte("ExplosionRadius"); + } } - public void h_() { + public void j_() { if (this.isAlive()) { - this.e = this.fuseTicks; - int i = this.p(); + this.d = this.fuseTicks; + int i = this.o(); if (i > 0 && this.fuseTicks == 0) { this.world.makeSound(this, "random.fuse", 1.0F, 0.5F); @@ -65,16 +89,17 @@ public class EntityCreeper extends EntityMonster { this.fuseTicks = 0; } - if (this.fuseTicks >= 30) { - this.fuseTicks = 30; + if (this.fuseTicks >= this.maxFuseTicks) { + this.fuseTicks = this.maxFuseTicks; if (!this.world.isStatic) { + boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit start float radius = this.isPowered() ? 6.0F : 3.0F; ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false); this.world.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire()); + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); this.die(); } else { this.fuseTicks = 0; @@ -84,15 +109,15 @@ public class EntityCreeper extends EntityMonster { } } - super.h_(); + super.j_(); } - protected String aR() { - return "mob.creeper"; + protected String aX() { + return "mob.creeper.say"; } - protected String aS() { - return "mob.creeperdeath"; + protected String aY() { + return "mob.creeper.death"; } public void die(DamageSource damagesource) { @@ -134,7 +159,7 @@ public class EntityCreeper extends EntityMonster { } // CraftBukkit end - public boolean k(Entity entity) { + public boolean l(Entity entity) { return true; } @@ -146,7 +171,7 @@ public class EntityCreeper extends EntityMonster { return Item.SULPHUR.id; } - public int p() { + public int o() { 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 9222a1bb..5cbdf721 100644 --- a/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java +++ b/src/main/java/net/minecraft/server/EntityDamageSourceIndirect.java @@ -10,7 +10,7 @@ public class EntityDamageSourceIndirect extends EntityDamageSource { } public Entity f() { - return this.o; + return this.r; } public Entity getEntity() { diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 8fb76c7a..7d73cc62 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -57,7 +57,7 @@ public class EntityEgg extends EntityProjectile { // CraftBukkit end for (int j = 0; j < 8; ++j) { - this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); + this.world.addParticle("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); } if (!this.world.isStatic) { diff --git a/src/main/java/net/minecraft/server/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java index 641dc654..410fc289 100644 --- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java +++ b/src/main/java/net/minecraft/server/EntityEnderCrystal.java @@ -14,7 +14,7 @@ public class EntityEnderCrystal extends Entity { this.a = this.random.nextInt(100000); } - protected boolean e_() { + protected boolean f_() { return false; } @@ -22,7 +22,7 @@ public class EntityEnderCrystal extends Entity { this.datawatcher.a(8, Integer.valueOf(this.b)); } - public void h_() { + public void j_() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; @@ -57,7 +57,7 @@ public class EntityEnderCrystal extends Entity { if (this.b <= 0) { this.die(); if (!this.world.isStatic) { - this.world.explode(this, this.locX, this.locY, this.locZ, 6.0F); // CraftBukkit - (Entity) null -> this + this.world.explode(this, this.locX, this.locY, this.locZ, 6.0F, true); // CraftBukkit - (Entity) null -> this } } } diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java index 51411bef..75547e9c 100644 --- a/src/main/java/net/minecraft/server/EntityEnderDragon.java +++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java @@ -13,45 +13,48 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.Bukkit; // CraftBukkit end -public class EntityEnderDragon extends EntityComplex { +public class EntityEnderDragon extends EntityLiving implements IComplex { + public double a; public double b; public double c; - public double d; - public double[][] e = new double[64][3]; - public int f = -1; + public double[][] d = new double[64][3]; + public int e = -1; public EntityComplexPart[] children; + public EntityComplexPart g; public EntityComplexPart h; public EntityComplexPart i; public EntityComplexPart j; - public EntityComplexPart by; - public EntityComplexPart bz; - public EntityComplexPart bA; - public EntityComplexPart bB; - public float bC = 0.0F; - public float bD = 0.0F; - public boolean bE = false; - public boolean bF = false; - private Entity bI; - public int bG = 0; - public EntityEnderCrystal bH = null; + public EntityComplexPart bK; + public EntityComplexPart bL; + public EntityComplexPart bM; + public float bN = 0.0F; + public float bO = 0.0F; + public boolean bP = false; + public boolean bQ = false; + private Entity bT; + public int bR = 0; + public EntityEnderCrystal bS = null; public EntityEnderDragon(World world) { super(world); - this.children = new EntityComplexPart[] { this.h = new EntityComplexPart(this, "head", 6.0F, 6.0F), this.i = new EntityComplexPart(this, "body", 8.0F, 8.0F), this.j = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.by = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bz = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bA = new EntityComplexPart(this, "wing", 4.0F, 4.0F), this.bB = new EntityComplexPart(this, "wing", 4.0F, 4.0F)}; - this.a = 200; - this.setHealth(this.a); + this.children = new EntityComplexPart[] { this.g = new EntityComplexPart(this, "head", 6.0F, 6.0F), this.h = new EntityComplexPart(this, "body", 8.0F, 8.0F), this.i = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.j = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bK = new EntityComplexPart(this, "tail", 4.0F, 4.0F), this.bL = new EntityComplexPart(this, "wing", 4.0F, 4.0F), this.bM = new EntityComplexPart(this, "wing", 4.0F, 4.0F)}; + this.setHealth(this.getMaxHealth()); this.texture = "/mob/enderdragon/ender.png"; this.a(16.0F, 8.0F); - this.X = true; + this.Y = true; this.fireProof = true; - this.c = 100.0D; - this.ak = true; + this.b = 100.0D; + this.al = true; + } + + public int getMaxHealth() { + return 200; } protected void a() { super.a(); - this.datawatcher.a(16, new Integer(this.a)); + this.datawatcher.a(16, new Integer(this.getMaxHealth())); } public double[] a(int i, float f) { @@ -60,59 +63,66 @@ public class EntityEnderDragon extends EntityComplex { } f = 1.0F - f; - int j = this.f - i * 1 & 63; - int k = this.f - i * 1 - 1 & 63; + int j = this.e - i * 1 & 63; + int k = this.e - i * 1 - 1 & 63; double[] adouble = new double[3]; - double d0 = this.e[j][0]; - double d1 = MathHelper.g(this.e[k][0] - d0); + double d0 = this.d[j][0]; + double d1 = MathHelper.g(this.d[k][0] - d0); adouble[0] = d0 + d1 * (double) f; - d0 = this.e[j][1]; - d1 = this.e[k][1] - d0; + d0 = this.d[j][1]; + d1 = this.d[k][1] - d0; adouble[1] = d0 + d1 * (double) f; - adouble[2] = this.e[j][2] + (this.e[k][2] - this.e[j][2]) * (double) f; + adouble[2] = this.d[j][2] + (this.d[k][2] - this.d[j][2]) * (double) f; return adouble; } - public void d() { - this.bC = this.bD; + public void c() { + float f; + float f1; + if (!this.world.isStatic) { this.datawatcher.watch(16, Integer.valueOf(this.health)); + } else { + f = MathHelper.cos(this.bO * 3.1415927F * 2.0F); + f1 = MathHelper.cos(this.bN * 3.1415927F * 2.0F); + if (f1 <= -0.3F && f >= -0.3F) { + this.world.b(this.locX, this.locY, this.locZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.random.nextFloat() * 0.3F); + } } - float f; - float f1; - float d05; + this.bN = this.bO; + float f2; if (this.health <= 0) { f = (this.random.nextFloat() - 0.5F) * 8.0F; - d05 = (this.random.nextFloat() - 0.5F) * 4.0F; - f1 = (this.random.nextFloat() - 0.5F) * 8.0F; - this.world.a("largeexplode", this.locX + (double) f, this.locY + 2.0D + (double) d05, this.locZ + (double) f1, 0.0D, 0.0D, 0.0D); + f1 = (this.random.nextFloat() - 0.5F) * 4.0F; + f2 = (this.random.nextFloat() - 0.5F) * 8.0F; + this.world.addParticle("largeexplode", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D); } else { - this.j(); + this.h(); f = 0.2F / (MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 10.0F + 1.0F); f *= (float) Math.pow(2.0D, this.motY); - if (this.bF) { - this.bD += f * 0.5F; + if (this.bQ) { + this.bO += f * 0.5F; } else { - this.bD += f; + this.bO += f; } this.yaw = MathHelper.g(this.yaw); - if (this.f < 0) { - for (int i = 0; i < this.e.length; ++i) { - this.e[i][0] = (double) this.yaw; - this.e[i][1] = this.locY; + if (this.e < 0) { + for (int d05 = 0; d05 < this.d.length; ++d05) { + this.d[d05][0] = (double) this.yaw; + this.d[d05][1] = this.locY; } } - if (++this.f == this.e.length) { - this.f = 0; + if (++this.e == this.d.length) { + this.e = 0; } - this.e[this.f][0] = (double) this.yaw; - this.e[this.f][1] = this.locY; + this.d[this.e][0] = (double) this.yaw; + this.d[this.e][1] = this.locY; double d0; double d1; double d2; @@ -120,27 +130,27 @@ public class EntityEnderDragon extends EntityComplex { float f3; if (this.world.isStatic) { - if (this.bi > 0) { - d0 = this.locX + (this.bj - this.locX) / (double) this.bi; - d1 = this.locY + (this.bk - this.locY) / (double) this.bi; - d2 = this.locZ + (this.bl - this.locZ) / (double) this.bi; - d3 = MathHelper.g(this.bm - (double) this.yaw); - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bi); - this.pitch = (float) ((double) this.pitch + (this.bn - (double) this.pitch) / (double) this.bi); - --this.bi; + if (this.bu > 0) { + d0 = this.locX + (this.bv - this.locX) / (double) this.bu; + d1 = this.locY + (this.bw - this.locY) / (double) this.bu; + d2 = this.locZ + (this.bx - this.locZ) / (double) this.bu; + d3 = MathHelper.g(this.by - (double) this.yaw); + this.yaw = (float) ((double) this.yaw + d3 / (double) this.bu); + this.pitch = (float) ((double) this.pitch + (this.bz - (double) this.pitch) / (double) this.bu); + --this.bu; this.setPosition(d0, d1, d2); this.b(this.yaw, this.pitch); } } else { - d0 = this.b - this.locX; - d1 = this.c - this.locY; - d2 = this.d - this.locZ; + d0 = this.a - this.locX; + d1 = this.b - this.locY; + d2 = this.c - this.locZ; d3 = d0 * d0 + d1 * d1 + d2 * d2; - if (this.bI != null) { - this.b = this.bI.locX; - this.d = this.bI.locZ; - double d4 = this.b - this.locX; - double d5 = this.d - this.locZ; + if (this.bT != null) { + this.a = this.bT.locX; + this.c = this.bT.locZ; + double d4 = this.a - this.locX; + double d5 = this.c - this.locZ; double d6 = Math.sqrt(d4 * d4 + d5 * d5); double d7 = 0.4000000059604645D + d6 / 80.0D - 1.0D; @@ -148,14 +158,14 @@ public class EntityEnderDragon extends EntityComplex { d7 = 10.0D; } - this.c = this.bI.boundingBox.b + d7; + this.b = this.bT.boundingBox.b + d7; } else { - this.b += this.random.nextGaussian() * 2.0D; - this.d += this.random.nextGaussian() * 2.0D; + this.a += this.random.nextGaussian() * 2.0D; + this.c += this.random.nextGaussian() * 2.0D; } - if (this.bE || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.G) { - this.k(); + if (this.bP || d3 < 100.0D || d3 > 22500.0D || this.positionChanged || this.G) { + this.i(); } d1 /= (double) MathHelper.sqrt(d0 * d0 + d2 * d2); @@ -181,15 +191,15 @@ public class EntityEnderDragon extends EntityComplex { d9 = -50.0D; } - Vec3D vec3d = Vec3D.a().create(this.b - this.locX, this.c - this.locY, this.d - this.locZ).b(); - Vec3D vec3d1 = Vec3D.a().create((double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F), this.motY, (double) (-MathHelper.cos(this.yaw * 3.1415927F / 180.0F))).b(); + Vec3D vec3d = this.world.getVec3DPool().create(this.a - this.locX, this.b - this.locY, this.c - this.locZ).a(); + Vec3D vec3d1 = this.world.getVec3DPool().create((double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F), this.motY, (double) (-MathHelper.cos(this.yaw * 3.1415927F / 180.0F))).a(); float f4 = (float) (vec3d1.b(vec3d) + 0.5D) / 1.5F; if (f4 < 0.0F) { f4 = 0.0F; } - this.bt *= 0.8F; + this.bF *= 0.8F; float f5 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 1.0F + 1.0F; double d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ) * 1.0D + 1.0D; @@ -197,19 +207,19 @@ public class EntityEnderDragon extends EntityComplex { d10 = 40.0D; } - this.bt = (float) ((double) this.bt + d9 * (0.699999988079071D / d10 / (double) f5)); - this.yaw += this.bt * 0.1F; + this.bF = (float) ((double) this.bF + d9 * (0.699999988079071D / d10 / (double) f5)); + this.yaw += this.bF * 0.1F; float f6 = (float) (2.0D / (d10 + 1.0D)); float f7 = 0.06F; this.a(0.0F, -1.0F, f7 * (f4 * f6 + (1.0F - f6))); - if (this.bF) { + if (this.bQ) { this.move(this.motX * 0.800000011920929D, this.motY * 0.800000011920929D, this.motZ * 0.800000011920929D); } else { this.move(this.motX, this.motY, this.motZ); } - Vec3D vec3d2 = Vec3D.a().create(this.motX, this.motY, this.motZ).b(); + Vec3D vec3d2 = this.world.getVec3DPool().create(this.motX, this.motY, this.motZ).a(); float f8 = (float) (vec3d2.b(vec3d1) + 1.0D) / 2.0F; f8 = 0.8F + 0.15F * f8; @@ -218,58 +228,58 @@ public class EntityEnderDragon extends EntityComplex { this.motY *= 0.9100000262260437D; } - this.aq = this.yaw; - this.h.width = this.h.length = 3.0F; + this.aw = this.yaw; + this.g.width = this.g.length = 3.0F; + this.i.width = this.i.length = 2.0F; this.j.width = this.j.length = 2.0F; - this.by.width = this.by.length = 2.0F; - this.bz.width = this.bz.length = 2.0F; - this.i.length = 3.0F; - this.i.width = 5.0F; - this.bA.length = 2.0F; - this.bA.width = 4.0F; - this.bB.length = 3.0F; - this.bB.width = 4.0F; - d05 = (float) (this.a(5, 1.0F)[1] - this.a(10, 1.0F)[1]) * 10.0F / 180.0F * 3.1415927F; - f1 = MathHelper.cos(d05); - float f9 = -MathHelper.sin(d05); + this.bK.width = this.bK.length = 2.0F; + this.h.length = 3.0F; + this.h.width = 5.0F; + this.bL.length = 2.0F; + this.bL.width = 4.0F; + this.bM.length = 3.0F; + this.bM.width = 4.0F; + f1 = (float) (this.a(5, 1.0F)[1] - this.a(10, 1.0F)[1]) * 10.0F / 180.0F * 3.1415927F; + f2 = MathHelper.cos(f1); + float f9 = -MathHelper.sin(f1); float f10 = this.yaw * 3.1415927F / 180.0F; float f11 = MathHelper.sin(f10); float f12 = MathHelper.cos(f10); - this.i.h_(); - this.i.setPositionRotation(this.locX + (double) (f11 * 0.5F), this.locY, this.locZ - (double) (f12 * 0.5F), 0.0F, 0.0F); - this.bA.h_(); - this.bA.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F); - this.bB.h_(); - this.bB.setPositionRotation(this.locX - (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ - (double) (f11 * 4.5F), 0.0F, 0.0F); + this.h.j_(); + this.h.setPositionRotation(this.locX + (double) (f11 * 0.5F), this.locY, this.locZ - (double) (f12 * 0.5F), 0.0F, 0.0F); + this.bL.j_(); + this.bL.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F); + this.bM.j_(); + this.bM.setPositionRotation(this.locX - (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ - (double) (f11 * 4.5F), 0.0F, 0.0F); if (!this.world.isStatic && this.hurtTicks == 0) { - this.a(this.world.getEntities(this, this.bA.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); - this.a(this.world.getEntities(this, this.bB.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); - this.b(this.world.getEntities(this, this.h.boundingBox.grow(1.0D, 1.0D, 1.0D))); + this.a(this.world.getEntities(this, this.bL.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); + this.a(this.world.getEntities(this, this.bM.boundingBox.grow(4.0D, 2.0D, 4.0D).d(0.0D, -2.0D, 0.0D))); + this.b(this.world.getEntities(this, this.g.boundingBox.grow(1.0D, 1.0D, 1.0D))); } double[] adouble = this.a(5, 1.0F); double[] adouble1 = this.a(0, 1.0F); - f3 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F - this.bt * 0.01F); - float f13 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F - this.bt * 0.01F); + f3 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F - this.bF * 0.01F); + float f13 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F - this.bF * 0.01F); - this.h.h_(); - this.h.setPositionRotation(this.locX + (double) (f3 * 5.5F * f1), this.locY + (adouble1[1] - adouble[1]) * 1.0D + (double) (f9 * 5.5F), this.locZ - (double) (f13 * 5.5F * f1), 0.0F, 0.0F); + this.g.j_(); + this.g.setPositionRotation(this.locX + (double) (f3 * 5.5F * f2), this.locY + (adouble1[1] - adouble[1]) * 1.0D + (double) (f9 * 5.5F), this.locZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); for (int j = 0; j < 3; ++j) { EntityComplexPart entitycomplexpart = null; if (j == 0) { - entitycomplexpart = this.j; + entitycomplexpart = this.i; } if (j == 1) { - entitycomplexpart = this.by; + entitycomplexpart = this.j; } if (j == 2) { - entitycomplexpart = this.bz; + entitycomplexpart = this.bK; } double[] adouble2 = this.a(12 + j * 2, 1.0F); @@ -279,25 +289,25 @@ public class EntityEnderDragon extends EntityComplex { float f17 = 1.5F; float f18 = (float) (j + 1) * 2.0F; - entitycomplexpart.h_(); - entitycomplexpart.setPositionRotation(this.locX - (double) ((f11 * f17 + f15 * f18) * f1), this.locY + (adouble2[1] - adouble[1]) * 1.0D - (double) ((f18 + f17) * f9) + 1.5D, this.locZ + (double) ((f12 * f17 + f16 * f18) * f1), 0.0F, 0.0F); + entitycomplexpart.j_(); + entitycomplexpart.setPositionRotation(this.locX - (double) ((f11 * f17 + f15 * f18) * f2), this.locY + (adouble2[1] - adouble[1]) * 1.0D - (double) ((f18 + f17) * f9) + 1.5D, this.locZ + (double) ((f12 * f17 + f16 * f18) * f2), 0.0F, 0.0F); } if (!this.world.isStatic) { - this.bF = this.a(this.h.boundingBox) | this.a(this.i.boundingBox); + this.bQ = this.a(this.g.boundingBox) | this.a(this.h.boundingBox); } } } - private void j() { - if (this.bH != null) { - if (this.bH.dead) { + private void h() { + if (this.bS != null) { + if (this.bS.dead) { if (!this.world.isStatic) { - this.a(this.h, DamageSource.EXPLOSION, 10); + this.a(this.g, DamageSource.EXPLOSION, 10); } - this.bH = null; - } else if (this.ticksLived % 10 == 0 && this.health < this.a) { + this.bS = null; + } else if (this.ticksLived % 10 == 0 && this.health < this.getMaxHealth()) { // CraftBukkit start EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL); this.world.getServer().getPluginManager().callEvent(event); @@ -326,13 +336,13 @@ public class EntityEnderDragon extends EntityComplex { } } - this.bH = entityendercrystal; + this.bS = entityendercrystal; } } private void a(List list) { - double d0 = (this.i.boundingBox.a + this.i.boundingBox.d) / 2.0D; - double d1 = (this.i.boundingBox.c + this.i.boundingBox.f) / 2.0D; + double d0 = (this.h.boundingBox.a + this.h.boundingBox.d) / 2.0D; + double d1 = (this.h.boundingBox.c + this.h.boundingBox.f) / 2.0D; Iterator iterator = list.iterator(); while (iterator.hasNext()) { @@ -373,27 +383,27 @@ public class EntityEnderDragon extends EntityComplex { } } - private void k() { - this.bE = false; + private void i() { + this.bP = false; if (this.random.nextInt(2) == 0 && !this.world.players.isEmpty()) { - this.bI = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size())); + this.bT = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size())); } else { boolean flag = false; do { - this.b = 0.0D; - this.c = (double) (70.0F + this.random.nextFloat() * 50.0F); - this.d = 0.0D; - this.b += (double) (this.random.nextFloat() * 120.0F - 60.0F); - this.d += (double) (this.random.nextFloat() * 120.0F - 60.0F); - double d0 = this.locX - this.b; - double d1 = this.locY - this.c; - double d2 = this.locZ - this.d; + this.a = 0.0D; + this.b = (double) (70.0F + this.random.nextFloat() * 50.0F); + this.c = 0.0D; + this.a += (double) (this.random.nextFloat() * 120.0F - 60.0F); + this.c += (double) (this.random.nextFloat() * 120.0F - 60.0F); + double d0 = this.locX - this.a; + double d1 = this.locY - this.b; + double d2 = this.locZ - this.c; flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; } while (!flag); - this.bI = null; + this.bT = null; } } @@ -456,14 +466,14 @@ public class EntityEnderDragon extends EntityComplex { double d1 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) this.random.nextFloat(); double d2 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) this.random.nextFloat(); - this.world.a("largeexplode", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.world.addParticle("largeexplode", d0, d1, d2, 0.0D, 0.0D, 0.0D); } return flag; } public boolean a(EntityComplexPart entitycomplexpart, DamageSource damagesource, int i) { - if (entitycomplexpart != this.h) { + if (entitycomplexpart != this.g) { i = i / 4 + 1; } @@ -471,10 +481,10 @@ public class EntityEnderDragon extends EntityComplex { float f1 = MathHelper.sin(f); float f2 = MathHelper.cos(f); - this.b = this.locX + (double) (f1 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.c = this.locY + (double) (this.random.nextFloat() * 3.0F) + 1.0D; - this.d = this.locZ - (double) (f2 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); - this.bI = null; + this.a = this.locX + (double) (f1 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); + this.b = this.locY + (double) (this.random.nextFloat() * 3.0F) + 1.0D; + this.c = this.locZ - (double) (f2 * 5.0F) + (double) ((this.random.nextFloat() - 0.5F) * 2.0F); + this.bT = null; if (damagesource.getEntity() instanceof EntityHuman || damagesource == DamageSource.EXPLOSION) { this.dealDamage(damagesource, i); } @@ -482,32 +492,46 @@ public class EntityEnderDragon extends EntityComplex { return true; } - protected void aI() { - ++this.bG; - if (this.bG >= 180 && this.bG <= 200) { + public boolean damageEntity(DamageSource damagesource, int i) { + return false; + } + + public boolean dealDamage(DamageSource damagesource, int i) { // CraftBukkit - protected -> public + return super.damageEntity(damagesource, i); + } + + protected void aO() { + ++this.bR; + if (this.bR >= 180 && this.bR <= 200) { float f = (this.random.nextFloat() - 0.5F) * 8.0F; float f1 = (this.random.nextFloat() - 0.5F) * 4.0F; float f2 = (this.random.nextFloat() - 0.5F) * 8.0F; - this.world.a("hugeexplosion", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D); + this.world.addParticle("hugeexplosion", this.locX + (double) f, this.locY + 2.0D + (double) f1, this.locZ + (double) f2, 0.0D, 0.0D, 0.0D); } int i; int j; - if (!this.world.isStatic && this.bG > 150 && this.bG % 5 == 0) { - i = expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward() + if (!this.world.isStatic) { + if (this.bR > 150 && this.bR % 5 == 0) { + i = expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward() - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); + while (i > 0) { + j = EntityExperienceOrb.getOrbValue(i); + i -= j; + this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); + } + } + + if (this.bR == 1) { + this.world.e(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } } this.move(0.0D, 0.10000000149011612D, 0.0D); - this.aq = this.yaw += 20.0F; - if (this.bG == 200 && !this.world.isStatic) { + this.aw = this.yaw += 20.0F; + if (this.bR == 200 && !this.world.isStatic) { i = expToDrop - 10 * (expToDrop / 12); // CraftBukkit - drop the remaining experience while (i > 0) { @@ -516,12 +540,12 @@ public class EntityEnderDragon extends EntityComplex { this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); } - this.a(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); + this.c(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); this.die(); } } - private void a(int i, int j) { + private void c(int i, int j) { byte b0 = 64; BlockEnderPortal.a = true; @@ -587,9 +611,9 @@ public class EntityEnderDragon extends EntityComplex { BlockEnderPortal.a = false; } - protected void bb() {} + protected void bh() {} - public Entity[] al() { + public Entity[] ao() { return this.children; } @@ -597,6 +621,22 @@ public class EntityEnderDragon extends EntityComplex { return false; } + public World d() { + return this.world; + } + + protected String aW() { + return "mob.enderdragon.growl"; + } + + protected String aX() { + return "mob.enderdragon.hit"; + } + + protected float aV() { + return 5.0F; + } + // CraftBukkit start public int getExpReward() { // This value is equal to the amount of experience dropped while falling from the sky (10 * 1000) diff --git a/src/main/java/net/minecraft/server/EntityEnderPearl.java b/src/main/java/net/minecraft/server/EntityEnderPearl.java index ed18d558..cc897ac1 100644 --- a/src/main/java/net/minecraft/server/EntityEnderPearl.java +++ b/src/main/java/net/minecraft/server/EntityEnderPearl.java @@ -22,7 +22,7 @@ public class EntityEnderPearl extends EntityProjectile { } for (int i = 0; i < 32; ++i) { - this.world.a("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian()); + this.world.addParticle("portal", this.locX, this.locY + this.random.nextDouble() * 2.0D, this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian()); } if (!this.world.isStatic) { diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java index 3e6c8004..7e522cae 100644 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java @@ -10,15 +10,14 @@ public class EntityEnderman extends EntityMonster { private static boolean[] d = new boolean[256]; private int e = 0; - private int g = 0; + private int f = 0; public EntityEnderman(World world) { super(world); this.texture = "/mob/enderman.png"; - this.bw = 0.2F; - this.damage = 7; + this.bI = 0.2F; this.a(0.6F, 2.9F); - this.W = 1.0F; + this.X = 1.0F; } public int getMaxHealth() { @@ -49,13 +48,17 @@ public class EntityEnderman extends EntityMonster { if (entityhuman != null) { if (this.d(entityhuman)) { - if (this.g++ == 5) { - this.g = 0; - this.e(true); + if (this.f == 0) { + this.world.makeSound(entityhuman, "mob.endermen.stare", 1.0F, 1.0F); + } + + if (this.f++ == 5) { + this.f = 0; + this.f(true); return entityhuman; } } else { - this.g = 0; + this.f = 0; } } @@ -68,26 +71,26 @@ public class EntityEnderman extends EntityMonster { if (itemstack != null && itemstack.id == Block.PUMPKIN.id) { return false; } else { - Vec3D vec3d = entityhuman.i(1.0F).b(); - Vec3D vec3d1 = Vec3D.a().create(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.length / 2.0F) - (entityhuman.locY + (double) entityhuman.getHeadHeight()), this.locZ - entityhuman.locZ); - double d0 = vec3d1.c(); + Vec3D vec3d = entityhuman.i(1.0F).a(); + Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.length / 2.0F) - (entityhuman.locY + (double) entityhuman.getHeadHeight()), this.locZ - entityhuman.locZ); + double d0 = vec3d1.b(); - vec3d1 = vec3d1.b(); + vec3d1 = vec3d1.a(); double d1 = vec3d.b(vec3d1); - return d1 > 1.0D - 0.025D / d0 ? entityhuman.l(this) : false; + return d1 > 1.0D - 0.025D / d0 ? entityhuman.m(this) : false; } } - public void d() { + public void c() { if (this.G()) { this.damageEntity(DamageSource.DROWN, 1); } - this.bw = this.target != null ? 6.5F : 0.3F; + this.bI = this.target != null ? 6.5F : 0.3F; int i; - if (!this.world.isStatic) { + if (!this.world.isStatic && this.world.getGameRules().getBoolean("mobGriefing")) { int j; int k; int l; @@ -115,7 +118,7 @@ public class EntityEnderman extends EntityMonster { l = this.world.getTypeId(i, j, k); int i1 = this.world.getTypeId(i, j - 1, k); - if (l == 0 && i1 > 0 && Block.byId[i1].c()) { + if (l == 0 && i1 > 0 && Block.byId[i1].b()) { // CraftBukkit start - place event org.bukkit.block.Block bblock = this.world.getWorld().getBlockAt(i, j, k); @@ -129,26 +132,26 @@ public class EntityEnderman extends EntityMonster { } for (i = 0; i < 2; ++i) { - this.world.a("portal", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D); + this.world.addParticle("portal", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D); } - if (this.world.s() && !this.world.isStatic) { + if (this.world.t() && !this.world.isStatic) { float f = this.c(1.0F); if (f > 0.5F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { this.target = null; - this.e(false); - this.n(); + this.f(false); + this.m(); } } if (this.G()) { this.target = null; - this.e(false); - this.n(); + this.f(false); + this.m(); } - this.bu = false; + this.bG = false; if (this.target != null) { this.a(this.target, 100.0F, 100.0F); } @@ -156,26 +159,26 @@ public class EntityEnderman extends EntityMonster { if (!this.world.isStatic && this.isAlive()) { if (this.target != null) { if (this.target instanceof EntityHuman && this.d((EntityHuman) this.target)) { - this.br = this.bs = 0.0F; - this.bw = 0.0F; + this.bD = this.bE = 0.0F; + this.bI = 0.0F; if (this.target.e((Entity) this) < 16.0D) { - this.n(); + this.m(); } this.e = 0; - } else if (this.target.e((Entity) this) > 256.0D && this.e++ >= 30 && this.c(this.target)) { + } else if (this.target.e((Entity) this) > 256.0D && this.e++ >= 30 && this.o(this.target)) { this.e = 0; } } else { - this.e(false); + this.f(false); this.e = 0; } } - super.d(); + super.c(); } - protected boolean n() { + protected boolean m() { 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; @@ -183,14 +186,14 @@ public class EntityEnderman extends EntityMonster { return this.j(d0, d1, d2); } - protected boolean c(Entity entity) { - Vec3D vec3d = Vec3D.a().create(this.locX - entity.locX, this.boundingBox.b + (double) (this.length / 2.0F) - entity.locY + (double) entity.getHeadHeight(), this.locZ - entity.locZ); + protected boolean o(Entity entity) { + Vec3D vec3d = this.world.getVec3DPool().create(this.locX - entity.locX, this.boundingBox.b + (double) (this.length / 2.0F) - entity.locY + (double) entity.getHeadHeight(), this.locZ - entity.locZ); - vec3d = vec3d.b(); + vec3d = vec3d.a(); double d0 = 16.0D; - double d1 = this.locX + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.a * d0; - 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; + double d1 = this.locX + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.c * d0; + double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.d * d0; + double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.e * d0; return this.j(d1, d2, d3); } @@ -255,7 +258,7 @@ public class EntityEnderman extends EntityMonster { double d8 = d4 + (this.locY - d4) * d6 + this.random.nextDouble() * (double) this.length; double d9 = d5 + (this.locZ - d5) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D; - this.world.a("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); + this.world.addParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2); } this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); @@ -264,15 +267,15 @@ public class EntityEnderman extends EntityMonster { } } - protected String aQ() { - return "mob.endermen.idle"; + protected String aW() { + return this.q() ? "mob.endermen.scream" : "mob.endermen.idle"; } - protected String aR() { + protected String aX() { return "mob.endermen.hit"; } - protected String aS() { + protected String aY() { return "mob.endermen.death"; } @@ -316,7 +319,7 @@ public class EntityEnderman extends EntityMonster { public boolean damageEntity(DamageSource damagesource, int i) { if (damagesource instanceof EntityDamageSourceIndirect) { for (int j = 0; j < 64; ++j) { - if (this.n()) { + if (this.m()) { return true; } } @@ -324,17 +327,25 @@ public class EntityEnderman extends EntityMonster { return false; } else { if (damagesource.getEntity() instanceof EntityHuman) { - this.e(true); + this.f(true); } return super.damageEntity(damagesource, i); } } - public void e(boolean flag) { + public boolean q() { + return this.datawatcher.getByte(18) > 0; + } + + public void f(boolean flag) { this.datawatcher.watch(18, Byte.valueOf((byte) (flag ? 1 : 0))); } + public int c(Entity entity) { + return 7; + } + static { d[Block.GRASS.id] = true; d[Block.DIRT.id] = true; diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java index c1e1feaf..235cac9a 100644 --- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java +++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java @@ -27,7 +27,7 @@ public class EntityExperienceOrb extends Entity { this.value = i; } - protected boolean e_() { + protected boolean f_() { return false; } @@ -39,8 +39,8 @@ public class EntityExperienceOrb extends Entity { protected void a() {} - public void h_() { - super.h_(); + public void j_() { + super.j_(); if (this.c > 0) { --this.c; } @@ -115,7 +115,7 @@ public class EntityExperienceOrb extends Entity { } public boolean I() { - return this.world.a(this.boundingBox, Material.WATER, this); + return this.world.a(this.boundingBox, Material.WATER, (Entity) this); } protected void burn(int i) { @@ -146,8 +146,8 @@ public class EntityExperienceOrb extends Entity { public void b_(EntityHuman entityhuman) { if (!this.world.isStatic) { - if (this.c == 0 && entityhuman.bL == 0) { - entityhuman.bL = 2; + if (this.c == 0 && entityhuman.bU == 0) { + entityhuman.bU = 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.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value to event.getAmount() @@ -156,7 +156,7 @@ public class EntityExperienceOrb extends Entity { } } - public int d() { + public int c() { return this.value; } @@ -183,7 +183,7 @@ public class EntityExperienceOrb extends Entity { return i >= 2477 ? 2477 : (i >= 1237 ? 1237 : (i >= 617 ? 617 : (i >= 307 ? 307 : (i >= 149 ? 149 : (i >= 73 ? 73 : (i >= 37 ? 37 : (i >= 17 ? 17 : (i >= 7 ? 7 : (i >= 3 ? 3 : 1))))))))); } - public boolean an() { + public boolean aq() { return false; } } diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 05a14ab8..b3209a39 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -3,12 +3,9 @@ package net.minecraft.server; import java.util.Iterator; import java.util.List; -// CraftBukkit start -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -// CraftBukkit end +import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit -public class EntityFireball extends Entity { +public abstract class EntityFireball extends Entity { private int e = -1; private int f = -1; @@ -17,7 +14,7 @@ public class EntityFireball extends Entity { private boolean i = false; public EntityLiving shooter; private int j; - private int an = 0; + private int as = 0; public double dirX; public double dirY; public double dirZ; @@ -67,11 +64,11 @@ public class EntityFireball extends Entity { this.dirZ = d2 / d3 * 0.1D; } - public void h_() { + public void j_() { if (!this.world.isStatic && (this.shooter != null && this.shooter.dead || !this.world.isLoaded((int) this.locX, (int) this.locY, (int) this.locZ))) { this.die(); } else { - super.h_(); + super.j_(); this.setOnFire(1); if (this.i) { int i = this.world.getTypeId(this.e, this.f, this.g); @@ -90,19 +87,19 @@ public class EntityFireball extends Entity { this.motY *= (double) (this.random.nextFloat() * 0.2F); this.motZ *= (double) (this.random.nextFloat() * 0.2F); this.j = 0; - this.an = 0; + this.as = 0; } else { - ++this.an; + ++this.as; } - Vec3D vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); if (movingobjectposition != null) { - vec3d1 = Vec3D.a().create(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); + vec3d1 = this.world.getVec3DPool().create(movingobjectposition.pos.c, movingobjectposition.pos.d, movingobjectposition.pos.e); } Entity entity = null; @@ -113,7 +110,7 @@ public class EntityFireball extends Entity { while (iterator.hasNext()) { Entity entity1 = (Entity) iterator.next(); - if (entity1.L() && (!entity1.i(this.shooter) || this.an >= 25)) { + if (entity1.L() && (!entity1.i(this.shooter) || this.as >= 25)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.boundingBox.grow((double) f, (double) f, (double) f); MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1); @@ -149,9 +146,9 @@ public class EntityFireball extends Entity { this.locZ += this.motZ; float f1 = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D); + this.yaw = (float) (Math.atan2(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) + 90.0F; - for (this.pitch = (float) (Math.atan2(this.motY, (double) f1) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { + for (this.pitch = (float) (Math.atan2((double) f1, this.motY) * 180.0D / 3.1415927410125732D) - 90.0F; this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) { ; } @@ -169,13 +166,13 @@ public class EntityFireball extends Entity { this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F; this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F; - float f2 = 0.95F; + float f2 = this.c(); if (this.H()) { for (int j = 0; j < 4; ++j) { float f3 = 0.25F; - this.world.a("bubble", this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ); + this.world.addParticle("bubble", this.locX - this.motX * (double) f3, this.locY - this.motY * (double) f3, this.locZ - this.motZ * (double) f3, this.motX, this.motY, this.motZ); } f2 = 0.8F; @@ -187,30 +184,17 @@ public class EntityFireball extends Entity { this.motX *= (double) f2; this.motY *= (double) f2; this.motZ *= (double) f2; - this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); + this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); this.setPosition(this.locX, this.locY, this.locZ); } } - protected void a(MovingObjectPosition movingobjectposition) { - if (!this.world.isStatic) { - if (movingobjectposition.entity != null) { - movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 6); - } - - // CraftBukkit start - ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.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(); - } + protected float c() { + return 0.95F; } + protected abstract void a(MovingObjectPosition movingobjectposition); + public void b(NBTTagCompound nbttagcompound) { nbttagcompound.setShort("xTile", (short) this.e); nbttagcompound.setShort("yTile", (short) this.f); @@ -251,9 +235,9 @@ public class EntityFireball extends Entity { Vec3D vec3d = damagesource.getEntity().Z(); if (vec3d != null) { - this.motX = vec3d.a; - this.motY = vec3d.b; - this.motZ = vec3d.c; + this.motX = vec3d.c; + this.motY = vec3d.d; + this.motZ = vec3d.e; this.dirX = this.motX * 0.1D; this.dirY = this.motY * 0.1D; this.dirZ = this.motZ * 0.1D; diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java index cb1a6d87..a67c5c7d 100644 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/src/main/java/net/minecraft/server/EntityFishingHook.java @@ -19,24 +19,24 @@ public class EntityFishingHook extends Entity { public EntityHuman owner; private int i; private int j = 0; - private int an = 0; + private int as = 0; public Entity hooked = null; - private int ao; - private double ap; - private double aq; - private double ar; - private double as; - private double at; + private int at; + private double au; + private double av; + private double aw; + private double ax; + private double ay; public EntityFishingHook(World world) { super(world); this.a(0.25F, 0.25F); - this.ak = true; + this.al = true; } public EntityFishingHook(World world, EntityHuman entityhuman) { super(world); - this.ak = true; + this.al = true; this.owner = entityhuman; this.owner.hookedFish = this; this.a(0.25F, 0.25F); @@ -78,22 +78,22 @@ public class EntityFishingHook extends Entity { this.i = 0; } - public void h_() { - super.h_(); - if (this.ao > 0) { - double d0 = this.locX + (this.ap - this.locX) / (double) this.ao; - double d1 = this.locY + (this.aq - this.locY) / (double) this.ao; - double d2 = this.locZ + (this.ar - this.locZ) / (double) this.ao; - double d3 = MathHelper.g(this.as - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.ao); - this.pitch = (float) ((double) this.pitch + (this.at - (double) this.pitch) / (double) this.ao); - --this.ao; + public void j_() { + super.j_(); + if (this.at > 0) { + double d0 = this.locX + (this.au - this.locX) / (double) this.at; + double d1 = this.locY + (this.av - this.locY) / (double) this.at; + double d2 = this.locZ + (this.aw - this.locZ) / (double) this.at; + double d3 = MathHelper.g(this.ax - (double) this.yaw); + + this.yaw = (float) ((double) this.yaw + d3 / (double) this.at); + this.pitch = (float) ((double) this.pitch + (this.ay - (double) this.pitch) / (double) this.at); + --this.at; this.setPosition(d0, d1, d2); this.b(this.yaw, this.pitch); } else { if (!this.world.isStatic) { - ItemStack itemstack = this.owner.bC(); + ItemStack itemstack = this.owner.bP(); if (this.owner.dead || !this.owner.isAlive() || itemstack == null || itemstack.getItem() != Item.FISHING_ROD || this.e(this.owner) > 1024.0D) { this.die(); @@ -139,14 +139,14 @@ public class EntityFishingHook extends Entity { ++this.j; } - Vec3D vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); if (movingobjectposition != null) { - vec3d1 = Vec3D.a().create(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); + vec3d1 = this.world.getVec3DPool().create(movingobjectposition.pos.c, movingobjectposition.pos.d, movingobjectposition.pos.e); } Entity entity = null; @@ -232,8 +232,8 @@ public class EntityFishingHook extends Entity { } if (d6 > 0.0D) { - if (this.an > 0) { - --this.an; + if (this.as > 0) { + --this.as; } else { short short1 = 500; @@ -242,7 +242,7 @@ public class EntityFishingHook extends Entity { } if (this.random.nextInt(short1) == 0) { - this.an = this.random.nextInt(30) + 10; + this.as = this.random.nextInt(30) + 10; this.motY -= 0.20000000298023224D; this.world.makeSound(this, "random.splash", 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); float f3 = (float) MathHelper.floor(this.boundingBox.b); @@ -254,19 +254,19 @@ public class EntityFishingHook extends Entity { for (k = 0; (float) k < 1.0F + this.width * 20.0F; ++k) { f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.a("bubble", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); + this.world.addParticle("bubble", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ); } for (k = 0; (float) k < 1.0F + this.width * 20.0F; ++k) { f5 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; f4 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width; - this.world.a("splash", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY, this.motZ); + this.world.addParticle("splash", this.locX + (double) f5, (double) (f3 + 1.0F), this.locZ + (double) f4, this.motX, this.motY, this.motZ); } } } } - if (this.an > 0) { + if (this.as > 0) { this.motY -= (double) (this.random.nextFloat() * this.random.nextFloat() * this.random.nextFloat()) * 0.2D; } @@ -303,7 +303,7 @@ public class EntityFishingHook extends Entity { this.h = nbttagcompound.getByte("inGround") == 1; } - public int d() { + public int c() { if (this.world.isStatic) { return 0; } else { @@ -331,7 +331,7 @@ public class EntityFishingHook extends Entity { this.hooked.motY += d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D; this.hooked.motZ += d2 * d4; b0 = 3; - } else if (this.an > 0) { + } else if (this.as > 0) { EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH)); // CraftBukkit start PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); @@ -355,6 +355,7 @@ public class EntityFishingHook extends Entity { entityitem.motZ = d7 * d9; this.world.addEntity(entityitem); this.owner.a(StatisticList.B, 1); + this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, this.random.nextInt(3) + 1)); b0 = 1; } diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index e4377eee..8ec253fe 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -8,21 +8,21 @@ import org.bukkit.event.entity.EntityTargetEvent; public class EntityGhast extends EntityFlying implements IMonster { - public int a = 0; - public double b; + public int b = 0; public double c; public double d; + public double e; private Entity target = null; - private int h = 0; - public int e = 0; + private int i = 0; public int f = 0; + public int g = 0; public EntityGhast(World world) { super(world); this.texture = "/mob/ghast.png"; this.a(4.0F, 4.0F); this.fireProof = true; - this.aV = 5; + this.bc = 5; } public boolean damageEntity(DamageSource damagesource, int i) { @@ -44,42 +44,42 @@ public class EntityGhast extends EntityFlying implements IMonster { return 10; } - public void h_() { - super.h_(); + public void j_() { + super.j_(); byte b0 = this.datawatcher.getByte(16); this.texture = b0 == 1 ? "/mob/ghast_fire.png" : "/mob/ghast.png"; } - protected void be() { + protected void bk() { if (!this.world.isStatic && this.world.difficulty == 0) { this.die(); } - this.bb(); - this.e = this.f; - double d0 = this.b - this.locX; - double d1 = this.c - this.locY; - double d2 = this.d - this.locZ; + this.bh(); + this.f = this.g; + double d0 = this.c - this.locX; + double d1 = this.d - this.locY; + double d2 = this.e - this.locZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (d3 < 1.0D || d3 > 3600.0D) { - this.b = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.c = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); - this.d = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.c = this.locX + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.d = this.locY + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.e = this.locZ + (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 16.0F); } - if (this.a-- <= 0) { - this.a += this.random.nextInt(5) + 2; + if (this.b-- <= 0) { + this.b += this.random.nextInt(5) + 2; d3 = (double) MathHelper.sqrt(d3); - if (this.a(this.b, this.c, this.d, d3)) { + if (this.a(this.c, this.d, this.e, d3)) { this.motX += d0 / d3 * 0.1D; this.motY += d1 / d3 * 0.1D; this.motZ += d2 / d3 * 0.1D; } else { - this.b = this.locX; - this.c = this.locY; - this.d = this.locZ; + this.c = this.locX; + this.d = this.locY; + this.e = this.locZ; } } @@ -98,7 +98,7 @@ public class EntityGhast extends EntityFlying implements IMonster { // CraftBukkit end } - if (this.target == null || this.h-- <= 0) { + if (this.target == null || this.i-- <= 0) { // CraftBukkit start Entity target = this.world.findNearbyVulnerablePlayer(this, 100.0D); if (target != null) { @@ -116,7 +116,7 @@ public class EntityGhast extends EntityFlying implements IMonster { // CraftBukkit end if (this.target != null) { - this.h = 20; + this.i = 20; } } @@ -127,38 +127,38 @@ public class EntityGhast extends EntityFlying implements IMonster { double d6 = this.target.boundingBox.b + (double) (this.target.length / 2.0F) - (this.locY + (double) (this.length / 2.0F)); double d7 = this.target.locZ - this.locZ; - this.aq = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; - if (this.l(this.target)) { - if (this.f == 10) { + this.aw = this.yaw = -((float) Math.atan2(d5, d7)) * 180.0F / 3.1415927F; + if (this.m(this.target)) { + if (this.g == 10) { this.world.a((EntityHuman) null, 1007, (int) this.locX, (int) this.locY, (int) this.locZ, 0); } - ++this.f; - if (this.f == 20) { + ++this.g; + if (this.g == 20) { 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); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.world, this, d5, d6, d7); double d8 = 4.0D; Vec3D vec3d = this.i(1.0F); - entityfireball.locX = this.locX + vec3d.a * d8; - entityfireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D; - entityfireball.locZ = this.locZ + vec3d.c * d8; - this.world.addEntity(entityfireball); - this.f = -40; + entitylargefireball.locX = this.locX + vec3d.c * d8; + entitylargefireball.locY = this.locY + (double) (this.length / 2.0F) + 0.5D; + entitylargefireball.locZ = this.locZ + vec3d.e * d8; + this.world.addEntity(entitylargefireball); + this.g = -40; } - } else if (this.f > 0) { - --this.f; + } else if (this.g > 0) { + --this.g; } } else { - this.aq = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; - if (this.f > 0) { - --this.f; + this.aw = this.yaw = -((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F; + if (this.g > 0) { + --this.g; } } if (!this.world.isStatic) { byte b0 = this.datawatcher.getByte(16); - byte b1 = (byte) (this.f > 10 ? 1 : 0); + byte b1 = (byte) (this.g > 10 ? 1 : 0); if (b0 != b1) { this.datawatcher.watch(16, Byte.valueOf(b1)); @@ -167,9 +167,9 @@ public class EntityGhast extends EntityFlying implements IMonster { } private boolean a(double d0, double d1, double d2, double d3) { - double d4 = (this.b - this.locX) / d3; - double d5 = (this.c - this.locY) / d3; - double d6 = (this.d - this.locZ) / d3; + double d4 = (this.c - this.locX) / d3; + double d5 = (this.d - this.locY) / d3; + double d6 = (this.e - this.locZ) / d3; AxisAlignedBB axisalignedbb = this.boundingBox.clone(); for (int i = 1; (double) i < d3; ++i) { @@ -182,15 +182,15 @@ public class EntityGhast extends EntityFlying implements IMonster { return true; } - protected String aQ() { + protected String aW() { return "mob.ghast.moan"; } - protected String aR() { + protected String aX() { return "mob.ghast.scream"; } - protected String aS() { + protected String aY() { return "mob.ghast.death"; } @@ -219,7 +219,7 @@ public class EntityGhast extends EntityFlying implements IMonster { // CraftBukkit end } - protected float aP() { + protected float aV() { return 10.0F; } @@ -227,7 +227,7 @@ public class EntityGhast extends EntityFlying implements IMonster { return this.random.nextInt(20) == 0 && super.canSpawn() && this.world.difficulty > 0; } - public int bl() { + public int bs() { return 1; } } diff --git a/src/main/java/net/minecraft/server/EntityHanging.java b/src/main/java/net/minecraft/server/EntityHanging.java new file mode 100644 index 00000000..97ae4f6f --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityHanging.java @@ -0,0 +1,318 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.List; + +// CraftBukkit start +import org.bukkit.entity.Painting; +import org.bukkit.event.painting.PaintingBreakEvent.RemoveCause; +import org.bukkit.event.painting.PaintingBreakEvent; +// CraftBukkit end + +public abstract class EntityHanging extends Entity { + + private int e; + public int direction; + public int x; + public int y; + public int z; + + public EntityHanging(World world) { + super(world); + this.e = 0; + this.direction = 0; + this.height = 0.0F; + this.a(0.5F, 0.5F); + } + + public EntityHanging(World world, int i, int j, int k, int l) { + this(world); + this.x = i; + this.y = j; + this.z = k; + } + + protected void a() {} + + public void setDirection(int i) { + this.direction = i; + this.lastYaw = this.yaw = (float) (i * 90); + float f = (float) this.d(); + float f1 = (float) this.g(); + float f2 = (float) this.d(); + + if (i != 2 && i != 0) { + f = 0.5F; + } else { + f2 = 0.5F; + this.yaw = this.lastYaw = (float) (Direction.f[i] * 90); + } + + f /= 32.0F; + f1 /= 32.0F; + f2 /= 32.0F; + float f3 = (float) this.x + 0.5F; + float f4 = (float) this.y + 0.5F; + float f5 = (float) this.z + 0.5F; + float f6 = 0.5625F; + + if (i == 2) { + f5 -= f6; + } + + if (i == 1) { + f3 -= f6; + } + + if (i == 0) { + f5 += f6; + } + + if (i == 3) { + f3 += f6; + } + + if (i == 2) { + f3 -= this.g(this.d()); + } + + if (i == 1) { + f5 += this.g(this.d()); + } + + if (i == 0) { + f3 += this.g(this.d()); + } + + if (i == 3) { + f5 -= this.g(this.d()); + } + + f4 += this.g(this.g()); + this.setPosition((double) f3, (double) f4, (double) f5); + float f7 = -0.03125F; + + this.boundingBox.b((double) (f3 - f - f7), (double) (f4 - f1 - f7), (double) (f5 - f2 - f7), (double) (f3 + f + f7), (double) (f4 + f1 + f7), (double) (f5 + f2 + f7)); + } + + private float g(int i) { + return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); + } + + public void j_() { + if (this.e++ == 100 && !this.world.isStatic) { + this.e = 0; + if (!this.dead && !this.survives()) { + // CraftBukkit start + if (this instanceof EntityPainting) { + Material material = this.world.getMaterial((int) this.locX, (int) this.locY, (int) this.locZ); + RemoveCause cause; + + if (material.equals(Material.WATER)) { + cause = RemoveCause.WATER; + } else if (!material.equals(Material.AIR)) { + // TODO: This feels insufficient to catch 100% of suffocation cases + cause = RemoveCause.OBSTRUCTION; + } else { + cause = RemoveCause.PHYSICS; + } + + PaintingBreakEvent event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), cause); + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled() || dead) { + return; + } + } + // CraftBukkit end + + this.die(); + this.h(); + } + } + } + + public boolean survives() { + if (!this.world.getCubes(this, this.boundingBox).isEmpty()) { + return false; + } else { + int i = Math.max(1, this.d() / 16); + int j = Math.max(1, this.g() / 16); + int k = this.x; + int l = this.y; + int i1 = this.z; + + if (this.direction == 2) { + k = MathHelper.floor(this.locX - (double) ((float) this.d() / 32.0F)); + } + + if (this.direction == 1) { + i1 = MathHelper.floor(this.locZ - (double) ((float) this.d() / 32.0F)); + } + + if (this.direction == 0) { + k = MathHelper.floor(this.locX - (double) ((float) this.d() / 32.0F)); + } + + if (this.direction == 3) { + i1 = MathHelper.floor(this.locZ - (double) ((float) this.d() / 32.0F)); + } + + l = MathHelper.floor(this.locY - (double) ((float) this.g() / 32.0F)); + + for (int j1 = 0; j1 < i; ++j1) { + for (int k1 = 0; k1 < j; ++k1) { + Material material; + + if (this.direction != 2 && this.direction != 0) { + material = this.world.getMaterial(this.x, l + k1, i1 + j1); + } else { + material = this.world.getMaterial(k + j1, l + k1, this.z); + } + + if (!material.isBuildable()) { + return false; + } + } + } + + List list = this.world.getEntities(this, this.boundingBox); + Iterator iterator = list.iterator(); + + Entity entity; + + do { + if (!iterator.hasNext()) { + return true; + } + + entity = (Entity) iterator.next(); + } while (!(entity instanceof EntityHanging)); + + return false; + } + } + + public boolean L() { + return true; + } + + public boolean damageEntity(DamageSource damagesource, int i) { + if (!this.dead && !this.world.isStatic) { + // CraftBukkit start + if (this instanceof EntityPainting) { + PaintingBreakEvent event = null; + if (damagesource.getEntity() != null) { + event = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity()); + } else { + if (damagesource == DamageSource.FIRE) { + event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), RemoveCause.FIRE); + } + // TODO: Could put other stuff here? + } + + if (event != null) { + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + } + + if (this.dead) { + return true; + } + } + // CraftBukkit end + + this.die(); + this.K(); + EntityHuman entityhuman = null; + + if (damagesource.getEntity() instanceof EntityHuman) { + entityhuman = (EntityHuman) damagesource.getEntity(); + } + + if (entityhuman != null && entityhuman.abilities.canInstantlyBuild) { + return true; + } + + this.h(); + } + + return true; + } + + public void move(double d0, double d1, double d2) { + if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (dead) return; // CraftBukkit + + this.die(); + this.h(); + } + } + + public void g(double d0, double d1, double d2) { + if (false && !this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed + this.die(); + this.h(); + } + } + + public void b(NBTTagCompound nbttagcompound) { + nbttagcompound.setByte("Direction", (byte) this.direction); + nbttagcompound.setInt("TileX", this.x); + nbttagcompound.setInt("TileY", this.y); + nbttagcompound.setInt("TileZ", this.z); + switch (this.direction) { + case 0: + nbttagcompound.setByte("Dir", (byte) 2); + break; + + case 1: + nbttagcompound.setByte("Dir", (byte) 1); + break; + + case 2: + nbttagcompound.setByte("Dir", (byte) 0); + break; + + case 3: + nbttagcompound.setByte("Dir", (byte) 3); + } + } + + public void a(NBTTagCompound nbttagcompound) { + if (nbttagcompound.hasKey("Direction")) { + this.direction = nbttagcompound.getByte("Direction"); + } else { + switch (nbttagcompound.getByte("Dir")) { + case 0: + this.direction = 2; + break; + + case 1: + this.direction = 1; + break; + + case 2: + this.direction = 0; + break; + + case 3: + this.direction = 3; + } + } + + this.x = nbttagcompound.getInt("TileX"); + this.y = nbttagcompound.getInt("TileY"); + this.z = nbttagcompound.getInt("TileZ"); + this.setDirection(this.direction); + } + + public abstract int d(); + + public abstract int g(); + + public abstract void h(); +} diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index a269b009..9665716c 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -20,24 +20,21 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public Container defaultContainer; public Container activeContainer; protected FoodMetaData foodData = new FoodMetaData(); - protected int bC = 0; - public byte bD = 0; - public int bE = 0; - public float bF; - public float bG; - public boolean bH = false; - public int bI = 0; + protected int bO = 0; + public byte bP = 0; + public int bQ = 0; + public float bR; + public float bS; public String name; - public int dimension; - public int bL = 0; - public double bM; - public double bN; - public double bO; - public double bP; - public double bQ; - public double bR; + public int bU = 0; + public double bV; + public double bW; + public double bX; + public double bY; + public double bZ; + public double ca; // CraftBukkit start - public boolean sleeping; + public boolean sleeping; // protected -> public public boolean fauxSleeping; public String spawnWorld = ""; @@ -46,36 +43,35 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } // CraftBukkit end - public ChunkCoordinates bT; + public ChunkCoordinates cc; public int sleepTicks; // CraftBukkit - private -> public - public float bU; - public float bV; + public float cd; + public float ce; private ChunkCoordinates c; - private ChunkCoordinates d; - public int bW = 20; - protected boolean bX = false; - public float bY; + private boolean d; + private ChunkCoordinates e; public PlayerAbilities abilities = new PlayerAbilities(); public int oldLevel = -1; // CraftBukkit public int expLevel; public int expTotal; public float exp; - private ItemStack e; - private int f; - protected float cd = 0.1F; - protected float ce = 0.02F; + private ItemStack f; + private int g; + protected float cj = 0.1F; + protected float ck = 0.02F; + private int h = 0; public EntityFishingHook hookedFish = null; public EntityHuman(World world) { super(world); - this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic); + this.defaultContainer = new ContainerPlayer(this.inventory, !world.isStatic, this); this.activeContainer = this.defaultContainer; this.height = 1.62F; 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.aC = "humanoid"; - this.aB = 180.0F; + this.aI = "humanoid"; + this.aH = 180.0F; this.maxFireTicks = 20; this.texture = "/mob/char.png"; } @@ -90,49 +86,49 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.datawatcher.a(17, Byte.valueOf((byte) 0)); } - public boolean bw() { - return this.e != null; + public boolean bI() { + return this.f != null; } - public void by() { - if (this.e != null) { - this.e.b(this.world, this, this.f); + public void bK() { + if (this.f != null) { + this.f.b(this.world, this, this.g); } - this.bz(); + this.bL(); } - public void bz() { - this.e = null; - this.f = 0; + public void bL() { + this.f = null; + this.g = 0; if (!this.world.isStatic) { - this.c(false); + this.d(false); } } - public boolean aY() { - return this.bw() && Item.byId[this.e.id].b(this.e) == EnumAnimation.d; + public boolean be() { + return this.bI() && Item.byId[this.f.id].d_(this.f) == EnumAnimation.d; } - public void h_() { - if (this.e != null) { + public void j_() { + if (this.f != null) { ItemStack itemstack = this.inventory.getItemInHand(); - if (itemstack == this.e) { - if (this.f <= 25 && this.f % 4 == 0) { + if (itemstack == this.f) { + if (this.g <= 25 && this.g % 4 == 0) { this.c(itemstack, 5); } - if (--this.f == 0 && !this.world.isStatic) { - this.o(); + if (--this.g == 0 && !this.world.isStatic) { + this.n(); } } else { - this.bz(); + this.bL(); } } - if (this.bL > 0) { - --this.bL; + if (this.bU > 0) { + --this.bU; } if (this.isSleeping()) { @@ -142,9 +138,9 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } if (!this.world.isStatic) { - if (!this.l()) { + if (!this.j()) { this.a(true, true, false); - } else if (this.world.s()) { + } else if (this.world.t()) { this.a(false, true, true); } } @@ -155,7 +151,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } } - super.h_(); + super.j_(); if (!this.world.isStatic && this.activeContainer != null && !this.activeContainer.c(this)) { this.closeInventory(); this.activeContainer = this.defaultContainer; @@ -165,44 +161,44 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.extinguish(); } - this.bM = this.bP; - this.bN = this.bQ; - this.bO = this.bR; - double d0 = this.locX - this.bP; - double d1 = this.locY - this.bQ; - double d2 = this.locZ - this.bR; + this.bV = this.bY; + this.bW = this.bZ; + this.bX = this.ca; + double d0 = this.locX - this.bY; + double d1 = this.locY - this.bZ; + double d2 = this.locZ - this.ca; double d3 = 10.0D; if (d0 > d3) { - this.bM = this.bP = this.locX; + this.bV = this.bY = this.locX; } if (d2 > d3) { - this.bO = this.bR = this.locZ; + this.bX = this.ca = this.locZ; } if (d1 > d3) { - this.bN = this.bQ = this.locY; + this.bW = this.bZ = this.locY; } if (d0 < -d3) { - this.bM = this.bP = this.locX; + this.bV = this.bY = this.locX; } if (d2 < -d3) { - this.bO = this.bR = this.locZ; + this.bX = this.ca = this.locZ; } if (d1 < -d3) { - this.bN = this.bQ = this.locY; + this.bW = this.bZ = this.locY; } - this.bP += d0 * 0.25D; - this.bR += d2 * 0.25D; - this.bQ += d1 * 0.25D; + this.bY += d0 * 0.25D; + this.ca += d2 * 0.25D; + this.bZ += d1 * 0.25D; this.a(StatisticList.k, 1); if (this.vehicle == null) { - this.d = null; + this.e = null; } if (!this.world.isStatic) { @@ -210,6 +206,14 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } } + public int z() { + return this.abilities.isInvulnerable ? 0 : 80; + } + + public int ab() { + return 10; + } + protected void c(ItemStack itemstack, int i) { if (itemstack.n() == EnumAnimation.c) { this.world.makeSound(this, "random.drink", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); @@ -217,40 +221,40 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (itemstack.n() == EnumAnimation.b) { for (int j = 0; j < i; ++j) { - Vec3D vec3d = Vec3D.a().create(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + Vec3D vec3d = this.world.getVec3DPool().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.a().create(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D); + Vec3D vec3d1 = this.world.getVec3DPool().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.getHeadHeight(), 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.addParticle("iconcrack_" + itemstack.getItem().id, vec3d1.c, vec3d1.d, vec3d1.e, vec3d.c, vec3d.d + 0.05D, vec3d.e); } 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 o() { - if (this.e != null) { - this.c(this.e, 16); - int i = this.e.count; - ItemStack itemstack = this.e.b(this.world, this); + protected void n() { + if (this.f != null) { + this.c(this.f, 16); + int i = this.f.count; + ItemStack itemstack = this.f.b(this.world, this); - if (itemstack != this.e || itemstack != null && itemstack.count != i) { + if (itemstack != this.f || itemstack != null && itemstack.count != i) { this.inventory.items[this.inventory.itemInHandIndex] = itemstack; if (itemstack.count == 0) { this.inventory.items[this.inventory.itemInHandIndex] = null; } } - this.bz(); + this.bL(); } } - protected boolean aX() { + protected boolean bd() { return this.getHealth() <= 0 || this.isSleeping(); } @@ -263,36 +267,27 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen double d0 = this.locX; double d1 = this.locY; double d2 = this.locZ; + float f = this.yaw; + float f1 = this.pitch; super.U(); - this.bF = this.bG; - this.bG = 0.0F; + this.bR = this.bS; + this.bS = 0.0F; this.k(this.locX - d0, this.locY - d1, this.locZ - d2); - } - - private int k() { - 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 be() { - int i = this.k(); - - if (this.bH) { - ++this.bI; - if (this.bI >= i) { - this.bI = 0; - this.bH = false; - } - } else { - this.bI = 0; + if (this.vehicle instanceof EntityPig) { + this.pitch = f1; + this.yaw = f; + this.aw = ((EntityPig) this.vehicle).aw; } + } - this.aJ = (float) this.bI / (float) i; + protected void bk() { + this.bl(); } - public void d() { - if (this.bC > 0) { - --this.bC; + public void c() { + if (this.bO > 0) { + --this.bO; } if (this.world.difficulty == 0 && this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 * 12 == 0) { @@ -300,14 +295,14 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.heal(1, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); } - this.inventory.k(); - this.bF = this.bG; - super.d(); - this.aG = this.abilities.b(); - this.aH = this.ce; + this.inventory.j(); + this.bR = this.bS; + super.c(); + this.aM = this.abilities.b(); + this.aN = this.ck; if (this.isSprinting()) { - this.aG = (float) ((double) this.aG + (double) this.abilities.b() * 0.3D); - this.aH = (float) ((double) this.aH + (double) this.ce * 0.3D); + this.aM = (float) ((double) this.aM + (double) this.abilities.b() * 0.3D); + this.aN = (float) ((double) this.aN + (double) this.ck * 0.3D); } float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); @@ -326,8 +321,8 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen f1 = 0.0F; } - this.bG += (f - this.bG) * 0.4F; - this.aT += (f1 - this.aT) * 0.8F; + this.bS += (f - this.bS) * 0.4F; + this.ba += (f1 - this.ba) * 0.8F; if (this.getHealth() > 0) { List list = this.world.getEntities(this, this.boundingBox.grow(1.0D, 0.0D, 1.0D)); @@ -338,14 +333,14 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen Entity entity = (Entity) iterator.next(); if (!entity.dead) { - this.o(entity); + this.q(entity); } } } } } - private void o(Entity entity) { + private void q(Entity entity) { entity.b_(this); } @@ -358,10 +353,13 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.a(new ItemStack(Item.APPLE, 1), true); } - this.inventory.m(); + if (!this.world.getGameRules().getBoolean("keepInventory")) { + this.inventory.l(); + } + if (damagesource != null) { - this.motX = (double) (-MathHelper.cos((this.aP + this.yaw) * 3.1415927F / 180.0F) * 0.1F); - this.motZ = (double) (-MathHelper.sin((this.aP + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motX = (double) (-MathHelper.cos((this.aW + this.yaw) * 3.1415927F / 180.0F) * 0.1F); + this.motZ = (double) (-MathHelper.sin((this.aW + this.yaw) * 3.1415927F / 180.0F) * 0.1F); } else { this.motX = this.motZ = 0.0D; } @@ -371,7 +369,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } public void c(Entity entity, int i) { - this.bE += i; + this.bQ += i; if (entity instanceof EntityHuman) { this.a(StatisticList.A, 1); } else { @@ -379,13 +377,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } } - protected int h(int i) { - int j = EnchantmentManager.getOxygenEnchantmentLevel(this.inventory); - - return j > 0 && this.random.nextInt(j + 1) > 0 ? i : super.h(i); - } - - public EntityItem bB() { + public EntityItem bN() { return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, 1), false); } @@ -448,7 +440,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public float a(Block block) { float f = this.inventory.a(block); - int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this.inventory); + int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this); if (i > 0 && this.inventory.b(block)) { f += (float) (i * i + 1); @@ -462,7 +454,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen f *= 1.0F - (float) (this.getEffect(MobEffectList.SLOWER_DIG).getAmplifier() + 1) * 0.2F; } - if (this.a(Material.WATER) && !EnchantmentManager.hasWaterWorkerEnchantment(this.inventory)) { + if (this.a(Material.WATER) && !EnchantmentManager.hasWaterWorkerEnchantment(this)) { f /= 5.0F; } @@ -482,14 +474,13 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen NBTTagList nbttaglist = nbttagcompound.getList("Inventory"); this.inventory.b(nbttaglist); - this.dimension = nbttagcompound.getInt("Dimension"); this.sleeping = nbttagcompound.getBoolean("Sleeping"); this.sleepTicks = nbttagcompound.getShort("SleepTimer"); this.exp = nbttagcompound.getFloat("XpP"); this.expLevel = nbttagcompound.getInt("XpLevel"); this.expTotal = nbttagcompound.getInt("XpTotal"); if (this.sleeping) { - this.bT = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + this.cc = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); this.a(true, true, false); } @@ -502,6 +493,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { this.c = new ChunkCoordinates(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.d = nbttagcompound.getBoolean("SpawnForced"); } this.foodData.a(nbttagcompound); @@ -516,7 +508,6 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.set("Inventory", this.inventory.a(new NBTTagList())); - nbttagcompound.setInt("Dimension", this.dimension); nbttagcompound.setBoolean("Sleeping", this.sleeping); nbttagcompound.setShort("SleepTimer", (short) this.sleepTicks); nbttagcompound.setFloat("XpP", this.exp); @@ -526,6 +517,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen nbttagcompound.setInt("SpawnX", this.c.x); nbttagcompound.setInt("SpawnY", this.c.y); nbttagcompound.setInt("SpawnZ", this.c.z); + nbttagcompound.setBoolean("SpawnForced", this.d); nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds } @@ -538,15 +530,15 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public void startEnchanting(int i, int j, int k) {} - public void startCrafting(int i, int j, int k) {} + public void openAnvil(int i, int j, int k) {} - public void receive(Entity entity, int i) {} + public void startCrafting(int i, int j, int k) {} public float getHeadHeight() { return 0.12F; } - protected void d_() { + protected void e_() { this.height = 1.62F; } @@ -554,7 +546,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) { return false; } else { - this.bq = 0; + this.bC = 0; if (this.getHealth() <= 0) { return false; } else { @@ -562,8 +554,6 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.a(true, true, false); } - Entity entity = damagesource.getEntity(); - if (damagesource.n()) { if (this.world.difficulty == 0) { return false; // CraftBukkit - i = 0 -> return false @@ -581,14 +571,14 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (false && i == 0) { // CraftBukkit - Don't filter out 0 damage return false; } else { - Entity entity1 = damagesource.getEntity(); + Entity entity = damagesource.getEntity(); - if (entity1 instanceof EntityArrow && ((EntityArrow) entity1).shooter != null) { - entity1 = ((EntityArrow) entity1).shooter; + if (entity instanceof EntityArrow && ((EntityArrow) entity).shooter != null) { + entity = ((EntityArrow) entity).shooter; } - if (entity1 instanceof EntityLiving) { - this.a((EntityLiving) entity1, false); + if (entity instanceof EntityLiving) { + this.a((EntityLiving) entity, false); } this.a(StatisticList.x, i); @@ -604,7 +594,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (j <= 0) { return 0; } else { - int k = EnchantmentManager.a(this.inventory, damagesource); + int k = EnchantmentManager.a(this.inventory.armor, damagesource); if (k > 20) { k = 20; @@ -612,10 +602,10 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (k > 0 && k <= 20) { int l = 25 - k; - int i1 = j * l + this.aM; + int i1 = j * l + this.aS; j = i1 / 25; - this.aM = i1 % 25; + this.aS = i1 % 25; } return j; @@ -643,7 +633,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen while (iterator.hasNext()) { EntityWolf entitywolf1 = (EntityWolf) iterator.next(); - if (entitywolf1.isTamed() && entitywolf1.m() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { + if (entitywolf1.isTamed() && entitywolf1.l() == null && this.name.equals(entitywolf1.getOwnerName()) && (!flag || !entitywolf1.isSitting())) { entitywolf1.setSitting(false); entitywolf1.setTarget(entityliving); } @@ -656,38 +646,58 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.inventory.g(i); } - public int aO() { - return this.inventory.l(); + public int aU() { + return this.inventory.k(); } - protected void d(DamageSource damagesource, int i) { - if (!damagesource.ignoresArmor() && this.aY()) { - i = 1 + i >> 1; + public float bO() { + int i = 0; + ItemStack[] aitemstack = this.inventory.armor; + int j = aitemstack.length; + + for (int k = 0; k < j; ++k) { + ItemStack itemstack = aitemstack[k]; + + if (itemstack != null) { + ++i; + } } - i = this.b(damagesource, i); - i = this.c(damagesource, i); - this.j(damagesource.d()); - this.health -= i; + return (float) i / (float) this.inventory.armor.length; + } + + protected void d(DamageSource damagesource, int i) { + if (!this.invulnerable) { + if (!damagesource.ignoresArmor() && this.be()) { + i = 1 + i >> 1; + } + + i = this.b(damagesource, i); + i = this.c(damagesource, i); + this.j(damagesource.d()); + this.health -= i; + } } public void openFurnace(TileEntityFurnace tileentityfurnace) {} public void openDispenser(TileEntityDispenser tileentitydispenser) {} - public void a(TileEntitySign tileentitysign) {} + public void a(TileEntity tileentity) {} public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) {} + public void openBeacon(TileEntityBeacon tileentitybeacon) {} + public void openTrade(IMerchant imerchant) {} - public void c(ItemStack itemstack) {} + public void d(ItemStack itemstack) {} - public boolean m(Entity entity) { + public boolean o(Entity entity) { if (entity.c(this)) { return true; } else { - ItemStack itemstack = this.bC(); + ItemStack itemstack = this.bP(); if (itemstack != null && entity instanceof EntityLiving) { if (this.abilities.canInstantlyBuild) { @@ -697,7 +707,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (itemstack.a((EntityLiving) entity)) { // CraftBukkit - bypass infinite items; <= 0 -> == 0 if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) { - this.bD(); + this.bQ(); } return true; @@ -708,11 +718,11 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } } - public ItemStack bC() { + public ItemStack bP() { return this.inventory.getItemInHand(); } - public void bD() { + public void bQ() { this.inventory.setItem(this.inventory.itemInHandIndex, (ItemStack) null); } @@ -720,15 +730,8 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return (double) (this.height - 0.5F); } - public void i() { - if (!this.bH || this.bI >= this.k() / 2 || this.bI < 0) { - this.bI = -1; - this.bH = true; - } - } - public void attack(Entity entity) { - if (entity.an()) { + if (entity.aq()) { int i = this.inventory.a(entity); if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) { @@ -743,8 +746,8 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen int k = 0; if (entity instanceof EntityLiving) { - k = EnchantmentManager.a(this.inventory, (EntityLiving) entity); - j += EnchantmentManager.getKnockbackEnchantmentLevel(this.inventory, (EntityLiving) entity); + k = EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity); + j += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); } if (this.isSprinting()) { @@ -752,7 +755,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } if (i > 0 || k > 0) { - boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.f_() && !this.H() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving; + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.g_() && !this.H() && !this.hasEffect(MobEffectList.BLINDNESS) && this.vehicle == null && entity instanceof EntityLiving; if (flag) { i += this.random.nextInt(i / 2 + 2); @@ -787,16 +790,16 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.a((Statistic) AchievementList.E); } - this.j(entity); + this.k(entity); } - ItemStack itemstack = this.bC(); + ItemStack itemstack = this.bP(); if (itemstack != null && entity instanceof EntityLiving) { itemstack.a((EntityLiving) entity, this); // CraftBukkit - bypass infinite items; <= 0 -> == 0 if (itemstack.count == 0) { - this.bD(); + this.bQ(); } } @@ -806,9 +809,9 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } this.a(StatisticList.w, i); - int l = EnchantmentManager.getFireAspectEnchantmentLevel(this.inventory, (EntityLiving) entity); + int l = EnchantmentManager.getFireAspectEnchantmentLevel(this, (EntityLiving) entity); - if (l > 0) { + if (l > 0 && flag1) { // CraftBukkit start - raise a combust event when somebody hits with a fire enchanted item EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), l * 4); org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); @@ -841,7 +844,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return !this.sleeping && super.inBlock(); } - public boolean bF() { + public boolean bS() { return false; } @@ -855,7 +858,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return EnumBedResult.NOT_POSSIBLE_HERE; } - if (this.world.s()) { + if (this.world.t()) { return EnumBedResult.NOT_POSSIBLE_NOW; } @@ -890,7 +893,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.height = 0.2F; if (this.world.isLoaded(i, j, k)) { int l = this.world.getData(i, j, k); - int i1 = BlockBed.d(l); + int i1 = BlockBed.e(l); float f = 0.5F; float f1 = 0.5F; @@ -911,7 +914,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen f = 0.9F; } - this.b(i1); + this.u(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)); @@ -919,7 +922,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.sleeping = true; this.sleepTicks = 0; - this.bT = new ChunkCoordinates(i, j, k); + this.cc = new ChunkCoordinates(i, j, k); this.motX = this.motZ = this.motY = 0.0D; if (!this.world.isStatic) { this.world.everyoneSleeping(); @@ -928,32 +931,32 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return EnumBedResult.OK; } - private void b(int i) { - this.bU = 0.0F; - this.bV = 0.0F; + private void u(int i) { + this.cd = 0.0F; + this.ce = 0.0F; switch (i) { case 0: - this.bV = -1.8F; + this.ce = -1.8F; break; case 1: - this.bU = 1.8F; + this.cd = 1.8F; break; case 2: - this.bV = 1.8F; + this.ce = 1.8F; break; case 3: - this.bU = -1.8F; + this.cd = -1.8F; } } public void a(boolean flag, boolean flag1, boolean flag2) { this.a(0.6F, 1.8F); - this.d_(); - ChunkCoordinates chunkcoordinates = this.bT; - ChunkCoordinates chunkcoordinates1 = this.bT; + this.e_(); + ChunkCoordinates chunkcoordinates = this.cc; + ChunkCoordinates chunkcoordinates1 = this.cc; 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); @@ -993,23 +996,23 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } if (flag2) { - this.setRespawnPosition(this.bT); + this.setRespawnPosition(this.cc, false); } } - private boolean l() { - return this.world.getTypeId(this.bT.x, this.bT.y, this.bT.z) == Block.BED.id; + private boolean j() { + return this.world.getTypeId(this.cc.x, this.cc.y, this.cc.z) == Block.BED.id; } - public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates) { - IChunkProvider ichunkprovider = world.F(); + public static ChunkCoordinates getBed(World world, ChunkCoordinates chunkcoordinates, boolean flag) { + IChunkProvider ichunkprovider = world.H(); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z - 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x - 3 >> 4, chunkcoordinates.z + 3 >> 4); ichunkprovider.getChunkAt(chunkcoordinates.x + 3 >> 4, chunkcoordinates.z + 3 >> 4); if (world.getTypeId(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) != Block.BED.id) { - return null; + return flag && world.isEmpty(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z) && world.isEmpty(chunkcoordinates.x, chunkcoordinates.y + 1, chunkcoordinates.z) ? chunkcoordinates : null; } else { ChunkCoordinates chunkcoordinates1 = BlockBed.b(world, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, 0); @@ -1025,18 +1028,34 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return this.sleeping && this.sleepTicks >= 100; } - public void c(String s) {} + protected void b(int i, boolean flag) { + byte b0 = this.datawatcher.getByte(16); + + if (flag) { + this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1 << i))); + } else { + this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & ~(1 << i)))); + } + } + + public void b(String s) {} public ChunkCoordinates getBed() { return this.c; } - public void setRespawnPosition(ChunkCoordinates chunkcoordinates) { + public boolean isRespawnForced() { + return this.d; + } + + public void setRespawnPosition(ChunkCoordinates chunkcoordinates, boolean flag) { if (chunkcoordinates != null) { this.c = new ChunkCoordinates(chunkcoordinates); - this.spawnWorld = this.world.worldData.getName(); + this.d = flag; + this.spawnWorld = this.world.worldData.getName(); // CraftBukkit } else { this.c = null; + this.d = false; } } @@ -1046,8 +1065,8 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public void a(Statistic statistic, int i) {} - protected void aZ() { - super.aZ(); + protected void bf() { + super.bf(); this.a(StatisticList.u, 1); if (this.isSprinting()) { this.j(0.8F); @@ -1063,12 +1082,12 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (this.abilities.isFlying && this.vehicle == null) { double d3 = this.motY; - float f2 = this.aH; + float f2 = this.aN; - this.aH = this.abilities.a(); + this.aN = this.abilities.a(); super.e(f, f1); this.motY = d3 * 0.6D; - this.aH = f2; + this.aN = f2; } else { super.e(f, f1); } @@ -1092,7 +1111,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.a(StatisticList.m, i); this.j(0.015F * (float) i * 0.01F); } - } else if (this.f_()) { + } else if (this.g_()) { if (d1 > 0.0D) { this.a(StatisticList.o, (int) Math.round(d1 * 100.0D)); } @@ -1122,9 +1141,9 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen if (i > 0) { if (this.vehicle instanceof EntityMinecart) { this.a(StatisticList.r, i); - if (this.d == null) { - this.d = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); - } else if ((double) this.d.e(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) >= 1000000.0D) { + if (this.e == null) { + this.e = new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + } else if ((double) this.e.e(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) >= 1000000.0D) { this.a((Statistic) AchievementList.q, 1); } } else if (this.vehicle instanceof EntityBoat) { @@ -1147,21 +1166,21 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen } public void a(EntityLiving entityliving) { - if (entityliving instanceof EntityMonster) { + if (entityliving instanceof IMonster) { this.a((Statistic) AchievementList.s); } } - public void aa() { - if (this.bW > 0) { - this.bW = 10; - } else { - this.bX = true; - } + public ItemStack q(int i) { + return this.inventory.f(i); } + protected void bB() {} + + protected void bC() {} + public void giveExp(int i) { - this.bE += i; + this.bQ += i; int j = Integer.MAX_VALUE - this.expTotal; if (i > j) { @@ -1172,25 +1191,28 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen for (this.expTotal += i; this.exp >= 1.0F; this.exp /= (float) this.getExpToLevel()) { this.exp = (this.exp - 1.0F) * (float) this.getExpToLevel(); - this.levelUp(); + this.levelDown(1); } } public void levelDown(int i) { - this.expLevel -= i; + this.expLevel += i; if (this.expLevel < 0) { this.expLevel = 0; } + + if (i > 0 && this.expLevel % 5 == 0 && (float) this.h < (float) this.ticksLived - 100.0F) { + float f = this.expLevel > 30 ? 1.0F : (float) this.expLevel / 30.0F; + + this.world.makeSound(this, "random.levelup", f * 0.75F, 1.0F); + this.h = this.ticksLived; + } } public int getExpToLevel() { return this.expLevel >= 30 ? 62 + (this.expLevel - 30) * 7 : (this.expLevel >= 15 ? 17 + (this.expLevel - 15) * 3 : 17); } - private void levelUp() { - ++this.expLevel; - } - public void j(float f) { if (!this.abilities.isInvulnerable) { if (!this.world.isStatic) { @@ -1203,32 +1225,55 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return this.foodData; } - public boolean e(boolean flag) { + public boolean f(boolean flag) { return (flag || this.foodData.c()) && !this.abilities.isInvulnerable; } - public boolean bM() { + public boolean ca() { return this.getHealth() > 0 && this.getHealth() < this.getMaxHealth(); } public void a(ItemStack itemstack, int i) { - if (itemstack != this.e) { - this.e = itemstack; - this.f = i; + if (itemstack != this.f) { + this.f = itemstack; + this.g = i; if (!this.world.isStatic) { - this.c(true); + this.d(true); + } + } + } + + public boolean f(int i, int j, int k) { + if (this.abilities.mayBuild) { + return true; + } else { + int l = this.world.getTypeId(i, j, k); + + if (l > 0 && this.bP() != null) { + Block block = Block.byId[l]; + ItemStack itemstack = this.bP(); + + if (itemstack.b(block) || itemstack.a(block) > 1.0F) { + return true; + } } + + return false; } } - public boolean e(int i, int j, int k) { - return this.abilities.mayBuild; + public boolean a(int i, int j, int k, int l, ItemStack itemstack) { + return this.abilities.mayBuild ? true : (itemstack != null ? itemstack.x() : false); } protected int getExpValue(EntityHuman entityhuman) { - int i = this.expLevel * 7; + if (this.world.getGameRules().getBoolean("keepInventory")) { + return 0; + } else { + int i = this.expLevel * 7; - return i > 100 ? 100 : i; + return i > 100 ? 100 : i; + } } protected boolean alwaysGivesExp() { @@ -1239,8 +1284,6 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen return this.name; } - public void c(int i) {} - public void copyTo(EntityHuman entityhuman, boolean flag) { if (flag) { this.inventory.b(entityhuman.inventory); @@ -1249,13 +1292,20 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen this.expLevel = entityhuman.expLevel; this.expTotal = entityhuman.expTotal; this.exp = entityhuman.exp; - this.bE = entityhuman.bE; + this.bQ = entityhuman.bQ; + this.aq = entityhuman.aq; + } else if (this.world.getGameRules().getBoolean("keepInventory")) { + this.inventory.b(entityhuman.inventory); + this.expLevel = entityhuman.expLevel; + this.expTotal = entityhuman.expTotal; + this.exp = entityhuman.exp; + this.bQ = entityhuman.bQ; } this.enderChest = entityhuman.enderChest; } - protected boolean e_() { + protected boolean f_() { return !this.abilities.isFlying; } @@ -1278,4 +1328,20 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen public InventoryEnderChest getEnderChest() { return this.enderChest; } + + public ItemStack getEquipment(int i) { + return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; + } + + public ItemStack bA() { + return this.inventory.getItemInHand(); + } + + public void setEquipment(int i, ItemStack itemstack) { + this.inventory.armor[i] = itemstack; + } + + public ItemStack[] getEquipment() { + return this.inventory.armor; + } } diff --git a/src/main/java/net/minecraft/server/EntityIronGolem.java b/src/main/java/net/minecraft/server/EntityIronGolem.java index 937e1791..d0d2357d 100644 --- a/src/main/java/net/minecraft/server/EntityIronGolem.java +++ b/src/main/java/net/minecraft/server/EntityIronGolem.java @@ -24,7 +24,7 @@ public class EntityIronGolem extends EntityGolem { this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalDefendVillage(this)); this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false)); - this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, false, true)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, false, true, IMonster.a)); } protected void a() { @@ -32,36 +32,44 @@ public class EntityIronGolem extends EntityGolem { this.datawatcher.a(16, Byte.valueOf((byte) 0)); } - public boolean aV() { + public boolean bb() { return true; } - protected void bd() { + protected void bj() { if (--this.e <= 0) { this.e = 70 + this.random.nextInt(50); this.d = this.world.villages.getClosestVillage(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 32); if (this.d == null) { - this.aE(); + this.aK(); } else { ChunkCoordinates chunkcoordinates = this.d.getCenter(); - this.b(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, this.d.getSize()); + this.b(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, (int) ((float) this.d.getSize() * 0.6F)); } } - super.bd(); + super.bj(); } public int getMaxHealth() { return 100; } - protected int h(int i) { + protected int g(int i) { return i; } - public void d() { - super.d(); + protected void n(Entity entity) { + if (entity instanceof IMonster && this.aA().nextInt(20) == 0) { + this.b((EntityLiving) entity); + } + + super.n(entity); + } + + public void c() { + super.c(); if (this.f > 0) { --this.f; } @@ -77,16 +85,26 @@ public class EntityIronGolem extends EntityGolem { int l = this.world.getTypeId(i, j, k); if (l > 0) { - this.world.a("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.random.nextFloat() - 0.5D), 0.5D, ((double) this.random.nextFloat() - 0.5D) * 4.0D); + this.world.addParticle("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.random.nextFloat() - 0.5D), 0.5D, ((double) this.random.nextFloat() - 0.5D) * 4.0D); } } } public boolean a(Class oclass) { - return this.q() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass); + return this.p() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.setBoolean("PlayerCreated", this.p()); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.setPlayerCreated(nbttagcompound.getBoolean("PlayerCreated")); } - public boolean k(Entity entity) { + public boolean l(Entity entity) { this.f = 10; this.world.broadcastEntityEffect(this, (byte) 4); boolean flag = entity.damageEntity(DamageSource.mobAttack(this), 7 + this.random.nextInt(15)); @@ -99,24 +117,24 @@ public class EntityIronGolem extends EntityGolem { return flag; } - public Village n() { + public Village m() { return this.d; } - public void e(boolean flag) { + public void f(boolean flag) { this.g = flag ? 400 : 0; this.world.broadcastEntityEffect(this, (byte) 11); } - protected String aQ() { + protected String aW() { return "none"; } - protected String aR() { + protected String aX() { return "mob.irongolem.hit"; } - protected String aS() { + protected String aY() { return "mob.irongolem.death"; } @@ -145,15 +163,15 @@ public class EntityIronGolem extends EntityGolem { // CraftBukkit end } - public int p() { + public int o() { return this.g; } - public boolean q() { + public boolean p() { return (this.datawatcher.getByte(16) & 1) != 0; } - public void f(boolean flag) { + public void setPlayerCreated(boolean flag) { byte b0 = this.datawatcher.getByte(16); if (flag) { @@ -162,4 +180,12 @@ public class EntityIronGolem extends EntityGolem { this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2))); } } + + public void die(DamageSource damagesource) { + if (!this.p() && this.killer != null && this.d != null) { + this.d.a(this.killer.getName(), -5); + } + + super.die(damagesource); + } } diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index 5003452c..cecd16d8 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -19,6 +19,7 @@ public class EntityItem extends Entity { this.height = this.length / 2.0F; this.setPosition(d0, d1, d2); this.itemStack = itemstack; + // CraftBukkit start - infinite item fix & nullcheck if (this.itemStack == null) { throw new IllegalArgumentException("Can't create an EntityItem for a null item"); @@ -27,13 +28,14 @@ public class EntityItem extends Entity { this.itemStack.count = 1; } // CraftBukkit end + this.yaw = (float) (Math.random() * 360.0D); this.motX = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); this.motY = 0.20000000298023224D; this.motZ = (double) ((float) (Math.random() * 0.20000000298023224D - 0.10000000149011612D)); } - protected boolean e_() { + protected boolean f_() { return false; } @@ -45,8 +47,8 @@ public class EntityItem extends Entity { protected void a() {} - public void h_() { - super.h_(); + public void j_() { + super.j_(); // CraftBukkit start int currentTick = (int) (System.currentTimeMillis() / 50); this.pickupDelay -= (currentTick - this.lastTick); @@ -99,7 +101,7 @@ public class EntityItem extends Entity { } ++this.age; - if (this.age >= 6000) { + if (!this.world.isStatic && this.age >= 6000) { // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { this.age = 0; @@ -116,34 +118,38 @@ public class EntityItem extends Entity { } else if (entityitem.isAlive() && this.isAlive()) { if (entityitem.itemStack.getItem() != this.itemStack.getItem()) { return false; - } else if (entityitem.itemStack.getItem().k() && entityitem.itemStack.getData() != this.itemStack.getData()) { - return false; - } else if (entityitem.itemStack.count < this.itemStack.count) { - return entityitem.a(this); - } else if (entityitem.itemStack.count + this.itemStack.count > entityitem.itemStack.getMaxStackSize()) { - return false; - // CraftBukkit start - don't merge items with enchantments - } else if (entityitem.itemStack.hasEnchantments() || this.itemStack.hasEnchantments()) { - return false; - // CraftBukkit end + } else if (!entityitem.itemStack.hasTag() && !this.itemStack.hasTag()) { + if (entityitem.itemStack.getItem().l() && entityitem.itemStack.getData() != this.itemStack.getData()) { + return false; + } else if (entityitem.itemStack.count < this.itemStack.count) { + return entityitem.a(this); + } else if (entityitem.itemStack.count + this.itemStack.count > entityitem.itemStack.getMaxStackSize()) { + return false; + // CraftBukkit start - don't merge items with enchantments + } else if (entityitem.itemStack.hasEnchantments() || this.itemStack.hasEnchantments()) { + return false; + // CraftBukkit end + } else { + entityitem.itemStack.count += this.itemStack.count; + entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); + entityitem.age = Math.min(entityitem.age, this.age); + this.die(); + return true; + } } else { - entityitem.itemStack.count += this.itemStack.count; - entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); - entityitem.age = Math.min(entityitem.age, this.age); - this.die(); - return true; + return false; } } else { return false; } } - public void d() { + public void c() { this.age = 4800; } public boolean I() { - return this.world.a(this.boundingBox, Material.WATER, this); + return this.world.a(this.boundingBox, Material.WATER, (Entity) this); } protected void burn(int i) { @@ -233,7 +239,7 @@ public class EntityItem extends Entity { return LocaleI18n.get("item." + this.itemStack.a()); } - public boolean an() { + public boolean aq() { return false; } } diff --git a/src/main/java/net/minecraft/server/EntityLargeFireball.java b/src/main/java/net/minecraft/server/EntityLargeFireball.java new file mode 100644 index 00000000..3f7d9502 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityLargeFireball.java @@ -0,0 +1,34 @@ +package net.minecraft.server; + +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit + +public class EntityLargeFireball extends EntityFireball { + + public EntityLargeFireball(World world) { + super(world); + } + + public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { + super(world, entityliving, d0, d1, d2); + } + + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + if (movingobjectposition.entity != null) { + movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 6); + } + + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.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(), this.world.getGameRules().getBoolean("mobGriefing")); + } + // CraftBukkit end + + this.die(); + } + } +} diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java index 28aee4cf..e386fbe6 100644 --- a/src/main/java/net/minecraft/server/EntityLightning.java +++ b/src/main/java/net/minecraft/server/EntityLightning.java @@ -70,8 +70,8 @@ public class EntityLightning extends EntityWeather { } } - public void h_() { - super.h_(); + public void j_() { + super.j_(); 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); @@ -118,7 +118,7 @@ public class EntityLightning extends EntityWeather { entity.a(this); } - this.world.s = 2; + this.world.r = 2; } } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 826ab5ea..884a797f 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -15,57 +15,61 @@ import org.bukkit.event.entity.EntityRegainHealthEvent; public abstract class EntityLiving extends Entity { + private static final float[] b = new float[] { 0.0F, 0.0F, 0.005F, 0.01F}; + private static final float[] c = new float[] { 0.0F, 0.0F, 0.05F, 0.1F}; + private static final float[] d = new float[] { 0.0F, 0.0F, 0.005F, 0.02F}; + public static final float[] as = new float[] { 0.0F, 0.01F, 0.07F, 0.2F}; public int maxNoDamageTicks = 20; - public float ao; - public float ap; - public float aq = 0.0F; - public float ar = 0.0F; - public float as = 0.0F; - public float at = 0.0F; - protected float au; - protected float av; - protected float aw; - protected float ax; - protected boolean ay = true; + public float au; + public float av; + public float aw = 0.0F; + public float ax = 0.0F; + public float ay = 0.0F; + public float az = 0.0F; + protected float aA; + protected float aB; + protected float aC; + protected float aD; + protected boolean aE = true; protected String texture = "/mob/char.png"; - protected boolean aA = true; - protected float aB = 0.0F; - protected String aC = null; - protected float aD = 1.0F; - protected int aE = 0; - protected float aF = 0.0F; - public float aG = 0.1F; - public float aH = 0.02F; - public float aI; - public float aJ; + protected boolean aG = true; + protected float aH = 0.0F; + protected String aI = null; + protected float aJ = 1.0F; + protected int aK = 0; + protected float aL = 0.0F; + public float aM = 0.1F; + public float aN = 0.02F; + public float aO; + public float aP; protected int health = this.getMaxHealth(); - public int aL; - protected int aM; - private int a; + public int aR; + protected int aS; + public int aT; public int hurtTicks; - public int aO; - public float aP = 0.0F; + public int aV; + public float aW = 0.0F; public int deathTicks = 0; public int attackTicks = 0; - public float aS; - public float aT; - protected boolean aU = false; - protected int aV; - public int aW = -1; - public float aX = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); - public float aY; public float aZ; public float ba; + protected boolean bb = false; + protected int bc; + public int bd = -1; + public float be = (float) (Math.random() * 0.8999999761581421D + 0.10000000149011612D); + public float bf; + public float bg; + public float bh; public EntityHuman killer = null; // CraftBukkit - protected -> public protected int lastDamageByPlayerTime = 0; public EntityLiving lastDamager = null; // CraftBukkit - private -> public - private int c = 0; - private EntityLiving d = null; - public int bd = 0; - public int be = 0; + private int f = 0; + private EntityLiving g = null; + public int bk = 0; + public int bl = 0; public HashMap effects = new HashMap(); // CraftBukkit - protected -> public public boolean updateEffects = true; // CraftBukkit - private -> public - private int f; + private int i; private ControllerLook lookController; private ControllerMove moveController; private ControllerJump jumpController; @@ -73,29 +77,37 @@ public abstract class EntityLiving extends Entity { private Navigation navigation; protected final PathfinderGoalSelector goalSelector; protected final PathfinderGoalSelector targetSelector; - private EntityLiving bz; - private EntitySenses bA; - private float bB; - private ChunkCoordinates bC = new ChunkCoordinates(0, 0, 0); - private float bD = -1.0F; - protected int bi; - protected double bj; - protected double bk; - protected double bl; - protected double bm; - protected double bn; - float bo = 0.0F; + private EntityLiving bO; + private EntitySenses bP; + private float bQ; + private ChunkCoordinates bR = new ChunkCoordinates(0, 0, 0); + private float bS = -1.0F; + private ItemStack[] equipment = new ItemStack[5]; + protected float[] dropChances = new float[5]; + private ItemStack[] bU = new ItemStack[5]; + public boolean bq = false; + public int br = 0; + protected boolean canPickUpLoot = false; + private boolean persistent = false; + protected boolean invulnerable = false; + protected int bu; + protected double bv; + protected double bw; + protected double bx; + protected double by; + protected double bz; + float bA = 0.0F; public int lastDamage = 0; // CraftBukkit - protected -> public - protected int bq = 0; - protected float br; - protected float bs; - protected float bt; - protected boolean bu = false; - protected float bv = 0.0F; - protected float bw = 0.7F; - private int bE = 0; - private Entity bF; - protected int bx = 0; + protected int bC = 0; + protected float bD; + protected float bE; + protected float bF; + protected boolean bG = false; + protected float bH = 0.0F; + protected float bI = 0.7F; + private int bW = 0; + private Entity bX; + protected int bJ = 0; public int expToDrop = 0; // CraftBukkit public int maxAirTicks = 300; // CraftBukkit @@ -109,13 +121,18 @@ public abstract class EntityLiving extends Entity { this.jumpController = new ControllerJump(this); this.senses = new EntityAIBodyControl(this); this.navigation = new Navigation(this, world, 16.0F); - this.bA = new EntitySenses(this); - this.ap = (float) (Math.random() + 1.0D) * 0.01F; + this.bP = new EntitySenses(this); + this.av = (float) (Math.random() + 1.0D) * 0.01F; this.setPosition(this.locX, this.locY, this.locZ); - this.ao = (float) Math.random() * 12398.0F; + this.au = (float) Math.random() * 12398.0F; this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D); - this.as = this.yaw; - this.W = 0.5F; + this.ay = this.yaw; + + for (int i = 0; i < this.dropChances.length; ++i) { + this.dropChances[i] = 0.05F; + } + + this.X = 0.5F; } public ControllerLook getControllerLook() { @@ -134,104 +151,124 @@ public abstract class EntityLiving extends Entity { return this.navigation; } - public EntitySenses at() { - return this.bA; + public EntitySenses az() { + return this.bP; } - public Random au() { + public Random aA() { return this.random; } - public EntityLiving av() { + public EntityLiving aB() { return this.lastDamager; } - public EntityLiving aw() { - return this.d; + public EntityLiving aC() { + return this.g; } - public void j(Entity entity) { + public void k(Entity entity) { if (entity instanceof EntityLiving) { - this.d = (EntityLiving) entity; + this.g = (EntityLiving) entity; } } - public int ax() { - return this.bq; + public int aD() { + return this.bC; } - public float am() { - return this.as; + public float ap() { + return this.ay; } - public float ay() { - return this.bB; + public float aE() { + return this.bQ; } public void e(float f) { - this.bB = f; + this.bQ = f; this.f(f); } - public boolean k(Entity entity) { - this.j(entity); + public boolean l(Entity entity) { + this.k(entity); return false; } - public EntityLiving az() { - return this.bz; + public EntityLiving aF() { + return this.bO; } public void b(EntityLiving entityliving) { - this.bz = entityliving; + this.bO = entityliving; } public boolean a(Class oclass) { return EntityCreeper.class != oclass && EntityGhast.class != oclass; } - public void aA() {} + public void aG() {} + + protected void a(double d0, boolean flag) { + if (flag && this.fallDistance > 0.0F) { + int i = MathHelper.floor(this.locX); + int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height); + int k = MathHelper.floor(this.locZ); + int l = this.world.getTypeId(i, j, k); + + if (l == 0 && this.world.getTypeId(i, j - 1, k) == Block.FENCE.id) { + l = this.world.getTypeId(i, j - 1, k); + } + + if (l > 0) { + Block.byId[l].a(this.world, i, j, k, this, this.fallDistance); + } + } + + super.a(d0, flag); + } - public boolean aB() { - return this.d(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + public boolean aH() { + return this.e(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); } - public boolean d(int i, int j, int k) { - return this.bD == -1.0F ? true : this.bC.e(i, j, k) < this.bD * this.bD; + public boolean e(int i, int j, int k) { + return this.bS == -1.0F ? true : this.bR.e(i, j, k) < this.bS * this.bS; } public void b(int i, int j, int k, int l) { - this.bC.b(i, j, k); - this.bD = (float) l; + this.bR.b(i, j, k); + this.bS = (float) l; } - public ChunkCoordinates aC() { - return this.bC; + public ChunkCoordinates aI() { + return this.bR; } - public float aD() { - return this.bD; + public float aJ() { + return this.bS; } - public void aE() { - this.bD = -1.0F; + public void aK() { + this.bS = -1.0F; } - public boolean aF() { - return this.bD != -1.0F; + public boolean aL() { + return this.bS != -1.0F; } public void c(EntityLiving entityliving) { this.lastDamager = entityliving; - this.c = this.lastDamager != null ? 60 : 0; + this.f = this.lastDamager != null ? 60 : 0; } protected void a() { - this.datawatcher.a(8, Integer.valueOf(this.f)); + this.datawatcher.a(8, Integer.valueOf(this.i)); + this.datawatcher.a(9, Byte.valueOf((byte) 0)); } - public boolean l(Entity entity) { - return this.world.a(Vec3D.a().create(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), Vec3D.a().create(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null; + public boolean m(Entity entity) { + return this.world.a(this.world.getVec3DPool().create(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ), this.world.getVec3DPool().create(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ)) == null; } public boolean L() { @@ -246,25 +283,25 @@ public abstract class EntityLiving extends Entity { return this.length * 0.85F; } - public int aG() { + public int aM() { return 80; } - public void aH() { - String s = this.aQ(); + public void aN() { + String s = this.aW(); if (s != null) { - this.world.makeSound(this, s, this.aP(), this.i()); + this.world.makeSound(this, s, this.aV(), this.h()); } } - public void z() { - this.aI = this.aJ; - super.z(); + public void y() { + this.aO = this.aP; + super.y(); this.world.methodProfiler.a("mobBaseTick"); - if (this.isAlive() && this.random.nextInt(1000) < this.a++) { - this.a = -this.aG(); - this.aH(); + if (this.isAlive() && this.random.nextInt(1000) < this.aT++) { + this.aT = -this.aM(); + this.aN(); } // CraftBukkit start @@ -283,8 +320,8 @@ public abstract class EntityLiving extends Entity { this.extinguish(); } - if (this.isAlive() && this.a(Material.WATER) && !this.aU() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id))) { - this.setAirTicks(this.h(this.getAirTicks())); + if (this.isAlive() && this.a(Material.WATER) && !this.ba() && !this.effects.containsKey(Integer.valueOf(MobEffectList.WATER_BREATHING.id))) { + this.setAirTicks(this.g(this.getAirTicks())); if (this.getAirTicks() == -20) { this.setAirTicks(0); @@ -293,7 +330,7 @@ public abstract class EntityLiving extends Entity { float f1 = this.random.nextFloat() - this.random.nextFloat(); float f2 = this.random.nextFloat() - this.random.nextFloat(); - this.world.a("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ); + this.world.addParticle("bubble", this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, this.motX, this.motY, this.motZ); } // CraftBukkit start @@ -316,7 +353,7 @@ public abstract class EntityLiving extends Entity { // CraftBukkit end } - this.aS = this.aT; + this.aZ = this.ba; if (this.attackTicks > 0) { --this.attackTicks; } @@ -330,7 +367,7 @@ public abstract class EntityLiving extends Entity { } if (this.health <= 0) { - this.aI(); + this.aO(); } if (this.lastDamageByPlayerTime > 0) { @@ -339,24 +376,24 @@ public abstract class EntityLiving extends Entity { this.killer = null; } - if (this.d != null && !this.d.isAlive()) { - this.d = null; + if (this.g != null && !this.g.isAlive()) { + this.g = null; } if (this.lastDamager != null) { if (!this.lastDamager.isAlive()) { this.c((EntityLiving) null); - } else if (this.c > 0) { - --this.c; + } else if (this.f > 0) { + --this.f; } else { this.c((EntityLiving) null); } } - this.bo(); + this.bu(); + this.aD = this.aC; this.ax = this.aw; - this.ar = this.aq; - this.at = this.as; + this.az = this.ay; this.lastYaw = this.yaw; this.lastPitch = this.pitch; this.world.methodProfiler.b(); @@ -374,7 +411,7 @@ public abstract class EntityLiving extends Entity { } // CraftBukkit end - protected void aI() { + protected void aO() { ++this.deathTicks; if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) int i; @@ -396,62 +433,75 @@ public abstract class EntityLiving extends Entity { 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.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2); + this.world.addParticle("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, d0, d1, d2); } } } - protected int h(int i) { - return i - 1; + protected int g(int i) { + int j = EnchantmentManager.getOxygenEnchantmentLevel(this); + + return j > 0 && this.random.nextInt(j + 1) > 0 ? i : i - 1; } protected int getExpValue(EntityHuman entityhuman) { - return this.aV; + return this.bc; } protected boolean alwaysGivesExp() { return false; } - public void aK() { + public void aQ() { for (int i = 0; i < 20; ++i) { double d0 = this.random.nextGaussian() * 0.02D; double d1 = this.random.nextGaussian() * 0.02D; double d2 = this.random.nextGaussian() * 0.02D; double d3 = 10.0D; - this.world.a("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2); + this.world.addParticle("explode", this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d0 * d3, this.locY + (double) (this.random.nextFloat() * this.length) - d1 * d3, this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width - d2 * d3, d0, d1, d2); } } public void U() { super.U(); - this.au = this.av; - this.av = 0.0F; + this.aA = this.aB; + this.aB = 0.0F; this.fallDistance = 0.0F; } - public void h_() { - super.h_(); - if (this.bd > 0) { - if (this.be <= 0) { - this.be = 60; + public void j_() { + super.j_(); + if (!this.world.isStatic) { + for (int i = 0; i < 5; ++i) { + ItemStack itemstack = this.getEquipment(i); + + if (!ItemStack.matches(itemstack, this.bU[i])) { + ((WorldServer) this.world).getTracker().a(this, new Packet5EntityEquipment(this.id, i, itemstack)); + this.bU[i] = itemstack == null ? null : itemstack.cloneItemStack(); + } + } + } + + if (this.bk > 0) { + if (this.bl <= 0) { + this.bl = 60; } - --this.be; - if (this.be <= 0) { - --this.bd; + --this.bl; + if (this.bl <= 0) { + --this.bk; } } - this.d(); + this.c(); double d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f = (float) (d0 * d0 + d1 * d1); - float f1 = this.aq; + float f1 = this.aw; float f2 = 0.0F; - this.au = this.av; + this.aA = this.aB; float f3 = 0.0F; if (f > 0.0025000002F) { @@ -461,7 +511,7 @@ public abstract class EntityLiving extends Entity { f1 = (float) org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; } - if (this.aJ > 0.0F) { + if (this.aP > 0.0F) { f1 = this.yaw; } @@ -469,15 +519,15 @@ public abstract class EntityLiving extends Entity { f3 = 0.0F; } - this.av += (f3 - this.av) * 0.3F; + this.aB += (f3 - this.aB) * 0.3F; this.world.methodProfiler.a("headTurn"); - if (this.aV()) { + if (this.bb()) { this.senses.a(); } else { - float f4 = MathHelper.g(f1 - this.aq); + float f4 = MathHelper.g(f1 - this.aw); - this.aq += f4 * 0.3F; - float f5 = MathHelper.g(this.yaw - this.aq); + this.aw += f4 * 0.3F; + float f5 = MathHelper.g(this.yaw - this.aw); boolean flag = f5 < -90.0F || f5 >= 90.0F; if (f5 < -75.0F) { @@ -488,9 +538,9 @@ public abstract class EntityLiving extends Entity { f5 = 75.0F; } - this.aq = this.yaw - f5; + this.aw = this.yaw - f5; if (f5 * f5 > 2500.0F) { - this.aq += f5 * 0.2F; + this.aw += f5 * 0.2F; } if (flag) { @@ -509,12 +559,12 @@ public abstract class EntityLiving extends Entity { this.lastYaw += 360.0F; } - while (this.aq - this.ar < -180.0F) { - this.ar -= 360.0F; + while (this.aw - this.ax < -180.0F) { + this.ax -= 360.0F; } - while (this.aq - this.ar >= 180.0F) { - this.ar += 360.0F; + while (this.aw - this.ax >= 180.0F) { + this.ax += 360.0F; } while (this.pitch - this.lastPitch < -180.0F) { @@ -525,16 +575,16 @@ public abstract class EntityLiving extends Entity { this.lastPitch += 360.0F; } - while (this.as - this.at < -180.0F) { - this.at -= 360.0F; + while (this.ay - this.az < -180.0F) { + this.az -= 360.0F; } - while (this.as - this.at >= 180.0F) { - this.at += 360.0F; + while (this.ay - this.az >= 180.0F) { + this.az += 360.0F; } this.world.methodProfiler.b(); - this.aw += f2; + this.aC += f2; } // CraftBukkit start - delegate so we can handle providing a reason for health being regained @@ -577,13 +627,17 @@ public abstract class EntityLiving extends Entity { if (this.world.isStatic) { return false; } else { - this.bq = 0; + this.bC = 0; if (this.health <= 0) { return false; } else if (damagesource.k() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { return false; } else { - this.aZ = 1.5F; + if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) { + i = (int) ((float) i * 0.55F); + } + + this.bg = 1.5F; boolean flag = true; // CraftBukkit start @@ -606,13 +660,13 @@ public abstract class EntityLiving extends Entity { flag = false; } else { this.lastDamage = i; - this.aL = this.health; + this.aR = this.health; this.noDamageTicks = this.maxNoDamageTicks; this.d(damagesource, i); - this.hurtTicks = this.aO = 10; + this.hurtTicks = this.aV = 10; } - this.aP = 0.0F; + this.aW = 0.0F; Entity entity = damagesource.getEntity(); if (entity != null) { @@ -648,21 +702,21 @@ public abstract class EntityLiving extends Entity { d0 = (Math.random() - Math.random()) * 0.01D; } - this.aP = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; + this.aW = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - this.yaw; this.a(entity, i, d0, d1); } else { - this.aP = (float) ((int) (Math.random() * 2.0D) * 180); + this.aW = (float) ((int) (Math.random() * 2.0D) * 180); } } if (this.health <= 0) { if (flag) { - this.world.makeSound(this, this.aS(), this.aP(), this.i()); + this.world.makeSound(this, this.aY(), this.aV(), this.h()); } this.die(damagesource); } else if (flag) { - this.world.makeSound(this, this.aR(), this.aP(), this.i()); + this.world.makeSound(this, this.aX(), this.aV(), this.h()); } return true; @@ -670,24 +724,38 @@ public abstract class EntityLiving extends Entity { } } - private float i() { + private float h() { return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F; } - public int aO() { - return 0; + public int aU() { + int i = 0; + ItemStack[] aitemstack = this.getEquipment(); + int j = aitemstack.length; + + for (int k = 0; k < j; ++k) { + ItemStack itemstack = aitemstack[k]; + + if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { + int l = ((ItemArmor) itemstack.getItem()).b; + + i += l; + } + } + + return i; } protected void k(int i) {} protected int b(DamageSource damagesource, int i) { if (!damagesource.ignoresArmor()) { - int j = 25 - this.aO(); - int k = i * j + this.aM; + int j = 25 - this.aU(); + int k = i * j + this.aS; this.k(i); i = k / 25; - this.aM = k % 25; + this.aS = k % 25; } return i; @@ -697,39 +765,41 @@ public abstract class EntityLiving extends Entity { if (this.hasEffect(MobEffectList.RESISTANCE)) { int j = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5; int k = 25 - j; - int l = i * k + this.aM; + int l = i * k + this.aS; i = l / 25; - this.aM = l % 25; + this.aS = l % 25; } return i; } protected void d(DamageSource damagesource, int i) { - i = this.b(damagesource, i); - i = this.c(damagesource, i); - this.health -= i; + if (!this.invulnerable) { + i = this.b(damagesource, i); + i = this.c(damagesource, i); + this.health -= i; + } } - protected float aP() { + protected float aV() { return 1.0F; } - protected String aQ() { + protected String aW() { return null; } - protected String aR() { - return "damage.hurtflesh"; + protected String aX() { + return "damage.hit"; } - protected String aS() { - return "damage.hurtflesh"; + protected String aY() { + return "damage.hit"; } public void a(Entity entity, int i, double d0, double d1) { - this.al = true; + this.am = true; float f = MathHelper.sqrt(d0 * d0 + d1 * d1); float f1 = 0.4F; @@ -747,24 +817,25 @@ public abstract class EntityLiving extends Entity { public void die(DamageSource damagesource) { Entity entity = damagesource.getEntity(); - if (this.aE >= 0 && entity != null) { - entity.c(this, this.aE); + if (this.aK >= 0 && entity != null) { + entity.c(this, this.aK); } if (entity != null) { entity.a(this); } - this.aU = true; + this.bb = true; if (!this.world.isStatic) { int i = 0; if (entity instanceof EntityHuman) { - i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel(((EntityHuman) entity).inventory); + i = EnchantmentManager.getBonusMonsterLootEnchantmentLevel((EntityLiving) entity); } - if (!this.isBaby()) { + if (!this.isBaby() && this.world.getGameRules().getBoolean("doMobLoot")) { this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); + this.dropEquipment(this.lastDamageByPlayerTime > 0, i); if (false && this.lastDamageByPlayerTime > 0) { // CraftBukkit - move rare item drop call to dropDeathLoot int j = this.random.nextInt(200) - i; @@ -861,7 +932,7 @@ public abstract class EntityLiving extends Entity { if (this.H() && (!(this instanceof EntityHuman) || !((EntityHuman) this).abilities.isFlying)) { d0 = this.locY; - this.a(f, f1, this.aV() ? 0.04F : 0.02F); + this.a(f, f1, this.bb() ? 0.04F : 0.02F); this.move(this.motX, this.motY, this.motZ); this.motX *= 0.800000011920929D; this.motY *= 0.800000011920929D; @@ -897,15 +968,15 @@ public abstract class EntityLiving extends Entity { float f4; if (this.onGround) { - if (this.aV()) { - f4 = this.ay(); + if (this.bb()) { + f4 = this.aE(); } else { - f4 = this.aG; + f4 = this.aM; } f4 *= f3; } else { - f4 = this.aH; + f4 = this.aN; } this.a(f, f1, f4); @@ -919,7 +990,7 @@ public abstract class EntityLiving extends Entity { } } - if (this.f_()) { + if (this.g_()) { float f5 = 0.15F; if (this.motX < (double) (-f5)) { @@ -951,7 +1022,7 @@ public abstract class EntityLiving extends Entity { } this.move(this.motX, this.motY, this.motZ); - if (this.positionChanged && this.f_()) { + if (this.positionChanged && this.g_()) { this.motY = 0.2D; } @@ -961,7 +1032,7 @@ public abstract class EntityLiving extends Entity { this.motZ *= (double) f2; } - this.aY = this.aZ; + this.bf = this.bg; d0 = this.locX - this.lastX; double d1 = this.locZ - this.lastZ; float f6 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F; @@ -970,11 +1041,11 @@ public abstract class EntityLiving extends Entity { f6 = 1.0F; } - this.aZ += (f6 - this.aZ) * 0.4F; - this.ba += this.aZ; + this.bg += (f6 - this.bg) * 0.4F; + this.bh += this.bg; } - public boolean f_() { + public boolean g_() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); @@ -988,22 +1059,44 @@ public abstract class EntityLiving extends Entity { nbttagcompound.setShort("HurtTime", (short) this.hurtTicks); nbttagcompound.setShort("DeathTime", (short) this.deathTicks); nbttagcompound.setShort("AttackTime", (short) this.attackTicks); + nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot); + nbttagcompound.setBoolean("PersistenceRequired", this.persistent); + nbttagcompound.setBoolean("Invulnerable", this.invulnerable); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.equipment.length; ++i) { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + if (this.equipment[i] != null) { + this.equipment[i].save(nbttagcompound1); + } + + nbttaglist.add(nbttagcompound1); + } + + nbttagcompound.set("Equipment", nbttaglist); + NBTTagList nbttaglist1; + if (!this.effects.isEmpty()) { - NBTTagList nbttaglist = new NBTTagList(); + nbttaglist1 = new NBTTagList(); Iterator iterator = this.effects.values().iterator(); while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Id", (byte) mobeffect.getEffectId()); - nbttagcompound1.setByte("Amplifier", (byte) mobeffect.getAmplifier()); - nbttagcompound1.setInt("Duration", mobeffect.getDuration()); - nbttaglist.add(nbttagcompound1); + nbttaglist1.add(mobeffect.a(new NBTTagCompound())); } - nbttagcompound.set("ActiveEffects", nbttaglist); + nbttagcompound.set("ActiveEffects", nbttaglist1); } + + nbttaglist1 = new NBTTagList(); + + for (int j = 0; j < this.dropChances.length; ++j) { + nbttaglist1.add(new NBTTagFloat(j + "", this.dropChances[j])); + } + + nbttagcompound.set("DropChances", nbttaglist1); } public void a(NBTTagCompound nbttagcompound) { @@ -1019,16 +1112,36 @@ public abstract class EntityLiving extends Entity { this.hurtTicks = nbttagcompound.getShort("HurtTime"); this.deathTicks = nbttagcompound.getShort("DeathTime"); this.attackTicks = nbttagcompound.getShort("AttackTime"); + this.canPickUpLoot = nbttagcompound.getBoolean("CanPickUpLoot"); + this.persistent = nbttagcompound.getBoolean("PersistenceRequired"); + this.invulnerable = nbttagcompound.getBoolean("Invulnerable"); + NBTTagList nbttaglist; + int i; + + if (nbttagcompound.hasKey("Equipment")) { + nbttaglist = nbttagcompound.getList("Equipment"); + + for (i = 0; i < this.equipment.length; ++i) { + this.equipment[i] = ItemStack.a((NBTTagCompound) nbttaglist.get(i)); + } + } + if (nbttagcompound.hasKey("ActiveEffects")) { - NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects"); + nbttaglist = nbttagcompound.getList("ActiveEffects"); - for (int i = 0; i < nbttaglist.size(); ++i) { + for (i = 0; i < nbttaglist.size(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i); - byte b0 = nbttagcompound1.getByte("Id"); - byte b1 = nbttagcompound1.getByte("Amplifier"); - int j = nbttagcompound1.getInt("Duration"); + MobEffect mobeffect = MobEffect.b(nbttagcompound1); + + this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect); + } + } + + if (nbttagcompound.hasKey("DropChances")) { + nbttaglist = nbttagcompound.getList("DropChances"); - this.effects.put(Integer.valueOf(b0), new MobEffect(b0, j, b1)); + for (i = 0; i < nbttaglist.size(); ++i) { + this.dropChances[i] = ((NBTTagFloat) nbttaglist.get(i)).data; } } } @@ -1037,32 +1150,32 @@ public abstract class EntityLiving extends Entity { return !this.dead && this.health > 0; } - public boolean aU() { + public boolean ba() { return false; } public void f(float f) { - this.bs = f; + this.bE = f; } - public void d(boolean flag) { - this.bu = flag; + public void e(boolean flag) { + this.bG = flag; } - public void d() { - if (this.bE > 0) { - --this.bE; + public void c() { + if (this.bW > 0) { + --this.bW; } - if (this.bi > 0) { - double d0 = this.locX + (this.bj - this.locX) / (double) this.bi; - double d1 = this.locY + (this.bk - this.locY) / (double) this.bi; - double d2 = this.locZ + (this.bl - this.locZ) / (double) this.bi; - double d3 = MathHelper.g(this.bm - (double) this.yaw); + if (this.bu > 0) { + double d0 = this.locX + (this.bv - this.locX) / (double) this.bu; + double d1 = this.locY + (this.bw - this.locY) / (double) this.bu; + double d2 = this.locZ + (this.bx - this.locZ) / (double) this.bu; + double d3 = MathHelper.g(this.by - (double) this.yaw); - this.yaw = (float) ((double) this.yaw + d3 / (double) this.bi); - this.pitch = (float) ((double) this.pitch + (this.bn - (double) this.pitch) / (double) this.bi); - --this.bi; + this.yaw = (float) ((double) this.yaw + d3 / (double) this.bu); + this.pitch = (float) ((double) this.pitch + (this.bz - (double) this.pitch) / (double) this.bu); + --this.bu; this.setPosition(d0, d1, d2); this.b(this.yaw, this.pitch); } @@ -1080,62 +1193,129 @@ public abstract class EntityLiving extends Entity { } this.world.methodProfiler.a("ai"); - if (this.aX()) { - this.bu = false; - this.br = 0.0F; - this.bs = 0.0F; - this.bt = 0.0F; - } else if (this.aW()) { - if (this.aV()) { + if (this.bd()) { + this.bG = false; + this.bD = 0.0F; + this.bE = 0.0F; + this.bF = 0.0F; + } else if (this.bc()) { + if (this.bb()) { this.world.methodProfiler.a("newAi"); - this.bc(); + this.bi(); this.world.methodProfiler.b(); } else { this.world.methodProfiler.a("oldAi"); - this.be(); + this.bk(); this.world.methodProfiler.b(); - this.as = this.yaw; + this.ay = this.yaw; } } this.world.methodProfiler.b(); this.world.methodProfiler.a("jump"); - if (this.bu) { + if (this.bG) { if (!this.H() && !this.J()) { - if (this.onGround && this.bE == 0) { - this.aZ(); - this.bE = 10; + if (this.onGround && this.bW == 0) { + this.bf(); + this.bW = 10; } } else { this.motY += 0.03999999910593033D; } } else { - this.bE = 0; + this.bW = 0; } this.world.methodProfiler.b(); this.world.methodProfiler.a("travel"); - this.br *= 0.98F; - this.bs *= 0.98F; - this.bt *= 0.9F; - float f = this.aG; - - this.aG *= this.bs(); - this.e(this.br, this.bs); - this.aG = f; + this.bD *= 0.98F; + this.bE *= 0.98F; + this.bF *= 0.9F; + float f = this.aM; + + this.aM *= this.by(); + this.e(this.bD, this.bE); + this.aM = f; this.world.methodProfiler.b(); this.world.methodProfiler.a("push"); - if (!this.world.isStatic) { - List list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + List list; + Iterator iterator; + if (!this.world.isStatic) { + list = this.world.getEntities(this, this.boundingBox.grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)); if (list != null && !list.isEmpty()) { - Iterator iterator = list.iterator(); + iterator = list.iterator(); while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); if (entity.M()) { - entity.collide(this); + this.n(entity); + } + } + } + } + + this.world.methodProfiler.b(); + this.world.methodProfiler.a("looting"); + if (!this.world.isStatic && this.canPickUpLoot && this.world.getGameRules().getBoolean("mobGriefing")) { + list = this.world.a(EntityItem.class, this.boundingBox.grow(1.0D, 0.0D, 1.0D)); + iterator = list.iterator(); + + while (iterator.hasNext()) { + EntityItem entityitem = (EntityItem) iterator.next(); + + if (!entityitem.dead && entityitem.itemStack != null) { + ItemStack itemstack = entityitem.itemStack; + int i = b(itemstack); + + if (i > -1) { + boolean flag = true; + ItemStack itemstack1 = this.getEquipment(i); + + if (itemstack1 != null) { + if (i == 0) { + if (itemstack.getItem() instanceof ItemSword && !(itemstack1.getItem() instanceof ItemSword)) { + flag = true; + } else if (itemstack.getItem() instanceof ItemSword && itemstack1.getItem() instanceof ItemSword) { + ItemSword itemsword = (ItemSword) itemstack.getItem(); + ItemSword itemsword1 = (ItemSword) itemstack1.getItem(); + + if (itemsword.g() == itemsword1.g()) { + flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); + } else { + flag = itemsword.g() > itemsword1.g(); + } + } else { + flag = false; + } + } else if (itemstack.getItem() instanceof ItemArmor && !(itemstack1.getItem() instanceof ItemArmor)) { + flag = true; + } else if (itemstack.getItem() instanceof ItemArmor && itemstack1.getItem() instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); + ItemArmor itemarmor1 = (ItemArmor) itemstack1.getItem(); + + if (itemarmor.b == itemarmor1.b) { + flag = itemstack.getData() > itemstack1.getData() || itemstack.hasTag() && !itemstack1.hasTag(); + } else { + flag = itemarmor.b > itemarmor1.b; + } + } else { + flag = false; + } + } + + if (flag) { + if (itemstack1 != null && this.random.nextFloat() - 0.1F < this.dropChances[i]) { + this.a(itemstack1, 0.0F); + } + + this.setEquipment(i, itemstack); + this.dropChances[i] = 2.0F; + this.persistent = true; + this.receive(entityitem, 1); + entityitem.die(); + } } } } @@ -1144,23 +1324,27 @@ public abstract class EntityLiving extends Entity { this.world.methodProfiler.b(); } - protected boolean aV() { + protected void n(Entity entity) { + entity.collide(this); + } + + protected boolean bb() { return false; } - protected boolean aW() { + protected boolean bc() { return !this.world.isStatic; } - protected boolean aX() { + protected boolean bd() { return this.health <= 0; } - public boolean aY() { + public boolean be() { return false; } - protected void aZ() { + protected void bf() { this.motY = 0.41999998688697815D; if (this.hasEffect(MobEffectList.JUMP)) { this.motY += (double) ((float) (this.getEffect(MobEffectList.JUMP).getAmplifier() + 1) * 0.1F); @@ -1173,41 +1357,43 @@ public abstract class EntityLiving extends Entity { this.motZ += (double) (MathHelper.cos(f) * 0.2F); } - this.al = true; + this.am = true; } - protected boolean ba() { + protected boolean bg() { return true; } - protected void bb() { - EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); + protected void bh() { + if (!this.persistent) { + EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); - 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 (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 (this.ba() && d3 > 16384.0D) { - this.die(); - } + if (this.bg() && d3 > 16384.0D) { + this.die(); + } - if (this.bq > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.ba()) { - this.die(); - } else if (d3 < 1024.0D) { - this.bq = 0; + if (this.bC > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.bg()) { + this.die(); + } else if (d3 < 1024.0D) { + this.bC = 0; + } } } } - protected void bc() { - ++this.bq; + protected void bi() { + ++this.bC; this.world.methodProfiler.a("checkDespawn"); - this.bb(); + this.bh(); this.world.methodProfiler.b(); this.world.methodProfiler.a("sensing"); - this.bA.a(); + this.bP.a(); this.world.methodProfiler.b(); this.world.methodProfiler.a("targetSelector"); this.targetSelector.a(); @@ -1219,7 +1405,7 @@ public abstract class EntityLiving extends Entity { this.navigation.e(); this.world.methodProfiler.b(); this.world.methodProfiler.a("mob tick"); - this.bd(); + this.bj(); this.world.methodProfiler.b(); this.world.methodProfiler.a("controls"); this.world.methodProfiler.a("move"); @@ -1232,49 +1418,65 @@ public abstract class EntityLiving extends Entity { this.world.methodProfiler.b(); } - protected void bd() {} + protected void bj() {} - protected void be() { - ++this.bq; - this.bb(); - this.br = 0.0F; - this.bs = 0.0F; + protected void bk() { + ++this.bC; + this.bh(); + this.bD = 0.0F; + this.bE = 0.0F; float f = 8.0F; if (this.random.nextFloat() < 0.02F) { EntityHuman entityhuman = this.world.findNearbyPlayer(this, (double) f); if (entityhuman != null) { - this.bF = entityhuman; - this.bx = 10 + this.random.nextInt(20); + this.bX = entityhuman; + this.bJ = 10 + this.random.nextInt(20); } else { - this.bt = (this.random.nextFloat() - 0.5F) * 20.0F; + this.bF = (this.random.nextFloat() - 0.5F) * 20.0F; } } - if (this.bF != null) { - this.a(this.bF, 10.0F, (float) this.bf()); - if (this.bx-- <= 0 || this.bF.dead || this.bF.e((Entity) this) > (double) (f * f)) { - this.bF = null; + if (this.bX != null) { + this.a(this.bX, 10.0F, (float) this.bm()); + if (this.bJ-- <= 0 || this.bX.dead || this.bX.e((Entity) this) > (double) (f * f)) { + this.bX = null; } } else { if (this.random.nextFloat() < 0.05F) { - this.bt = (this.random.nextFloat() - 0.5F) * 20.0F; + this.bF = (this.random.nextFloat() - 0.5F) * 20.0F; } - this.yaw += this.bt; - this.pitch = this.bv; + this.yaw += this.bF; + this.pitch = this.bH; } boolean flag = this.H(); boolean flag1 = this.J(); if (flag || flag1) { - this.bu = this.random.nextFloat() < 0.8F; + this.bG = this.random.nextFloat() < 0.8F; + } + } + + protected void bl() { + int i = this.i(); + + if (this.bq) { + ++this.br; + if (this.br >= i) { + this.br = 0; + this.bq = false; + } + } else { + this.br = 0; } + + this.aP = (float) this.br / (float) i; } - public int bf() { + public int bm() { return 40; } @@ -1346,7 +1548,7 @@ public abstract class EntityLiving extends Entity { f2 = MathHelper.sin(-this.yaw * 0.017453292F - 3.1415927F); f3 = -MathHelper.cos(-this.pitch * 0.017453292F); f4 = MathHelper.sin(-this.pitch * 0.017453292F); - return Vec3D.a().create((double) (f2 * f3), (double) f4, (double) (f1 * f3)); + return this.world.getVec3DPool().create((double) (f2 * f3), (double) f4, (double) (f1 * f3)); } else { f1 = this.lastPitch + (this.pitch - this.lastPitch) * f; f2 = this.lastYaw + (this.yaw - this.lastYaw) * f; @@ -1355,11 +1557,11 @@ public abstract class EntityLiving extends Entity { float f5 = -MathHelper.cos(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F); - return Vec3D.a().create((double) (f4 * f5), (double) f6, (double) (f3 * f5)); + return this.world.getVec3DPool().create((double) (f4 * f5), (double) f6, (double) (f3 * f5)); } } - public int bl() { + public int bs() { return 4; } @@ -1367,7 +1569,7 @@ public abstract class EntityLiving extends Entity { return false; } - protected void bo() { + protected void bu() { Iterator iterator = this.effects.keySet().iterator(); while (iterator.hasNext()) { @@ -1385,29 +1587,47 @@ public abstract class EntityLiving extends Entity { if (this.updateEffects) { if (!this.world.isStatic) { if (this.effects.isEmpty()) { + this.datawatcher.watch(9, Byte.valueOf((byte) 0)); this.datawatcher.watch(8, Integer.valueOf(0)); + this.setInvisible(false); } else { i = PotionBrewer.a(this.effects.values()); + this.datawatcher.watch(9, Byte.valueOf((byte) (PotionBrewer.b(this.effects.values()) ? 1 : 0))); this.datawatcher.watch(8, Integer.valueOf(i)); + this.setInvisible(this.hasEffect(MobEffectList.INVISIBILITY.id)); } } this.updateEffects = false; } - if (this.random.nextBoolean()) { - i = this.datawatcher.getInt(8); - if (i > 0) { + i = this.datawatcher.getInt(8); + boolean flag = this.datawatcher.getByte(9) > 0; + + if (i > 0) { + boolean flag1 = false; + + if (!this.isInvisible()) { + flag1 = this.random.nextBoolean(); + } else { + flag1 = this.random.nextInt(15) == 0; + } + + if (flag) { + flag1 &= this.random.nextInt(5) == 0; + } + + if (flag1 && 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.width, this.locY + this.random.nextDouble() * (double) this.length - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2); + this.world.addParticle(flag ? "mobSpellAmbient" : "mobSpell", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - (double) this.height, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, d0, d1, d2); } } } - public void bp() { + public void bv() { Iterator iterator = this.effects.keySet().iterator(); while (iterator.hasNext()) { @@ -1425,6 +1645,10 @@ public abstract class EntityLiving extends Entity { return this.effects.values(); } + public boolean hasEffect(int i) { + return this.effects.containsKey(Integer.valueOf(i)); + } + public boolean hasEffect(MobEffectList mobeffectlist) { return this.effects.containsKey(Integer.valueOf(mobeffectlist.id)); } @@ -1457,10 +1681,18 @@ public abstract class EntityLiving extends Entity { return true; } - public boolean br() { + public boolean bx() { return this.getMonsterType() == EnumMonsterType.UNDEAD; } + public void o(int i) { + MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i)); + + if (mobeffect != null) { + this.c(mobeffect); + } + } + protected void a(MobEffect mobeffect) { this.updateEffects = true; } @@ -1473,7 +1705,7 @@ public abstract class EntityLiving extends Entity { this.updateEffects = true; } - protected float bs() { + public float by() { float f = 1.0F; if (this.hasEffect(MobEffectList.FASTER_MOVEMENT)) { @@ -1503,16 +1735,247 @@ public abstract class EntityLiving extends Entity { 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.a().create(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + Vec3D vec3d = this.world.getVec3DPool().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.a().create(((double) this.random.nextFloat() - 0.5D) * 0.3D, (double) (-this.random.nextFloat()) * 0.6D - 0.3D, 0.6D); + Vec3D vec3d1 = this.world.getVec3DPool().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.getHeadHeight(), 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.addParticle("iconcrack_" + itemstack.getItem().id, vec3d1.c, vec3d1.d, vec3d1.e, vec3d.c, vec3d.d + 0.05D, vec3d.e); + } + } + + public int as() { + if (this.aF() == null) { + return 3; + } else { + int i = (int) ((float) this.health - (float) this.getMaxHealth() * 0.33F); + + i -= (3 - this.world.difficulty) * 4; + if (i < 0) { + i = 0; + } + + return i + 3; + } + } + + public ItemStack bA() { + return this.equipment[0]; + } + + public ItemStack getEquipment(int i) { + return this.equipment[i]; + } + + public ItemStack q(int i) { + return this.equipment[i + 1]; + } + + public void setEquipment(int i, ItemStack itemstack) { + this.equipment[i] = itemstack; + } + + public ItemStack[] getEquipment() { + return this.equipment; + } + + protected void dropEquipment(boolean flag, int i) { + for (int j = 0; j < this.getEquipment().length; ++j) { + ItemStack itemstack = this.getEquipment(j); + boolean flag1 = this.dropChances[j] > 1.0F; + + if (itemstack != null && (flag || flag1) && this.random.nextFloat() - (float) i * 0.01F < this.dropChances[j]) { + if (!flag1 && itemstack.f()) { + int k = Math.max(itemstack.k() - 25, 1); + int l = itemstack.k() - this.random.nextInt(this.random.nextInt(k) + 1); + + if (l > k) { + l = k; + } + + if (l < 1) { + l = 1; + } + + itemstack.setData(l); + } + + this.a(itemstack, 0.0F); + } } } + + protected void bB() { + if (this.random.nextFloat() < d[this.world.difficulty]) { + int i = this.random.nextInt(2); + float f = this.world.difficulty == 3 ? 0.1F : 0.25F; + + if (this.random.nextFloat() < 0.07F) { + ++i; + } + + if (this.random.nextFloat() < 0.07F) { + ++i; + } + + if (this.random.nextFloat() < 0.07F) { + ++i; + } + + for (int j = 3; j >= 0; --j) { + ItemStack itemstack = this.q(j); + + if (j < 3 && this.random.nextFloat() < f) { + break; + } + + if (itemstack == null) { + Item item = a(j + 1, i); + + if (item != null) { + this.setEquipment(j + 1, new ItemStack(item)); + } + } + } + } + } + + public void receive(Entity entity, int i) { + if (!entity.dead && !this.world.isStatic) { + EntityTracker entitytracker = ((WorldServer) this.world).getTracker(); + + if (entity instanceof EntityItem) { + entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); + } + + if (entity instanceof EntityArrow) { + entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); + } + + if (entity instanceof EntityExperienceOrb) { + entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); + } + } + } + + public static int b(ItemStack itemstack) { + if (itemstack.id != Block.PUMPKIN.id && itemstack.id != Item.SKULL.id) { + if (itemstack.getItem() instanceof ItemArmor) { + switch (((ItemArmor) itemstack.getItem()).a) { + case 0: + return 4; + + case 1: + return 3; + + case 2: + return 2; + + case 3: + return 1; + } + } + + return 0; + } else { + return 4; + } + } + + public static Item a(int i, int j) { + switch (i) { + case 4: + if (j == 0) { + return Item.LEATHER_HELMET; + } else if (j == 1) { + return Item.GOLD_HELMET; + } else if (j == 2) { + return Item.CHAINMAIL_HELMET; + } else if (j == 3) { + return Item.IRON_HELMET; + } else if (j == 4) { + return Item.DIAMOND_HELMET; + } + + case 3: + if (j == 0) { + return Item.LEATHER_CHESTPLATE; + } else if (j == 1) { + return Item.GOLD_CHESTPLATE; + } else if (j == 2) { + return Item.CHAINMAIL_CHESTPLATE; + } else if (j == 3) { + return Item.IRON_CHESTPLATE; + } else if (j == 4) { + return Item.DIAMOND_CHESTPLATE; + } + + case 2: + if (j == 0) { + return Item.LEATHER_LEGGINGS; + } else if (j == 1) { + return Item.GOLD_LEGGINGS; + } else if (j == 2) { + return Item.CHAINMAIL_LEGGINGS; + } else if (j == 3) { + return Item.IRON_LEGGINGS; + } else if (j == 4) { + return Item.DIAMOND_LEGGINGS; + } + + case 1: + if (j == 0) { + return Item.LEATHER_BOOTS; + } else if (j == 1) { + return Item.GOLD_BOOTS; + } else if (j == 2) { + return Item.CHAINMAIL_BOOTS; + } else if (j == 3) { + return Item.IRON_BOOTS; + } else if (j == 4) { + return Item.DIAMOND_BOOTS; + } + + default: + return null; + } + } + + protected void bC() { + if (this.bA() != null && this.random.nextFloat() < b[this.world.difficulty]) { + EnchantmentManager.a(this.random, this.bA(), 5); + } + + for (int i = 0; i < 4; ++i) { + ItemStack itemstack = this.q(i); + + if (itemstack != null && this.random.nextFloat() < c[this.world.difficulty]) { + EnchantmentManager.a(this.random, itemstack, 5); + } + } + } + + public void bD() {} + + private int i() { + 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); + } + + public void bE() { + if (!this.bq || this.br >= this.i() / 2 || this.br < 0) { + this.br = -1; + this.bq = true; + if (this.world instanceof WorldServer) { + ((WorldServer) this.world).getTracker().a(this, new Packet18ArmAnimation(this, 1)); + } + } + } + + public boolean bF() { + return false; + } } diff --git a/src/main/java/net/minecraft/server/EntityMagmaCube.java b/src/main/java/net/minecraft/server/EntityMagmaCube.java index 8bccfaa4..5229383e 100644 --- a/src/main/java/net/minecraft/server/EntityMagmaCube.java +++ b/src/main/java/net/minecraft/server/EntityMagmaCube.java @@ -6,14 +6,14 @@ public class EntityMagmaCube extends EntitySlime { super(world); this.texture = "/mob/lava.png"; this.fireProof = true; - this.aG = 0.2F; + this.aM = 0.2F; } public boolean canSpawn() { return this.world.difficulty > 0 && this.world.b(this.boundingBox) && this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox); } - public int aO() { + public int aU() { return this.getSize() * 3; } @@ -21,11 +21,11 @@ public class EntityMagmaCube extends EntitySlime { return 1.0F; } - protected String i() { + protected String h() { return "flame"; } - protected EntitySlime j() { + protected EntitySlime i() { return new EntityMagmaCube(this.world); } @@ -58,38 +58,38 @@ public class EntityMagmaCube extends EntitySlime { return false; } - protected int k() { - return super.k() * 4; + protected int j() { + return super.j() * 4; } - protected void l() { - this.a *= 0.9F; + protected void k() { + this.b *= 0.9F; } - protected void aZ() { + protected void bf() { this.motY = (double) (0.42F + (float) this.getSize() * 0.1F); - this.al = true; + this.am = true; } protected void a(float f) {} - protected boolean m() { + protected boolean l() { return true; } - protected int n() { - return super.n() + 2; + protected int m() { + return super.m() + 2; } - protected String aR() { - return "mob.slime"; + protected String aX() { + return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); } - protected String aS() { - return "mob.slime"; + protected String aY() { + return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); } - protected String o() { + protected String n() { return this.getSize() > 1 ? "mob.magmacube.big" : "mob.magmacube.small"; } @@ -97,7 +97,7 @@ public class EntityMagmaCube extends EntitySlime { return false; } - protected boolean p() { + protected boolean o() { return true; } } diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index f60dcdb3..044c91a4 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -22,13 +22,15 @@ public class EntityMinecart extends Entity implements IInventory { public int type; public double b; public double c; + private final IUpdatePlayerListBox g; + private boolean h; 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 h; - private double i; - private double j; - private double an; - private double ao; - private double ap; + private int j; + private double as; + private double at; + private double au; + private double av; + private double aw; // CraftBukkit start public boolean slowWhenEmpty = true; @@ -74,12 +76,14 @@ public class EntityMinecart extends Entity implements IInventory { this.items = new ItemStack[27]; // CraftBukkit this.e = 0; this.f = false; + this.h = true; this.m = true; this.a(0.98F, 0.7F); this.height = this.length / 2.0F; + this.g = world != null ? world.a(this) : null; } - protected boolean e_() { + protected boolean f_() { return false; } @@ -209,42 +213,52 @@ public class EntityMinecart extends Entity implements IInventory { } public void die() { - for (int i = 0; i < this.getSize(); ++i) { - ItemStack itemstack = this.getItem(i); + if (this.h) { + for (int i = 0; i < this.getSize(); ++i) { + ItemStack itemstack = this.getItem(i); - if (itemstack != null) { - float f = this.random.nextFloat() * 0.8F + 0.1F; - float f1 = this.random.nextFloat() * 0.8F + 0.1F; - float f2 = this.random.nextFloat() * 0.8F + 0.1F; + if (itemstack != null) { + float f = this.random.nextFloat() * 0.8F + 0.1F; + float f1 = this.random.nextFloat() * 0.8F + 0.1F; + float f2 = this.random.nextFloat() * 0.8F + 0.1F; - while (itemstack.count > 0) { - int j = this.random.nextInt(21) + 10; + while (itemstack.count > 0) { + int j = this.random.nextInt(21) + 10; - if (j > itemstack.count) { - j = itemstack.count; - } + if (j > itemstack.count) { + j = itemstack.count; + } - itemstack.count -= j; - EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, j, itemstack.getData())); + itemstack.count -= j; + EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, j, itemstack.getData())); - if (itemstack.hasTag()) { - entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone()); - } + if (itemstack.hasTag()) { + entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone()); + } - float f3 = 0.05F; + float f3 = 0.05F; - entityitem.motX = (double) ((float) this.random.nextGaussian() * f3); - entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F); - entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3); - this.world.addEntity(entityitem); + entityitem.motX = (double) ((float) this.random.nextGaussian() * f3); + entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F); + entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3); + this.world.addEntity(entityitem); + } } } } super.die(); + if (this.g != null) { + this.g.a(); + } } - public void h_() { + public void b(int i) { + this.h = false; + super.b(i); + } + + public void j_() { // CraftBukkit start double prevX = this.locX; double prevY = this.locY; @@ -253,6 +267,10 @@ public class EntityMinecart extends Entity implements IInventory { float prevPitch = this.pitch; // CraftBukkit end + if (this.g != null) { + this.g.a(); + } + if (this.j() > 0) { this.h(this.j() - 1); } @@ -266,19 +284,19 @@ public class EntityMinecart extends Entity implements IInventory { } if (this.h() && this.random.nextInt(4) == 0) { - this.world.a("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D); + this.world.addParticle("largesmoke", this.locX, this.locY + 0.8D, this.locZ, 0.0D, 0.0D, 0.0D); } 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.an - this.locZ) / (double) this.h; - double d3 = MathHelper.g(this.ao - (double) this.yaw); - - this.yaw = (float) ((double) this.yaw + d3 / (double) this.h); - this.pitch = (float) ((double) this.pitch + (this.ap - (double) this.pitch) / (double) this.h); - --this.h; + if (this.j > 0) { + double d0 = this.locX + (this.as - this.locX) / (double) this.j; + double d1 = this.locY + (this.at - this.locY) / (double) this.j; + double d2 = this.locZ + (this.au - this.locZ) / (double) this.j; + double d3 = MathHelper.g(this.av - (double) this.yaw); + + this.yaw = (float) ((double) this.yaw + d3 / (double) this.j); + this.pitch = (float) ((double) this.pitch + (this.aw - (double) this.pitch) / (double) this.j); + --this.j; this.setPosition(d0, d1, d2); this.b(this.yaw, this.pitch); } else { @@ -294,7 +312,7 @@ public class EntityMinecart extends Entity implements IInventory { int j = MathHelper.floor(this.locY); int k = MathHelper.floor(this.locZ); - if (BlockMinecartTrack.d_(this.world, i, j - 1, k)) { + if (BlockMinecartTrack.e_(this.world, i, j - 1, k)) { --j; } @@ -316,7 +334,7 @@ public class EntityMinecart extends Entity implements IInventory { flag1 = !flag; } - if (((BlockMinecartTrack) Block.byId[l]).n()) { + if (((BlockMinecartTrack) Block.byId[l]).p()) { i1 &= 7; } @@ -472,7 +490,7 @@ public class EntityMinecart extends Entity implements IInventory { Vec3D vec3d1 = this.a(this.locX, this.locY, this.locZ); if (vec3d1 != null && vec3d != null) { - double d20 = (vec3d.b - vec3d1.b) * 0.05D; + double d20 = (vec3d.d - vec3d1.d) * 0.05D; d10 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ); if (d10 > 0.0D) { @@ -480,7 +498,7 @@ public class EntityMinecart extends Entity implements IInventory { this.motZ = this.motZ / d10 * (d10 + d20); } - this.setPosition(this.locX, vec3d1.b, this.locZ); + this.setPosition(this.locX, vec3d1.d, this.locZ); } int j1 = MathHelper.floor(this.locX); @@ -531,8 +549,6 @@ public class EntityMinecart extends Entity implements IInventory { } } } - - this.D(); } else { if (this.motX < -d4) { this.motX = -d4; @@ -568,6 +584,7 @@ public class EntityMinecart extends Entity implements IInventory { } } + this.D(); this.pitch = 0.0F; double d23 = this.lastX - this.locX; double d24 = this.lastZ - this.locZ; @@ -629,7 +646,7 @@ public class EntityMinecart extends Entity implements IInventory { this.b = this.c = 0.0D; } - this.d(this.e > 0); + this.e(this.e > 0); } } @@ -638,7 +655,7 @@ public class EntityMinecart extends Entity implements IInventory { int j = MathHelper.floor(d1); int k = MathHelper.floor(d2); - if (BlockMinecartTrack.d_(this.world, i, j - 1, k)) { + if (BlockMinecartTrack.e_(this.world, i, j - 1, k)) { --j; } @@ -648,7 +665,7 @@ public class EntityMinecart extends Entity implements IInventory { int i1 = this.world.getData(i, j, k); d1 = (double) j; - if (((BlockMinecartTrack) Block.byId[l]).n()) { + if (((BlockMinecartTrack) Block.byId[l]).p()) { i1 &= 7; } @@ -692,7 +709,7 @@ public class EntityMinecart extends Entity implements IInventory { d1 += 0.5D; } - return Vec3D.a().create(d0, d1, d2); + return this.world.getVec3DPool().create(d0, d1, d2); } else { return null; } @@ -781,15 +798,15 @@ public class EntityMinecart extends Entity implements IInventory { d1 *= d3; d0 *= 0.10000000149011612D; d1 *= 0.10000000149011612D; - d0 *= (double) (1.0F - this.Y); - d1 *= (double) (1.0F - this.Y); + d0 *= (double) (1.0F - this.Z); + d1 *= (double) (1.0F - this.Z); d0 *= 0.5D; d1 *= 0.5D; if (entity instanceof EntityMinecart) { double d4 = entity.locX - this.locX; double d5 = entity.locZ - this.locZ; - Vec3D vec3d = Vec3D.a().create(d4, 0.0D, d5).b(); - Vec3D vec3d1 = Vec3D.a().create((double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F), 0.0D, (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F)).b(); + Vec3D vec3d = this.world.getVec3DPool().create(d4, 0.0D, d5).a(); + Vec3D vec3d1 = this.world.getVec3DPool().create((double) MathHelper.cos(this.yaw * 3.1415927F / 180.0F), 0.0D, (double) MathHelper.sin(this.yaw * 3.1415927F / 180.0F)).a(); double d6 = Math.abs(vec3d.b(vec3d1)); if (d6 < 0.800000011920929D) { @@ -926,7 +943,7 @@ public class EntityMinecart extends Entity implements IInventory { return (this.datawatcher.getByte(16) & 1) != 0; } - protected void d(boolean flag) { + protected void e(boolean flag) { if (flag) { this.datawatcher.watch(16, Byte.valueOf((byte) (this.datawatcher.getByte(16) | 1))); } else { diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java index 0a2eae32..58f78047 100644 --- a/src/main/java/net/minecraft/server/EntityMonster.java +++ b/src/main/java/net/minecraft/server/EntityMonster.java @@ -4,25 +4,24 @@ import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public abstract class EntityMonster extends EntityCreature implements IMonster { - protected int damage = 2; - public EntityMonster(World world) { super(world); - this.aV = 5; + this.bc = 5; } - public void d() { + public void c() { + this.bl(); float f = this.c(1.0F); if (f > 0.5F) { - this.bq += 2; + this.bC += 2; } - super.d(); + super.c(); } - public void h_() { - super.h_(); + public void j_() { + super.j_(); if (!this.world.isStatic && this.world.difficulty == 0) { this.die(); } @@ -31,7 +30,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { protected Entity findTarget() { EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); - return entityhuman != null && this.l(entityhuman) ? entityhuman : null; + return entityhuman != null && this.m(entityhuman) ? entityhuman : null; } public boolean damageEntity(DamageSource damagesource, int i) { @@ -66,8 +65,8 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { } } - public boolean k(Entity entity) { - int i = this.damage; + public boolean l(Entity entity) { + int i = this.c(entity); if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) { i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); @@ -77,13 +76,36 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier(); } - return entity.damageEntity(DamageSource.mobAttack(this), i); + int j = 0; + + if (entity instanceof EntityLiving) { + i += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity); + j += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity); + } + + boolean flag = entity.damageEntity(DamageSource.mobAttack(this), i); + + if (flag) { + if (j > 0) { + entity.g((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; + } + + int k = EnchantmentManager.getFireAspectEnchantmentLevel(this, (EntityLiving) entity); + + if (k > 0) { + entity.setOnFire(k * 4); + } + } + + return flag; } 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.k(entity); + this.l(entity); } } @@ -91,7 +113,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { return 0.5F - this.world.o(i, j, k); } - protected boolean o() { + protected boolean i_() { int i = MathHelper.floor(this.locX); int j = MathHelper.floor(this.boundingBox.b); int k = MathHelper.floor(this.locZ); @@ -101,12 +123,12 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { } else { int l = this.world.getLightLevel(i, j, k); - if (this.world.I()) { - int i1 = this.world.k; + if (this.world.L()) { + int i1 = this.world.j; - this.world.k = 10; + this.world.j = 10; l = this.world.getLightLevel(i, j, k); - this.world.k = i1; + this.world.j = i1; } return l <= this.random.nextInt(8); @@ -114,6 +136,10 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { } public boolean canSpawn() { - return this.o() && super.canSpawn(); + return this.i_() && super.canSpawn(); + } + + public int c(Entity entity) { + return 2; } } diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java index 7043682f..bfcea8c3 100644 --- a/src/main/java/net/minecraft/server/EntityMushroomCow.java +++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java @@ -36,13 +36,13 @@ public class EntityMushroomCow extends EntityCow { // CraftBukkit end this.die(); - this.world.a("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); + this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); if (!this.world.isStatic) { EntityCow entitycow = new EntityCow(this.world); entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); entitycow.setHealth(this.getHealth()); - entitycow.aq = this.aq; + entitycow.aw = this.aw; this.world.addEntity(entitycow); for (int i = 0; i < 5; ++i) { diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java index 276c219b..958869b7 100644 --- a/src/main/java/net/minecraft/server/EntityOcelot.java +++ b/src/main/java/net/minecraft/server/EntityOcelot.java @@ -16,7 +16,7 @@ public class EntityOcelot extends EntityTameableAnimal { this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 0.3F, 10.0F, 5.0F)); this.goalSelector.a(6, new PathfinderGoalJumpOnBlock(this, 0.4F)); this.goalSelector.a(7, new PathfinderGoalLeapAtTarget(this, 0.3F)); - this.goalSelector.a(8, new PathfinderGoalOzelotAttack(this)); + this.goalSelector.a(8, new PathfinderGoalOcelotAttack(this)); this.goalSelector.a(9, new PathfinderGoalBreed(this, 0.23F)); this.goalSelector.a(10, new PathfinderGoalRandomStroll(this, 0.23F)); this.goalSelector.a(11, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 10.0F)); @@ -28,7 +28,7 @@ public class EntityOcelot extends EntityTameableAnimal { this.datawatcher.a(18, Byte.valueOf((byte) 0)); } - public void bd() { + public void bj() { if (this.getControllerMove().a()) { float f = this.getControllerMove().b(); @@ -48,11 +48,11 @@ public class EntityOcelot extends EntityTameableAnimal { } } - protected boolean ba() { + protected boolean bg() { return !this.isTamed(); } - public boolean aV() { + public boolean bb() { return true; } @@ -72,19 +72,19 @@ public class EntityOcelot extends EntityTameableAnimal { this.setCatType(nbttagcompound.getInt("CatType")); } - protected String aQ() { - return this.isTamed() ? (this.s() ? "mob.cat.purr" : (this.random.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : ""; + protected String aW() { + return this.isTamed() ? (this.r() ? "mob.cat.purr" : (this.random.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : ""; } - protected String aR() { + protected String aX() { return "mob.cat.hitt"; } - protected String aS() { + protected String aY() { return "mob.cat.hitt"; } - protected float aP() { + protected float aV() { return 0.4F; } @@ -92,7 +92,7 @@ public class EntityOcelot extends EntityTameableAnimal { return Item.LEATHER.id; } - public boolean k(Entity entity) { + public boolean l(Entity entity) { return entity.damageEntity(DamageSource.mobAttack(this), 3); } @@ -109,7 +109,7 @@ public class EntityOcelot extends EntityTameableAnimal { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (this.isTamed()) { - if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.b(itemstack)) { + if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) { this.d.a(!this.isSitting()); } } else if (this.e.f() && itemstack != null && itemstack.id == Item.RAW_FISH.id && entityhuman.e(this) < 9.0D) { @@ -127,11 +127,11 @@ public class EntityOcelot extends EntityTameableAnimal { this.setTamed(true); this.setCatType(1 + this.world.random.nextInt(3)); this.setOwnerName(entityhuman.name); - this.e(true); + this.f(true); this.d.a(true); this.world.broadcastEntityEffect(this, (byte) 7); } else { - this.e(false); + this.f(false); this.world.broadcastEntityEffect(this, (byte) 6); } } @@ -154,7 +154,7 @@ public class EntityOcelot extends EntityTameableAnimal { return entityocelot; } - public boolean b(ItemStack itemstack) { + public boolean c(ItemStack itemstack) { return itemstack != null && itemstack.id == Item.RAW_FISH.id; } @@ -168,7 +168,7 @@ public class EntityOcelot extends EntityTameableAnimal { } else { EntityOcelot entityocelot = (EntityOcelot) entityanimal; - return !entityocelot.isTamed() ? false : this.s() && entityocelot.s(); + return !entityocelot.isTamed() ? false : this.r() && entityocelot.r(); } } @@ -207,4 +207,16 @@ public class EntityOcelot extends EntityTameableAnimal { public String getLocalizedName() { return this.isTamed() ? "entity.Cat.name" : super.getLocalizedName(); } + + public void bD() { + if (this.world.random.nextInt(7) == 0) { + for (int i = 0; i < 2; ++i) { + EntityOcelot entityocelot = new EntityOcelot(this.world); + + entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); + entityocelot.setAge(-24000); + this.world.addEntity(entityocelot); + } + } + } } diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java index 46da1989..6fb2afa5 100644 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ b/src/main/java/net/minecraft/server/EntityPainting.java @@ -1,38 +1,18 @@ package net.minecraft.server; import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -// CraftBukkit start -import org.bukkit.entity.Painting; -import org.bukkit.event.painting.PaintingBreakEvent.RemoveCause; -import org.bukkit.event.painting.PaintingBreakEvent; -// CraftBukkit end +public class EntityPainting extends EntityHanging { -public class EntityPainting extends Entity { - - private int f; - public int direction; - public int x; - public int y; - public int z; public EnumArt art; public EntityPainting(World world) { super(world); - this.f = 0; - this.direction = 0; - this.height = 0.0F; - this.a(0.5F, 0.5F); this.art = EnumArt.values()[this.random.nextInt(EnumArt.values().length)]; // CraftBukkit - generate a non-null painting } public EntityPainting(World world, int i, int j, int k, int l) { - this(world); - this.x = i; - this.y = j; - this.z = k; + super(world, i, j, k, l); ArrayList arraylist = new ArrayList(); EnumArt[] aenumart = EnumArt.values(); int i1 = aenumart.length; @@ -54,225 +34,12 @@ public class EntityPainting extends Entity { this.setDirection(l); } - protected void a() {} - - public void setDirection(int i) { - this.direction = i; - this.lastYaw = this.yaw = (float) (i * 90); - float f = (float) this.art.B; - float f1 = (float) this.art.C; - float f2 = (float) this.art.B; - - if (i != 0 && i != 2) { - f = 0.5F; - } else { - f2 = 0.5F; - } - - f /= 32.0F; - f1 /= 32.0F; - f2 /= 32.0F; - float f3 = (float) this.x + 0.5F; - float f4 = (float) this.y + 0.5F; - float f5 = (float) this.z + 0.5F; - float f6 = 0.5625F; - - if (i == 0) { - f5 -= f6; - } - - if (i == 1) { - f3 -= f6; - } - - if (i == 2) { - f5 += f6; - } - - if (i == 3) { - f3 += f6; - } - - if (i == 0) { - f3 -= this.b(this.art.B); - } - - if (i == 1) { - f5 += this.b(this.art.B); - } - - if (i == 2) { - f3 += this.b(this.art.B); - } - - if (i == 3) { - f5 -= this.b(this.art.B); - } - - f4 += this.b(this.art.C); - this.setPosition((double) f3, (double) f4, (double) f5); - float f7 = -0.00625F; - - this.boundingBox.b((double) (f3 - f - f7), (double) (f4 - f1 - f7), (double) (f5 - f2 - f7), (double) (f3 + f + f7), (double) (f4 + f1 + f7), (double) (f5 + f2 + f7)); - } - - private float b(int i) { - return i == 32 ? 0.5F : (i == 64 ? 0.5F : 0.0F); - } - - public void h_() { - if (this.f++ == 100 && !this.world.isStatic) { - this.f = 0; - if (!this.dead && !this.survives()) { - // CraftBukkit start - Material material = this.world.getMaterial((int) this.locX, (int) this.locY, (int) this.locZ); - RemoveCause cause; - - if (material.equals(Material.WATER)) { - cause = RemoveCause.WATER; - } else if (!material.equals(Material.AIR)) { - // TODO: This feels insufficient to catch 100% of suffocation cases - cause = RemoveCause.OBSTRUCTION; - } else { - cause = RemoveCause.PHYSICS; - } - - PaintingBreakEvent event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), cause); - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled() || dead) { - return; - } - // CraftBukkit end - - this.die(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } - } - } - - public boolean survives() { - if (!this.world.getCubes(this, this.boundingBox).isEmpty()) { - return false; - } else { - int i = this.art.B / 16; - int j = this.art.C / 16; - int k = this.x; - int l = this.y; - int i1 = this.z; - - if (this.direction == 0) { - k = MathHelper.floor(this.locX - (double) ((float) this.art.B / 32.0F)); - } - - if (this.direction == 1) { - i1 = MathHelper.floor(this.locZ - (double) ((float) this.art.B / 32.0F)); - } - - if (this.direction == 2) { - k = MathHelper.floor(this.locX - (double) ((float) this.art.B / 32.0F)); - } - - if (this.direction == 3) { - i1 = MathHelper.floor(this.locZ - (double) ((float) this.art.B / 32.0F)); - } - - l = MathHelper.floor(this.locY - (double) ((float) this.art.C / 32.0F)); - - for (int j1 = 0; j1 < i; ++j1) { - for (int k1 = 0; k1 < j; ++k1) { - Material material; - - if (this.direction != 0 && this.direction != 2) { - material = this.world.getMaterial(this.x, l + k1, i1 + j1); - } else { - material = this.world.getMaterial(k + j1, l + k1, this.z); - } - - if (!material.isBuildable()) { - return false; - } - } - } - - List list = this.world.getEntities(this, this.boundingBox); - Iterator iterator = list.iterator(); - - Entity entity; - - do { - if (!iterator.hasNext()) { - return true; - } - - entity = (Entity) iterator.next(); - } while (!(entity instanceof EntityPainting)); - - return false; - } - } - - public boolean L() { - return true; - } - - public boolean damageEntity(DamageSource damagesource, int i) { - if (!this.dead && !this.world.isStatic) { - // CraftBukkit start - PaintingBreakEvent event = null; - if (damagesource.getEntity() != null) { - event = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity()); - } else { - if (damagesource == DamageSource.FIRE) { - event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), RemoveCause.FIRE); - } - // TODO: Could put other stuff here? - } - - if (event != null) { - this.world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - } - - if (this.dead) { - return true; - } - // CraftBukkit end - - this.die(); - this.K(); - EntityHuman entityhuman = null; - - if (damagesource.getEntity() instanceof EntityHuman) { - entityhuman = (EntityHuman) damagesource.getEntity(); - } - - if (entityhuman != null && entityhuman.abilities.canInstantlyBuild) { - return true; - } - - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } - - return true; - } - public void b(NBTTagCompound nbttagcompound) { - nbttagcompound.setByte("Dir", (byte) this.direction); - nbttagcompound.setString("Motive", this.art.A); - nbttagcompound.setInt("TileX", this.x); - nbttagcompound.setInt("TileY", this.y); - nbttagcompound.setInt("TileZ", this.z); + nbttagcompound.setString("Motive", this.art.B); + super.b(nbttagcompound); } public void a(NBTTagCompound nbttagcompound) { - this.direction = nbttagcompound.getByte("Dir"); - this.x = nbttagcompound.getInt("TileX"); - this.y = nbttagcompound.getInt("TileY"); - this.z = nbttagcompound.getInt("TileZ"); String s = nbttagcompound.getString("Motive"); EnumArt[] aenumart = EnumArt.values(); int i = aenumart.length; @@ -280,7 +47,7 @@ public class EntityPainting extends Entity { for (int j = 0; j < i; ++j) { EnumArt enumart = aenumart[j]; - if (enumart.A.equals(s)) { + if (enumart.B.equals(s)) { this.art = enumart; } } @@ -289,22 +56,18 @@ public class EntityPainting extends Entity { this.art = EnumArt.KEBAB; } - this.setDirection(this.direction); + super.a(nbttagcompound); } - public void move(double d0, double d1, double d2) { - if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { - if (dead) return; // CraftBukkit + public int d() { + return this.art.C; + } - this.die(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } + public int g() { + return this.art.D; } - public void g(double d0, double d1, double d2) { - if (false && !this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed for paintings - this.die(); - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); - } + public void h() { + this.a(new ItemStack(Item.PAINTING), 0.0F); } } diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index a66c26f2..62e9c14f 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -4,6 +4,8 @@ import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit public class EntityPig extends EntityAnimal { + private final PathfinderGoalPassengerCarrotStick d; + public EntityPig(World world) { super(world); this.texture = "/mob/pig.png"; @@ -13,15 +15,17 @@ public class EntityPig extends EntityAnimal { this.goalSelector.a(0, new PathfinderGoalFloat(this)); this.goalSelector.a(1, new PathfinderGoalPanic(this, 0.38F)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, f)); - this.goalSelector.a(3, new PathfinderGoalTempt(this, 0.25F, Item.WHEAT.id, false)); - this.goalSelector.a(4, new PathfinderGoalFollowParent(this, 0.28F)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, f)); - this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); - this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); + this.goalSelector.a(2, this.d = new PathfinderGoalPassengerCarrotStick(this, 0.34F)); + this.goalSelector.a(3, new PathfinderGoalBreed(this, f)); + this.goalSelector.a(4, new PathfinderGoalTempt(this, 0.3F, Item.CARROT_STICK.id, false)); + this.goalSelector.a(4, new PathfinderGoalTempt(this, 0.3F, Item.CARROT.id, false)); + this.goalSelector.a(5, new PathfinderGoalFollowParent(this, 0.28F)); + this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, f)); + this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); } - public boolean aV() { + public boolean bb() { return true; } @@ -29,6 +33,16 @@ public class EntityPig extends EntityAnimal { return 10; } + protected void bi() { + super.bi(); + } + + public boolean bF() { + ItemStack itemstack = ((EntityHuman) this.passenger).bA(); + + return itemstack != null && itemstack.id == Item.CARROT_STICK.id; + } + protected void a() { super.a(); this.datawatcher.a(16, Byte.valueOf((byte) 0)); @@ -44,16 +58,20 @@ public class EntityPig extends EntityAnimal { this.setSaddle(nbttagcompound.getBoolean("Saddle")); } - protected String aQ() { - return "mob.pig"; + protected String aW() { + return "mob.pig.say"; + } + + protected String aX() { + return "mob.pig.say"; } - protected String aR() { - return "mob.pig"; + protected String aY() { + return "mob.pig.death"; } - protected String aS() { - return "mob.pigdeath"; + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.pig.step", 0.15F, 1.0F); } public boolean c(EntityHuman entityhuman) { @@ -84,6 +102,10 @@ public class EntityPig extends EntityAnimal { } } + if (this.hasSaddle()) { + loot.add(new org.bukkit.inventory.ItemStack(Item.SADDLE.id, 1)); + } + CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } @@ -127,4 +149,12 @@ public class EntityPig extends EntityAnimal { public EntityAnimal createChild(EntityAnimal entityanimal) { return new EntityPig(this.world); } + + public boolean c(ItemStack itemstack) { + return itemstack != null && itemstack.id == Item.CARROT.id; + } + + public PathfinderGoalPassengerCarrotStick n() { + return this.d; + } } diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 35a21eb0..bd8b5f71 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -12,27 +12,25 @@ public class EntityPigZombie extends EntityZombie { public int angerLevel = 0; // CraftBukkit - private -> public private int soundDelay = 0; - private static final ItemStack g = new ItemStack(Item.GOLD_SWORD, 1); public EntityPigZombie(World world) { super(world); this.texture = "/mob/pigzombie.png"; - this.bw = 0.5F; - this.damage = 5; + this.bI = 0.5F; this.fireProof = true; } - protected boolean aV() { + protected boolean bb() { return false; } - public void h_() { - this.bw = this.target != null ? 0.95F : 0.5F; + public void j_() { + this.bI = this.target != null ? 0.95F : 0.5F; if (this.soundDelay > 0 && --this.soundDelay == 0) { - this.world.makeSound(this, "mob.zombiepig.zpigangry", this.aP() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); + this.world.makeSound(this, "mob.zombiepig.zpigangry", this.aV() * 2.0F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 1.8F); } - super.h_(); + super.j_(); } public boolean canSpawn() { @@ -66,17 +64,17 @@ public class EntityPigZombie extends EntityZombie { if (entity1 instanceof EntityPigZombie) { EntityPigZombie entitypigzombie = (EntityPigZombie) entity1; - entitypigzombie.c(entity); + entitypigzombie.o(entity); } } - this.c(entity); + this.o(entity); } return super.damageEntity(damagesource, i); } - private void c(Entity entity) { + private void o(Entity entity) { // CraftBukkit start org.bukkit.entity.Entity bukkitTarget = entity == null ? null : entity.getBukkitEntity(); @@ -99,15 +97,15 @@ public class EntityPigZombie extends EntityZombie { this.soundDelay = this.random.nextInt(40); } - protected String aQ() { + protected String aW() { return "mob.zombiepig.zpig"; } - protected String aR() { + protected String aX() { return "mob.zombiepig.zpighurt"; } - protected String aS() { + protected String aY() { return "mob.zombiepig.zpigdeath"; } @@ -142,30 +140,36 @@ public class EntityPigZombie extends EntityZombie { // CraftBukkit end } + public boolean c(EntityHuman entityhuman) { + return false; + } + // CraftBukkit start - return rare dropped item instead of dropping it protected ItemStack l(int i) { - if (i > 0) { - ItemStack itemstack = new ItemStack(Item.GOLD_SWORD); - - EnchantmentManager.a(this.random, itemstack, 5); - return itemstack; - } else { - int j = this.random.nextInt(3); - - if (j == 0) { - return new ItemStack(Item.GOLD_INGOT.id, 1, 0); - } else if (j == 1) { - return new ItemStack(Item.GOLD_SWORD.id, 1, 0); - } else if (j == 2) { - return new ItemStack(Item.GOLD_HELMET.id, 1, 0); - } else { - return null; - } - } + return new ItemStack(Item.GOLD_INGOT.id, 1, 0); } - // CraftBukkit end protected int getLootId() { return Item.ROTTEN_FLESH.id; } + + protected void bB() { + this.setEquipment(0, new ItemStack(Item.GOLD_SWORD)); + } + + public void bD() { + super.bD(); + this.setVillager(false); + } + + public int c(Entity entity) { + ItemStack itemstack = this.bA(); + int i = 5; + + if (itemstack != null) { + i += itemstack.a((Entity) this); + } + + return i; + } } diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index b991bfa7..b306a238 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -26,16 +26,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public double d; public double e; public final List chunkCoordIntPairQueue = new LinkedList(); - public final List g = new LinkedList(); - private int ch = -99999999; - private int ci = -99999999; - private boolean cj = true; + public final List removeQueue = new LinkedList(); + private int cn = -99999999; + private int co = -99999999; + private boolean cp = true; public int lastSentExp = -99999999; // CraftBukkit - private -> public public int invulnerableTicks = 60; // CraftBukkit - private -> public - private int cm = 0; - private int cn = 0; - private boolean co = true; - private ItemStack[] cp = new ItemStack[] { null, null, null, null, null}; + private int cs = 0; + private int ct = 0; + private boolean cu = true; private int containerCounter = 0; public boolean h; public int ping; @@ -54,21 +53,23 @@ public class EntityPlayer extends EntityHuman implements ICrafting { super(world); iteminworldmanager.player = this; this.itemInWorldManager = iteminworldmanager; - this.cm = minecraftserver.getServerConfigurationManager().o(); + this.cs = minecraftserver.getServerConfigurationManager().o(); ChunkCoordinates chunkcoordinates = world.getSpawn(); int i = chunkcoordinates.x; int j = chunkcoordinates.z; int k = chunkcoordinates.y; - if (!world.worldProvider.e && world.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { - i += this.random.nextInt(20) - 10; - k = world.h(i, j); - j += this.random.nextInt(20) - 10; + if (!world.worldProvider.f && world.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { + int l = Math.max(5, minecraftserver.getSpawnProtection() - 6); + + i += this.random.nextInt(l * 2) - l; + j += this.random.nextInt(l * 2) - l; + k = world.i(i, j); } this.setPositionRotation((double) i + 0.5D, (double) k, (double) j + 0.5D, 0.0F, 0.0F); this.server = minecraftserver; - this.W = 0.0F; + this.X = 0.0F; this.name = s; this.height = 0.0F; this.displayName = this.name; // CraftBukkit @@ -99,7 +100,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld); if (cworld != null && this.getBed() != null) { world = cworld.getHandle(); - position = EntityHuman.getBed(cworld.getHandle(), this.getBed()); + position = EntityHuman.getBed(cworld.getHandle(), this.getBed(), false); } } if (world == null || position == null) { @@ -123,11 +124,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.activeContainer.addSlotListener(this); } - public ItemStack[] getEquipment() { - return this.cp; - } - - protected void d_() { + protected void e_() { this.height = 0.0F; } @@ -135,22 +132,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return 1.62F; } - public void h_() { + public void j_() { this.itemInWorldManager.a(); --this.invulnerableTicks; this.activeContainer.b(); - - int i; - - for (i = 0; i < 5; ++i) { - ItemStack itemstack = this.b(i); - - if (itemstack != this.cp[i]) { - this.q().getTracker().a(this, new Packet5EntityEquipment(this.id, i, itemstack)); - this.cp[i] = itemstack; - } - } - if (!this.chunkCoordIntPairQueue.isEmpty()) { ArrayList arraylist = new ArrayList(); Iterator iterator = this.chunkCoordIntPairQueue.iterator(); @@ -179,15 +164,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { while (iterator1.hasNext()) { TileEntity tileentity = (TileEntity) iterator1.next(); - this.a(tileentity); + this.b(tileentity); } } } - if (!this.g.isEmpty()) { - i = Math.min(this.g.size(), 127); + if (!this.removeQueue.isEmpty()) { + int i = Math.min(this.removeQueue.size(), 127); int[] aint = new int[i]; - Iterator iterator2 = this.g.iterator(); + Iterator iterator2 = this.removeQueue.iterator(); int j = 0; while (iterator2.hasNext() && j < i) { @@ -200,12 +185,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void g() { - super.h_(); + super.j_(); for (int i = 0; i < this.inventory.getSize(); ++i) { ItemStack itemstack = this.inventory.getItem(i); - if (itemstack != null && Item.byId[itemstack.id].m_() && this.netServerHandler.lowPriorityCount() <= 2) { + if (itemstack != null && Item.byId[itemstack.id].f() && this.netServerHandler.lowPriorityCount() <= 5) { Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this); if (packet != null) { @@ -214,57 +199,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - if (this.bX) { - // if (this.server.getAllowNether()) { // CraftBukkit - if (this.activeContainer != this.defaultContainer) { - this.closeInventory(); - } - - if (this.vehicle != null) { - this.mount(this.vehicle); - } else { - this.bY += 0.0125F; - if (this.bY >= 1.0F) { - this.bY = 1.0F; - this.bW = 10; - boolean flag = false; - byte b0; - - if (this.dimension == -1) { - b0 = 0; - } else { - b0 = -1; - } - - this.server.getServerConfigurationManager().changeDimension(this, b0); - this.lastSentExp = -1; - this.ch = -1; - this.ci = -1; - this.a((Statistic) AchievementList.x); - } - } - - this.bX = false; - // } // CraftBukkit - } else { - if (this.bY > 0.0F) { - this.bY -= 0.05F; - } - - if (this.bY < 0.0F) { - this.bY = 0.0F; - } - } - - if (this.bW > 0) { - --this.bW; - } - - if (this.getHealth() != this.ch || this.ci != this.foodData.a() || this.foodData.e() == 0.0F != this.cj) { + if (this.getHealth() != this.cn || this.co != this.foodData.a() || this.foodData.e() == 0.0F != this.cp) { this.netServerHandler.sendPacket(new Packet8UpdateHealth(this.getHealth(), this.foodData.a(), this.foodData.e())); - this.ch = this.getHealth(); - this.ci = this.foodData.a(); - this.cj = this.foodData.e() == 0.0F; + this.cn = this.getHealth(); + this.co = this.foodData.a(); + this.cp = this.foodData.e() == 0.0F; } if (this.expTotal != this.lastSentExp) { @@ -284,10 +223,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting { // CraftBukkit end } - public ItemStack b(int i) { - return i == 0 ? this.inventory.getItemInHand() : this.inventory.armor[i - 1]; - } - public void die(DamageSource damagesource) { // CraftBukkit start if (this.dead) { @@ -358,7 +293,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { return this.server.getPvP(); } - public void c(int i) { + public void b(int i) { if (this.dimension == 1 && i == 1) { this.a((Statistic) AchievementList.C); this.world.kill(this); @@ -369,21 +304,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting { /* CraftBukkit start - removed to fix our handling of The End portals ChunkCoordinates chunkcoordinates = this.server.getWorldServer(i).getDimensionSpawn(); - if (chunkcoordinates != null) { - this.netServerHandler.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F); + if (chunkcoordinates != null) { + this.netServerHandler.a((double) chunkcoordinates.x, (double) chunkcoordinates.y, (double) chunkcoordinates.z, 0.0F, 0.0F); + } + + i = 1; + } else { + this.a((Statistic) AchievementList.x); } // CraftBukkit end */ - this.server.getServerConfigurationManager().changeDimension(this, 1); + this.server.getServerConfigurationManager().changeDimension(this, i); this.lastSentExp = -1; - this.ch = -1; - this.ci = -1; + this.cn = -1; + this.co = -1; } } - private void a(TileEntity tileentity) { + private void b(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.e(); + Packet packet = tileentity.l(); if (packet != null) { this.netServerHandler.sendPacket(packet); @@ -392,41 +332,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void receive(Entity entity, int i) { - if (!entity.dead) { - EntityTracker entitytracker = this.q().getTracker(); - - if (entity instanceof EntityItem) { - entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); - } - - if (entity instanceof EntityArrow) { - entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); - } - - if (entity instanceof EntityExperienceOrb) { - entitytracker.a(entity, new Packet22Collect(entity.id, this.id)); - } - } - super.receive(entity, i); this.activeContainer.b(); } - public void i() { - if (!this.bH) { - this.bI = -1; - this.bH = true; - this.q().getTracker().a(this, new Packet18ArmAnimation(this, 1)); - } - } - public EnumBedResult a(int i, int j, int k) { EnumBedResult enumbedresult = super.a(i, j, k); if (enumbedresult == EnumBedResult.OK) { Packet17EntityLocationAction packet17entitylocationaction = new Packet17EntityLocationAction(this, 0, i, j, k); - this.q().getTracker().a(this, packet17entitylocationaction); + this.p().getTracker().a(this, packet17entitylocationaction); this.netServerHandler.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch); this.netServerHandler.sendPacket(packet17entitylocationaction); } @@ -438,7 +354,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (this.fauxSleeping && !this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! if (this.isSleeping()) { - this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 3)); + this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 3)); } super.a(flag, flag1, flag2); @@ -475,7 +391,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void startCrafting(int i, int j, int k) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.world, i, j, k)); if(container == null) return; // CraftBukkit end @@ -488,7 +404,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void startEnchanting(int i, int j, int k) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantTable(this.inventory, this.world, i, j, k)); if(container == null) return; // CraftBukkit end @@ -500,12 +416,25 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.activeContainer.addSlotListener(this); } + public void openAnvil(int i, int j, int k) { + // CraftBukkit start - inventory open hook + Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerAnvil(this.inventory, this.world, i, j, k, this)); + if(container == null) return; + // CraftBukkit end + + this.nextContainerCounter(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.containerCounter, 8, "Repairing", 9)); + this.activeContainer = container; // CraftBukkit - use container we passed to event + this.activeContainer.windowId = this.containerCounter; + this.activeContainer.addSlotListener(this); + } + public void openContainer(IInventory iinventory) { if (this.activeContainer != this.defaultContainer) { this.closeInventory(); } - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory)); if(container == null) return; // CraftBukkit end @@ -518,7 +447,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void openFurnace(TileEntityFurnace tileentityfurnace) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, tileentityfurnace)); if(container == null) return; // CraftBukkit end @@ -531,7 +460,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void openDispenser(TileEntityDispenser tileentitydispenser) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, tileentitydispenser)); if(container == null) return; // CraftBukkit end @@ -544,7 +473,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void openBrewingStand(TileEntityBrewingStand tileentitybrewingstand) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, tileentitybrewingstand)); if(container == null) return; // CraftBukkit end @@ -556,14 +485,27 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.activeContainer.addSlotListener(this); } + public void openBeacon(TileEntityBeacon tileentitybeacon) { + // CraftBukkit start - inventory open hook + Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBeacon(this.inventory, tileentitybeacon)); + if(container == null) return; + // CraftBukkit end + + this.nextContainerCounter(); + this.netServerHandler.sendPacket(new Packet100OpenWindow(this.containerCounter, 7, tileentitybeacon.getName(), tileentitybeacon.getSize())); + this.activeContainer = container; // CraftBukkit - Use container passed to event + this.activeContainer.windowId = this.containerCounter; + this.activeContainer.addSlotListener(this); + } + public void openTrade(IMerchant imerchant) { - // CraftBukkit start - INVENTORY_OPEN hook + // CraftBukkit start - inventory open hook Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, imerchant, this.world)); if(container == null) return; // CraftBukkit end this.nextContainerCounter(); - this.activeContainer = container; // CraftBukkit - User container passed to event + this.activeContainer = container; // CraftBukkit - Use container passed to event this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory(); @@ -613,7 +555,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { public void closeInventory() { this.netServerHandler.sendPacket(new Packet101CloseWindow(this.activeContainer.windowId)); - this.l(); + this.k(); } public void broadcastCarriedItem() { @@ -622,7 +564,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void l() { + public void k() { this.activeContainer.a((EntityHuman) this); this.activeContainer = this.defaultContainer; } @@ -640,7 +582,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void m() { + public void l() { if (this.vehicle != null) { this.mount(this.vehicle); } @@ -654,30 +596,38 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public void n() { - this.ch = -99999999; + public void m() { + this.cn = -99999999; this.lastSentExp = -1; // CraftBukkit - Added to reset } - public void c(String s) { + public void b(String s) { LocaleLanguage localelanguage = LocaleLanguage.a(); String s1 = localelanguage.b(s); this.netServerHandler.sendPacket(new Packet3Chat(s1)); } - protected void o() { + protected void n() { this.netServerHandler.sendPacket(new Packet38EntityStatus(this.id, (byte) 9)); - super.o(); + super.n(); } public void a(ItemStack itemstack, int i) { super.a(itemstack, i); - if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().b(itemstack) == EnumAnimation.b) { - this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 5)); + if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().d_(itemstack) == EnumAnimation.b) { + this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(this, 5)); } } + public void copyTo(EntityHuman entityhuman, boolean flag) { + super.copyTo(entityhuman, flag); + this.lastSentExp = -1; + this.cn = -1; + this.co = -1; + this.removeQueue.addAll(((EntityPlayer) entityhuman).removeQueue); + } + protected void a(MobEffect mobeffect) { super.a(mobeffect); this.netServerHandler.sendPacket(new Packet41MobEffect(this.id, mobeffect)); @@ -698,11 +648,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public void b(Entity entity) { - this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6)); + this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 6)); } public void c(Entity entity) { - this.q().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7)); + this.p().getTracker().sendPacketToEntity(this, new Packet18ArmAnimation(entity, 7)); } public void updateAbilities() { @@ -711,7 +661,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - public WorldServer q() { + public WorldServer p() { return (WorldServer) this.world; } @@ -724,11 +674,11 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.netServerHandler.sendPacket(new Packet3Chat(s)); } - public boolean b(String s) { - return "seed".equals(s) && !this.server.S() ? true : (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) ? this.server.getServerConfigurationManager().isOp(this.name) : true); + public boolean a(int i, String s) { + return "seed".equals(s) && !this.server.T() ? true : (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) ? this.server.getServerConfigurationManager().isOp(this.name) : true); } - public String r() { + public String q() { String s = this.netServerHandler.networkManager.getSocketAddress().toString(); s = s.substring(s.indexOf("/") + 1); @@ -744,14 +694,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting { int i = 256 >> packet204localeandviewdistance.f(); if (i > 3 && i < 15) { - this.cm = i; + this.cs = i; } - this.cn = packet204localeandviewdistance.g(); - this.co = packet204localeandviewdistance.h(); - if (this.server.H() && this.server.G().equals(this.name)) { + this.ct = packet204localeandviewdistance.g(); + this.cu = packet204localeandviewdistance.h(); + if (this.server.I() && this.server.H().equals(this.name)) { this.server.c(packet204localeandviewdistance.i()); } + + this.b(1, !packet204localeandviewdistance.j()); } public LocaleLanguage getLocale() { @@ -759,7 +711,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } public int getChatFlags() { - return this.cn; + return this.ct; } public void a(String s, int i) { @@ -768,6 +720,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { this.netServerHandler.sendPacket(new Packet250CustomPayload("MC|TPack", s1.getBytes())); } + public ChunkCoordinates b() { + return new ChunkCoordinates(MathHelper.floor(this.locX), MathHelper.floor(this.locY + 0.5D), MathHelper.floor(this.locZ)); + } + // CraftBukkit start public long timeOffset = 0; public boolean relativeTime = true; diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java index 95b3454d..ed382160 100644 --- a/src/main/java/net/minecraft/server/EntityPotion.java +++ b/src/main/java/net/minecraft/server/EntityPotion.java @@ -12,41 +12,57 @@ import org.bukkit.entity.LivingEntity; public class EntityPotion extends EntityProjectile { - private int d; + private ItemStack d; public EntityPotion(World world) { super(world); } public EntityPotion(World world, EntityLiving entityliving, int i) { + this(world, entityliving, new ItemStack(Item.POTION, 1, i)); + } + + public EntityPotion(World world, EntityLiving entityliving, ItemStack itemstack) { super(world, entityliving); - this.d = i; + this.d = itemstack; } - public EntityPotion(World world, double d0, double d1, double d2, int i) { + public EntityPotion(World world, double d0, double d1, double d2, ItemStack itemstack) { super(world, d0, d1, d2); - this.d = i; + this.d = itemstack; } - protected float h() { + protected float g() { return 0.05F; } - protected float d() { + protected float c() { return 0.5F; } - protected float g() { + protected float d() { return -20.0F; } + public void setPotionValue(int i) { + if (this.d == null) { + this.d = new ItemStack(Item.POTION, 1, 0); + } + + this.d.setData(i); + } + public int getPotionValue() { - return this.d; + if (this.d == null) { + this.d = new ItemStack(Item.POTION, 1, 0); + } + + return this.d.getData(); } protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isStatic) { - List list = Item.POTION.f(this.d); + List list = Item.POTION.l(this.d); if (list != null && !list.isEmpty()) { AxisAlignedBB axisalignedbb = this.boundingBox.grow(4.0D, 2.0D, 4.0D); @@ -114,18 +130,28 @@ public class EntityPotion extends EntityProjectile { } } - this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.d); + this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), this.getPotionValue()); this.die(); } } public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); - this.d = nbttagcompound.getInt("potionValue"); + if (nbttagcompound.hasKey("Potion")) { + this.d = ItemStack.a(nbttagcompound.getCompound("Potion")); + } else { + this.setPotionValue(nbttagcompound.getInt("potionValue")); + } + + if (this.d == null) { + this.die(); + } } public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); - nbttagcompound.setInt("potionValue", this.d); + if (this.d != null) { + nbttagcompound.setCompound("Potion", this.d.save(new NBTTagCompound())); + } } } diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java index cca2d9b7..132af67d 100644 --- a/src/main/java/net/minecraft/server/EntityProjectile.java +++ b/src/main/java/net/minecraft/server/EntityProjectile.java @@ -5,7 +5,7 @@ import java.util.List; import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit -public abstract class EntityProjectile extends Entity { +public abstract class EntityProjectile extends Entity implements IProjectile { private int blockX = -1; private int blockY = -1; @@ -38,8 +38,8 @@ public abstract class EntityProjectile extends Entity { 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.g()) / 180.0F * 3.1415927F) * f); - this.c(this.motX, this.motY, this.motZ, this.d(), 1.0F); + this.motY = (double) (-MathHelper.sin((this.pitch + this.d()) / 180.0F * 3.1415927F) * f); + this.shoot(this.motX, this.motY, this.motZ, this.c(), 1.0F); } public EntityProjectile(World world, double d0, double d1, double d2) { @@ -50,15 +50,15 @@ public abstract class EntityProjectile extends Entity { this.height = 0.0F; } - protected float d() { + protected float c() { return 1.5F; } - protected float g() { + protected float d() { return 0.0F; } - public void c(double d0, double d1, double d2, float f, float f1) { + public void shoot(double d0, double d1, double d2, float f, float f1) { float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); d0 /= (double) f2; @@ -80,11 +80,11 @@ public abstract class EntityProjectile extends Entity { this.h = 0; } - public void h_() { - this.S = this.locX; - this.T = this.locY; - this.U = this.locZ; - super.h_(); + public void j_() { + this.T = this.locX; + this.U = this.locY; + this.V = this.locZ; + super.j_(); if (this.shake > 0) { --this.shake; } @@ -111,14 +111,14 @@ public abstract class EntityProjectile extends Entity { ++this.i; } - Vec3D vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - Vec3D vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + Vec3D vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); MovingObjectPosition movingobjectposition = this.world.a(vec3d, vec3d1); - vec3d = Vec3D.a().create(this.locX, this.locY, this.locZ); - vec3d1 = Vec3D.a().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + vec3d = this.world.getVec3DPool().create(this.locX, this.locY, this.locZ); + vec3d1 = this.world.getVec3DPool().create(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); if (movingobjectposition != null) { - vec3d1 = Vec3D.a().create(movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); + vec3d1 = this.world.getVec3DPool().create(movingobjectposition.pos.c, movingobjectposition.pos.d, movingobjectposition.pos.e); } if (!this.world.isStatic) { @@ -152,13 +152,17 @@ public abstract class EntityProjectile extends Entity { } if (movingobjectposition != null) { - this.a(movingobjectposition); - // CraftBukkit start - if (this.dead) { - ProjectileHitEvent hitEvent = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity()); - org.bukkit.Bukkit.getPluginManager().callEvent(hitEvent); + if (movingobjectposition.type == EnumMovingObjectType.TILE && this.world.getTypeId(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d) == Block.PORTAL.id) { + this.aa(); + } else { + this.a(movingobjectposition); + // CraftBukkit start + if (this.dead) { + ProjectileHitEvent hitEvent = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity()); + org.bukkit.Bukkit.getPluginManager().callEvent(hitEvent); + } + // CraftBukkit end } - // CraftBukkit end } this.locX += this.motX; @@ -187,13 +191,13 @@ public abstract class EntityProjectile extends Entity { 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.h(); + float f3 = this.g(); if (this.H()) { for (int j = 0; j < 4; ++j) { 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); + this.world.addParticle("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; @@ -206,7 +210,7 @@ public abstract class EntityProjectile extends Entity { this.setPosition(this.locX, this.locY, this.locZ); } - protected float h() { + protected float g() { return 0.03F; } diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index d74cf4d7..aadad334 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -31,21 +31,21 @@ public class EntitySheep extends EntityAnimal { this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); } - protected boolean aV() { + protected boolean bb() { return true; } - protected void bc() { + protected void bi() { this.e = this.f.f(); - super.bc(); + super.bi(); } - public void d() { + public void c() { if (this.world.isStatic) { this.e = Math.max(0, this.e - 1); } - super.d(); + super.c(); } public int getMaxHealth() { @@ -100,6 +100,7 @@ public class EntitySheep extends EntityAnimal { } itemstack.damage(1, entityhuman); + this.world.makeSound(this, "mob.sheep.shear", 1.0F, 1.0F); } return super.c(entityhuman); @@ -117,16 +118,20 @@ public class EntitySheep extends EntityAnimal { this.setColor(nbttagcompound.getByte("Color")); } - protected String aQ() { - return "mob.sheep"; + protected String aW() { + return "mob.sheep.say"; } - protected String aR() { - return "mob.sheep"; + protected String aX() { + return "mob.sheep.say"; } - protected String aS() { - return "mob.sheep"; + protected String aY() { + return "mob.sheep.say"; + } + + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.sheep.step", 0.15F, 1.0F); } public int getColor() { @@ -172,7 +177,7 @@ public class EntitySheep extends EntityAnimal { return entitysheep1; } - public void aA() { + public void aG() { // CraftBukkit start SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); this.world.getServer().getPluginManager().callEvent(event); @@ -192,4 +197,8 @@ public class EntitySheep extends EntityAnimal { this.setAge(i); } } + + public void bD() { + this.setColor(a(this.world.random)); + } } diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java index 35eba18a..802169c6 100644 --- a/src/main/java/net/minecraft/server/EntitySilverfish.java +++ b/src/main/java/net/minecraft/server/EntitySilverfish.java @@ -10,15 +10,14 @@ public class EntitySilverfish extends EntityMonster { super(world); this.texture = "/mob/silverfish.png"; this.a(0.3F, 0.7F); - this.bw = 0.6F; - this.damage = 1; + this.bI = 0.6F; } public int getMaxHealth() { return 8; } - protected boolean e_() { + protected boolean f_() { return false; } @@ -28,15 +27,15 @@ public class EntitySilverfish extends EntityMonster { return this.world.findNearbyVulnerablePlayer(this, d0); } - protected String aQ() { + protected String aW() { return "mob.silverfish.say"; } - protected String aR() { + protected String aX() { return "mob.silverfish.hit"; } - protected String aS() { + protected String aY() { return "mob.silverfish.kill"; } @@ -51,25 +50,25 @@ public class EntitySilverfish extends EntityMonster { 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); + entity.damageEntity(DamageSource.mobAttack(this), this.c(entity)); } } protected void a(int i, int j, int k, int l) { - this.world.makeSound(this, "mob.silverfish.step", 1.0F, 1.0F); + this.world.makeSound(this, "mob.silverfish.step", 0.15F, 1.0F); } protected int getLootId() { return 0; } - public void h_() { - this.aq = this.yaw; - super.h_(); + public void j_() { + this.aw = this.yaw; + super.j_(); } - protected void be() { - super.be(); + protected void bk() { + super.bk(); if (!this.world.isStatic) { int i; int j; @@ -110,7 +109,7 @@ public class EntitySilverfish extends EntityMonster { } } - if (this.target == null && !this.l()) { + if (this.target == null && !this.k()) { i = MathHelper.floor(this.locX); j = MathHelper.floor(this.locY + 0.5D); k = MathHelper.floor(this.locZ); @@ -125,12 +124,12 @@ public class EntitySilverfish extends EntityMonster { // CraftBukkit end this.world.setTypeIdAndData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.f(l)); - this.aK(); + this.aQ(); this.die(); } else { - this.j(); + this.i(); } - } else if (this.target != null && !this.l()) { + } else if (this.target != null && !this.k()) { this.target = null; } } @@ -140,7 +139,7 @@ public class EntitySilverfish extends EntityMonster { return this.world.getTypeId(i, j - 1, k) == Block.STONE.id ? 10.0F : super.a(i, j, k); } - protected boolean o() { + protected boolean i_() { return true; } @@ -154,6 +153,10 @@ public class EntitySilverfish extends EntityMonster { } } + public int c(Entity entity) { + return 1; + } + public EnumMonsterType getMonsterType() { return EnumMonsterType.ARTHROPOD; } diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index 6cfe0539..70130d7d 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -1,27 +1,31 @@ package net.minecraft.server; -import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit +import java.util.Calendar; -public class EntitySkeleton extends EntityMonster { +import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit - private static final ItemStack d = new ItemStack(Item.BOW, 1); +public class EntitySkeleton extends EntityMonster implements IRangedEntity { public EntitySkeleton(World world) { super(world); this.texture = "/mob/skeleton.png"; - this.bw = 0.25F; + this.bI = 0.25F; this.goalSelector.a(1, new PathfinderGoalFloat(this)); this.goalSelector.a(2, new PathfinderGoalRestrictSun(this)); - this.goalSelector.a(3, new PathfinderGoalFleeSun(this, this.bw)); - this.goalSelector.a(4, new PathfinderGoalArrowAttack(this, this.bw, 1, 60)); - this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, this.bw)); + this.goalSelector.a(3, new PathfinderGoalFleeSun(this, this.bI)); + this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, this.bI)); this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); this.goalSelector.a(6, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false)); this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, true)); } - public boolean aV() { + protected void a() { + super.a(); + this.datawatcher.a(13, new Byte((byte) 0)); + } + + public boolean bb() { return true; } @@ -29,28 +33,75 @@ public class EntitySkeleton extends EntityMonster { return 20; } - protected String aQ() { - return "mob.skeleton"; + protected String aW() { + return "mob.skeleton.say"; + } + + protected String aX() { + return "mob.skeleton.hurt"; + } + + protected String aY() { + return "mob.skeleton.death"; } - protected String aR() { - return "mob.skeletonhurt"; + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.skeleton.step", 0.15F, 1.0F); } - protected String aS() { - return "mob.skeletonhurt"; + public boolean l(Entity entity) { + if (super.l(entity)) { + if (this.getSkeletonType() == 1 && entity instanceof EntityLiving) { + ((EntityLiving) entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 200)); + } + + return true; + } else { + return false; + } + } + + public int c(Entity entity) { + if (this.getSkeletonType() == 1) { + ItemStack itemstack = this.bA(); + int i = 4; + + if (itemstack != null) { + i += itemstack.a((Entity) this); + } + + return i; + } else { + return super.c(entity); + } } public EnumMonsterType getMonsterType() { return EnumMonsterType.UNDEAD; } - public void d() { - if (this.world.s() && !this.world.isStatic) { + public void c() { + if (this.world.t() && !this.world.isStatic) { float f = this.c(1.0F); - if (f > 0.5F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { - // CraftBukkit start + if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))) { + boolean flag = true; + ItemStack itemstack = this.getEquipment(4); + + if (itemstack != null) { + if (itemstack.f()) { + itemstack.setData(itemstack.i() + this.random.nextInt(2)); + if (itemstack.i() >= itemstack.k()) { + this.a(itemstack); + this.setEquipment(4, (ItemStack) null); + } + } + + flag = false; + } + + if (flag) { + // CraftBukkit start EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); this.world.getServer().getPluginManager().callEvent(event); @@ -58,10 +109,11 @@ public class EntitySkeleton extends EntityMonster { this.setOnFire(event.getDuration()); } // CraftBukkit end + } } } - super.d(); + super.c(); } public void die(DamageSource damagesource) { @@ -84,14 +136,20 @@ public class EntitySkeleton extends EntityMonster { protected void dropDeathLoot(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 j = this.random.nextInt(3 + i); - int count = this.random.nextInt(3 + i); - if (count > 0) { - loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count)); + if (this.getSkeletonType() == 1) { + int count = this.random.nextInt(3 + i) - 1; + if (count > 0) { + loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.COAL, count)); + } + } else { + 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 + i); + int count = this.random.nextInt(3 + i); if (count > 0) { loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count)); } @@ -112,16 +170,94 @@ public class EntitySkeleton extends EntityMonster { // CraftBukkit end } - // CraftBukkit start - return rare dropped item instead of dropping it + // CraftBukkit - return rare dropped item instead of dropping it protected ItemStack l(int i) { + if (this.getSkeletonType() == 1) { + return new ItemStack(Item.SKULL.id, 1, 1); // CraftBukkit + } + + return null; + } + + protected void bB() { + super.bB(); + this.setEquipment(0, new ItemStack(Item.BOW)); + } + + public void bD() { + if (this.world.worldProvider instanceof WorldProviderHell && this.aA().nextInt(5) > 0) { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityHuman.class, this.bI, false)); + this.setSkeletonType(1); + this.setEquipment(0, new ItemStack(Item.STONE_SWORD)); + } else { + this.goalSelector.a(4, new PathfinderGoalArrowAttack(this, this.bI, 60, 10.0F)); + this.bB(); + this.bC(); + } + + this.canPickUpLoot = this.random.nextFloat() < as[this.world.difficulty]; + if (this.getEquipment(4) == null) { + Calendar calendar = this.world.S(); + + if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) { + this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Block.JACK_O_LANTERN : Block.PUMPKIN)); + this.dropChances[4] = 0.0F; + } + } + } + + public void d(EntityLiving entityliving) { + EntityArrow entityarrow = new EntityArrow(this.world, this, entityliving, 1.6F, 12.0F); + int i = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, this.bA()); + int j = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, this.bA()); + if (i > 0) { - ItemStack itemstack = new ItemStack(Item.BOW); + entityarrow.b(entityarrow.c() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) { + entityarrow.a(j); + } + + if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, this.bA()) > 0 || this.getSkeletonType() == 1) { + entityarrow.setOnFire(100); + } + + this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.aA().nextFloat() * 0.4F + 0.8F)); + this.world.addEntity(entityarrow); + } + + public int getSkeletonType() { + return this.datawatcher.getByte(13); + } + + public void setSkeletonType(int i) { + this.datawatcher.watch(13, Byte.valueOf((byte) i)); + this.fireProof = i == 1; + if (i == 1) { + this.a(0.72F, 2.16F); + } else { + this.a(0.6F, 1.8F); + } + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + if (nbttagcompound.hasKey("SkeletonType")) { + byte b0 = nbttagcompound.getByte("SkeletonType"); - EnchantmentManager.a(this.random, itemstack, 5); - return itemstack; + this.setSkeletonType(b0); + } + + if (this.getSkeletonType() == 1) { + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityHuman.class, this.bI, false)); } else { - return new ItemStack(Item.BOW.id, 1, 0); + this.goalSelector.a(4, new PathfinderGoalArrowAttack(this, this.bI, 60, 10.0F)); } } - // CraftBukkit end + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.setByte("SkeletonType", (byte) this.getSkeletonType()); + } } diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java index a4681baf..8bb950a9 100644 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ b/src/main/java/net/minecraft/server/EntitySlime.java @@ -4,9 +4,9 @@ import org.bukkit.event.entity.SlimeSplitEvent; // CraftBukkit public class EntitySlime extends EntityLiving implements IMonster { - public float a; public float b; public float c; + public float d; private int jumpDelay = 0; public EntitySlime(World world) { @@ -29,7 +29,7 @@ public class EntitySlime extends EntityLiving implements IMonster { this.a(0.6F * (float) i, 0.6F * (float) i); this.setPosition(this.locX, this.locY, this.locZ); this.setHealth(this.getMaxHealth()); - this.aV = i; + this.bc = i; } public int getMaxHealth() { @@ -52,24 +52,24 @@ public class EntitySlime extends EntityLiving implements IMonster { this.setSize(nbttagcompound.getInt("Size") + 1); } - protected String i() { + protected String h() { return "slime"; } - protected String o() { - return "mob.slime"; + protected String n() { + return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); } - public void h_() { + public void j_() { 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; + this.c += (this.b - this.c) * 0.5F; + this.d = this.c; boolean flag = this.onGround; - super.h_(); + super.j_(); if (this.onGround && !flag) { int i = this.getSize(); @@ -79,23 +79,23 @@ 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(this.i(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); + this.world.addParticle(this.h(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D); } - if (this.p()) { - this.world.makeSound(this, this.o(), this.aP(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); + if (this.o()) { + this.world.makeSound(this, this.n(), this.aV(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F); } - this.a = -0.5F; + this.b = -0.5F; } else if (!this.onGround && flag) { - this.a = 1.0F; + this.b = 1.0F; } - this.l(); + this.k(); } - protected void be() { - this.bb(); + protected void bk() { + this.bh(); EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // CraftBukkit TODO: EntityTargetEvent if (entityhuman != null) { @@ -103,35 +103,35 @@ public class EntitySlime extends EntityLiving implements IMonster { } if (this.onGround && this.jumpDelay-- <= 0) { - this.jumpDelay = this.k(); + this.jumpDelay = this.j(); if (entityhuman != null) { this.jumpDelay /= 3; } - this.bu = true; - if (this.r()) { - this.world.makeSound(this, this.o(), this.aP(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); + this.bG = true; + if (this.q()) { + this.world.makeSound(this, this.n(), this.aV(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F); } - this.br = 1.0F - this.random.nextFloat() * 2.0F; - this.bs = (float) (1 * this.getSize()); + this.bD = 1.0F - this.random.nextFloat() * 2.0F; + this.bE = (float) (1 * this.getSize()); } else { - this.bu = false; + this.bG = false; if (this.onGround) { - this.br = this.bs = 0.0F; + this.bD = this.bE = 0.0F; } } } - protected void l() { - this.a *= 0.6F; + protected void k() { + this.b *= 0.6F; } - protected int k() { + protected int j() { return this.random.nextInt(20) + 10; } - protected EntitySlime j() { + protected EntitySlime i() { return new EntitySlime(this.world); } @@ -156,7 +156,7 @@ public class EntitySlime extends EntityLiving implements IMonster { 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.j(); + EntitySlime entityslime = this.i(); 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); @@ -168,29 +168,29 @@ public class EntitySlime extends EntityLiving implements IMonster { } public void b_(EntityHuman entityhuman) { - if (this.m()) { + if (this.l()) { int i = this.getSize(); - if (this.l(entityhuman) && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), this.n())) { - this.world.makeSound(this, "mob.slimeattack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + if (this.m(entityhuman) && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), this.m())) { + this.world.makeSound(this, "mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } } } - protected boolean m() { + protected boolean l() { return this.getSize() > 1; } - protected int n() { + protected int m() { return this.getSize(); } - protected String aR() { - return "mob.slime"; + protected String aX() { + return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); } - protected String aS() { - return "mob.slime"; + protected String aY() { + return "mob.slime." + (this.getSize() > 1 ? "big" : "small"); } protected int getLootId() { @@ -200,22 +200,36 @@ public class EntitySlime extends EntityLiving implements IMonster { public boolean canSpawn() { Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)); - return this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1 ? false : ((this.getSize() == 1 || this.world.difficulty > 0) && this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D ? super.canSpawn() : false); + if (this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1) { + return false; + } else { + if (this.getSize() == 1 || this.world.difficulty > 0) { + if (this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ)) == BiomeBase.SWAMPLAND && this.locY > 50.0D && this.locY < 70.0D && this.world.getLightLevel(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) <= this.random.nextInt(8)) { + return super.canSpawn(); + } + + if (this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D) { + return super.canSpawn(); + } + } + + return false; + } } - protected float aP() { + protected float aV() { return 0.4F * (float) this.getSize(); } - public int bf() { + public int bm() { return 0; } - protected boolean r() { - return this.getSize() > 1; + protected boolean q() { + return this.getSize() > 0; } - protected boolean p() { + protected boolean o() { return this.getSize() > 2; } } diff --git a/src/main/java/net/minecraft/server/EntitySnowman.java b/src/main/java/net/minecraft/server/EntitySnowman.java index 9348b6a6..b6fe1c4b 100644 --- a/src/main/java/net/minecraft/server/EntitySnowman.java +++ b/src/main/java/net/minecraft/server/EntitySnowman.java @@ -5,21 +5,21 @@ import org.bukkit.event.block.EntityBlockFormEvent; import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit end -public class EntitySnowman extends EntityGolem { +public class EntitySnowman extends EntityGolem implements IRangedEntity { public EntitySnowman(World world) { super(world); this.texture = "/mob/snowman.png"; this.a(0.4F, 1.8F); this.getNavigation().a(true); - this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 0.25F, 2, 20)); + this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 0.25F, 20, 10.0F)); this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, 0.2F)); this.goalSelector.a(3, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F)); this.goalSelector.a(4, new PathfinderGoalRandomLookaround(this)); - this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, true)); + this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, true, false, IMonster.a)); } - public boolean aV() { + public boolean bb() { return true; } @@ -27,8 +27,8 @@ public class EntitySnowman extends EntityGolem { return 4; } - public void d() { - super.d(); + public void c() { + super.c(); if (this.G()) { // CraftBukkit start EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1); @@ -93,4 +93,16 @@ public class EntitySnowman extends EntityGolem { org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); // CraftBukkit end } + + public void d(EntityLiving entityliving) { + EntitySnowball entitysnowball = new EntitySnowball(this.world, this); + double d0 = entityliving.locX - this.locX; + double d1 = entityliving.locY + (double) entityliving.getHeadHeight() - 1.100000023841858D - entitysnowball.locY; + double d2 = entityliving.locZ - this.locZ; + float f = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F; + + entitysnowball.shoot(d0, d1 + (double) f, d2, 1.6F, 12.0F); + this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.aA().nextFloat() * 0.4F + 0.8F)); + this.world.addEntity(entitysnowball); + } } diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index fa933849..6f2e1510 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -8,7 +8,7 @@ public class EntitySpider extends EntityMonster { super(world); this.texture = "/mob/spider.png"; this.a(1.4F, 0.9F); - this.bw = 0.8F; + this.bI = 0.8F; } protected void a() { @@ -16,10 +16,10 @@ public class EntitySpider extends EntityMonster { this.datawatcher.a(16, new Byte((byte) 0)); } - public void h_() { - super.h_(); + public void j_() { + super.j_(); if (!this.world.isStatic) { - this.e(this.positionChanged); + this.f(this.positionChanged); } } @@ -31,10 +31,6 @@ public class EntitySpider extends EntityMonster { return (double) this.length * 0.75D - 0.5D; } - protected boolean e_() { - return false; - } - protected Entity findTarget() { float f = this.c(1.0F); @@ -47,16 +43,20 @@ public class EntitySpider extends EntityMonster { } } - protected String aQ() { - return "mob.spider"; + protected String aW() { + return "mob.spider.say"; + } + + protected String aX() { + return "mob.spider.say"; } - protected String aR() { - return "mob.spider"; + protected String aY() { + return "mob.spider.death"; } - protected String aS() { - return "mob.spiderdeath"; + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.spider.step", 0.15F, 1.0F); } protected void a(Entity entity, float f) { @@ -119,11 +119,11 @@ public class EntitySpider extends EntityMonster { // CraftBukkit end } - public boolean f_() { - return this.p(); + public boolean g_() { + return this.o(); } - public void aj() {} + public void am() {} public EnumMonsterType getMonsterType() { return EnumMonsterType.ARTHROPOD; @@ -133,11 +133,11 @@ public class EntitySpider extends EntityMonster { return mobeffect.getEffectId() == MobEffectList.POISON.id ? false : super.e(mobeffect); } - public boolean p() { + public boolean o() { return (this.datawatcher.getByte(16) & 1) != 0; } - public void e(boolean flag) { + public void f(boolean flag) { byte b0 = this.datawatcher.getByte(16); if (flag) { @@ -148,4 +148,15 @@ public class EntitySpider extends EntityMonster { this.datawatcher.watch(16, Byte.valueOf(b0)); } + + public void bD() { + if (this.world.random.nextInt(100) == 0) { + EntitySkeleton entityskeleton = new EntitySkeleton(this.world); + + entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); + entityskeleton.bD(); + this.world.addEntity(entityskeleton); + entityskeleton.mount(this); + } + } } diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java index 030263ab..e1cb75eb 100644 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ b/src/main/java/net/minecraft/server/EntitySquid.java @@ -11,38 +11,38 @@ public class EntitySquid extends EntityWaterAnimal { public float h = 0.0F; public float i = 0.0F; public float j = 0.0F; - public float by = 0.0F; - private float bz = 0.0F; - private float bA = 0.0F; - private float bB = 0.0F; - private float bC = 0.0F; - private float bD = 0.0F; - private float bE = 0.0F; + public float bK = 0.0F; + private float bL = 0.0F; + private float bM = 0.0F; + private float bN = 0.0F; + private float bO = 0.0F; + private float bP = 0.0F; + private float bQ = 0.0F; public EntitySquid(World world) { super(world); this.texture = "/mob/squid.png"; this.a(0.95F, 0.95F); - this.bA = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; + this.bM = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } public int getMaxHealth() { return 10; } - protected String aQ() { + protected String aW() { return null; } - protected String aR() { + protected String aX() { return null; } - protected String aS() { + protected String aY() { return null; } - protected float aP() { + protected float aV() { return 0.4F; } @@ -64,20 +64,20 @@ public class EntitySquid extends EntityWaterAnimal { } public boolean H() { - return this.world.a(this.boundingBox.grow(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this); + return this.world.a(this.boundingBox.grow(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, (Entity) this); } - public void d() { - super.d(); + public void c() { + super.c(); this.e = this.d; this.g = this.f; this.i = this.h; - this.by = this.j; - this.h += this.bA; + this.bK = this.j; + this.h += this.bM; if (this.h > 6.2831855F) { this.h -= 6.2831855F; if (this.random.nextInt(10) == 0) { - this.bA = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; + this.bM = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; } } @@ -88,28 +88,28 @@ public class EntitySquid extends EntityWaterAnimal { f = this.h / 3.1415927F; this.j = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F; if ((double) f > 0.75D) { - this.bz = 1.0F; - this.bB = 1.0F; + this.bL = 1.0F; + this.bN = 1.0F; } else { - this.bB *= 0.8F; + this.bN *= 0.8F; } } else { this.j = 0.0F; - this.bz *= 0.9F; - this.bB *= 0.99F; + this.bL *= 0.9F; + this.bN *= 0.99F; } if (!this.world.isStatic) { - this.motX = (double) (this.bC * this.bz); - this.motY = (double) (this.bD * this.bz); - this.motZ = (double) (this.bE * this.bz); + this.motX = (double) (this.bO * this.bL); + this.motY = (double) (this.bN * this.bL); + this.motZ = (double) (this.bQ * this.bL); } f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); // CraftBukkit - Math -> TrigMath - this.aq += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aq) * 0.1F; - this.yaw = this.aq; - this.f += 3.1415927F * this.bB * 1.5F; + this.aw += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aw) * 0.1F; + this.yaw = this.aw; + this.f += 3.1415927F * this.bN * 1.5F; // CraftBukkit - Math -> TrigMath this.d += (-((float) TrigMath.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.d) * 0.1F; } else { @@ -129,19 +129,19 @@ public class EntitySquid extends EntityWaterAnimal { this.move(this.motX, this.motY, this.motZ); } - protected void be() { - ++this.bq; - if (this.bq > 100) { - this.bC = this.bD = this.bE = 0.0F; - } else if (this.random.nextInt(50) == 0 || !this.ac || this.bC == 0.0F && this.bD == 0.0F && this.bE == 0.0F) { + protected void bk() { + ++this.bC; + if (this.bC > 100) { + this.bO = this.bP = this.bQ = 0.0F; + } else if (this.random.nextInt(50) == 0 || !this.ad || this.bO == 0.0F && this.bP == 0.0F && this.bQ == 0.0F) { float f = this.random.nextFloat() * 3.1415927F * 2.0F; - this.bC = MathHelper.cos(f) * 0.2F; - this.bD = -0.1F + this.random.nextFloat() * 0.2F; - this.bE = MathHelper.sin(f) * 0.2F; + this.bO = MathHelper.cos(f) * 0.2F; + this.bP = -0.1F + this.random.nextFloat() * 0.2F; + this.bQ = MathHelper.sin(f) * 0.2F; } - this.bb(); + this.bh(); } public boolean canSpawn() { diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java index a45f4c5e..8db94ffe 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -32,7 +32,7 @@ public class EntityTNTPrimed extends Entity { protected void a() {} - protected boolean e_() { + protected boolean f_() { return false; } @@ -40,7 +40,7 @@ public class EntityTNTPrimed extends Entity { return !this.dead; } - public void h_() { + public void j_() { this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; @@ -63,7 +63,7 @@ public class EntityTNTPrimed extends Entity { this.die(); // CraftBukkit end } else { - this.world.a("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); + this.world.addParticle("smoke", this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); } } @@ -78,7 +78,7 @@ public class EntityTNTPrimed extends Entity { 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()); + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true); } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java index 97060359..eb8b59f3 100644 --- a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java +++ b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java @@ -14,15 +14,15 @@ public class EntityThrownExpBottle extends EntityProjectile { super(world, d0, d1, d2); } - protected float h() { + protected float g() { return 0.07F; } - protected float d() { + protected float c() { return 0.7F; } - protected float g() { + protected float d() { return -20.0F; } diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java index 9b6a2868..999a0b37 100644 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ b/src/main/java/net/minecraft/server/EntityTracker.java @@ -59,6 +59,10 @@ public class EntityTracker { this.addEntity(entity, 80, 3, true); } else if (entity instanceof EntitySquid) { this.addEntity(entity, 64, 3, true); + } else if (entity instanceof EntityWither) { + this.addEntity(entity, 80, 3, false); + } else if (entity instanceof EntityBat) { + this.addEntity(entity, 80, 3, false); } else if (entity instanceof IAnimal) { this.addEntity(entity, 80, 3, true); } else if (entity instanceof EntityEnderDragon) { @@ -73,6 +77,8 @@ public class EntityTracker { this.addEntity(entity, 160, 20, true); } else if (entity instanceof EntityEnderCrystal) { this.addEntity(entity, 256, Integer.MAX_VALUE, false); + } else if (entity instanceof EntityItemFrame) { + this.addEntity(entity, 160, 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 d735e8e0..d3e4978b 100644 --- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java +++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java @@ -45,7 +45,7 @@ public class EntityTrackerEntry { this.zLoc = MathHelper.floor(entity.locZ * 32.0D); this.yRot = MathHelper.d(entity.yaw * 256.0F / 360.0F); this.xRot = MathHelper.d(entity.pitch * 256.0F / 360.0F); - this.i = MathHelper.d(entity.am() * 256.0F / 360.0F); + this.i = MathHelper.d(entity.ap() * 256.0F / 360.0F); } public boolean equals(Object object) { @@ -72,19 +72,50 @@ public class EntityTrackerEntry { this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); } - if (this.tracker.vehicle == null) { - ++this.u; - if (this.m++ % this.c == 0 || this.tracker.al) { - int i = this.tracker.am.a(this.tracker.locX); - int j = MathHelper.floor(this.tracker.locY * 32.0D); - int k = this.tracker.am.a(this.tracker.locZ); + if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) { + EntityItemFrame i4 = (EntityItemFrame) this.tracker; + ItemStack i5 = i4.i(); + + if (i5 != null && i5.getItem() instanceof ItemWorldMap) { + WorldMap i7 = Item.MAP.getSavedMap(i5, this.tracker.world); + Iterator i8 = list.iterator(); + + while (i8.hasNext()) { + EntityHuman j0 = (EntityHuman) i8.next(); + EntityPlayer j1 = (EntityPlayer) j0; + + i7.a(j1, i5); + if (j1.netServerHandler.lowPriorityCount() <= 5) { + Packet j2 = Item.MAP.c(i5, this.tracker.world, j1); + + if (j2 != null) { + j1.netServerHandler.sendPacket(j2); + } + } + } + } + + DataWatcher i9 = this.tracker.getDataWatcher(); + + if (i9.a()) { + this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, i9, false)); + } + } else if (this.m++ % this.c == 0 || this.tracker.am) { + int i; + int j; + + if (this.tracker.vehicle == null) { + ++this.u; + i = this.tracker.ar.a(this.tracker.locX); + j = MathHelper.floor(this.tracker.locY * 32.0D); + int k = this.tracker.ar.a(this.tracker.locZ); int l = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F); int i1 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F); int j1 = i - this.xLoc; int k1 = j - this.yLoc; int l1 = k - this.zLoc; Object object = null; - boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4; + boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0; boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4; // CraftBukkit start - code moved from below @@ -137,17 +168,10 @@ public class EntityTrackerEntry { this.broadcast((Packet) object); } - DataWatcher datawatcher = this.tracker.getDataWatcher(); - - if (datawatcher.a()) { - this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher)); - } - - int i2 = MathHelper.d(this.tracker.am() * 256.0F / 360.0F); + DataWatcher datawatcher1 = this.tracker.getDataWatcher(); - if (Math.abs(i2 - this.i) >= 4) { - this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i2)); - this.i = i2; + if (datawatcher1.a()) { + this.broadcastIncludingSelf(new Packet40EntityMetadata(this.tracker.id, datawatcher1, false)); } /* CraftBukkit start - code moved up @@ -162,9 +186,29 @@ public class EntityTrackerEntry { this.xRot = i1; } // CraftBukkit end */ + } else { + i = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F); + j = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F); + boolean flag2 = Math.abs(i - this.yRot) >= 4 || Math.abs(j - this.xRot) >= 4; + + if (flag2) { + this.broadcast(new Packet32EntityLook(this.tracker.id, (byte) i, (byte) j)); + this.yRot = i; + this.xRot = j; + } + + this.xLoc = this.tracker.ar.a(this.tracker.locX); + this.yLoc = MathHelper.floor(this.tracker.locY * 32.0D); + this.zLoc = this.tracker.ar.a(this.tracker.locZ); } - this.tracker.al = false; + i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F); + if (Math.abs(i - this.i) >= 4) { + this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i)); + this.i = i; + } + + this.tracker.am = false; } if (this.tracker.velocityChanged) { @@ -189,6 +233,7 @@ public class EntityTrackerEntry { this.broadcastIncludingSelf((Packet) (new Packet28EntityVelocity(this.tracker))); } // CraftBukkit end + this.tracker.velocityChanged = false; } } @@ -216,12 +261,13 @@ public class EntityTrackerEntry { while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - entityplayer.g.add(Integer.valueOf(this.tracker.id)); + entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id)); } } public void a(EntityPlayer entityplayer) { if (this.trackedPlayers.contains(entityplayer)) { + entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id)); this.trackedPlayers.remove(entityplayer); } } @@ -241,12 +287,17 @@ public class EntityTrackerEntry { } } - entityplayer.g.remove(Integer.valueOf(this.tracker.id)); // Should be called destroyQueue + entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.id)); // CraftBukkit end + this.trackedPlayers.add(entityplayer); Packet packet = this.b(); entityplayer.netServerHandler.sendPacket(packet); + if (this.tracker instanceof EntityItemFrame) { + entityplayer.netServerHandler.sendPacket(new Packet40EntityMetadata(this.tracker.id, this.tracker.getDataWatcher(), true)); + } + this.j = this.tracker.motX; this.k = this.tracker.motY; this.l = this.tracker.motZ; @@ -258,11 +309,13 @@ public class EntityTrackerEntry { entityplayer.netServerHandler.sendPacket(new Packet39AttachEntity(this.tracker, this.tracker.vehicle)); } - ItemStack[] aitemstack = this.tracker.getEquipment(); + if (this.tracker instanceof EntityLiving) { + for (int i = 0; i < 5; ++i) { + ItemStack itemstack = ((EntityLiving) this.tracker).getEquipment(i); - if (aitemstack != null) { - for (int i = 0; i < aitemstack.length; ++i) { - entityplayer.netServerHandler.sendPacket(new Packet5EntityEquipment(this.tracker.id, i, aitemstack[i])); + if (itemstack != null) { + entityplayer.netServerHandler.sendPacket(new Packet5EntityEquipment(this.tracker.id, i, itemstack)); + } } } @@ -275,7 +328,7 @@ public class EntityTrackerEntry { } // CraftBukkit start - Fix for nonsensical head yaw - this.i = MathHelper.d(this.tracker.am() * 256.0F / 360.0F); // tracker.am() should be getHeadRotation + this.i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F); // tracker.am() should be getHeadRotation this.broadcast(new Packet35EntityHeadRotation(this.tracker.id, (byte) i)); // CraftBukkit end @@ -292,13 +345,13 @@ public class EntityTrackerEntry { } } else if (this.trackedPlayers.contains(entityplayer)) { this.trackedPlayers.remove(entityplayer); - entityplayer.g.add(Integer.valueOf(this.tracker.id)); + entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id)); } } } private boolean d(EntityPlayer entityplayer) { - return entityplayer.q().getPlayerManager().a(entityplayer, this.tracker.ah, this.tracker.aj); + return entityplayer.p().getPlayerManager().a(entityplayer, this.tracker.ai, this.tracker.ak); } public void scanPlayers(List list) { @@ -321,12 +374,12 @@ public class EntityTrackerEntry { if (this.tracker instanceof EntityItem) { EntityItem entityitem = (EntityItem) this.tracker; - Packet21PickupSpawn packet21pickupspawn = new Packet21PickupSpawn(entityitem); + Packet21PickupSpawn entityminecart0 = new Packet21PickupSpawn(entityitem); - entityitem.locX = (double) packet21pickupspawn.b / 32.0D; - entityitem.locY = (double) packet21pickupspawn.c / 32.0D; - entityitem.locZ = (double) packet21pickupspawn.d / 32.0D; - return packet21pickupspawn; + entityitem.locX = (double) entityminecart0.b / 32.0D; + entityitem.locY = (double) entityminecart0.c / 32.0D; + entityitem.locZ = (double) entityminecart0.d / 32.0D; + return entityminecart0; } else if (this.tracker instanceof EntityPlayer) { return new Packet20NamedEntitySpawn((EntityHuman) this.tracker); } else { @@ -370,28 +423,22 @@ public class EntityTrackerEntry { } else { Packet23VehicleSpawn packet23vehiclespawn; - if (this.tracker instanceof EntitySmallFireball) { - EntitySmallFireball entitysmallfireball = (EntitySmallFireball) this.tracker; + if (this.tracker instanceof EntityFireball) { + EntityFireball entityfireball = (EntityFireball) 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); - } + byte b0 = 63; - 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; + if (this.tracker instanceof EntitySmallFireball) { + b0 = 64; + } else if (this.tracker instanceof EntityWitherSkull) { + b0 = 66; + } - packet23vehiclespawn = null; if (entityfireball.shooter != null) { - packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, ((EntityFireball) this.tracker).shooter.id); + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, b0, ((EntityFireball) this.tracker).shooter.id); } else { - packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 63, 0); + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, b0, 0); } packet23vehiclespawn.e = (int) (entityfireball.dirX * 8000.0D); @@ -410,6 +457,14 @@ public class EntityTrackerEntry { return new Packet23VehicleSpawn(this.tracker, 70, entityfallingblock.id | entityfallingblock.data << 16); } else if (this.tracker instanceof EntityPainting) { return new Packet25EntityPainting((EntityPainting) this.tracker); + } else if (this.tracker instanceof EntityItemFrame) { + EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; + + packet23vehiclespawn = new Packet23VehicleSpawn(this.tracker, 71, entityitemframe.direction); + packet23vehiclespawn.b = MathHelper.d((float) (entityitemframe.x * 32)); + packet23vehiclespawn.c = MathHelper.d((float) (entityitemframe.y * 32)); + packet23vehiclespawn.d = MathHelper.d((float) (entityitemframe.z * 32)); + return packet23vehiclespawn; } else if (this.tracker instanceof EntityExperienceOrb) { return new Packet26AddExpOrb((EntityExperienceOrb) this.tracker); } else { @@ -417,7 +472,7 @@ public class EntityTrackerEntry { } } } else { - this.i = MathHelper.d(this.tracker.am() * 256.0F / 360.0F); + this.i = MathHelper.d(this.tracker.ap() * 256.0F / 360.0F); return new Packet24MobSpawn((EntityLiving) this.tracker); } } @@ -426,7 +481,7 @@ public class EntityTrackerEntry { public void clear(EntityPlayer entityplayer) { if (this.trackedPlayers.contains(entityplayer)) { this.trackedPlayers.remove(entityplayer); - entityplayer.g.add(Integer.valueOf(this.tracker.id)); + entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id)); } } } diff --git a/src/main/java/net/minecraft/server/EntityWitch.java b/src/main/java/net/minecraft/server/EntityWitch.java new file mode 100644 index 00000000..9026a63b --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityWitch.java @@ -0,0 +1,173 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.List; + +public class EntityWitch extends EntityMonster implements IRangedEntity { + + private static final int[] d = new int[] { Item.GLOWSTONE_DUST.id, Item.SUGAR.id, Item.REDSTONE.id, Item.SPIDER_EYE.id, Item.GLASS_BOTTLE.id, Item.SULPHUR.id, Item.STICK.id, Item.STICK.id}; + private int e = 0; + + public EntityWitch(World world) { + super(world); + this.texture = "/mob/villager/witch.png"; + this.bI = 0.25F; + this.goalSelector.a(1, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalArrowAttack(this, this.bI, 60, 10.0F)); + this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, this.bI)); + this.goalSelector.a(3, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(3, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, 16.0F, 0, true)); + } + + protected void a() { + super.a(); + this.getDataWatcher().a(21, Byte.valueOf((byte) 0)); + } + + protected String aW() { + return "mob.witch.idle"; + } + + protected String aX() { + return "mob.witch.hurt"; + } + + protected String aY() { + return "mob.witch.death"; + } + + public void f(boolean flag) { + this.getDataWatcher().watch(21, Byte.valueOf((byte) (flag ? 1 : 0))); + } + + public boolean m() { + return this.getDataWatcher().getByte(21) == 1; + } + + public int getMaxHealth() { + return 26; + } + + public boolean bb() { + return true; + } + + public void c() { + if (!this.world.isStatic) { + if (this.m()) { + if (this.e-- <= 0) { + this.f(false); + ItemStack itemstack = this.bA(); + + this.setEquipment(0, (ItemStack) null); + if (itemstack != null && itemstack.id == Item.POTION.id) { + List list = Item.POTION.l(itemstack); + + if (list != null) { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + MobEffect mobeffect = (MobEffect) iterator.next(); + + this.addEffect(new MobEffect(mobeffect)); + } + } + } + } + } else { + short short1 = -1; + + if (this.random.nextFloat() < 0.15F && this.isBurning() && !this.hasEffect(MobEffectList.FIRE_RESISTANCE)) { + short1 = 16307; + } else if (this.random.nextFloat() < 0.05F && this.health < this.getMaxHealth()) { + short1 = 16341; + } else if (this.random.nextFloat() < 0.25F && this.aF() != null && !this.hasEffect(MobEffectList.FASTER_MOVEMENT) && this.aF().e(this) > 121.0D) { + short1 = 16274; + } else if (this.random.nextFloat() < 0.25F && this.aF() != null && !this.hasEffect(MobEffectList.FASTER_MOVEMENT) && this.aF().e(this) > 121.0D) { + short1 = 16274; + } + + if (short1 > -1) { + this.setEquipment(0, new ItemStack(Item.POTION, 1, short1)); + this.e = this.bA().m(); + this.f(true); + } + } + + if (this.random.nextFloat() < 7.5E-4F) { + this.world.broadcastEntityEffect(this, (byte) 15); + } + } + + super.c(); + } + + protected int c(DamageSource damagesource, int i) { + i = super.c(damagesource, i); + if (damagesource.getEntity() == this) { + i = 0; + } + + if (damagesource.o()) { + i = (int) ((double) i * 0.15D); + } + + return i; + } + + public float by() { + float f = super.by(); + + if (this.m()) { + f *= 0.75F; + } + + return f; + } + + protected void dropDeathLoot(boolean flag, int i) { + // CraftBukkit start + java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + + int j = this.random.nextInt(3) + 1; + + for (int k = 0; k < j; ++k) { + int l = this.random.nextInt(3); + int i1 = d[this.random.nextInt(d.length)]; + + if (i > 0) { + l += this.random.nextInt(i + 1); + } + + loot.add(new org.bukkit.inventory.ItemStack(i1, l)); + } + + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end + } + + public void d(EntityLiving entityliving) { + if (!this.m()) { + EntityPotion entitypotion = new EntityPotion(this.world, this, 32732); + + entitypotion.pitch -= -20.0F; + double d0 = entityliving.locX + entityliving.motX - this.locX; + double d1 = entityliving.locY + (double) entityliving.getHeadHeight() - 1.100000023841858D - this.locY; + double d2 = entityliving.locZ + entityliving.motZ - this.locZ; + float f = MathHelper.sqrt(d0 * d0 + d2 * d2); + + if (f >= 8.0F && !entityliving.hasEffect(MobEffectList.SLOWER_MOVEMENT)) { + entitypotion.setPotionValue(32698); + } else if (entityliving.getHealth() >= 8 && !entityliving.hasEffect(MobEffectList.POISON)) { + entitypotion.setPotionValue(32660); + } else if (f <= 3.0F && !entityliving.hasEffect(MobEffectList.WEAKNESS) && this.random.nextFloat() < 0.25F) { + entitypotion.setPotionValue(32696); + } + + entitypotion.shoot(d0, d1 + (double) (f * 0.2F), d2, 0.75F, 8.0F); + this.world.addEntity(entitypotion); + } + } +} diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java new file mode 100644 index 00000000..b4ce3a80 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityWither.java @@ -0,0 +1,465 @@ +package net.minecraft.server; + +import java.util.List; + +// CraftBukkit start +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + +public class EntityWither extends EntityMonster implements IRangedEntity { + + private float[] d = new float[2]; + private float[] e = new float[2]; + private float[] f = new float[2]; + private float[] g = new float[2]; + private int[] h = new int[2]; + private int[] i = new int[2]; + private int j; + private static final IEntitySelector bK = new EntitySelectorNotUndead(); + + public EntityWither(World world) { + super(world); + this.setHealth(this.getMaxHealth()); + this.texture = "/mob/wither.png"; + this.a(0.9F, 4.0F); + this.fireProof = true; + this.bI = 0.6F; + this.getNavigation().e(true); + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(2, new PathfinderGoalArrowAttack(this, this.bI, 40, 20.0F)); + this.goalSelector.a(5, new PathfinderGoalRandomStroll(this, this.bI)); + this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); + this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 30.0F, 0, false, false, bK)); + this.bc = 50; + } + + protected void a() { + super.a(); + this.datawatcher.a(16, new Integer(100)); + this.datawatcher.a(17, new Integer(0)); + this.datawatcher.a(18, new Integer(0)); + this.datawatcher.a(19, new Integer(0)); + this.datawatcher.a(20, new Integer(0)); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.setInt("Invul", this.n()); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.s(nbttagcompound.getInt("Invul")); + this.datawatcher.watch(16, Integer.valueOf(this.health)); + } + + protected String aW() { + return "mob.wither.idle"; + } + + protected String aX() { + return "mob.wither.hurt"; + } + + protected String aY() { + return "mob.wither.death"; + } + + public void c() { + if (!this.world.isStatic) { + this.datawatcher.watch(16, Integer.valueOf(this.health)); + } + + this.motY *= 0.6000000238418579D; + double d0; + double d1; + double d2; + + if (!this.world.isStatic && this.t(0) > 0) { + Entity entity = this.world.getEntity(this.t(0)); + + if (entity != null) { + if (this.locY < entity.locY || !this.o() && this.locY < entity.locY + 5.0D) { + if (this.motY < 0.0D) { + this.motY = 0.0D; + } + + this.motY += (0.5D - this.motY) * 0.6000000238418579D; + } + + double d3 = entity.locX - this.locX; + + d0 = entity.locZ - this.locZ; + d1 = d3 * d3 + d0 * d0; + if (d1 > 9.0D) { + d2 = (double) MathHelper.sqrt(d1); + this.motX += (d3 / d2 * 0.5D - this.motX) * 0.6000000238418579D; + this.motZ += (d0 / d2 * 0.5D - this.motZ) * 0.6000000238418579D; + } + } + } + + if (this.motX * this.motX + this.motZ * this.motZ > 0.05000000074505806D) { + this.yaw = (float) Math.atan2(this.motZ, this.motX) * 57.295776F - 90.0F; + } + + super.c(); + + int i; + + for (i = 0; i < 2; ++i) { + this.g[i] = this.e[i]; + this.f[i] = this.d[i]; + } + + int j; + + for (i = 0; i < 2; ++i) { + j = this.t(i + 1); + Entity entity1 = null; + + if (j > 0) { + entity1 = this.world.getEntity(j); + } + + if (entity1 != null) { + d0 = this.u(i + 1); + d1 = this.v(i + 1); + d2 = this.w(i + 1); + double d4 = entity1.locX - d0; + double d5 = entity1.locY + (double) entity1.getHeadHeight() - d1; + double d6 = entity1.locZ - d2; + double d7 = (double) MathHelper.sqrt(d4 * d4 + d6 * d6); + float f = (float) (Math.atan2(d6, d4) * 180.0D / 3.1415927410125732D) - 90.0F; + float f1 = (float) (-(Math.atan2(d5, d7) * 180.0D / 3.1415927410125732D)); + + this.d[i] = this.b(this.d[i], f1, 40.0F); + this.e[i] = this.b(this.e[i], f, 10.0F); + } else { + this.e[i] = this.b(this.e[i], this.aw, 10.0F); + } + } + + boolean flag = this.o(); + + for (j = 0; j < 3; ++j) { + double d8 = this.u(j); + double d9 = this.v(j); + double d10 = this.w(j); + + this.world.addParticle("smoke", d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D); + if (flag && this.world.random.nextInt(4) == 0) { + this.world.addParticle("mobSpell", d8 + this.random.nextGaussian() * 0.30000001192092896D, d9 + this.random.nextGaussian() * 0.30000001192092896D, d10 + this.random.nextGaussian() * 0.30000001192092896D, 0.699999988079071D, 0.699999988079071D, 0.5D); + } + } + + if (this.n() > 0) { + for (j = 0; j < 3; ++j) { + this.world.addParticle("mobSpell", this.locX + this.random.nextGaussian() * 1.0D, this.locY + (double) (this.random.nextFloat() * 3.3F), this.locZ + this.random.nextGaussian() * 1.0D, 0.699999988079071D, 0.699999988079071D, 0.8999999761581421D); + } + } + } + + protected void bi() { + int i; + + if (this.n() > 0) { + i = this.n() - 1; + if (i <= 0) { + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, event.getRadius(), event.getFire(), this.world.getGameRules().getBoolean("mobGriefing")); + } + // CraftBukkit end + + this.world.e(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + } + + this.s(i); + if (this.ticksLived % 10 == 0) { + this.heal(10, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit + } + } else { + super.bi(); + + int j; + + for (i = 1; i < 3; ++i) { + if (this.ticksLived >= this.h[i - 1]) { + this.h[i - 1] = this.ticksLived + 10 + this.random.nextInt(10); + if (this.world.difficulty >= 2) { + int i1001 = i - 1; + int i1003 = this.i[i - 1]; + + this.i[i1001] = this.i[i - 1] + 1; + if (i1003 > 15) { + float f = 10.0F; + float f1 = 5.0F; + double d0 = MathHelper.a(this.random, this.locX - (double) f, this.locX + (double) f); + double d1 = MathHelper.a(this.random, this.locY - (double) f1, this.locY + (double) f1); + double d2 = MathHelper.a(this.random, this.locZ - (double) f, this.locZ + (double) f); + + this.a(i + 1, d0, d1, d2, true); + this.i[i - 1] = 0; + } + } + + j = this.t(i); + if (j > 0) { + Entity entity = this.world.getEntity(j); + + if (entity != null && entity.isAlive() && this.e(entity) <= 900.0D && this.m(entity)) { + this.a(i + 1, (EntityLiving) entity); + this.h[i - 1] = this.ticksLived + 40 + this.random.nextInt(20); + this.i[i - 1] = 0; + } else { + this.c(i, 0); + } + } else { + List list = this.world.a(EntityLiving.class, this.boundingBox.grow(20.0D, 8.0D, 20.0D), bK); + + for (int i1 = 0; i1 < 10 && !list.isEmpty(); ++i1) { + EntityLiving entityliving = (EntityLiving) list.get(this.random.nextInt(list.size())); + + if (entityliving != this && entityliving.isAlive() && this.m(entityliving)) { + if (entityliving instanceof EntityHuman) { + if (!((EntityHuman) entityliving).abilities.isInvulnerable) { + this.c(i, entityliving.id); + } + } else { + this.c(i, entityliving.id); + } + break; + } + + list.remove(entityliving); + } + } + } + } + + if (this.aF() != null) { + this.c(0, this.aF().id); + } else { + this.c(0, 0); + } + + if (this.j > 0) { + --this.j; + if (this.j == 0 && this.world.getGameRules().getBoolean("mobGriefing")) { + i = MathHelper.floor(this.locY); + j = MathHelper.floor(this.locX); + int j1 = MathHelper.floor(this.locZ); + boolean flag = false; + + for (int k1 = -1; k1 <= 1; ++k1) { + for (int l1 = -1; l1 <= 1; ++l1) { + for (int i2 = 0; i2 <= 3; ++i2) { + int j2 = j + k1; + int k2 = i + i2; + int l2 = j1 + l1; + int i3 = this.world.getTypeId(j2, k2, l2); + + if (i3 > 0 && i3 != Block.BEDROCK.id) { + int j3 = this.world.getData(j2, k2, l2); + + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, j2, k2, l2, 0).isCancelled()) { + continue; + } + // CraftBukkit end + + this.world.triggerEffect(2001, j2, k2, l2, i3 + (j3 << 12)); + Block.byId[i3].c(this.world, j2, k2, l2, j3, 0); + this.world.setTypeId(j2, k2, l2, 0); + flag = true; + } + } + } + } + + if (flag) { + this.world.a((EntityHuman) null, 1012, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + } + } + } + + if (this.ticksLived % 20 == 0) { + this.heal(1); + } + } + } + + public void m() { + this.s(220); + this.setHealth(this.getMaxHealth() / 3); + } + + public void am() {} + + public int aU() { + return 4; + } + + private double u(int i) { + if (i <= 0) { + return this.locX; + } else { + float f = (this.aw + (float) (180 * (i - 1))) / 180.0F * 3.1415927F; + float f1 = MathHelper.cos(f); + + return this.locX + (double) f1 * 1.3D; + } + } + + private double v(int i) { + return i <= 0 ? this.locY + 3.0D : this.locY + 2.2D; + } + + private double w(int i) { + if (i <= 0) { + return this.locZ; + } else { + float f = (this.aw + (float) (180 * (i - 1))) / 180.0F * 3.1415927F; + float f1 = MathHelper.sin(f); + + return this.locZ + (double) f1 * 1.3D; + } + } + + private float b(float f, float f1, float f2) { + float f3 = MathHelper.g(f1 - f); + + if (f3 > f2) { + f3 = f2; + } + + if (f3 < -f2) { + f3 = -f2; + } + + return f + f3; + } + + private void a(int i, EntityLiving entityliving) { + this.a(i, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() * 0.5D, entityliving.locZ, i == 0 && this.random.nextFloat() < 0.001F); + } + + private void a(int i, double d0, double d1, double d2, boolean flag) { + this.world.a((EntityHuman) null, 1014, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + double d3 = this.u(i); + double d4 = this.v(i); + double d5 = this.w(i); + double d6 = d0 - d3; + double d7 = d1 - d4; + double d8 = d2 - d5; + EntityWitherSkull entitywitherskull = new EntityWitherSkull(this.world, this, d6, d7, d8); + + if (flag) { + entitywitherskull.e(true); + } + + entitywitherskull.locY = d4; + entitywitherskull.locX = d3; + entitywitherskull.locZ = d5; + this.world.addEntity(entitywitherskull); + } + + public void d(EntityLiving entityliving) { + this.a(0, entityliving); + } + + public boolean damageEntity(DamageSource damagesource, int i) { + if (damagesource == DamageSource.DROWN) { + return false; + } else if (this.n() > 0) { + return false; + } else { + Entity entity; + + if (this.o()) { + entity = damagesource.f(); + if (entity instanceof EntityArrow) { + return false; + } + } + + entity = damagesource.getEntity(); + if (entity != null && !(entity instanceof EntityHuman) && entity instanceof EntityLiving && ((EntityLiving) entity).getMonsterType() == this.getMonsterType()) { + return false; + } else { + if (this.j <= 0) { + this.j = 20; + } + + for (int j = 0; j < this.i.length; ++j) { + this.i[j] += 3; + } + + return super.damageEntity(damagesource, i); + } + } + } + + protected void dropDeathLoot(boolean flag, int i) { + // CraftBukkit start + java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); + loot.add(new org.bukkit.inventory.ItemStack(Item.NETHER_STAR.id, 1)); + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end + } + + protected void bh() { + this.bC = 0; + } + + public boolean L() { + return !this.dead; + } + + public int b() { + return this.datawatcher.getInt(16); + } + + protected void a(float f) {} + + public void addEffect(MobEffect mobeffect) {} + + protected boolean bb() { + return true; + } + + public int getMaxHealth() { + return 300; + } + + public int n() { + return this.datawatcher.getInt(20); + } + + public void s(int i) { + this.datawatcher.watch(20, Integer.valueOf(i)); + } + + public int t(int i) { + return this.datawatcher.getInt(17 + i); + } + + public void c(int i, int j) { + this.datawatcher.watch(17 + i, Integer.valueOf(j)); + } + + public boolean o() { + return this.b() <= this.getMaxHealth() / 2; + } + + public EnumMonsterType getMonsterType() { + return EnumMonsterType.UNDEAD; + } +} diff --git a/src/main/java/net/minecraft/server/EntityWitherSkull.java b/src/main/java/net/minecraft/server/EntityWitherSkull.java new file mode 100644 index 00000000..645210e4 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityWitherSkull.java @@ -0,0 +1,98 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +// CraftBukkit end + +public class EntityWitherSkull extends EntityFireball { + + public EntityWitherSkull(World world) { + super(world); + this.a(0.3125F, 0.3125F); + } + + public EntityWitherSkull(World world, EntityLiving entityliving, double d0, double d1, double d2) { + super(world, entityliving, d0, d1, d2); + this.a(0.3125F, 0.3125F); + } + + protected float c() { + return this.d() ? 0.73F : super.c(); + } + + public boolean isBurning() { + return false; + } + + public float a(Explosion explosion, Block block, int i, int j, int k) { + float f = super.a(explosion, block, i, j, k); + + if (this.d() && block != Block.BEDROCK) { + f = Math.min(0.8F, f); + } + + return f; + } + + protected void a(MovingObjectPosition movingobjectposition) { + if (!this.world.isStatic) { + if (movingobjectposition.entity != null) { + if (this.shooter != null) { + if (movingobjectposition.entity.damageEntity(DamageSource.mobAttack(this.shooter), 8) && !movingobjectposition.entity.isAlive()) { + this.shooter.heal(5, EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit + } + } else { + movingobjectposition.entity.damageEntity(DamageSource.MAGIC, 5); + } + + if (movingobjectposition.entity instanceof EntityLiving) { + byte b0 = 0; + + if (this.world.difficulty > 1) { + if (this.world.difficulty == 2) { + b0 = 10; + } else if (this.world.difficulty == 3) { + b0 = 40; + } + } + + if (b0 > 0) { + ((EntityLiving) movingobjectposition.entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 20 * b0, 1)); + } + } + } + + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), this.world.getGameRules().getBoolean("mobGriefing")); + } + // CraftBukkit end + + this.die(); + } + } + + public boolean L() { + return false; + } + + public boolean damageEntity(DamageSource damagesource, int i) { + return false; + } + + protected void a() { + this.datawatcher.a(10, Byte.valueOf((byte) 0)); + } + + public boolean d() { + return this.datawatcher.getByte(10) == 1; + } + + public void e(boolean flag) { + this.datawatcher.watch(10, Byte.valueOf((byte) (flag ? 1 : 0))); + } +} diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java index 2c1f7d1c..077a8a31 100644 --- a/src/main/java/net/minecraft/server/EntityWolf.java +++ b/src/main/java/net/minecraft/server/EntityWolf.java @@ -13,15 +13,15 @@ public class EntityWolf extends EntityTameableAnimal { super(world); this.texture = "/mob/wolf.png"; this.a(0.6F, 0.8F); - this.bw = 0.3F; + this.bI = 0.3F; this.getNavigation().a(true); this.goalSelector.a(1, new PathfinderGoalFloat(this)); this.goalSelector.a(2, this.d); this.goalSelector.a(3, new PathfinderGoalLeapAtTarget(this, 0.4F)); - this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, this.bw, true)); - this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, this.bw, 10.0F, 2.0F)); - this.goalSelector.a(6, new PathfinderGoalBreed(this, this.bw)); - this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, this.bw)); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, this.bI, true)); + this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, this.bI, 10.0F, 2.0F)); + this.goalSelector.a(6, new PathfinderGoalBreed(this, this.bI)); + this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, this.bI)); this.goalSelector.a(8, new PathfinderGoalBeg(this, 8.0F)); this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); this.goalSelector.a(9, new PathfinderGoalRandomLookaround(this)); @@ -31,7 +31,7 @@ public class EntityWolf extends EntityTameableAnimal { this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed(this, EntitySheep.class, 16.0F, 200, false)); } - public boolean aV() { + public boolean bb() { return true; } @@ -42,7 +42,7 @@ public class EntityWolf extends EntityTameableAnimal { } } - protected void bd() { + protected void bj() { this.datawatcher.watch(18, Integer.valueOf(this.getHealth())); } @@ -54,39 +54,44 @@ public class EntityWolf extends EntityTameableAnimal { super.a(); this.datawatcher.a(18, new Integer(this.getHealth())); this.datawatcher.a(19, new Byte((byte) 0)); + this.datawatcher.a(20, new Byte((byte) BlockCloth.e_(1))); } - protected boolean e_() { - return false; + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.wolf.step", 0.15F, 1.0F); } public void b(NBTTagCompound nbttagcompound) { super.b(nbttagcompound); nbttagcompound.setBoolean("Angry", this.isAngry()); + nbttagcompound.setByte("CollarColor", (byte) this.getCollarColor()); } public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); this.setAngry(nbttagcompound.getBoolean("Angry")); + if (nbttagcompound.hasKey("CollarColor")) { + this.setCollarColor(nbttagcompound.getByte("CollarColor")); + } } - protected boolean ba() { + protected boolean bg() { return this.isAngry(); } - protected String aQ() { + protected String aW() { 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 aR() { + protected String aX() { return "mob.wolf.hurt"; } - protected String aS() { + protected String aY() { return "mob.wolf.death"; } - protected float aP() { + protected float aV() { return 0.4F; } @@ -94,9 +99,9 @@ public class EntityWolf extends EntityTameableAnimal { return -1; } - public void d() { - super.d(); - if (!this.world.isStatic && this.g && !this.h && !this.l() && this.onGround) { + public void c() { + super.c(); + if (!this.world.isStatic && this.g && !this.h && !this.k() && this.onGround) { this.h = true; this.i = 0.0F; this.j = 0.0F; @@ -104,17 +109,17 @@ public class EntityWolf extends EntityTameableAnimal { } } - public void h_() { - super.h_(); + public void j_() { + super.j_(); this.f = this.e; - if (this.bv()) { + if (this.bI()) { this.e += (1.0F - this.e) * 0.4F; } else { this.e += (0.0F - this.e) * 0.4F; } - if (this.bv()) { - this.bx = 10; + if (this.bI()) { + this.bJ = 10; } if (this.G()) { @@ -124,7 +129,7 @@ public class EntityWolf extends EntityTameableAnimal { 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.aP(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.world.makeSound(this, "mob.wolf.shake", this.aV(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } this.j = this.i; @@ -144,7 +149,7 @@ public class EntityWolf extends EntityTameableAnimal { float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; - this.world.a("splash", this.locX + (double) f1, (double) (f + 0.8F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); + this.world.addParticle("splash", this.locX + (double) f1, (double) (f + 0.8F), this.locZ + (double) f2, this.motX, this.motY, this.motZ); } } } @@ -154,8 +159,8 @@ public class EntityWolf extends EntityTameableAnimal { return this.length * 0.8F; } - public int bf() { - return this.isSitting() ? 20 : super.bf(); + public int bm() { + return this.isSitting() ? 20 : super.bm(); } public boolean damageEntity(DamageSource damagesource, int i) { @@ -169,7 +174,7 @@ public class EntityWolf extends EntityTameableAnimal { return super.damageEntity(damagesource, i); } - public boolean k(Entity entity) { + public boolean l(Entity entity) { int i = this.isTamed() ? 4 : 2; return entity.damageEntity(DamageSource.mobAttack(this), i); @@ -179,26 +184,39 @@ public class EntityWolf extends EntityTameableAnimal { ItemStack itemstack = entityhuman.inventory.getItemInHand(); if (this.isTamed()) { - if (itemstack != null && Item.byId[itemstack.id] instanceof ItemFood) { - ItemFood itemfood = (ItemFood) Item.byId[itemstack.id]; + if (itemstack != null) { + if (Item.byId[itemstack.id] instanceof ItemFood) { + ItemFood itemfood = (ItemFood) Item.byId[itemstack.id]; - if (itemfood.h() && this.datawatcher.getInt(18) < 20) { - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - } + if (itemfood.i() && this.datawatcher.getInt(18) < 20) { + if (!entityhuman.abilities.canInstantlyBuild) { + --itemstack.count; + } + + this.heal(itemfood.getNutrition()); + if (itemstack.count <= 0) { + entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); + } - this.heal(itemfood.getNutrition()); - if (itemstack.count <= 0) { - entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); + return true; } + } else if (itemstack.id == Item.INK_SACK.id) { + int i = BlockCloth.e_(itemstack.getData()); - return true; + if (i != this.getCollarColor()) { + this.setCollarColor(i); + if (!entityhuman.abilities.canInstantlyBuild && itemstack.count-- <= 0) { + entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); + } + + return true; + } } } - if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.b(itemstack)) { + if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.c(itemstack)) { this.d.a(!this.isSitting()); - this.bu = false; + this.bG = false; this.setPathEntity((PathEntity) null); } } else if (itemstack != null && itemstack.id == Item.BONE.id && !this.isAngry()) { @@ -219,10 +237,10 @@ public class EntityWolf extends EntityTameableAnimal { this.d.a(true); this.setHealth(20); this.setOwnerName(entityhuman.name); - this.e(true); + this.f(true); this.world.broadcastEntityEffect(this, (byte) 7); } else { - this.e(false); + this.f(false); this.world.broadcastEntityEffect(this, (byte) 6); } } @@ -233,11 +251,11 @@ public class EntityWolf extends EntityTameableAnimal { return super.c(entityhuman); } - public boolean b(ItemStack itemstack) { - return itemstack == null ? false : (!(Item.byId[itemstack.id] instanceof ItemFood) ? false : ((ItemFood) Item.byId[itemstack.id]).h()); + public boolean c(ItemStack itemstack) { + return itemstack == null ? false : (!(Item.byId[itemstack.id] instanceof ItemFood) ? false : ((ItemFood) Item.byId[itemstack.id]).i()); } - public int bl() { + public int bs() { return 8; } @@ -255,6 +273,14 @@ public class EntityWolf extends EntityTameableAnimal { } } + public int getCollarColor() { + return this.datawatcher.getByte(20) & 15; + } + + public void setCollarColor(int i) { + this.datawatcher.watch(20, Byte.valueOf((byte) (i & 15))); + } + public EntityAnimal createChild(EntityAnimal entityanimal) { EntityWolf entitywolf = new EntityWolf(this.world); @@ -263,7 +289,7 @@ public class EntityWolf extends EntityTameableAnimal { return entitywolf; } - public void i(boolean flag) { + public void j(boolean flag) { byte b0 = this.datawatcher.getByte(19); if (flag) { @@ -283,11 +309,11 @@ public class EntityWolf extends EntityTameableAnimal { } else { EntityWolf entitywolf = (EntityWolf) entityanimal; - return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.s() && entitywolf.s()); + return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.r() && entitywolf.r()); } } - public boolean bv() { + public boolean bI() { return this.datawatcher.getByte(19) == 1; } } diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 400f3b1c..8960f782 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -1,22 +1,25 @@ package net.minecraft.server; +import java.util.Calendar; + import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit public class EntityZombie extends EntityMonster { + private int d = 0; + public EntityZombie(World world) { super(world); this.texture = "/mob/zombie.png"; - this.bw = 0.23F; - this.damage = 4; + this.bI = 0.23F; this.getNavigation().b(true); this.goalSelector.a(0, new PathfinderGoalFloat(this)); this.goalSelector.a(1, new PathfinderGoalBreakDoor(this)); - this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, this.bw, false)); - this.goalSelector.a(3, new PathfinderGoalMeleeAttack(this, EntityVillager.class, this.bw, true)); - this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, this.bw)); - this.goalSelector.a(5, new PathfinderGoalMoveThroughVillage(this, this.bw, false)); - this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, this.bw)); + this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, EntityHuman.class, this.bI, false)); + this.goalSelector.a(3, new PathfinderGoalMeleeAttack(this, EntityVillager.class, this.bI, true)); + this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, this.bI)); + this.goalSelector.a(5, new PathfinderGoalMoveThroughVillage(this, this.bI, false)); + this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, this.bI)); this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F)); this.goalSelector.a(7, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, false)); @@ -24,47 +27,125 @@ public class EntityZombie extends EntityMonster { this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityVillager.class, 16.0F, 0, false)); } + public float by() { + return super.by() * (this.isBaby() ? 1.5F : 1.0F); + } + + protected void a() { + super.a(); + this.getDataWatcher().a(12, Byte.valueOf((byte) 0)); + this.getDataWatcher().a(13, Byte.valueOf((byte) 0)); + this.getDataWatcher().a(14, Byte.valueOf((byte) 0)); + } + public int getMaxHealth() { return 20; } - public int aO() { - return 2; + public int aU() { + int i = super.aU() + 2; + + if (i > 20) { + i = 20; + } + + return i; } - protected boolean aV() { + protected boolean bb() { return true; } - public void d() { - if (this.world.s() && !this.world.isStatic) { + public boolean isBaby() { + return this.getDataWatcher().getByte(12) == 1; + } + + public void setBaby(boolean flag) { + this.getDataWatcher().watch(12, Byte.valueOf((byte) 1)); + } + + public boolean isVillager() { + return this.getDataWatcher().getByte(13) == 1; + } + + public void setVillager(boolean flag) { + this.getDataWatcher().watch(13, Byte.valueOf((byte) (flag ? 1 : 0))); + } + + public void c() { + if (this.world.t() && !this.world.isStatic && !this.isBaby()) { float f = this.c(1.0F); - if (f > 0.5F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) { - // CraftBukkit start - EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); - this.world.getServer().getPluginManager().callEvent(event); + if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.j(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ))) { + boolean flag = true; + ItemStack itemstack = this.getEquipment(4); + + if (itemstack != null) { + if (itemstack.f()) { + itemstack.setData(itemstack.i() + this.random.nextInt(2)); + if (itemstack.i() >= itemstack.k()) { + this.a(itemstack); + this.setEquipment(4, (ItemStack) null); + } + } + + flag = false; + } + + if (flag) { + // CraftBukkit start + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); + this.world.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.setOnFire(event.getDuration()); + if (!event.isCancelled()) { + this.setOnFire(event.getDuration()); + } + // CraftBukkit end } - // CraftBukkit end } } - super.d(); + super.c(); } - protected String aQ() { - return "mob.zombie"; + public void j_() { + if (!this.world.isStatic && this.o()) { + int i = this.q(); + + this.d -= i; + if (this.d <= 0) { + this.p(); + } + } + + super.j_(); } - protected String aR() { - return "mob.zombiehurt"; + public int c(Entity entity) { + ItemStack itemstack = this.bA(); + int i = 4; + + if (itemstack != null) { + i += itemstack.a((Entity) this); + } + + return i; + } + + protected String aW() { + return "mob.zombie.say"; + } + + protected String aX() { + return "mob.zombie.hurt"; + } + + protected String aY() { + return "mob.zombie.death"; } - protected String aS() { - return "mob.zombiedeath"; + protected void a(int i, int j, int k, int l) { + this.world.makeSound(this, "mob.zombie.step", 0.15F, 1.0F); } protected int getLootId() { @@ -77,18 +158,173 @@ public class EntityZombie extends EntityMonster { // CraftBukkit start - return rare dropped item instead of dropping it protected ItemStack l(int i) { - switch (this.random.nextInt(4)) { + switch (this.random.nextInt(3)) { case 0: - return new ItemStack(Item.IRON_SWORD.id, 1, 0); + return new ItemStack(Item.IRON_INGOT.id, 1, 0); case 1: - return new ItemStack(Item.IRON_HELMET.id, 1, 0); + return new ItemStack(Item.CARROT.id, 1, 0); case 2: - return new ItemStack(Item.IRON_INGOT.id, 1, 0); - case 3: - return new ItemStack(Item.IRON_SPADE.id, 1, 0); + return new ItemStack(Item.POTATO.id, 1, 0); default: return null; } } // CraftBukkit end + + protected void bB() { + super.bB(); + if (this.random.nextFloat() < (this.world.difficulty == 3 ? 0.05F : 0.01F)) { + int i = this.random.nextInt(3); + + if (i == 0) { + this.setEquipment(0, new ItemStack(Item.IRON_SWORD)); + } else { + this.setEquipment(0, new ItemStack(Item.IRON_SPADE)); + } + } + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + if (this.isBaby()) { + nbttagcompound.setBoolean("IsBaby", true); + } + + if (this.isVillager()) { + nbttagcompound.setBoolean("IsVillager", true); + } + + nbttagcompound.setInt("ConversionTime", this.o() ? this.d : -1); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + if (nbttagcompound.getBoolean("IsBaby")) { + this.setBaby(true); + } + + if (nbttagcompound.getBoolean("IsVillager")) { + this.setVillager(true); + } + + if (nbttagcompound.hasKey("ConversionTime") && nbttagcompound.getInt("ConversionTime") > -1) { + this.a(nbttagcompound.getInt("ConversionTime")); + } + } + + public void a(EntityLiving entityliving) { + super.a(entityliving); + if (this.world.difficulty >= 2 && entityliving instanceof EntityVillager) { + if (this.world.difficulty == 2 && this.random.nextBoolean()) { + return; + } + + EntityZombie entityzombie = new EntityZombie(this.world); + + entityzombie.j(entityliving); + this.world.kill(entityliving); + entityzombie.bD(); + entityzombie.setVillager(true); + if (entityliving.isBaby()) { + entityzombie.setBaby(true); + } + + this.world.addEntity(entityzombie); + this.world.a((EntityHuman) null, 1016, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + } + } + + public void bD() { + this.canPickUpLoot = this.random.nextFloat() < as[this.world.difficulty]; + if (this.world.random.nextFloat() < 0.05F) { + this.setVillager(true); + } + + this.bB(); + this.bC(); + if (this.getEquipment(4) == null) { + Calendar calendar = this.world.S(); + + if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.random.nextFloat() < 0.25F) { + this.setEquipment(4, new ItemStack(this.random.nextFloat() < 0.1F ? Block.JACK_O_LANTERN : Block.PUMPKIN)); + this.dropChances[4] = 0.0F; + } + } + } + + public boolean c(EntityHuman entityhuman) { + ItemStack itemstack = entityhuman.bP(); + + if (itemstack != null && itemstack.getItem() == Item.GOLDEN_APPLE && itemstack.getData() == 0 && this.isVillager() && this.hasEffect(MobEffectList.WEAKNESS)) { + if (!entityhuman.abilities.canInstantlyBuild) { + --itemstack.count; + } + + if (itemstack.count <= 0) { + entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); + } + + if (!this.world.isStatic) { + this.a(this.random.nextInt(2401) + 3600); + } + + return true; + } else { + return false; + } + } + + protected void a(int i) { + this.d = i; + this.getDataWatcher().watch(14, Byte.valueOf((byte) 1)); + this.o(MobEffectList.WEAKNESS.id); + this.addEffect(new MobEffect(MobEffectList.INCREASE_DAMAGE.id, i, Math.min(this.world.difficulty - 1, 0))); + this.world.broadcastEntityEffect(this, (byte) 16); + } + + public boolean o() { + return this.getDataWatcher().getByte(14) == 1; + } + + protected void p() { + EntityVillager entityvillager = new EntityVillager(this.world); + + entityvillager.j(this); + entityvillager.bD(); + entityvillager.q(); + if (this.isBaby()) { + entityvillager.setAge(-24000); + } + + this.world.kill(this); + this.world.addEntity(entityvillager); + entityvillager.addEffect(new MobEffect(MobEffectList.CONFUSION.id, 200, 0)); + this.world.a((EntityHuman) null, 1017, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + } + + protected int q() { + int i = 1; + + if (this.random.nextFloat() < 0.01F) { + int j = 0; + + for (int k = (int) this.locX - 4; k < (int) this.locX + 4 && j < 14; ++k) { + for (int l = (int) this.locY - 4; l < (int) this.locY + 4 && j < 14; ++l) { + for (int i1 = (int) this.locZ - 4; i1 < (int) this.locZ + 4 && j < 14; ++i1) { + int j1 = this.world.getTypeId(k, l, i1); + + if (j1 == Block.IRON_FENCE.id || j1 == Block.BED.id) { + if (this.random.nextFloat() < 0.3F) { + ++i; + } + + ++j; + } + } + } + } + } + + return i; + } } diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index b30e7662..fb30dc10 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -20,8 +20,9 @@ import org.bukkit.Location; public class Explosion { public boolean a = false; - private int h = 16; - private Random i = new Random(); + public boolean b = true; + private int i = 16; + private Random j = new Random(); private World world; public double posX; public double posY; @@ -29,7 +30,7 @@ public class Explosion { public Entity source; public float size; public List blocks = new ArrayList(); - private Map k = new HashMap(); + private Map l = new HashMap(); public boolean wasCanceled = false; // CraftBukkit public Explosion(World world, Entity entity, double d0, double d1, double d2, float f) { @@ -58,13 +59,13 @@ public class Explosion { double d1; double d2; - for (i = 0; i < this.h; ++i) { - for (j = 0; j < this.h; ++j) { - for (k = 0; k < this.h; ++k) { - if (i == 0 || i == this.h - 1 || j == 0 || j == this.h - 1 || k == 0 || k == this.h - 1) { - double d3 = (double) ((float) i / ((float) this.h - 1.0F) * 2.0F - 1.0F); - double d4 = (double) ((float) j / ((float) this.h - 1.0F) * 2.0F - 1.0F); - double d5 = (double) ((float) k / ((float) this.h - 1.0F) * 2.0F - 1.0F); + for (i = 0; i < this.i; ++i) { + for (j = 0; j < this.i; ++j) { + for (k = 0; k < this.i; ++k) { + if (i == 0 || i == this.i - 1 || j == 0 || j == this.i - 1 || k == 0 || k == this.i - 1) { + double d3 = (double) ((float) i / ((float) this.i - 1.0F) * 2.0F - 1.0F); + double d4 = (double) ((float) j / ((float) this.i - 1.0F) * 2.0F - 1.0F); + double d5 = (double) ((float) k / ((float) this.i - 1.0F) * 2.0F - 1.0F); double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); d3 /= d6; @@ -83,7 +84,10 @@ public class Explosion { int k1 = this.world.getTypeId(l, i1, j1); if (k1 > 0) { - f1 -= (Block.byId[k1].a(this.source) + 0.3F) * f2; + Block block = Block.byId[k1]; + float f3 = this.source != null ? this.source.a(this, block, l, i1, j1) : block.a(this.source); + + f1 -= (f3 + 0.3F) * f2; } if (f1 > 0.0F && i1 < 256 && i1 >= 0) { // CraftBukkit - don't wrap explosions @@ -108,7 +112,7 @@ public class Explosion { int i2 = MathHelper.floor(this.posZ - (double) this.size - 1.0D); int j2 = MathHelper.floor(this.posZ + (double) this.size + 1.0D); List list = this.world.getEntities(this.source, AxisAlignedBB.a().a((double) i, (double) k, (double) i2, (double) j, (double) l1, (double) j2)); - Vec3D vec3d = Vec3D.a().create(this.posX, this.posY, this.posZ); + Vec3D vec3d = this.world.getVec3DPool().create(this.posX, this.posY, this.posZ); for (int k2 = 0; k2 < list.size(); ++k2) { Entity entity = (Entity) list.get(k2); @@ -145,7 +149,7 @@ public class Explosion { entity.motY += d1 * d10; entity.motZ += d2 * d10; if (entity instanceof EntityHuman) { - this.k.put((EntityHuman) entity, Vec3D.a().create(d0 * d10, d1 * d10, d2 * d10)); + this.l.put((EntityHuman) entity, this.world.getVec3DPool().create(d0 * d10, d1 * d10, d2 * d10)); } } } else { @@ -169,7 +173,7 @@ public class Explosion { entity.motY += d1 * d10; entity.motZ += d2 * d10; if (entity instanceof EntityHuman) { - this.k.put((EntityHuman) entity, Vec3D.a().create(d0 * d10, d1 * d10, d2 * d10)); + this.l.put((EntityHuman) entity, this.world.getVec3DPool().create(d0 * d10, d1 * d10, d2 * d10)); } } } @@ -183,83 +187,91 @@ public class Explosion { public void a(boolean flag) { this.world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F); - this.world.a("hugeexplosion", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); - - // CraftBukkit start - org.bukkit.World bworld = this.world.getWorld(); - org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); - Location location = new Location(bworld, this.posX, this.posY, this.posZ); - - List<org.bukkit.block.Block> blockList = new ArrayList<org.bukkit.block.Block>(); - for (int j = blocks.size() - 1; j >= 0; j--) { - ChunkPosition cpos = (ChunkPosition) blocks.get(j); - org.bukkit.block.Block block = bworld.getBlockAt(cpos.x, cpos.y, cpos.z); - if (block.getType() != org.bukkit.Material.AIR) { - blockList.add(block); - } - } - - EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F); - this.world.getServer().getPluginManager().callEvent(event); - - blocks.clear(); - - for (org.bukkit.block.Block block : event.blockList()) { - ChunkPosition coords = new ChunkPosition(block.getX(), block.getY(), block.getZ()); - blocks.add(coords); + if (this.size >= 2.0F && this.b) { + this.world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D); + } else { + this.world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D); } - if (event.isCancelled()) { - this.wasCanceled = true; - return; - } - - Iterator iterator = this.blocks.iterator(); - // CraftBukkit end - + Iterator iterator; ChunkPosition chunkposition; int i; int j; int k; int l; - while (iterator.hasNext()) { - chunkposition = (ChunkPosition) iterator.next(); - i = chunkposition.x; - j = chunkposition.y; - k = chunkposition.z; - l = this.world.getTypeId(i, j, k); - if (flag) { - double d0 = (double) ((float) i + this.world.random.nextFloat()); - double d1 = (double) ((float) j + this.world.random.nextFloat()); - double d2 = (double) ((float) k + this.world.random.nextFloat()); - double d3 = d0 - this.posX; - double d4 = d1 - this.posY; - double d5 = d2 - this.posZ; - double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - - d3 /= d6; - d4 /= d6; - d5 /= d6; - double d7 = 0.5D / (d6 / (double) this.size + 0.1D); - - d7 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F); - d3 *= d7; - d4 *= d7; - d5 *= d7; - this.world.a("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5); - this.world.a("smoke", d0, d1, d2, d3, d4, d5); + if (this.b) { + // CraftBukkit start + org.bukkit.World bworld = this.world.getWorld(); + org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); + Location location = new Location(bworld, this.posX, this.posY, this.posZ); + + List<org.bukkit.block.Block> blockList = new ArrayList<org.bukkit.block.Block>(); + for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) { + ChunkPosition cpos = (ChunkPosition) this.blocks.get(i1); + org.bukkit.block.Block block = bworld.getBlockAt(cpos.x, cpos.y, cpos.z); + if (block.getType() != org.bukkit.Material.AIR) { + blockList.add(block); + } + } + + EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F); + this.world.getServer().getPluginManager().callEvent(event); + + this.blocks.clear(); + + for (org.bukkit.block.Block block : event.blockList()) { + ChunkPosition coords = new ChunkPosition(block.getX(), block.getY(), block.getZ()); + blocks.add(coords); + } + + if (event.isCancelled()) { + this.wasCanceled = true; + return; } + // CraftBukkit end - // CraftBukkit - stop explosions from putting out fire - if (l > 0 && l != Block.FIRE.id) { - // CraftBukkit - Block.byId[l].dropNaturally(this.world, i, j, k, this.world.getData(i, j, k), event.getYield(), 0); - if (this.world.setRawTypeIdAndData(i, j, k, 0, 0, this.world.isStatic)) { - this.world.applyPhysics(i, j, k, 0); + iterator = this.blocks.iterator(); + + while (iterator.hasNext()) { + chunkposition = (ChunkPosition) iterator.next(); + i = chunkposition.x; + j = chunkposition.y; + k = chunkposition.z; + l = this.world.getTypeId(i, j, k); + if (flag) { + double d0 = (double) ((float) i + this.world.random.nextFloat()); + double d1 = (double) ((float) j + this.world.random.nextFloat()); + double d2 = (double) ((float) k + this.world.random.nextFloat()); + double d3 = d0 - this.posX; + double d4 = d1 - this.posY; + double d5 = d2 - this.posZ; + double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); + + d3 /= d6; + d4 /= d6; + d5 /= d6; + double d7 = 0.5D / (d6 / (double) this.size + 0.1D); + + d7 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F); + d3 *= d7; + d4 *= d7; + d5 *= d7; + this.world.addParticle("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D, (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5); + this.world.addParticle("smoke", d0, d1, d2, d3, d4, d5); } - Block.byId[l].wasExploded(this.world, i, j, k); + + // CraftBukkit - stop explosions from putting out fire + if (l > 0 && l != Block.FIRE.id) { + // CraftBukkit + Block.byId[l].dropNaturally(this.world, i, j, k, this.world.getData(i, j, k), event.getYield(), 0); + if (this.world.setRawTypeIdAndData(i, j, k, 0, 0, this.world.isStatic)) { + this.world.applyPhysics(i, j, k, 0); + } + + Block.byId[l].wasExploded(this.world, i, j, k); + } } } @@ -274,7 +286,7 @@ public class Explosion { l = this.world.getTypeId(i, j, k); int i1 = this.world.getTypeId(i, j - 1, k); - if (l == 0 && Block.n[i1] && this.i.nextInt(3) == 0) { + if (l == 0 && Block.q[i1] && this.j.nextInt(3) == 0) { this.world.setTypeId(i, j, k, Block.FIRE.id); } } @@ -282,6 +294,6 @@ public class Explosion { } public Map b() { - return this.k; + return this.l; } } diff --git a/src/main/java/net/minecraft/server/FoodMetaData.java b/src/main/java/net/minecraft/server/FoodMetaData.java index 30f3fb68..f0b600e1 100644 --- a/src/main/java/net/minecraft/server/FoodMetaData.java +++ b/src/main/java/net/minecraft/server/FoodMetaData.java @@ -44,7 +44,7 @@ public class FoodMetaData { } } - if (this.foodLevel >= 18 && entityhuman.bM()) { + if (this.foodLevel >= 18 && entityhuman.ca()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { // CraftBukkit - added RegainReason diff --git a/src/main/java/net/minecraft/server/IRecipe.java b/src/main/java/net/minecraft/server/IRecipe.java index fbd3e3c4..bb28c12f 100644 --- a/src/main/java/net/minecraft/server/IRecipe.java +++ b/src/main/java/net/minecraft/server/IRecipe.java @@ -2,9 +2,9 @@ package net.minecraft.server; public interface IRecipe { - boolean a(InventoryCrafting inventorycrafting); + boolean a(InventoryCrafting inventorycrafting, World world); - ItemStack b(InventoryCrafting inventorycrafting); + ItemStack a(InventoryCrafting inventorycrafting); int a(); diff --git a/src/main/java/net/minecraft/server/InventoryCraftResult.java b/src/main/java/net/minecraft/server/InventoryCraftResult.java index f5855d65..065b3a54 100644 --- a/src/main/java/net/minecraft/server/InventoryCraftResult.java +++ b/src/main/java/net/minecraft/server/InventoryCraftResult.java @@ -39,7 +39,7 @@ public class InventoryCraftResult implements IInventory { } public ItemStack getItem(int i) { - return this.items[i]; + return this.items[0]; } public String getName() { @@ -47,10 +47,10 @@ public class InventoryCraftResult implements IInventory { } public ItemStack splitStack(int i, int j) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; + if (this.items[0] != null) { + ItemStack itemstack = this.items[0]; - this.items[i] = null; + this.items[0] = null; return itemstack; } else { return null; @@ -58,10 +58,10 @@ public class InventoryCraftResult implements IInventory { } public ItemStack splitWithoutUpdate(int i) { - if (this.items[i] != null) { - ItemStack itemstack = this.items[i]; + if (this.items[0] != null) { + ItemStack itemstack = this.items[0]; - this.items[i] = null; + this.items[0] = null; return itemstack; } else { return null; @@ -69,7 +69,7 @@ public class InventoryCraftResult implements IInventory { } public void setItem(int i, ItemStack itemstack) { - this.items[i] = itemstack; + this.items[0] = itemstack; } public int getMaxStackSize() { diff --git a/src/main/java/net/minecraft/server/InventoryMerchant.java b/src/main/java/net/minecraft/server/InventoryMerchant.java index f1d7add0..1e238710 100644 --- a/src/main/java/net/minecraft/server/InventoryMerchant.java +++ b/src/main/java/net/minecraft/server/InventoryMerchant.java @@ -124,7 +124,7 @@ public class InventoryMerchant implements IInventory { } public boolean a(EntityHuman entityhuman) { - return this.merchant.l_() == entityhuman; + return this.merchant.m_() == entityhuman; } public void startOpen() {} @@ -153,12 +153,12 @@ public class InventoryMerchant implements IInventory { if (merchantrecipelist != null) { MerchantRecipe merchantrecipe = merchantrecipelist.a(itemstack, itemstack1, this.e); - if (merchantrecipe != null) { + if (merchantrecipe != null && !merchantrecipe.g()) { this.recipe = merchantrecipe; this.setItem(2, merchantrecipe.getBuyItem3().cloneItemStack()); } else if (itemstack1 != null) { merchantrecipe = merchantrecipelist.a(itemstack1, itemstack, this.e); - if (merchantrecipe != null) { + if (merchantrecipe != null && !merchantrecipe.g()) { this.recipe = merchantrecipe; this.setItem(2, merchantrecipe.getBuyItem3().cloneItemStack()); } else { diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index ddf61bce..fe1c4a1e 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -37,7 +37,7 @@ public class ItemBed extends Item { b0 = 1; } - if (entityhuman.e(i, j, k) && entityhuman.e(i + b0, j, k + b1)) { + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i + b0, j, k + b1, l, itemstack)) { if (world.isEmpty(i, j, k) && world.isEmpty(i + b0, j, k + b1) && world.t(i, j - 1, k) && world.t(i + b0, j - 1, k + b1)) { CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index c2b9d54f..e3fe0132 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -12,7 +12,7 @@ public class ItemBlock extends Item { this.c(Block.byId[i + 256].a(2)); } - public int f() { + public int g() { return this.id; } @@ -50,7 +50,7 @@ public class ItemBlock extends Item { if (itemstack.count == 0) { return false; - } else if (!entityhuman.e(i, j, k)) { + } else if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else if (j == 255 && Block.byId[this.id].material.isBuildable()) { return false; @@ -89,7 +89,7 @@ public class ItemBlock extends Item { // 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); + world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.b(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); --itemstack.count; } @@ -99,7 +99,7 @@ public class ItemBlock extends Item { } } - public String c(ItemStack itemstack) { + public String c_(ItemStack itemstack) { return Block.byId[this.id].a(); } diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java index e53dc600..5f6acc37 100644 --- a/src/main/java/net/minecraft/server/ItemBoat.java +++ b/src/main/java/net/minecraft/server/ItemBoat.java @@ -18,7 +18,7 @@ public class ItemBoat extends Item { 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.a().create(d0, d1, d2); + Vec3D vec3d = world.getVec3DPool().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); @@ -35,7 +35,7 @@ public class ItemBoat extends Item { Vec3D vec3d2 = entityhuman.i(f); boolean flag = false; float f9 = 1.0F; - List list = world.getEntities(entityhuman, entityhuman.boundingBox.a(vec3d2.a * d3, vec3d2.b * d3, vec3d2.c * d3).grow((double) f9, (double) f9, (double) f9)); + List list = world.getEntities(entityhuman, entityhuman.boundingBox.a(vec3d2.c * d3, vec3d2.d * d3, vec3d2.e * d3).grow((double) f9, (double) f9, (double) f9)); Iterator iterator = list.iterator(); while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/ItemBow.java b/src/main/java/net/minecraft/server/ItemBow.java index 9ef4285a..a5f278bb 100644 --- a/src/main/java/net/minecraft/server/ItemBow.java +++ b/src/main/java/net/minecraft/server/ItemBow.java @@ -28,13 +28,13 @@ public class ItemBow extends Item { EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F); if (f == 1.0F) { - entityarrow.d(true); + entityarrow.e(true); } int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack); if (k > 0) { - entityarrow.b(entityarrow.d() + (double) k * 0.5D + 0.5D); + entityarrow.b(entityarrow.c() + (double) k * 0.5D + 0.5D); } int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack); diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index bab155b0..5aa39216 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -39,7 +39,7 @@ public class ItemBucket extends Item { } if (this.a == 0) { - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { return itemstack; } @@ -131,7 +131,7 @@ public class ItemBucket extends Item { ++i; } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { return itemstack; } @@ -170,11 +170,11 @@ public class ItemBucket extends Item { } else if (!world.isEmpty(i, j, k) && world.getMaterial(i, j, k).isBuildable()) { return false; } else { - if (world.worldProvider.d && this.a == Block.WATER.id) { + if (world.worldProvider.e && this.a == Block.WATER.id) { world.makeSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) { - world.a("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D); + world.addParticle("largesmoke", (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D); } } else { world.setTypeIdAndData(i, j, k, this.a, 0); diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index ddc014c5..de557ac4 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -26,7 +26,7 @@ public class ItemDoor extends Item { block = Block.IRON_DOOR_BLOCK; } - if (entityhuman.e(i, j, k) && entityhuman.e(i, j + 1, k)) { + if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { if (!block.canPlace(world, i, j, k)) { return false; } else { diff --git a/src/main/java/net/minecraft/server/ItemDye.java b/src/main/java/net/minecraft/server/ItemDye.java index 7ac00233..744ff365 100644 --- a/src/main/java/net/minecraft/server/ItemDye.java +++ b/src/main/java/net/minecraft/server/ItemDye.java @@ -17,14 +17,14 @@ public class ItemDye extends Item { this.a(CreativeModeTab.l); } - public String c(ItemStack itemstack) { + public String c_(ItemStack itemstack) { int i = MathHelper.a(itemstack.getData(), 0, 15); return super.getName() + "." + a[i]; } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1; @@ -69,13 +69,13 @@ public class ItemDye extends Item { return true; } - if (i1 == Block.CROPS.id) { + if (i1 > 0 && Block.byId[i1] instanceof BlockCrops) { if (world.getData(i, j, k) == 7) { return false; } if (!world.isStatic) { - ((BlockCrops) Block.CROPS).c_(world, i, j, k); + ((BlockCrops) Block.byId[i1]).c_(world, i, j, k); --itemstack.count; } @@ -84,7 +84,7 @@ public class ItemDye extends Item { if (i1 == Block.COCOA.id) { if (!world.isStatic) { - world.setData(i, j, k, 8 | BlockDirectional.d(world.getData(i, j, k))); + world.setData(i, j, k, 8 | BlockDirectional.e(world.getData(i, j, k))); --itemstack.count; } @@ -95,7 +95,7 @@ public class ItemDye extends Item { if (!world.isStatic) { --itemstack.count; - label135: + label137: for (j1 = 0; j1 < 128; ++j1) { int k1 = i; int l1 = j + 1; @@ -106,7 +106,7 @@ public class ItemDye extends Item { l1 += (d.nextInt(3) - 1) * d.nextInt(3) / 2; i2 += d.nextInt(3) - 1; if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.s(k1, l1, i2)) { - continue label135; + continue label137; } } diff --git a/src/main/java/net/minecraft/server/ItemFireball.java b/src/main/java/net/minecraft/server/ItemFireball.java index 8719b443..6705127e 100644 --- a/src/main/java/net/minecraft/server/ItemFireball.java +++ b/src/main/java/net/minecraft/server/ItemFireball.java @@ -40,7 +40,7 @@ public class ItemFireball extends Item { ++i; } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1 = world.getTypeId(i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemFishingRod.java b/src/main/java/net/minecraft/server/ItemFishingRod.java index 5d5bba35..1ce129e7 100644 --- a/src/main/java/net/minecraft/server/ItemFishingRod.java +++ b/src/main/java/net/minecraft/server/ItemFishingRod.java @@ -13,10 +13,10 @@ public class ItemFishingRod extends Item { public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) { if (entityhuman.hookedFish != null) { - int i = entityhuman.hookedFish.d(); + int i = entityhuman.hookedFish.c(); itemstack.damage(i, entityhuman); - entityhuman.i(); + entityhuman.bE(); } else { // CraftBukkit start PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, PlayerFishEvent.State.FISHING); @@ -32,7 +32,7 @@ public class ItemFishingRod extends Item { world.addEntity(new EntityFishingHook(world, entityhuman)); } - entityhuman.i(); + entityhuman.bE(); } return itemstack; diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 385a88ad..c12b297b 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -42,7 +42,7 @@ public class ItemFlintAndSteel extends Item { ++i; } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1 = world.getTypeId(i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemFood.java b/src/main/java/net/minecraft/server/ItemFood.java index ffe16976..a2214886 100644 --- a/src/main/java/net/minecraft/server/ItemFood.java +++ b/src/main/java/net/minecraft/server/ItemFood.java @@ -5,18 +5,18 @@ public class ItemFood extends Item { public final int a; private final int b; private final float c; - private final boolean bY; - private boolean bZ; - private int ca; - private int cb; - private int cc; - private float cd; + private final boolean ck; + private boolean cl; + private int cm; + private int cn; + private int co; + private float cp; public ItemFood(int i, int j, float f, boolean flag) { super(i); this.a = 32; this.b = j; - this.bY = flag; + this.ck = flag; this.c = f; this.a(CreativeModeTab.h); } @@ -45,8 +45,8 @@ public class ItemFood extends Item { } protected void c(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (!world.isStatic && this.ca > 0 && world.random.nextFloat() < this.cd) { - entityhuman.addEffect(new MobEffect(this.ca, this.cb * 20, this.cc)); + if (!world.isStatic && this.cm > 0 && world.random.nextFloat() < this.cp) { + entityhuman.addEffect(new MobEffect(this.cm, this.cn * 20, this.co)); } } @@ -54,12 +54,12 @@ 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.e(this.bZ)) { + if (entityhuman.f(this.cl)) { entityhuman.a(itemstack, this.a(itemstack)); } @@ -74,20 +74,20 @@ public class ItemFood extends Item { return this.c; } - public boolean h() { - return this.bY; + public boolean i() { + return this.ck; } public ItemFood a(int i, int j, int k, float f) { - this.ca = i; - this.cb = j; - this.cc = k; - this.cd = f; + this.cm = i; + this.cn = j; + this.co = k; + this.cp = f; return this; } - public ItemFood i() { - this.bZ = true; + public ItemFood j() { + this.cl = true; return this; } } diff --git a/src/main/java/net/minecraft/server/ItemHanging.java b/src/main/java/net/minecraft/server/ItemHanging.java new file mode 100644 index 00000000..85ccd00c --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemHanging.java @@ -0,0 +1,61 @@ +package net.minecraft.server; + +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.event.painting.PaintingPlaceEvent; +// CraftBukkit end + +public class ItemHanging extends Item { + + private final Class a; + + public ItemHanging(int i, Class oclass) { + super(i); + this.a = oclass; + this.a(CreativeModeTab.c); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l == 0) { + return false; + } else if (l == 1) { + return false; + } else { + int i1 = Direction.e[l]; + EntityHanging entityhanging = this.a(world, i, j, k, i1); + + if (!entityhuman.a(i, j, k, l, itemstack)) { + return false; + } else { + if (entityhanging != null && entityhanging.survives()) { + if (!world.isStatic) { + // CraftBukkit start + if (entityhanging instanceof EntityPainting) { + Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(l); + + PaintingPlaceEvent event = new PaintingPlaceEvent((org.bukkit.entity.Painting) entityhanging.getBukkitEntity(), who, blockClicked, blockFace); + world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + } + // CraftBukkit end + + world.addEntity(entityhanging); + } + + --itemstack.count; + } + + return true; + } + } + } + + private EntityHanging a(World world, int i, int j, int k, int l) { + return (EntityHanging) (this.a == EntityPainting.class ? new EntityPainting(world, i, j, k, l) : (this.a == EntityItemFrame.class ? new EntityItemFrame(world, i, j, k, l) : null)); + } +} diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index bad137e3..8b934c29 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -15,7 +15,7 @@ public class ItemHoe extends Item { } public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1 = world.getTypeId(i, j, k); @@ -50,7 +50,7 @@ public class ItemHoe extends Item { } } - public String f() { + public String g() { return this.a.toString(); } } diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index 64515d16..5aa9ae45 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -78,7 +78,7 @@ public class ItemInWorldManager { f = block.getDamage(this.player, this.player.world, this.k, this.l, this.m) * (float) (i + 1); j = (int) (f * 10.0F); if (j != this.o) { - this.world.f(this.player.id, this.k, this.l, this.m, j); + this.world.g(this.player.id, this.k, this.l, this.m, j); this.o = j; } @@ -92,7 +92,7 @@ public class ItemInWorldManager { Block block1 = Block.byId[i]; if (block1 == null) { - this.world.f(this.player.id, this.f, this.g, this.h, -1); + this.world.g(this.player.id, this.f, this.g, this.h, -1); this.o = -1; this.d = false; } else { @@ -101,7 +101,7 @@ public class ItemInWorldManager { f = block1.getDamage(this.player, this.player.world, this.f, this.g, this.h) * (float) (l + 1); j = (int) (f * 10.0F); if (j != this.o) { - this.world.f(this.player.id, this.f, this.g, this.h, j); + this.world.g(this.player.id, this.f, this.g, this.h, j); this.o = j; } } @@ -113,7 +113,7 @@ public class ItemInWorldManager { // CraftBukkit PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, l, this.player.inventory.getItemInHand()); - if (!this.gamemode.isAdventure()) { + if (!this.gamemode.isAdventure() || this.player.f(i, j, k)) { // CraftBukkit start if (event.isCancelled()) { // Let the client know the block still exists @@ -182,7 +182,7 @@ public class ItemInWorldManager { this.h = k; int j1 = (int) (f * 10.0F); - this.world.f(this.player.id, i, j, k, j1); + this.world.g(this.player.id, i, j, k, j1); this.o = j1; } } @@ -201,7 +201,7 @@ public class ItemInWorldManager { if (f >= 0.7F) { this.d = false; - this.world.f(this.player.id, i, j, k, -1); + this.world.g(this.player.id, i, j, k, -1); this.breakBlock(i, j, k); } else if (!this.j) { this.d = false; @@ -221,7 +221,7 @@ public class ItemInWorldManager { public void c(int i, int j, int k) { this.d = false; - this.world.f(this.player.id, this.f, this.g, this.h, -1); + this.world.g(this.player.id, this.f, this.g, this.h, -1); } private boolean d(int i, int j, int k) { @@ -260,16 +260,16 @@ public class ItemInWorldManager { event = new BlockBreakEvent(block, this.player.getBukkitEntity()); // Adventure mode pre-cancel - event.setCancelled(this.gamemode.isAdventure()); + event.setCancelled(this.gamemode.isAdventure() && !this.player.f(i, j, k)); // Calculate default block experience Block nmsBlock = Block.byId[block.getTypeId()]; if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.b(nmsBlock)) { // Copied from Block.a(world, entityhuman, int, int, int, int) - if (!(nmsBlock.q_() && EnchantmentManager.hasSilkTouchEnchantment(this.player.inventory))) { + if (!(nmsBlock.s_() && EnchantmentManager.hasSilkTouchEnchantment(this.player))) { int data = block.getData(); - int bonusLevel = EnchantmentManager.getBonusBlockLootEnchantmentLevel(this.player.inventory); + int bonusLevel = EnchantmentManager.getBonusBlockLootEnchantmentLevel(this.player); event.setExpToDrop(nmsBlock.getExpDrop(this.world, data, bonusLevel)); } @@ -298,13 +298,13 @@ public class ItemInWorldManager { if (this.isCreative()) { this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); } else { - ItemStack itemstack = this.player.bC(); + ItemStack itemstack = this.player.bP(); boolean flag1 = this.player.b(Block.byId[l]); if (itemstack != null) { itemstack.a(this.world, l, i, j, k, this.player); if (itemstack.count == 0) { - this.player.bD(); + this.player.bQ(); } } @@ -328,19 +328,25 @@ public class ItemInWorldManager { int j = itemstack.getData(); ItemStack itemstack1 = itemstack.a(world, entityhuman); - if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i) && (itemstack1 == null || itemstack1.m() <= 0)) { + if (itemstack1 == itemstack && (itemstack1 == null || itemstack1.count == i && itemstack1.m() <= 0 && itemstack1.getData() == j)) { return false; } else { entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = itemstack1; if (this.isCreative()) { itemstack1.count = i; - itemstack1.setData(j); + if (itemstack1.f()) { + itemstack1.setData(j); + } } if (itemstack1.count == 0) { entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null; } + if (!entityhuman.bI()) { + ((EntityPlayer) entityhuman).updateInventory(entityhuman.defaultContainer); + } + return true; } } diff --git a/src/main/java/net/minecraft/server/ItemMonsterEgg.java b/src/main/java/net/minecraft/server/ItemMonsterEgg.java index 7302e072..6769b1a3 100644 --- a/src/main/java/net/minecraft/server/ItemMonsterEgg.java +++ b/src/main/java/net/minecraft/server/ItemMonsterEgg.java @@ -8,8 +8,19 @@ public class ItemMonsterEgg extends Item { this.a(CreativeModeTab.f); } + public String j(ItemStack itemstack) { + String s = ("" + LocaleI18n.get(this.getName() + ".name")).trim(); + String s1 = EntityTypes.a(itemstack.getData()); + + if (s1 != null) { + s = s + " " + LocaleI18n.get("entity." + s1 + ".name"); + } + + return s; + } + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63) { // CraftBukkit + if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63 || itemstack.getData() == 64) { // CraftBukkit return true; } else { int i1 = world.getTypeId(i, j, k); @@ -23,7 +34,7 @@ public class ItemMonsterEgg extends Item { d0 = 0.5D; } - if (a(world, itemstack.getData(), (double) i + 0.5D, (double) j + d0, (double) k + 0.5D) && !entityhuman.abilities.canInstantlyBuild) { + if (a(world, itemstack.getData(), (double) i + 0.5D, (double) j + d0, (double) k + 0.5D) != null && !entityhuman.abilities.canInstantlyBuild) { --itemstack.count; } @@ -31,27 +42,23 @@ public class ItemMonsterEgg extends Item { } } - public static boolean a(World world, int i, double d0, double d1, double d2) { + public static Entity a(World world, int i, double d0, double d1, double d2) { if (!EntityTypes.a.containsKey(Integer.valueOf(i))) { - return false; + return null; } else { - Entity entity = EntityTypes.a(i, world); - - if (entity != null && entity instanceof EntityLiving) { // CraftBukkit - entity.setPositionRotation(d0, d1, d2, world.random.nextFloat() * 360.0F, 0.0F); - if (entity instanceof EntityVillager) { - EntityVillager entityvillager = (EntityVillager) entity; + Entity entity = null; - entityvillager.setProfession(entityvillager.au().nextInt(5)); - world.addEntity(entityvillager); - return true; + for (int j = 0; j < 1; ++j) { + entity = EntityTypes.a(i, world); + if (entity != null && entity instanceof EntityLiving) { // CraftBukkit + entity.setPositionRotation(d0, d1, d2, world.random.nextFloat() * 360.0F, 0.0F); + ((EntityLiving) entity).bD(); + world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit + ((EntityLiving) entity).aN(); } - - world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - ((EntityLiving) entity).aH(); } - return entity != null; + return entity; } } } diff --git a/src/main/java/net/minecraft/server/ItemPainting.java b/src/main/java/net/minecraft/server/ItemPainting.java deleted file mode 100644 index 46b7ac7c..00000000 --- a/src/main/java/net/minecraft/server/ItemPainting.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.minecraft.server; - -// CraftBukkit start -import org.bukkit.entity.Player; -import org.bukkit.event.painting.PaintingPlaceEvent; -// CraftBukkit end - -public class ItemPainting extends Item { - - public ItemPainting(int i) { - super(i); - this.a(CreativeModeTab.c); - } - - public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { - if (l == 0) { - return false; - } else if (l == 1) { - return false; - } else { - byte b0 = 0; - - if (l == 4) { - b0 = 1; - } - - if (l == 3) { - b0 = 2; - } - - if (l == 5) { - b0 = 3; - } - - if (!entityhuman.e(i, j, k)) { - return false; - } else { - EntityPainting entitypainting = new EntityPainting(world, i, j, k, b0); - - if (entitypainting.survives()) { - if (!world.isStatic) { - // CraftBukkit start - Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); - - org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); - org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(l); - - PaintingPlaceEvent event = new PaintingPlaceEvent((org.bukkit.entity.Painting) entitypainting.getBukkitEntity(), who, blockClicked, blockFace); - world.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return false; - } - // CraftBukkit end - world.addEntity(entitypainting); - } - - --itemstack.count; - } - - return true; - } - } - } -} diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index c0df7cd8..c9f91dae 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -42,7 +42,7 @@ public class ItemRedstone extends Item { } } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { 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 896f5121..66c54674 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -43,7 +43,7 @@ public class ItemReed extends Item { } } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else if (itemstack.count == 0) { return false; @@ -81,7 +81,7 @@ public class ItemReed extends Item { Block.byId[this.id].postPlace(world, i, j, k, entityhuman); } - world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.getName(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); + world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), block.stepSound.b(), (block.stepSound.getVolume1() + 1.0F) / 2.0F, block.stepSound.getVolume2() * 0.8F); --itemstack.count; } } diff --git a/src/main/java/net/minecraft/server/ItemSeedFood.java b/src/main/java/net/minecraft/server/ItemSeedFood.java new file mode 100644 index 00000000..7e56763f --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemSeedFood.java @@ -0,0 +1,45 @@ +package net.minecraft.server; + +import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit + +public class ItemSeedFood extends ItemFood { + + private int b; + private int c; + + public ItemSeedFood(int i, int j, float f, int k, int l) { + super(i, j, f, false); + this.b = k; + this.c = l; + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l != 1) { + return false; + } else if (entityhuman.a(i, j, k, l, itemstack) && entityhuman.a(i, j + 1, k, l, itemstack)) { + int i1 = world.getTypeId(i, j, k); + + if (i1 == this.c && world.isEmpty(i, j + 1, k)) { + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j + 1, k); // CraftBukkit + + world.setTypeId(i, j + 1, k, this.b); + + // CraftBukkit start - seeds + org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k); + + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeId(0); + return false; + } + // CraftBukkit end + + --itemstack.count; + return true; + } else { + return false; + } + } else { + return false; + } + } +} diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index c195a85f..1d09df1c 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -38,7 +38,7 @@ public class ItemSign extends Item { ++i; } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else if (!Block.SIGN_POST.canPlace(world, i, j, k)) { return false; @@ -66,7 +66,7 @@ public class ItemSign extends Item { TileEntitySign tileentitysign = (TileEntitySign) world.getTileEntity(i, j, k); if (tileentitysign != null) { - entityhuman.a(tileentitysign); + entityhuman.a((TileEntity) tileentitysign); } return true; diff --git a/src/main/java/net/minecraft/server/ItemSkull.java b/src/main/java/net/minecraft/server/ItemSkull.java new file mode 100644 index 00000000..4461dd63 --- /dev/null +++ b/src/main/java/net/minecraft/server/ItemSkull.java @@ -0,0 +1,105 @@ +package net.minecraft.server; + +import org.bukkit.craftbukkit.block.CraftBlockState; // CraftBukkit + +public class ItemSkull extends Item { + + private static final String[] a = new String[] { "skeleton", "wither", "zombie", "char", "creeper"}; + private static final int[] b = new int[] { 224, 225, 226, 227, 228}; + + public ItemSkull(int i) { + super(i); + this.a(CreativeModeTab.c); + this.setMaxDurability(0); + this.a(true); + } + + public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) { + if (l == 0) { + return false; + } else if (!world.getMaterial(i, j, k).isBuildable()) { + return false; + } else { + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + + if (l == 1) { + ++j; + } + + if (l == 2) { + --k; + } + + if (l == 3) { + ++k; + } + + if (l == 4) { + --i; + } + + if (l == 5) { + ++i; + } + + if (!entityhuman.a(i, j, k, l, itemstack)) { + return false; + } else if (!Block.SKULL.canPlace(world, i, j, k)) { + return false; + } else { + CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + + world.setTypeIdAndData(i, j, k, Block.SKULL.id, l); + int i1 = 0; + + if (l == 1) { + i1 = MathHelper.floor((double) (entityhuman.yaw * 16.0F / 360.0F) + 0.5D) & 15; + } + + TileEntity tileentity = world.getTileEntity(i, j, k); + + if (tileentity != null && tileentity instanceof TileEntitySkull) { + String s = ""; + + if (itemstack.hasTag() && itemstack.getTag().hasKey("SkullOwner")) { + s = itemstack.getTag().getString("SkullOwner"); + } + + ((TileEntitySkull) tileentity).a(itemstack.getData(), s); + ((TileEntitySkull) tileentity).a(i1); + ((BlockSkull) Block.SKULL).a(world, i, j, k, (TileEntitySkull) tileentity); + } + + // CraftBukkit start + org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ); + + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; + } + // CraftBukkit end + + --itemstack.count; + return true; + } + } + } + + public int filterData(int i) { + return i; + } + + public String c_(ItemStack itemstack) { + int i = itemstack.getData(); + + if (i < 0 || i >= a.length) { + i = 0; + } + + return super.getName() + "." + a[i]; + } + + public String j(ItemStack itemstack) { + return itemstack.getData() == 3 && itemstack.hasTag() && itemstack.getTag().hasKey("SkullOwner") ? LocaleI18n.get("item.skull.player.name", new Object[] { itemstack.getTag().getString("SkullOwner")}) : super.j(itemstack); + } +} diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index cee75b55..05e5df36 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -7,6 +7,7 @@ public final class ItemStack { public int id; public NBTTagCompound tag; private int damage; + private EntityItemFrame f; public ItemStack(Block block) { this(block, 1); @@ -34,6 +35,7 @@ public final class ItemStack { public ItemStack(int i, int j, int k) { this.count = 0; + this.f = null; this.id = i; this.count = j; this.setData(k); // CraftBukkit @@ -49,7 +51,7 @@ public final class ItemStack { } this.tag.set("ench", enchantments.clone()); // modify this part to use passed in enchantments list - // TODO Books + // TODO Books, Skulls, Item Names, Item Lore } } // CraftBukkit end @@ -63,6 +65,7 @@ public final class ItemStack { private ItemStack() { this.count = 0; + this.f = null; } public ItemStack a(int i) { @@ -135,7 +138,7 @@ public final class ItemStack { } public boolean usesData() { - return Item.byId[this.id].k(); + return Item.byId[this.id].l(); } public boolean h() { @@ -161,7 +164,7 @@ public final class ItemStack { public void damage(int i, EntityLiving entityliving) { if (this.f()) { if (i > 0 && entityliving instanceof EntityHuman) { - int j = EnchantmentManager.getDurabilityEnchantmentLevel(((EntityHuman) entityliving).inventory); + int j = EnchantmentManager.getDurabilityEnchantmentLevel(entityliving); if (j > 0 && entityliving.world.random.nextInt(j + 1) > 0) { return; @@ -249,7 +252,7 @@ public final class ItemStack { } public String a() { - return Item.byId[this.id].c(this); + return Item.byId[this.id].c_(this); } public static ItemStack b(ItemStack itemstack) { @@ -273,16 +276,12 @@ public final class ItemStack { Item.byId[this.id].d(this, world, entityhuman); } - public boolean c(ItemStack itemstack) { - return this.id == itemstack.id && this.count == itemstack.count && this.damage == itemstack.damage; - } - public int m() { return this.getItem().a(this); } public EnumAnimation n() { - return this.getItem().b(this); + return this.getItem().d_(this); } public void b(World world, EntityHuman entityhuman, int i) { @@ -305,7 +304,37 @@ public final class ItemStack { this.tag = nbttagcompound; } - public boolean u() { + public String r() { + String s = this.getItem().j(this); + + if (this.tag != null && this.tag.hasKey("display")) { + NBTTagCompound nbttagcompound = this.tag.getCompound("display"); + + if (nbttagcompound.hasKey("Name")) { + s = nbttagcompound.getString("Name"); + } + } + + return s; + } + + public void c(String s) { + if (this.tag == null) { + this.tag = new NBTTagCompound(); + } + + if (!this.tag.hasKey("display")) { + this.tag.setCompound("display", new NBTTagCompound()); + } + + this.tag.getCompound("display").setString("Name", s); + } + + public boolean s() { + return this.tag == null ? false : (!this.tag.hasKey("display") ? false : this.tag.getCompound("display").hasKey("Name")); + } + + public boolean v() { return !this.getItem().k(this) ? false : !this.hasEnchantments(); } @@ -330,7 +359,6 @@ public final class ItemStack { return this.tag != null && this.tag.hasKey("ench"); } - // CraftBukkit start - temporary method for book fix public void a(String s, NBTBase nbtbase) { if (this.tag == null) { this.setTag(new NBTTagCompound()); @@ -338,5 +366,32 @@ public final class ItemStack { this.tag.set(s, nbtbase); } - // CraftBukkit end + + public boolean x() { + return this.getItem().x(); + } + + public boolean y() { + return this.f != null; + } + + public void a(EntityItemFrame entityitemframe) { + this.f = entityitemframe; + } + + public EntityItemFrame z() { + return this.f; + } + + public int getRepairCost() { + return this.hasTag() && this.tag.hasKey("RepairCost") ? this.tag.getInt("RepairCost") : 0; + } + + public void setRepairCost(int i) { + if (!this.hasTag()) { + this.tag = new NBTTagCompound(); + } + + this.tag.setInt("RepairCost", i); + } } diff --git a/src/main/java/net/minecraft/server/ItemStep.java b/src/main/java/net/minecraft/server/ItemStep.java index 5da4a455..608a36bc 100644 --- a/src/main/java/net/minecraft/server/ItemStep.java +++ b/src/main/java/net/minecraft/server/ItemStep.java @@ -19,7 +19,7 @@ public class ItemStep extends ItemBlock { return i; } - public String c(ItemStack itemstack) { + public String c_(ItemStack itemstack) { return this.b.d(itemstack.getData()); } @@ -28,7 +28,7 @@ public class ItemStep extends ItemBlock { return super.interactWith(itemstack, entityhuman, world, i, j, k, l, f, f1, f2); } else if (itemstack.count == 0) { return false; - } else if (!entityhuman.e(i, j, k)) { + } else if (!entityhuman.a(i, j, k, l, itemstack)) { return false; } else { int i1 = world.getTypeId(i, j, k); diff --git a/src/main/java/net/minecraft/server/ItemWaterLily.java b/src/main/java/net/minecraft/server/ItemWaterLily.java index 5532bc2e..b1c43e80 100644 --- a/src/main/java/net/minecraft/server/ItemWaterLily.java +++ b/src/main/java/net/minecraft/server/ItemWaterLily.java @@ -23,7 +23,7 @@ public class ItemWaterLily extends ItemWithAuxData { return itemstack; } - if (!entityhuman.e(i, j, k)) { + if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) { return itemstack; } diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java index 7c1f926d..cf3bb1ff 100644 --- a/src/main/java/net/minecraft/server/ItemWorldMap.java +++ b/src/main/java/net/minecraft/server/ItemWorldMap.java @@ -9,24 +9,24 @@ public class ItemWorldMap extends ItemWorldMapBase { protected ItemWorldMap(int i) { super(i); - this.d(1); - this.a(CreativeModeTab.f); + this.a(true); } public WorldMap getSavedMap(ItemStack itemstack, World world) { + String s = "map_" + itemstack.getData(); + WorldMap worldmap = (WorldMap) world.a(WorldMap.class, s); - WorldMap worldmap = (WorldMap) world.a(WorldMap.class, "map_" + itemstack.getData()); - - if (worldmap == null) { + if (worldmap == null && !world.isStatic) { itemstack.setData(world.b("map")); - String s = "map_" + itemstack.getData(); - + s = "map_" + itemstack.getData(); worldmap = new WorldMap(s); - worldmap.centerX = world.getWorldData().c(); - worldmap.centerZ = world.getWorldData().e(); worldmap.scale = 3; - worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps. - worldmap.a(); + int i = 128 * (1 << worldmap.scale); + + worldmap.centerX = Math.round((float) world.getWorldData().c() / (float) i) * i; + worldmap.centerZ = Math.round((float) (world.getWorldData().e() / i)) * i; + worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps + worldmap.c(); world.a(s, (WorldMapBase) worldmap); // CraftBukkit start @@ -39,7 +39,8 @@ public class ItemWorldMap extends ItemWorldMapBase { } public void a(World world, Entity entity, WorldMap worldmap) { - if (((WorldServer) world).dimension == worldmap.map) { // CraftBukkit + // CraftBukkit + if (((WorldServer) world).dimension == worldmap.map && entity instanceof EntityHuman) { short short1 = 128; short short2 = 128; int i = 1 << worldmap.scale; @@ -49,14 +50,16 @@ public class ItemWorldMap extends ItemWorldMapBase { int i1 = MathHelper.floor(entity.locZ - (double) k) / i + short2 / 2; int j1 = 128 / i; - if (world.worldProvider.e) { + if (world.worldProvider.f) { j1 /= 2; } - ++worldmap.f; + WorldMapHumanTracker worldmaphumantracker = worldmap.a((EntityHuman) entity); + + ++worldmaphumantracker.d; for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) { - if ((k1 & 15) == (worldmap.f & 15)) { + if ((k1 & 15) == (worldmaphumantracker.d & 15)) { int l1 = 255; int i2 = 0; double d0 = 0.0D; @@ -68,9 +71,6 @@ public class ItemWorldMap extends ItemWorldMapBase { boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2); int i3 = (j / i + k1 - short1 / 2) * i; int j3 = (k / i + j2 - short2 / 2) * i; - byte b0 = 0; - byte b1 = 0; - byte b2 = 0; int[] aint = new int[256]; Chunk chunk = world.getChunkAtWorldCoords(i3, j3); @@ -84,10 +84,10 @@ public class ItemWorldMap extends ItemWorldMapBase { int l4; int i5; - if (world.worldProvider.e) { - l4 = i3 + j3 * 231871; - l4 = l4 * l4 * 31287121 + l4 * 11; - if ((l4 >> 20 & 1) == 0) { + if (world.worldProvider.f) { + j4 = i3 + j3 * 231871; + j4 = j4 * j4 * 31287121 + j4 * 11; + if ((j4 >> 20 & 1) == 0) { aint[Block.DIRT.id] += 10; } else { aint[Block.STONE.id] += 10; @@ -95,91 +95,87 @@ public class ItemWorldMap extends ItemWorldMapBase { d1 = 100.0D; } else { - for (l4 = 0; l4 < i; ++l4) { - for (j4 = 0; j4 < i; ++j4) { - k4 = chunk.b(l4 + k3, j4 + l3) + 1; + for (j4 = 0; j4 < i; ++j4) { + for (k4 = 0; k4 < i; ++k4) { + l4 = chunk.b(j4 + k3, k4 + l3) + 1; int j5 = 0; - if (k4 > 1) { - boolean flag1 = false; + if (l4 > 1) { + boolean flag1; do { flag1 = true; - j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3); + j5 = chunk.getTypeId(j4 + k3, l4 - 1, k4 + l3); if (j5 == 0) { flag1 = false; - } else if (k4 > 0 && j5 > 0 && Block.byId[j5].material.F == MaterialMapColor.b) { + } else if (l4 > 0 && j5 > 0 && Block.byId[j5].material.G == MaterialMapColor.b) { flag1 = false; } if (!flag1) { - --k4; - if (k4 <= 0) { + --l4; + if (l4 <= 0) { break; } - j5 = chunk.getTypeId(l4 + k3, k4 - 1, j4 + l3); + j5 = chunk.getTypeId(j4 + k3, l4 - 1, k4 + l3); } - } while (k4 > 0 && !flag1); + } while (l4 > 0 && !flag1); - if (k4 > 0 && j5 != 0 && Block.byId[j5].material.isLiquid()) { - i5 = k4 - 1; + if (l4 > 0 && j5 != 0 && Block.byId[j5].material.isLiquid()) { + i5 = l4 - 1; boolean flag2 = false; int k5; do { - k5 = chunk.getTypeId(l4 + k3, i5--, j4 + l3); + k5 = chunk.getTypeId(j4 + k3, i5--, k4 + l3); ++i4; } while (i5 > 0 && k5 != 0 && Block.byId[k5].material.isLiquid()); } } - d1 += (double) k4 / (double) (i * i); + d1 += (double) l4 / (double) (i * i); ++aint[j5]; } } } i4 /= i * i; - int l5 = b0 / (i * i); - - l5 = b1 / (i * i); - l5 = b2 / (i * i); - l4 = 0; j4 = 0; + k4 = 0; - for (k4 = 0; k4 < 256; ++k4) { - if (aint[k4] > l4) { - j4 = k4; - l4 = aint[k4]; + for (l4 = 0; l4 < 256; ++l4) { + if (aint[l4] > j4) { + k4 = l4; + j4 = aint[l4]; } } double d2 = (d1 - d0) * 4.0D / (double) (i + 4) + ((double) (k1 + j2 & 1) - 0.5D) * 0.4D; - byte b3 = 1; + byte b0 = 1; if (d2 > 0.6D) { - b3 = 2; + b0 = 2; } if (d2 < -0.6D) { - b3 = 0; + b0 = 0; } i5 = 0; - if (j4 > 0) { - MaterialMapColor materialmapcolor = Block.byId[j4].material.F; + if (k4 > 0) { + MaterialMapColor materialmapcolor = Block.byId[k4].material.G; if (materialmapcolor == MaterialMapColor.n) { d2 = (double) i4 * 0.1D + (double) (k1 + j2 & 1) * 0.2D; - b3 = 1; + b0 = 1; if (d2 < 0.5D) { - b3 = 2; + b0 = 2; } if (d2 > 0.9D) { - b3 = 0; + b0 = 0; } } @@ -188,10 +184,10 @@ public class ItemWorldMap extends ItemWorldMapBase { d0 = d1; if (j2 >= 0 && k2 * k2 + l2 * l2 < j1 * j1 && (!flag || (k1 + j2 & 1) != 0)) { - byte b4 = worldmap.colors[k1 + j2 * short1]; - byte b5 = (byte) (i5 * 4 + b3); + byte b1 = worldmap.colors[k1 + j2 * short1]; + byte b2 = (byte) (i5 * 4 + b0); - if (b4 != b5) { + if (b1 != b2) { if (l1 > j2) { l1 = j2; } @@ -200,7 +196,7 @@ public class ItemWorldMap extends ItemWorldMapBase { i2 = j2; } - worldmap.colors[k1 + j2 * short1] = b5; + worldmap.colors[k1 + j2 * short1] = b2; } } } @@ -231,27 +227,34 @@ public class ItemWorldMap extends ItemWorldMapBase { } } - public void d(ItemStack itemstack, World world, EntityHuman entityhuman) { - itemstack.setData(world.b("map")); - String s = "map_" + itemstack.getData(); - WorldMap worldmap = new WorldMap(s); - - world.a(s, (WorldMapBase) worldmap); - worldmap.centerX = MathHelper.floor(entityhuman.locX); - worldmap.centerZ = MathHelper.floor(entityhuman.locZ); - worldmap.scale = 3; - worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps. - worldmap.a(); - - // CraftBukkit start - MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); - Bukkit.getServer().getPluginManager().callEvent(event); - // CraftBukkit end - } - public Packet c(ItemStack itemstack, World world, EntityHuman entityhuman) { byte[] abyte = this.getSavedMap(itemstack, world).getUpdatePacket(itemstack, world, entityhuman); return abyte == null ? null : new Packet131ItemData((short) Item.MAP.id, (short) itemstack.getData(), abyte); } + + public void d(ItemStack itemstack, World world, EntityHuman entityhuman) { + if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) { + WorldMap worldmap = Item.MAP.getSavedMap(itemstack, world); + + itemstack.setData(world.b("map")); + WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData()); + + worldmap1.scale = (byte) (worldmap.scale + 1); + if (worldmap1.scale > 4) { + worldmap1.scale = 4; + } + + worldmap1.centerX = worldmap.centerX; + worldmap1.centerZ = worldmap.centerZ; + worldmap1.map = worldmap.map; + worldmap1.c(); + world.a("map_" + itemstack.getData(), (WorldMapBase) worldmap1); + + // CraftBukkit start + MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); + Bukkit.getServer().getPluginManager().callEvent(event); + // CraftBukkit end + } + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 9b00bb7f..96a17006 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -89,6 +89,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC // this.universe = file1; // CraftBukkit this.q = new CommandDispatcher(); // this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved to DedicatedServer.init + this.al(); // CraftBukkit start this.options = options; @@ -112,26 +113,47 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC primaryThread = new ThreadServerApplication(this, "Server thread"); // Moved from main } - public abstract PropertyManager getPropertyManager(); // protected -> public + public abstract PropertyManager getPropertyManager(); // CraftBukkit end + private void al() { + BlockDispenser.a.a(Item.ARROW, new DispenseBehaviorArrow(this)); + BlockDispenser.a.a(Item.EGG, new DispenseBehaviorEgg(this)); + BlockDispenser.a.a(Item.SNOW_BALL, new DispenseBehaviorSnowBall(this)); + BlockDispenser.a.a(Item.EXP_BOTTLE, new DispenseBehaviorExpBottle(this)); + BlockDispenser.a.a(Item.POTION, new DispenseBehaviorPotion(this)); + BlockDispenser.a.a(Item.MONSTER_EGG, new DispenseBehaviorMonsterEgg(this)); + BlockDispenser.a.a(Item.FIREBALL, new DispenseBehaviorFireball(this)); + DispenseBehaviorMinecart dispensebehaviorminecart = new DispenseBehaviorMinecart(this); + + BlockDispenser.a.a(Item.MINECART, dispensebehaviorminecart); + BlockDispenser.a.a(Item.STORAGE_MINECART, dispensebehaviorminecart); + BlockDispenser.a.a(Item.POWERED_MINECART, dispensebehaviorminecart); + BlockDispenser.a.a(Item.BOAT, new DispenseBehaviorBoat(this)); + DispenseBehaviorFilledBucket dispensebehaviorfilledbucket = new DispenseBehaviorFilledBucket(this); + + BlockDispenser.a.a(Item.LAVA_BUCKET, dispensebehaviorfilledbucket); + BlockDispenser.a.a(Item.WATER_BUCKET, dispensebehaviorfilledbucket); + BlockDispenser.a.a(Item.BUCKET, new DispenseBehaviorEmptyBucket(this)); + } + protected abstract boolean init() throws java.net.UnknownHostException; // CraftBukkit - throws UnknownHostException - protected void c(String s) { + protected void b(String s) { if (this.getConvertable().isConvertable(s)) { log.info("Converting map!"); - this.d("menu.convertingLevel"); + this.c("menu.convertingLevel"); this.getConvertable().convert(s, new ConvertProgressUpdater(this)); } } - protected synchronized void d(String s) { + protected synchronized void c(String s) { this.S = s; } - protected void a(String s, String s1, long i, WorldType worldtype) { - this.c(s); - this.d("menu.loadingLevel"); + protected void a(String s, String s1, long i, WorldType worldtype, String s2) { + this.b(s); + this.c("menu.loadingLevel"); // CraftBukkit - removed world and ticktime arrays IDataManager idatamanager = this.convertable.a(s, true); WorldData worlddata = idatamanager.getWorldData(); @@ -151,7 +173,6 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } if (j == 2) { - // don't do this in server.properties, do it in bukkit.yml if (this.server.getAllowEnd()) { dimension = 1; } else { @@ -166,7 +187,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); if (j == 0) { - if (this.L()) { // Strip out DEMO? + if (this.M()) { // Strip out DEMO? // CraftBukkit world = new DemoWorldServer(this, new ServerNBTManager(server.getWorldContainer(), s1, true), s1, dimension, this.methodProfiler); } else { @@ -215,7 +236,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); world.addIWorldAccess(new WorldManager(this, world)); - if (!this.H()) { + if (!this.I()) { world.getWorldData().setGameType(this.getGamemode()); } this.worlds.add(world); @@ -224,14 +245,15 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } this.c(this.getDifficulty()); - this.d(); + this.e(); } - protected void d() { + protected void e() { short short1 = 196; long i = System.currentTimeMillis(); - this.d("menu.generatingTerrain"); + this.c("menu.generatingTerrain"); + byte b0 = 0; // CraftBukkit start for (int j = 0; j < this.worlds.size(); ++j) { @@ -260,21 +282,11 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } worldserver.chunkProviderServer.getChunkAt(chunkcoordinates.x + k >> 4, chunkcoordinates.z + l >> 4); - - while (worldserver.updateLights() && this.isRunning()) { - ; - } } } } - // CraftBukkit start - for (World world : this.worlds) { - this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); - } - // CraftBukkit end - - this.i(); + this.j(); } public abstract boolean getGenerateStructures(); @@ -291,7 +303,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC log.info(s + ": " + i + "%"); } - protected void i() { + protected void j() { this.d = null; this.e = 0; @@ -329,8 +341,8 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } // CraftBukkit end - if (this.ac() != null) { - this.ac().a(); + if (this.ae() != null) { + this.ae().a(); } if (this.t != null) { @@ -361,7 +373,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC return this.serverIp; } - public void e(String s) { + public void d(String s) { this.serverIp = s; } @@ -397,13 +409,13 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC j += l; i = k; if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit - this.p(); + this.q(); j = 0L; } else { while (j > 50L) { MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit j -= 50L; - this.p(); + this.q(); } } @@ -423,7 +435,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC crashreport = this.b(new CrashReport("Exception in server tick loop", throwable)); } - File file1 = new File(new File(this.n(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); + File file1 = new File(new File(this.o(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); if (crashreport.a(file1)) { log.severe("This crash report has been saved to: " + file1.getAbsolutePath()); @@ -445,24 +457,23 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } catch (Exception e) { } // CraftBukkit end - this.o(); + this.p(); } } } - protected File n() { + protected File o() { return new File("."); } protected void a(CrashReport crashreport) {} - protected void o() {} + protected void p() {} - protected void p() throws ExceptionWorldConflict { // CraftBukkit - added throws + protected void q() throws ExceptionWorldConflict { // CraftBukkit - added throws long i = System.nanoTime(); AxisAlignedBB.a().a(); - Vec3D.a().a(); ++this.ticks; if (this.T) { this.T = false; @@ -471,7 +482,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } this.methodProfiler.a("root"); - this.q(); + this.r(); if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit this.methodProfiler.a("save"); this.t.savePlayers(); @@ -503,7 +514,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC this.methodProfiler.b(); } - public void q() { + public void r() { this.methodProfiler.a("levels"); // CraftBukkit start - only send timeupdates to the people in that world @@ -518,7 +529,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC if (this.ticks % 20 == 0) { for (int i = 0; i < this.getServerConfigurationManager().players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.getServerConfigurationManager().players.get(i); - entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time + entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime(), entityplayer.world.F())); // Add support for per player time } } @@ -528,37 +539,33 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC // if (i == 0 || this.getAllowNether()) { WorldServer worldserver = this.worlds.get(i); - /* Drop global timeupdates - this.b.a(worldserver.getWorldData().j()); + this.methodProfiler.a(worldserver.getWorldData().getName()); + this.methodProfiler.a("pools"); + worldserver.getVec3DPool().a(); + this.methodProfiler.b(); + /* Drop global time updates if (this.ticks % 20 == 0) { - this.b.a("timeSync"); - this.t.a(new Packet4UpdateTime(worldserver.getTime()), worldserver.worldProvider.dimension); - this.b.b(); + this.methodProfiler.a("timeSync"); + this.t.a(new Packet4UpdateTime(worldserver.getTime(), worldserver.F()), worldserver.worldProvider.dimension); + this.methodProfiler.b(); } // CraftBukkit end */ this.methodProfiler.a("tick"); worldserver.doTick(); - this.methodProfiler.c("lights"); - - while (true) { - if (!worldserver.updateLights()) { - this.methodProfiler.b(); - worldserver.tickEntities(); - this.methodProfiler.a("tracker"); - worldserver.getTracker().updatePlayers(); - this.methodProfiler.b(); - this.methodProfiler.b(); - break; - } - } + worldserver.tickEntities(); + this.methodProfiler.b(); + this.methodProfiler.a("tracker"); + worldserver.getTracker().updatePlayers(); + this.methodProfiler.b(); + this.methodProfiler.b(); // } // CraftBukkit // this.k[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit } this.methodProfiler.c("connection"); - this.ac().b(); + this.ae().b(); this.methodProfiler.c("players"); this.t.tick(); this.methodProfiler.c("tickables"); @@ -646,16 +653,16 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } if (options.has("world")) { - dedicatedserver.m((String) options.valueOf("world")); + dedicatedserver.l((String) options.valueOf("world")); } /* if (s != null) { - dedicatedserver.l(s); + dedicatedserver.k(s); } if (s2 != null) { - dedicatedserver.m(s2); + dedicatedserver.l(s2); } if (i >= 0) { @@ -671,7 +678,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } if (flag) { - dedicatedserver.ak(); + dedicatedserver.an(); } */ @@ -683,12 +690,12 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } } - public void s() { + public void t() { // (new ThreadServerApplication(this, "Server thread")).start(); // CraftBukkit - prevent abuse } - public File f(String s) { - return new File(this.n(), s); + public File e(String s) { + return new File(this.o(), s); } public void info(String s) { @@ -711,27 +718,27 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC // CraftBukkit end } - public String t() { + public String u() { return this.serverIp; } - public int u() { + public int v() { return this.s; } - public String v() { + public String w() { return this.motd; } public String getVersion() { - return "1.3.2"; + return "1.4.2"; } - public int x() { + public int y() { return this.t.getPlayerCount(); } - public int y() { + public int z() { return this.t.getMaxPlayers(); } @@ -767,11 +774,11 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } // CraftBukkit start - public String i(final String s) { // CraftBukkit - final parameter + public String h(final String s) { // CraftBukkit - final parameter Waitable<String> waitable = new Waitable<String>() { @Override protected String evaluate() { - RemoteControlCommandListener.instance.b(); + RemoteControlCommandListener.instance.c(); // Event changes start RemoteServerCommandEvent event = new RemoteServerCommandEvent(MinecraftServer.this.remoteConsole, s); MinecraftServer.this.server.getPluginManager().callEvent(event); @@ -779,7 +786,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC ServerCommand servercommand = new ServerCommand(event.getCommand(), RemoteControlCommandListener.instance); // this.q.a(RemoteControlCommandListener.instance, s); MinecraftServer.this.server.dispatchServerCommand(MinecraftServer.this.remoteConsole, servercommand); // CraftBukkit - return RemoteControlCommandListener.instance.c(); + return RemoteControlCommandListener.instance.d(); }}; processQueue.add(waitable); try { @@ -797,11 +804,11 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode } - public void j(String s) { + public void i(String s) { log.log(Level.SEVERE, s); } - public void k(String s) { + public void j(String s) { if (this.isDebugging()) { log.log(Level.INFO, s); } @@ -891,7 +898,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC log.info(StripColor.a(s)); } - public boolean b(String s) { + public boolean a(int i, String s) { return true; } @@ -903,11 +910,11 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC return this.q; } - public KeyPair E() { + public KeyPair F() { return this.I; } - public int F() { + public int G() { return this.s; } @@ -915,23 +922,23 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC this.s = i; } - public String G() { + public String H() { return this.J; } - public void l(String s) { + public void k(String s) { this.J = s; } - public boolean H() { + public boolean I() { return this.J != null; } - public String I() { + public String J() { return this.K; } - public void m(String s) { + public void l(String s) { this.K = s; } @@ -949,7 +956,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC if (worldserver.getWorldData().isHardcore()) { worldserver.difficulty = 3; worldserver.setSpawnFlags(true, true); - } else if (this.H()) { + } else if (this.I()) { worldserver.difficulty = i; worldserver.setSpawnFlags(worldserver.difficulty > 0, true); } else { @@ -964,7 +971,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC return true; } - public boolean L() { + public boolean M() { return this.demoMode; } @@ -980,7 +987,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC return this.convertable; } - public void O() { + public void P() { this.O = true; this.getConvertable().d(); @@ -994,7 +1001,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } } - this.getConvertable().e(this.worlds.get(0).getDataManager().g()); + this.getConvertable().e(this.worlds.get(0).getDataManager().g()); // CraftBukkit this.safeShutdown(); } @@ -1009,11 +1016,11 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC public void a(MojangStatisticsGenerator mojangstatisticsgenerator) { mojangstatisticsgenerator.a("whitelist_enabled", Boolean.valueOf(false)); mojangstatisticsgenerator.a("whitelist_count", Integer.valueOf(0)); - mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.x())); - mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.y())); + mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.y())); + mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.z())); mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.t.getSeenPlayers().length)); mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.onlineMode)); - mojangstatisticsgenerator.a("gui_state", this.ae() ? "enabled" : "disabled"); + mojangstatisticsgenerator.a("gui_state", this.ag() ? "enabled" : "disabled"); mojangstatisticsgenerator.a("avg_tick_ms", Integer.valueOf((int) (MathHelper.a(this.j) * 1.0E-6D))); mojangstatisticsgenerator.a("avg_sent_packet_count", Integer.valueOf((int) MathHelper.a(this.f))); mojangstatisticsgenerator.a("avg_sent_packet_size", Integer.valueOf((int) MathHelper.a(this.g))); @@ -1035,7 +1042,7 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC mojangstatisticsgenerator.a("world[" + i + "][generator_name]", worlddata.getType().name()); mojangstatisticsgenerator.a("world[" + i + "][generator_version]", Integer.valueOf(worlddata.getType().getVersion())); mojangstatisticsgenerator.a("world[" + i + "][height]", Integer.valueOf(this.D)); - mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.F().getLoadedChunks())); + mojangstatisticsgenerator.a("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.H().getLoadedChunks())); ++i; // } // CraftBukkit } @@ -1044,21 +1051,21 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } public void b(MojangStatisticsGenerator mojangstatisticsgenerator) { - mojangstatisticsgenerator.a("singleplayer", Boolean.valueOf(this.H())); + mojangstatisticsgenerator.a("singleplayer", Boolean.valueOf(this.I())); mojangstatisticsgenerator.a("server_brand", this.getServerModName()); mojangstatisticsgenerator.a("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported"); - mojangstatisticsgenerator.a("dedicated", Boolean.valueOf(this.S())); + mojangstatisticsgenerator.a("dedicated", Boolean.valueOf(this.T())); } public boolean getSnooperEnabled() { return true; } - public int R() { + public int S() { return 16; } - public abstract boolean S(); + public abstract boolean T(); public boolean getOnlineMode() { return this.onlineMode; @@ -1100,6 +1107,8 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC this.allowFlight = flag; } + public abstract boolean getEnableCommandBlock(); + public String getMotd() { return this.motd; } @@ -1136,22 +1145,30 @@ public abstract class MinecraftServer implements Runnable, IMojangStatistics, IC } } - public abstract ServerConnection ac(); + public abstract ServerConnection ae(); - public boolean ae() { + public boolean ag() { return false; } public abstract String a(EnumGamemode enumgamemode, boolean flag); - public int af() { + public int ah() { return this.ticks; } - public void ag() { + public void ai() { this.T = true; } + public ChunkCoordinates b() { + return new ChunkCoordinates(0, 0, 0); + } + + public int getSpawnProtection() { + return 16; + } + public static ServerConfigurationManagerAbstract a(MinecraftServer minecraftserver) { return minecraftserver.t; } diff --git a/src/main/java/net/minecraft/server/MobEffectList.java b/src/main/java/net/minecraft/server/MobEffectList.java index 28785a01..d8846033 100644 --- a/src/main/java/net/minecraft/server/MobEffectList.java +++ b/src/main/java/net/minecraft/server/MobEffectList.java @@ -23,13 +23,13 @@ public class MobEffectList { public static final MobEffectList RESISTANCE = (new MobEffectList(11, false, 10044730)).b("potion.resistance").b(6, 1); public static final MobEffectList FIRE_RESISTANCE = (new MobEffectList(12, false, 14981690)).b("potion.fireResistance").b(7, 1); public static final MobEffectList WATER_BREATHING = (new MobEffectList(13, false, 3035801)).b("potion.waterBreathing").b(0, 2); - public static final MobEffectList INVISIBILITY = (new MobEffectList(14, false, 8356754)).b("potion.invisibility").b(0, 1).h(); + public static final MobEffectList INVISIBILITY = (new MobEffectList(14, false, 8356754)).b("potion.invisibility").b(0, 1); public static final MobEffectList BLINDNESS = (new MobEffectList(15, true, 2039587)).b("potion.blindness").b(5, 1).a(0.25D); - public static final MobEffectList NIGHT_VISION = (new MobEffectList(16, false, 2039713)).b("potion.nightVision").b(4, 1).h(); + public static final MobEffectList NIGHT_VISION = (new MobEffectList(16, false, 2039713)).b("potion.nightVision").b(4, 1); public static final MobEffectList HUNGER = (new MobEffectList(17, true, 5797459)).b("potion.hunger").b(1, 1); public static final MobEffectList WEAKNESS = (new MobEffectList(18, true, 4738376)).b("potion.weakness").b(5, 0); public static final MobEffectList POISON = (new MobEffectList(19, true, 5149489)).b("potion.poison").b(6, 0).a(0.25D); - public static final MobEffectList v = null; + public static final MobEffectList WITHER = (new MobEffectList(20, true, 3484199)).b("potion.wither").b(1, 2).a(0.25D); public static final MobEffectList w = null; public static final MobEffectList x = null; public static final MobEffectList y = null; @@ -88,10 +88,18 @@ public class MobEffectList { } // CraftBukkit end } + } else if (this.id == WITHER.id) { + // CraftBukkit start + EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, EntityDamageEvent.DamageCause.WITHER, 1); + + if (!event.isCancelled() && event.getDamage() > 0) { + entityliving.damageEntity(DamageSource.WITHER, event.getDamage()); + } + // CraftBukkit end } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) { ((EntityHuman) entityliving).j(0.025F * (float) (i + 1)); - } else if ((this.id != HEAL.id || entityliving.br()) && (this.id != HARM.id || !entityliving.br())) { - if (this.id == HARM.id && !entityliving.br() || this.id == HEAL.id && entityliving.br()) { + } else if ((this.id != HEAL.id || entityliving.bx()) && (this.id != HARM.id || !entityliving.bx())) { + if (this.id == HARM.id && !entityliving.bx() || this.id == HEAL.id && entityliving.bx()) { // CraftBukkit start EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, EntityDamageEvent.DamageCause.MAGIC, 6 << i); @@ -114,8 +122,8 @@ public class MobEffectList { // CraftBukkit end int j; - if ((this.id != HEAL.id || entityliving1.br()) && (this.id != HARM.id || !entityliving1.br())) { - if (this.id == HARM.id && !entityliving1.br() || this.id == HEAL.id && entityliving1.br()) { + if ((this.id != HEAL.id || entityliving1.bx()) && (this.id != HARM.id || !entityliving1.bx())) { + if (this.id == HARM.id && !entityliving1.bx() || this.id == HEAL.id && entityliving1.bx()) { j = (int) (d0 * (double) (6 << i) + 0.5D); if (entityliving == null) { entityliving1.damageEntity(DamageSource.MAGIC, j); @@ -135,11 +143,17 @@ public class MobEffectList { } public boolean a(int i, int j) { + int k; + if (this.id != REGENERATION.id && this.id != POISON.id) { - return this.id == HUNGER.id; + if (this.id == WITHER.id) { + k = 40 >> j; + return k > 0 ? i % k == 0 : true; + } else { + return this.id == HUNGER.id; + } } else { - int k = 25 >> j; - + k = 25 >> j; return k > 0 ? i % k == 0 : true; } } @@ -162,11 +176,6 @@ public class MobEffectList { return this.L; } - public MobEffectList h() { - this.M = true; - return this; - } - public boolean i() { return this.M; } diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java index cd264824..2bc1d6c7 100644 --- a/src/main/java/net/minecraft/server/NBTTagCompound.java +++ b/src/main/java/net/minecraft/server/NBTTagCompound.java @@ -6,6 +6,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.Callable; public class NBTTagCompound extends NBTBase { @@ -116,57 +117,118 @@ public class NBTTagCompound extends NBTBase { } public byte getByte(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagByte) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagByte) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 1, classcastexception)); + } } public short getShort(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagShort) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagShort) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 2, classcastexception)); + } } public int getInt(String s) { - return !this.map.containsKey(s) ? 0 : ((NBTTagInt) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0 : ((NBTTagInt) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 3, classcastexception)); + } } public long getLong(String s) { - return !this.map.containsKey(s) ? 0L : ((NBTTagLong) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0L : ((NBTTagLong) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 4, classcastexception)); + } } public float getFloat(String s) { - return !this.map.containsKey(s) ? 0.0F : ((NBTTagFloat) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0.0F : ((NBTTagFloat) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 5, classcastexception)); + } } public double getDouble(String s) { - return !this.map.containsKey(s) ? 0.0D : ((NBTTagDouble) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? 0.0D : ((NBTTagDouble) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 6, classcastexception)); + } } public String getString(String s) { - return !this.map.containsKey(s) ? "" : ((NBTTagString) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? "" : ((NBTTagString) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 8, classcastexception)); + } } public byte[] getByteArray(String s) { - return !this.map.containsKey(s) ? new byte[0] : ((NBTTagByteArray) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? new byte[0] : ((NBTTagByteArray) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 7, classcastexception)); + } } public int[] getIntArray(String s) { - return !this.map.containsKey(s) ? new int[0] : ((NBTTagIntArray) this.map.get(s)).data; + try { + return !this.map.containsKey(s) ? new int[0] : ((NBTTagIntArray) this.map.get(s)).data; + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 11, classcastexception)); + } } public NBTTagCompound getCompound(String s) { - return !this.map.containsKey(s) ? new NBTTagCompound(s) : (NBTTagCompound) this.map.get(s); + try { + return !this.map.containsKey(s) ? new NBTTagCompound(s) : (NBTTagCompound) this.map.get(s); + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 10, classcastexception)); + } } public NBTTagList getList(String s) { - return !this.map.containsKey(s) ? new NBTTagList(s) : (NBTTagList) this.map.get(s); + try { + return !this.map.containsKey(s) ? new NBTTagList(s) : (NBTTagList) this.map.get(s); + } catch (ClassCastException classcastexception) { + throw new ReportedException(this.a(s, 9, classcastexception)); + } } public boolean getBoolean(String s) { return this.getByte(s) != 0; } + public void o(String s) { + this.map.remove(s); + } + public String toString() { return "" + this.map.size() + " entries"; } + public boolean d() { + return this.map.isEmpty(); + } + + private CrashReport a(String s, int i, ClassCastException classcastexception) { + CrashReport crashreport = new CrashReport("Reading NBT data", classcastexception); + + crashreport.a("Corrupt tag type found", (Callable) (new CrashReportCorruptNBTTag(this, s))); + crashreport.a("Corrupt tag type expected", (Callable) (new CrashReportCorruptNBTTag2(this, i))); + crashreport.a("Corrupt tag name", s); + return crashreport; + } + public NBTBase clone() { NBTTagCompound nbttagcompound = new NBTTagCompound(this.getName()); Iterator iterator = this.map.keySet().iterator(); @@ -193,4 +255,8 @@ public class NBTTagCompound extends NBTBase { public int hashCode() { return super.hashCode() ^ this.map.hashCode(); } + + static Map a(NBTTagCompound nbttagcompound) { + return nbttagcompound.map; + } } diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index 2d8d25f2..f46a83ad 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -1,10 +1,13 @@ package net.minecraft.server; +import java.io.Serializable; import java.net.InetAddress; import java.net.Socket; import java.security.PrivateKey; import java.security.PublicKey; import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import java.util.Random; import java.util.logging.Logger; import javax.crypto.SecretKey; @@ -27,7 +30,7 @@ public class NetLoginHandler extends NetHandler { public NetLoginHandler(MinecraftServer minecraftserver, Socket socket, String s) throws java.io.IOException { // CraftBukkit - throws IOException this.server = minecraftserver; - this.networkManager = new NetworkManager(socket, s, this, minecraftserver.E().getPrivate()); + this.networkManager = new NetworkManager(socket, s, this, minecraftserver.F().getPrivate()); this.networkManager.e = 0; } @@ -68,10 +71,10 @@ public class NetLoginHandler extends NetHandler { if (!this.h.equals(StripColor.a(this.h))) { this.disconnect("Invalid username!"); } else { - PublicKey publickey = this.server.E().getPublic(); + PublicKey publickey = this.server.F().getPublic(); - if (packet2handshake.d() != 39) { - if (packet2handshake.d() > 39) { + if (packet2handshake.d() != 47) { + if (packet2handshake.d() > 47) { this.disconnect("Outdated server!"); } else { this.disconnect("Outdated client!"); @@ -86,7 +89,7 @@ public class NetLoginHandler extends NetHandler { } public void a(Packet252KeyResponse packet252keyresponse) { - PrivateKey privatekey = this.server.E().getPrivate(); + PrivateKey privatekey = this.server.F().getPrivate(); this.k = packet252keyresponse.a(privatekey); if (!Arrays.equals(this.d, packet252keyresponse.b(privatekey))) { @@ -141,10 +144,29 @@ public class NetLoginHandler extends NetHandler { public void a(Packet254GetInfo packet254getinfo) { if (this.networkManager.getSocket() == null) return; // CraftBukkit - fix NPE when a client queries a server that is unable to handle it. try { - // CraftBukkit start - org.bukkit.event.server.ServerListPingEvent pingEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.getMotd(), this.server.getServerConfigurationManager().getPlayerCount(), this.server.getServerConfigurationManager().getMaxPlayers()); - String s = pingEvent.getMotd() + "\u00A7" + this.server.getServerConfigurationManager().getPlayerCount() + "\u00A7" + pingEvent.getMaxPlayers(); - // CraftBukkit end + ServerConfigurationManagerAbstract serverconfigurationmanagerabstract = this.server.getServerConfigurationManager(); + String s = null; + // CraftBukkit + org.bukkit.event.server.ServerListPingEvent pingEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.getMotd(), serverconfigurationmanagerabstract.getPlayerCount(), serverconfigurationmanagerabstract.getMaxPlayers()); + + if (packet254getinfo.a == 1) { + // CraftBukkit start - fix decompile issues, don't create a list from an array + Object[] list = new Object[] { 1, 47, this.server.getVersion(), pingEvent.getMotd(), serverconfigurationmanagerabstract.getPlayerCount(), pingEvent.getMaxPlayers() }; + + for (Object object : list) { + if (s == null) { + s = "\u00A7"; + } else { + s = s + "\0"; + } + + s += org.apache.commons.lang.StringUtils.replace(object.toString(), "\0", ""); + } + // CraftBukkit end + } else { + // CraftBukkit + s = pingEvent.getMotd() + "\u00A7" + serverconfigurationmanagerabstract.getPlayerCount() + "\u00A7" + pingEvent.getMaxPlayers(); + } InetAddress inetaddress = null; @@ -154,8 +176,8 @@ public class NetLoginHandler extends NetHandler { this.networkManager.queue(new Packet255KickDisconnect(s)); this.networkManager.d(); - if (inetaddress != null && this.server.ac() instanceof DedicatedServerConnection) { - ((DedicatedServerConnection) this.server.ac()).a(inetaddress); + if (inetaddress != null && this.server.ae() instanceof DedicatedServerConnection) { + ((DedicatedServerConnection) this.server.ae()).a(inetaddress); } this.c = true; diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 6b33ae53..02a3aaea 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -152,7 +152,7 @@ public class NetServerHandler extends NetHandler { s = event.getReason(); // CraftBukkit end - this.player.m(); + this.player.l(); this.sendPacket(new Packet255KickDisconnect(s)); this.networkManager.d(); @@ -347,7 +347,7 @@ public class NetServerHandler extends NetHandler { } this.player.g(); - this.player.V = 0.0F; + this.player.W = 0.0F; this.player.setLocation(this.y, this.z, this.q, f2, f3); if (!this.checkMovement) { return; @@ -363,7 +363,7 @@ public class NetServerHandler extends NetHandler { // CraftBukkit end double d11 = d8 * d8 + d9 * d9 + d10 * d10; - if (d11 > 100.0D && this.checkMovement && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.name))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports + if (d11 > 100.0D && this.checkMovement && (!this.minecraftServer.I() || !this.minecraftServer.H().equals(this.player.name))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports logger.warning(this.player.name + " moved too quickly! " + d4 + "," + d6 + "," + d7 + " (" + d8 + ", " + d9 + ", " + d10 + ")"); this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); return; @@ -497,11 +497,11 @@ public class NetServerHandler extends NetHandler { } } // CraftBukkit end - this.player.bB(); + this.player.bN(); } else if (packet14blockdig.e == 5) { - this.player.by(); + this.player.bK(); } else { - boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.getServerConfigurationManager().isOp(this.player.name) || this.minecraftServer.H(); // CraftBukkit + boolean flag = worldserver.worldProvider.dimension != 0 || this.minecraftServer.getServerConfigurationManager().getOPs().isEmpty() || this.minecraftServer.getServerConfigurationManager().isOp(this.player.name) || this.minecraftServer.I(); boolean flag1 = false; if (packet14blockdig.e == 0) { @@ -568,8 +568,6 @@ public class NetServerHandler extends NetHandler { this.player.netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, worldserver)); } } - - worldserver.weirdIsOpCache = false; } } @@ -610,7 +608,7 @@ public class NetServerHandler extends NetHandler { int j = packet15place.f(); int k = packet15place.g(); int l = packet15place.getFace(); - boolean flag1 = worldserver.weirdIsOpCache = worldserver.worldProvider.dimension != 0 || this.minecraftServer.getServerConfigurationManager().isOp(this.player.name) || this.minecraftServer.H(); + boolean flag1 = worldserver.worldProvider.dimension != 0 || this.minecraftServer.getServerConfigurationManager().getOPs().isEmpty() || this.minecraftServer.getServerConfigurationManager().isOp(this.player.name) || this.minecraftServer.I(); if (packet15place.getFace() == 255) { if (itemstack == null) { @@ -647,7 +645,7 @@ public class NetServerHandler extends NetHandler { return; } flag1 = true; // spawn protection moved to ItemBlock!!! - if (j1 > 16 || flag1) { + if (j1 > this.minecraftServer.getSpawnProtection() || flag1) { // CraftBukkit end this.player.itemInWorldManager.interact(this.player, worldserver, itemstack, i, j, k, l, packet15place.j(), packet15place.l(), packet15place.m()); } @@ -699,11 +697,9 @@ public class NetServerHandler extends NetHandler { 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.matches(this.player.inventory.getItemInHand(), packet15place.getItemStack()) || always) { - this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.d, this.player.inventory.getItemInHand())); + this.sendPacket(new Packet103SetSlot(this.player.activeContainer.windowId, slot.g, this.player.inventory.getItemInHand())); } } - - worldserver.weirdIsOpCache = false; } public void a(String s, Object[] aobject) { @@ -717,7 +713,7 @@ public class NetServerHandler extends NetHandler { } // CraftBukkit end this.disconnected = true; - if (this.minecraftServer.H() && this.player.name.equals(this.minecraftServer.G())) { + if (this.minecraftServer.I() && this.player.name.equals(this.minecraftServer.H())) { logger.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); } @@ -938,7 +934,7 @@ public class NetServerHandler extends NetHandler { double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f; double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height; double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f; - Vec3D vec3d = Vec3D.a().create(d0, d1, d2); + Vec3D vec3d = this.player.world.getVec3DPool().create(d0, d1, d2); float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); @@ -961,7 +957,7 @@ public class NetServerHandler extends NetHandler { if (event.isCancelled()) return; // CraftBukkit end - this.player.i(); + this.player.bE(); } } @@ -1020,7 +1016,7 @@ public class NetServerHandler extends NetHandler { Entity entity = worldserver.getEntity(packet7useentity.target); if (entity != null) { - boolean flag = this.player.l(entity); + boolean flag = this.player.m(entity); double d0 = 36.0D; if (!flag) { @@ -1038,7 +1034,7 @@ public class NetServerHandler extends NetHandler { return; } // CraftBukkit end - this.player.m(entity); + this.player.o(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); @@ -1085,10 +1081,10 @@ public class NetServerHandler extends NetHandler { Bukkit.getServer().getPluginManager().callEvent(event); this.player = this.minecraftServer.getServerConfigurationManager().moveToWorld(this.player, 0, true, event.getTo()); // CraftBukkit end - } else if (this.player.q().getWorldData().isHardcore()) { - if (this.minecraftServer.H() && this.player.name.equals(this.minecraftServer.G())) { + } else if (this.player.p().getWorldData().isHardcore()) { + if (this.minecraftServer.I() && this.player.name.equals(this.minecraftServer.H())) { this.player.netServerHandler.disconnect("You have died. Game over, man, it\'s game over!"); - this.minecraftServer.O(); + this.minecraftServer.P(); } else { BanEntry banentry = new BanEntry(this.player.name); @@ -1121,7 +1117,7 @@ public class NetServerHandler extends NetHandler { this.player.activeContainer.transferTo(this.player.defaultContainer, getPlayer()); // CraftBukkit end - this.player.l(); + this.player.k(); } public void a(Packet102WindowClick packet102windowclick) { @@ -1132,12 +1128,12 @@ public class NetServerHandler extends NetHandler { InventoryView inventory = this.player.activeContainer.getBukkitView(); SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot); - InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); + InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1); org.bukkit.inventory.Inventory top = inventory.getTopInventory(); if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) { org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); if (recipe != null) { - event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift); + event = new CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1); } } server.getPluginManager().callEvent(event); @@ -1267,7 +1263,7 @@ public class NetServerHandler extends NetHandler { EntityItem entityitem = this.player.drop(itemstack); if (entityitem != null) { - entityitem.d(); + entityitem.c(); } } } @@ -1438,22 +1434,86 @@ public class NetServerHandler extends NetHandler { // exception1.printStackTrace(); // CraftBukkit end } - } else if ("MC|TrSel".equals(packet250custompayload.tag)) { - try { - datainputstream = new DataInputStream(new ByteArrayInputStream(packet250custompayload.data)); - int i = datainputstream.readInt(); - Container container = this.player.activeContainer; + } else { + int i; + + if ("MC|TrSel".equals(packet250custompayload.tag)) { + try { + datainputstream = new DataInputStream(new ByteArrayInputStream(packet250custompayload.data)); + i = datainputstream.readInt(); + Container container = this.player.activeContainer; + + if (container instanceof ContainerMerchant) { + ((ContainerMerchant) container).b(i); + } + } catch (Exception exception2) { + exception2.printStackTrace(); + } + } else { + int j; + + if ("MC|AdvCdm".equals(packet250custompayload.tag)) { + if (!this.minecraftServer.getEnableCommandBlock()) { + this.player.sendMessage(this.player.a("advMode.notEnabled", new Object[0])); + } else if (this.player.a(2, "") && this.player.abilities.canInstantlyBuild) { + try { + datainputstream = new DataInputStream(new ByteArrayInputStream(packet250custompayload.data)); + i = datainputstream.readInt(); + j = datainputstream.readInt(); + int k = datainputstream.readInt(); + String s = Packet.a(datainputstream, 256); + TileEntity tileentity = this.player.world.getTileEntity(i, j, k); + + if (tileentity != null && tileentity instanceof TileEntityCommand) { + ((TileEntityCommand) tileentity).b(s); + this.player.world.notify(i, j, k); + this.player.sendMessage("Command set: " + s); + } + } catch (Exception exception3) { + exception3.printStackTrace(); + } + } else { + this.player.sendMessage(this.player.a("advMode.notAllowed", new Object[0])); + } + } else if ("MC|Beacon".equals(packet250custompayload.tag)) { + if (this.player.activeContainer instanceof ContainerBeacon) { + try { + datainputstream = new DataInputStream(new ByteArrayInputStream(packet250custompayload.data)); + i = datainputstream.readInt(); + j = datainputstream.readInt(); + ContainerBeacon containerbeacon = (ContainerBeacon) this.player.activeContainer; + Slot slot = containerbeacon.getSlot(0); + + if (slot.d()) { + slot.a(1); + TileEntityBeacon tileentitybeacon = containerbeacon.d(); + + tileentitybeacon.d(i); + tileentitybeacon.e(j); + tileentitybeacon.update(); + } + } catch (Exception exception4) { + exception4.printStackTrace(); + } + } + } else if ("MC|ItemName".equals(packet250custompayload.tag) && this.player.activeContainer instanceof ContainerAnvil) { + ContainerAnvil containeranvil = (ContainerAnvil) this.player.activeContainer; + + if (packet250custompayload.data != null && packet250custompayload.data.length >= 1) { + String s1 = SharedConstants.a(new String(packet250custompayload.data)); - if (container instanceof ContainerMerchant) { - ((ContainerMerchant) container).c(i); + if (s1.length() <= 30) { + containeranvil.a(s1); + } + } else { + containeranvil.a(""); + } } - } catch (Exception exception2) { - exception2.printStackTrace(); } } // CraftBukkit start - else if (packet250custompayload.tag.equals("REGISTER")) { + if (packet250custompayload.tag.equals("REGISTER")) { try { String channels = new String(packet250custompayload.data, "UTF8"); for (String channel : channels.split("\0")) { diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index a3f2841a..090060a1 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -190,7 +190,7 @@ public class NetworkManager implements INetworkManager { boolean flag = false; try { - Packet packet = Packet.a(this.input, this.packetListener.a()); + Packet packet = Packet.a(this.input, this.packetListener.a(), this.socket); if (packet != null) { if (packet instanceof Packet252KeyResponse && !this.f) { diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java index 380c0b96..dc692dd0 100644 --- a/src/main/java/net/minecraft/server/Packet.java +++ b/src/main/java/net/minecraft/server/Packet.java @@ -4,6 +4,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.EOFException; import java.io.IOException; +import java.net.Socket; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -81,25 +82,30 @@ public abstract class Packet { return packetID; // ((Integer) a.get(this.getClass())).intValue(); // CraftBukkit } - public static Packet a(DataInputStream datainputstream, boolean flag) throws IOException { // CraftBukkit - throws IOException + public static Packet a(DataInputStream datainputstream, boolean flag, Socket socket) throws IOException { // CraftBukkit - throws IOException boolean flag1 = false; Packet packet = null; + int i = socket.getSoTimeout(); - int i; + int j; try { - i = datainputstream.read(); - if (i == -1) { + j = datainputstream.read(); + if (j == -1) { return null; } - if (flag && !c.contains(Integer.valueOf(i)) || !flag && !b.contains(Integer.valueOf(i))) { - throw new IOException("Bad packet id " + i); + if (flag && !c.contains(Integer.valueOf(j)) || !flag && !b.contains(Integer.valueOf(j))) { + throw new IOException("Bad packet id " + j); } - packet = d(i); + packet = d(j); if (packet == null) { - throw new IOException("Bad packet id " + i); + throw new IOException("Bad packet id " + j); + } + + if (packet instanceof Packet254GetInfo) { + socket.setSoTimeout(1500); } packet.a(datainputstream); @@ -121,9 +127,10 @@ public abstract class Packet { // CraftBukkit end - PacketCounter.a(i, (long) packet.a()); + PacketCounter.a(j, (long) packet.a()); ++n; o += (long) packet.a(); + socket.setSoTimeout(i); return packet; } @@ -211,7 +218,7 @@ public abstract class Packet { dataoutputstream.writeShort(itemstack.getData()); NBTTagCompound nbttagcompound = null; - if (itemstack.getItem().m() || itemstack.getItem().p()) { + if (itemstack.getItem().n() || itemstack.getItem().q()) { nbttagcompound = itemstack.tag; } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java index c4838c4f..66431fb8 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalArrowAttack.java @@ -4,26 +4,30 @@ import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public class PathfinderGoalArrowAttack extends PathfinderGoal { - World a; - EntityLiving b; - EntityLiving c; - int d = 0; - float e; - int f = 0; - int g; - int h; + private final EntityLiving a; + private final IRangedEntity b; + private EntityLiving c; + private int d = 0; + private float e; + private int f = 0; + private int g; + private float h; - public PathfinderGoalArrowAttack(EntityLiving entityliving, float f, int i, int j) { - this.b = entityliving; - this.a = entityliving.world; - this.e = f; - this.g = i; - this.h = j; - this.a(3); + public PathfinderGoalArrowAttack(IRangedEntity irangedentity, float f, int i, float f1) { + if (!(irangedentity instanceof EntityLiving)) { + throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob"); + } else { + this.b = irangedentity; + this.a = (EntityLiving) irangedentity; + this.e = f; + this.g = i; + this.h = f1 * f1; + this.a(3); + } } public boolean a() { - EntityLiving entityliving = this.b.az(); + EntityLiving entityliving = this.a.aF(); if (entityliving == null) { return false; @@ -34,21 +38,21 @@ public class PathfinderGoalArrowAttack extends PathfinderGoal { } public boolean b() { - return this.a() || !this.b.getNavigation().f(); + return this.a() || !this.a.getNavigation().f(); } - public void c() { + public void d() { // CraftBukkit start EntityTargetEvent.TargetReason reason = this.c.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(b, null, reason); + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent((Entity) b, null, reason); // CraftBukkit end this.c = null; + this.f = 0; } - public void d() { - double d0 = 100.0D; - double d1 = this.b.e(this.c.locX, this.c.boundingBox.b, this.c.locZ); - boolean flag = this.b.at().canSee(this.c); + public void e() { + double d0 = this.a.e(this.c.locX, this.c.boundingBox.b, this.c.locZ); + boolean flag = this.a.az().canSee(this.c); if (flag) { ++this.f; @@ -56,38 +60,19 @@ public class PathfinderGoalArrowAttack extends PathfinderGoal { this.f = 0; } - if (d1 <= d0 && this.f >= 20) { - this.b.getNavigation().g(); + if (d0 <= (double) this.h && this.f >= 20) { + this.a.getNavigation().g(); } else { - this.b.getNavigation().a(this.c, this.e); + this.a.getNavigation().a(this.c, this.e); } - this.b.getControllerLook().a(this.c, 30.0F, 30.0F); + this.a.getControllerLook().a(this.c, 30.0F, 30.0F); this.d = Math.max(this.d - 1, 0); if (this.d <= 0) { - if (d1 <= d0 && flag) { - this.f(); - this.d = this.h; + if (d0 <= (double) this.h && flag) { + this.b.d(this.c); + this.d = this.g; } } } - - private void f() { - if (this.g == 1) { - EntityArrow entityarrow = new EntityArrow(this.a, this.b, this.c, 1.6F, 12.0F); - - this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F)); - this.a.addEntity(entityarrow); - } else if (this.g == 2) { - EntitySnowball entitysnowball = new EntitySnowball(this.a, this.b); - double d0 = this.c.locX - this.b.locX; - double d1 = this.c.locY + (double) this.c.getHeadHeight() - 1.100000023841858D - entitysnowball.locY; - double d2 = this.c.locZ - this.b.locZ; - float f = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F; - - entitysnowball.c(d0, d1 + (double) f, d2, 1.6F, 12.0F); - this.a.makeSound(this.b, "random.bow", 1.0F, 1.0F / (this.b.au().nextFloat() * 0.4F + 0.8F)); - this.a.addEntity(entitysnowball); - } - } } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java b/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java index b9620ecb..930f2cce 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalBreakDoor.java @@ -10,11 +10,11 @@ public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract { } public boolean a() { - return !super.a() ? false : !this.e.a_(this.a.world, this.b, this.c, this.d); + return !super.a() ? false : (!this.a.world.getGameRules().getBoolean("mobGriefing") ? false : !this.e.a_(this.a.world, this.b, this.c, this.d)); } - public void e() { - super.e(); + public void c() { + super.c(); this.i = 0; } @@ -24,14 +24,14 @@ public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract { return this.i <= 240 && !this.e.a_(this.a.world, this.b, this.c, this.d) && d0 < 4.0D; } - public void c() { - super.c(); - this.a.world.f(this.a.id, this.b, this.c, this.d, -1); - } - public void d() { super.d(); - if (this.a.au().nextInt(20) == 0) { + this.a.world.g(this.a.id, this.b, this.c, this.d, -1); + } + + public void e() { + super.e(); + if (this.a.aA().nextInt(20) == 0) { this.a.world.triggerEffect(1010, this.b, this.c, this.d, 0); } @@ -39,7 +39,7 @@ public class PathfinderGoalBreakDoor extends PathfinderGoalDoorInteract { int i = (int) ((float) this.i / 240.0F * 10.0F); if (i != this.j) { - this.a.world.f(this.a.id, this.b, this.c, this.d, i); + this.a.world.g(this.a.id, this.b, this.c, this.d, i); this.j = i; } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java b/src/main/java/net/minecraft/server/PathfinderGoalBreed.java index 50631387..3e96936c 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalBreed.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalBreed.java @@ -20,7 +20,7 @@ public class PathfinderGoalBreed extends PathfinderGoal { } public boolean a() { - if (!this.d.s()) { + if (!this.d.r()) { return false; } else { this.e = this.f(); @@ -29,20 +29,20 @@ public class PathfinderGoalBreed extends PathfinderGoal { } public boolean b() { - return this.e.isAlive() && this.e.s() && this.b < 60; + return this.e.isAlive() && this.e.r() && this.b < 60; } - public void c() { + public void d() { this.e = null; this.b = 0; } - public void d() { - this.d.getControllerLook().a(this.e, 10.0F, (float) this.d.bf()); + public void e() { + this.d.getControllerLook().a(this.e, 10.0F, (float) this.d.bm()); this.d.getNavigation().a((EntityLiving) this.e, this.c); ++this.b; if (this.b == 60) { - this.i(); + this.g(); } } @@ -64,26 +64,28 @@ public class PathfinderGoalBreed extends PathfinderGoal { return entityanimal; } - private void i() { + private void g() { EntityAnimal entityanimal = this.d.createChild(this.e); if (entityanimal != null) { this.d.setAge(6000); this.e.setAge(6000); - this.d.t(); - this.e.t(); + this.d.s(); + this.e.s(); entityanimal.setAge(-24000); entityanimal.setPositionRotation(this.d.locX, this.d.locY, this.d.locZ, 0.0F, 0.0F); this.a.addEntity(entityanimal, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - Random random = this.d.au(); + Random random = this.d.aA(); for (int i = 0; i < 7; ++i) { double d0 = random.nextGaussian() * 0.02D; double d1 = random.nextGaussian() * 0.02D; double d2 = random.nextGaussian() * 0.02D; - this.a.a("heart", this.d.locX + (double) (random.nextFloat() * this.d.width * 2.0F) - (double) this.d.width, this.d.locY + 0.5D + (double) (random.nextFloat() * this.d.length), this.d.locZ + (double) (random.nextFloat() * this.d.width * 2.0F) - (double) this.d.width, d0, d1, d2); + this.a.addParticle("heart", this.d.locX + (double) (random.nextFloat() * this.d.width * 2.0F) - (double) this.d.width, this.d.locY + 0.5D + (double) (random.nextFloat() * this.d.length), this.d.locZ + (double) (random.nextFloat() * this.d.width * 2.0F) - (double) this.d.width, d0, d1, d2); } + + this.a.addEntity(new EntityExperienceOrb(this.a, this.d.locX, this.d.locY, this.d.locZ, random.nextInt(4) + 1)); } } } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java b/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java index 05a12080..510d199b 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalEatTile.java @@ -18,7 +18,7 @@ public class PathfinderGoalEatTile extends PathfinderGoal { } public boolean a() { - if (this.b.au().nextInt(this.b.isBaby() ? 50 : 1000) != 0) { + if (this.b.aA().nextInt(this.b.isBaby() ? 50 : 1000) != 0) { return false; } else { int i = MathHelper.floor(this.b.locX); @@ -29,13 +29,13 @@ public class PathfinderGoalEatTile extends PathfinderGoal { } } - public void e() { + public void c() { this.a = 40; this.c.broadcastEntityEffect(this.b, (byte) 10); this.b.getNavigation().g(); } - public void c() { + public void d() { this.a = 0; } @@ -47,7 +47,7 @@ public class PathfinderGoalEatTile extends PathfinderGoal { return this.a; } - public void d() { + public void e() { this.a = Math.max(0, this.a - 1); if (this.a == 4) { int i = MathHelper.floor(this.b.locX); @@ -59,7 +59,7 @@ public class PathfinderGoalEatTile extends PathfinderGoal { if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) { this.c.triggerEffect(2001, i, j, k, Block.LONG_GRASS.id + 4096); this.c.setTypeId(i, j, k, 0); - this.b.aA(); + this.b.aG(); } // CraftBukkit end } else if (this.c.getTypeId(i, j - 1, k) == Block.GRASS.id) { @@ -67,7 +67,7 @@ public class PathfinderGoalEatTile extends PathfinderGoal { if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) { this.c.triggerEffect(2001, i, j - 1, k, Block.GRASS.id); this.c.setTypeId(i, j - 1, k, Block.DIRT.id); - this.b.aA(); + this.b.aG(); } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java b/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java index cca9c7a1..5c150b05 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalMeleeAttack.java @@ -29,7 +29,7 @@ public class PathfinderGoalMeleeAttack extends PathfinderGoal { } public boolean a() { - EntityLiving entityliving = this.b.az(); + EntityLiving entityliving = this.b.aF(); if (entityliving == null) { return false; @@ -43,17 +43,17 @@ public class PathfinderGoalMeleeAttack extends PathfinderGoal { } public boolean b() { - EntityLiving entityliving = this.b.az(); + EntityLiving entityliving = this.b.aF(); - return entityliving == null ? false : (!this.c.isAlive() ? false : (!this.f ? !this.b.getNavigation().f() : this.b.d(MathHelper.floor(this.c.locX), MathHelper.floor(this.c.locY), MathHelper.floor(this.c.locZ)))); + return entityliving == null ? false : (!this.c.isAlive() ? false : (!this.f ? !this.b.getNavigation().f() : this.b.e(MathHelper.floor(this.c.locX), MathHelper.floor(this.c.locY), MathHelper.floor(this.c.locZ)))); } - public void e() { + public void c() { this.b.getNavigation().a(this.g, this.e); this.i = 0; } - public void c() { + public void d() { // CraftBukkit start EntityTargetEvent.TargetReason reason = this.c.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(b, null, reason); @@ -63,10 +63,10 @@ public class PathfinderGoalMeleeAttack extends PathfinderGoal { this.b.getNavigation().g(); } - public void d() { + public void e() { this.b.getControllerLook().a(this.c, 30.0F, 30.0F); - if ((this.f || this.b.at().canSee(this.c)) && --this.i <= 0) { - this.i = 4 + this.b.au().nextInt(7); + if ((this.f || this.b.az().canSee(this.c)) && --this.i <= 0) { + this.i = 4 + this.b.aA().nextInt(7); this.b.getNavigation().a(this.c, this.e); } @@ -76,7 +76,11 @@ public class PathfinderGoalMeleeAttack extends PathfinderGoal { if (this.b.e(this.c.locX, this.c.boundingBox.b, this.c.locZ) <= d0) { if (this.d <= 0) { this.d = 20; - this.b.k(this.c); + if (this.b.bA() != null) { + this.b.bE(); + } + + this.b.l(this.c); } } } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java index cf4cce0a..a1870730 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java @@ -41,14 +41,14 @@ public class PathfinderGoalSelector { continue; } - pathfindergoalselectoritem.a.c(); + pathfindergoalselectoritem.a.d(); this.b.remove(pathfindergoalselectoritem); } if (this.b(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) { // CraftBukkit start - call method now instead of queueing // arraylist.add(pathfindergoalselectoritem); - pathfindergoalselectoritem.a.e(); + pathfindergoalselectoritem.a.c(); // CraftBukkit end this.b.add(pathfindergoalselectoritem); } @@ -59,7 +59,7 @@ public class PathfinderGoalSelector { while (iterator.hasNext()) { pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); if (!pathfindergoalselectoritem.a.b()) { - pathfindergoalselectoritem.a.c(); + pathfindergoalselectoritem.a.d(); iterator.remove(); } } @@ -72,7 +72,7 @@ public class PathfinderGoalSelector { while (iterator.hasNext()) { pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); - pathfindergoalselectoritem.a.e(); + pathfindergoalselectoritem.a.c(); this.c.b(); }*/ // CraftBukkit end @@ -83,9 +83,7 @@ public class PathfinderGoalSelector { while (iterator.hasNext()) { pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); - // this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); // CraftBukkit - getSimpleName is expensive - pathfindergoalselectoritem.a.d(); - // this.c.b(); // CraftBukkit - paired with above comment + pathfindergoalselectoritem.a.e(); } this.c.b(); @@ -115,7 +113,7 @@ public class PathfinderGoalSelector { return false; } // CraftBukkit - switch order - } else if (!pathfindergoalselectoritem1.a.g() && this.b.contains(pathfindergoalselectoritem1)) { + } else if (!pathfindergoalselectoritem1.a.i() && this.b.contains(pathfindergoalselectoritem1)) { this.c.b(); ((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse return false; @@ -128,6 +126,6 @@ public class PathfinderGoalSelector { } private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) { - return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0; + return (pathfindergoalselectoritem.a.j() & pathfindergoalselectoritem1.a.j()) == 0; } } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalTarget.java index bbb1cdfc..0e82447c 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalTarget.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalTarget.java @@ -27,7 +27,7 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { } public boolean b() { - EntityLiving entityliving = this.d.az(); + EntityLiving entityliving = this.d.aF(); if (entityliving == null) { return false; @@ -37,7 +37,7 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { return false; } else { if (this.f) { - if (this.d.at().canSee(entityliving)) { + if (this.d.az().canSee(entityliving)) { this.g = 0; } else if (++this.g > 60) { return false; @@ -48,13 +48,13 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { } } - public void e() { + public void c() { this.b = 0; this.c = 0; this.g = 0; } - public void c() { + public void d() { this.d.b((EntityLiving) null); } @@ -65,78 +65,78 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { return false; } else if (!entityliving.isAlive()) { return false; - } else if (entityliving.boundingBox.e > this.d.boundingBox.b && entityliving.boundingBox.b < this.d.boundingBox.e) { - if (!this.d.a(entityliving.getClass())) { + } else if (!this.d.a(entityliving.getClass())) { + return false; + } else { + if (this.d instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.d).isTamed()) { + if (entityliving instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityliving).isTamed()) { + return false; + } + + if (entityliving == ((EntityTameableAnimal) this.d).getOwner()) { + return false; + } + } else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) { + return false; + } + + if (!this.d.e(MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) { + return false; + } else if (this.f && !this.d.az().canSee(entityliving)) { return false; } else { - if (this.d instanceof EntityTameableAnimal && ((EntityTameableAnimal) this.d).isTamed()) { - if (entityliving instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityliving).isTamed()) { - return false; + if (this.a) { + if (--this.c <= 0) { + this.b = 0; } - if (entityliving == ((EntityTameableAnimal) this.d).getOwner()) { + if (this.b == 0) { + this.b = this.a(entityliving) ? 1 : 2; + } + + if (this.b == 2) { return false; } - } else if (entityliving instanceof EntityHuman && !flag && ((EntityHuman) entityliving).abilities.isInvulnerable) { - return false; } - if (!this.d.d(MathHelper.floor(entityliving.locX), MathHelper.floor(entityliving.locY), MathHelper.floor(entityliving.locZ))) { - return false; - } else if (this.f && !this.d.at().canSee(entityliving)) { - return false; - } else { - if (this.a) { - if (--this.c <= 0) { - this.b = 0; - } - - if (this.b == 0) { - this.b = this.a(entityliving) ? 1 : 2; - } - - if (this.b == 2) { - return false; - } - } + // CraftBukkit start - check all the different target goals for the reason, default to RANDOM_TARGET + EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET; - // CraftBukkit start - check all the different target goals for the reason, default to RANDOM_TARGET - EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET; - - if (this instanceof PathfinderGoalDefendVillage) { - reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE; - } else if (this instanceof PathfinderGoalHurtByTarget) { - reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY; - } else if (this instanceof PathfinderGoalNearestAttackableTarget) { - if (entityliving instanceof EntityHuman) { - reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER; - } - } else if (this instanceof PathfinderGoalOwnerHurtByTarget) { - reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER; - } else if (this instanceof PathfinderGoalOwnerHurtTarget) { - reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET; + if (this instanceof PathfinderGoalDefendVillage) { + reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE; + } else if (this instanceof PathfinderGoalHurtByTarget) { + reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY; + } else if (this instanceof PathfinderGoalNearestAttackableTarget) { + if (entityliving instanceof EntityHuman) { + reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER; } + } else if (this instanceof PathfinderGoalOwnerHurtByTarget) { + reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER; + } else if (this instanceof PathfinderGoalOwnerHurtTarget) { + reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET; + } - org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this.d, entityliving, reason); - if (event.isCancelled() || event.getTarget() == null) { - if (this.d instanceof EntityCreature) ((EntityCreature) this.d).target = null; - return false; - } else if (entityliving.getBukkitEntity() != event.getTarget()) { - this.d.b((EntityLiving) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle()); + org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this.d, entityliving, reason); + if (event.isCancelled() || event.getTarget() == null) { + if (this.d instanceof EntityCreature) { + ((EntityCreature) this.d).target = null; } - if (this.d instanceof EntityCreature) ((EntityCreature) this.d).target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); - // CraftBukkit end - - return true; + return false; + } else if (entityliving.getBukkitEntity() != event.getTarget()) { + this.d.b((EntityLiving) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle()); + } + if (this.d instanceof EntityCreature) { + ((EntityCreature) this.d).target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle(); } + // CraftBukkit end + + return true; } - } else { - return false; } } private boolean a(EntityLiving entityliving) { - this.c = 10 + this.d.au().nextInt(5); + this.c = 10 + this.d.aA().nextInt(5); PathEntity pathentity = this.d.getNavigation().a(entityliving); if (pathentity == null) { diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index 359df829..fcbd67c4 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -137,7 +137,7 @@ class PlayerInstance { private void sendTileEntity(TileEntity tileentity) { if (tileentity != null) { - Packet packet = tileentity.e(); + Packet packet = tileentity.l(); if (packet != null) { this.sendAll(packet); diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java index f1275e68..5b65b710 100644 --- a/src/main/java/net/minecraft/server/PlayerInventory.java +++ b/src/main/java/net/minecraft/server/PlayerInventory.java @@ -107,6 +107,31 @@ public class PlayerInventory implements IInventory { return -1; } + public int b(int i, int j) { + int k = 0; + + int l; + ItemStack itemstack; + + for (l = 0; l < this.items.length; ++l) { + itemstack = this.items[l]; + if (itemstack != null && (i <= -1 || itemstack.id == i) && (j <= -1 || itemstack.getData() == j)) { + k += itemstack.count; + this.items[l] = null; + } + } + + for (l = 0; l < this.armor.length; ++l) { + itemstack = this.armor[l]; + if (itemstack != null && (i <= -1 || itemstack.id == i) && (j <= -1 || itemstack.getData() == j)) { + k += itemstack.count; + this.armor[l] = null; + } + } + + return k; + } + private int e(ItemStack itemstack) { int i = itemstack.id; int j = itemstack.count; @@ -161,7 +186,7 @@ public class PlayerInventory implements IInventory { } } - public void k() { + public void j() { for (int i = 0; i < this.items.length; ++i) { if (this.items[i] != null) { this.items[i].a(this.player.world, this.player, i, this.itemInHandIndex == i); @@ -372,7 +397,11 @@ public class PlayerInventory implements IInventory { } } - public int l() { + public ItemStack f(int i) { + return this.armor[i]; + } + + public int k() { int i = 0; ItemStack[] aitemstack = this.armor; int j = aitemstack.length; @@ -406,7 +435,7 @@ public class PlayerInventory implements IInventory { } } - public void m() { + public void l() { int i; for (i = 0; i < this.items.length; ++i) { @@ -454,7 +483,7 @@ public class PlayerInventory implements IInventory { for (j = 0; j < i; ++j) { itemstack1 = aitemstack[j]; - if (itemstack1 != null && itemstack1.c(itemstack)) { + if (itemstack1 != null && itemstack1.doMaterialsMatch(itemstack)) { return true; } } @@ -464,7 +493,7 @@ public class PlayerInventory implements IInventory { for (j = 0; j < i; ++j) { itemstack1 = aitemstack[j]; - if (itemstack1 != null && itemstack1.c(itemstack)) { + if (itemstack1 != null && itemstack1.doMaterialsMatch(itemstack)) { return true; } } diff --git a/src/main/java/net/minecraft/server/PortalTravelAgent.java b/src/main/java/net/minecraft/server/PortalTravelAgent.java index 40c7b894..d385b0a3 100644 --- a/src/main/java/net/minecraft/server/PortalTravelAgent.java +++ b/src/main/java/net/minecraft/server/PortalTravelAgent.java @@ -18,11 +18,11 @@ public class PortalTravelAgent { public PortalTravelAgent() {} - public void a(World world, Entity entity) { + public void a(World world, Entity entity, double d0, double d1, double d2, float f) { if (world.worldProvider.dimension != 1) { - if (!this.b(world, entity)) { - this.c(world, entity); - this.b(world, entity); + if (!this.b(world, entity, d0, d1, d2, f)) { + this.a(world, entity); + this.b(world, entity, d0, d1, d2, f); } } else { int i = MathHelper.floor(entity.locX); @@ -49,34 +49,35 @@ public class PortalTravelAgent { } } - public boolean b(World world, Entity entity) { + public boolean b(World world, Entity entity, double d0, double d1, double d2, float f) { short short1 = 128; - double d0 = -1.0D; + double d3 = -1.0D; int i = 0; int j = 0; int k = 0; int l = MathHelper.floor(entity.locX); int i1 = MathHelper.floor(entity.locZ); - double d1; + int j1; + double d4; - for (int j1 = l - short1; j1 <= l + short1; ++j1) { - double d2 = (double) j1 + 0.5D - entity.locX; + for (j1 = l - short1; j1 <= l + short1; ++j1) { + double d5 = (double) j1 + 0.5D - entity.locX; for (int k1 = i1 - short1; k1 <= i1 + short1; ++k1) { - double d3 = (double) k1 + 0.5D - entity.locZ; + double d6 = (double) k1 + 0.5D - entity.locZ; - for (int l1 = world.L() - 1; l1 >= 0; --l1) { + for (int l1 = world.O() - 1; l1 >= 0; --l1) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { --l1; } - d1 = (double) l1 + 0.5D - entity.locY; - double d4 = d2 * d2 + d1 * d1 + d3 * d3; + d4 = (double) l1 + 0.5D - entity.locY; + double d7 = d5 * d5 + d4 * d4 + d6 * d6; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; + if (d3 < 0.0D || d7 < d3) { + d3 = d7; i = j1; j = l1; k = k1; @@ -86,36 +87,106 @@ public class PortalTravelAgent { } } - if (d0 >= 0.0D) { - double d5 = (double) i + 0.5D; - double d6 = (double) j + 0.5D; + if (d3 < 0.0D) { + return false; + } else { + double d8 = (double) i + 0.5D; + double d9 = (double) j + 0.5D; + + d4 = (double) k + 0.5D; + int i2 = -1; - d1 = (double) k + 0.5D; if (world.getTypeId(i - 1, j, k) == Block.PORTAL.id) { - d5 -= 0.5D; + i2 = 2; } if (world.getTypeId(i + 1, j, k) == Block.PORTAL.id) { - d5 += 0.5D; + i2 = 0; } if (world.getTypeId(i, j, k - 1) == Block.PORTAL.id) { - d1 -= 0.5D; + i2 = 3; } if (world.getTypeId(i, j, k + 1) == Block.PORTAL.id) { - d1 += 0.5D; + i2 = 1; } - entity.setPositionRotation(d5, d6, d1, entity.yaw, 0.0F); - entity.motX = entity.motY = entity.motZ = 0.0D; + int j2 = entity.at(); + + if (i2 > -1) { + int k2 = Direction.h[i2]; + int l2 = Direction.a[i2]; + int i3 = Direction.b[i2]; + int j3 = Direction.a[k2]; + int k3 = Direction.b[k2]; + boolean flag = !world.isEmpty(i + l2 + j3, j, k + i3 + k3) || !world.isEmpty(i + l2 + j3, j + 1, k + i3 + k3); + boolean flag1 = !world.isEmpty(i + l2, j, k + i3) || !world.isEmpty(i + l2, j + 1, k + i3); + + if (flag && flag1) { + i2 = Direction.f[i2]; + k2 = Direction.f[k2]; + l2 = Direction.a[i2]; + i3 = Direction.b[i2]; + j3 = Direction.a[k2]; + k3 = Direction.b[k2]; + j1 = i - j3; + d8 -= (double) j3; + int l3 = k - k3; + + d4 -= (double) k3; + flag = !world.isEmpty(j1 + l2 + j3, j, l3 + i3 + k3) || !world.isEmpty(j1 + l2 + j3, j + 1, l3 + i3 + k3); + flag1 = !world.isEmpty(j1 + l2, j, l3 + i3) || !world.isEmpty(j1 + l2, j + 1, l3 + i3); + } + + float f1 = 0.5F; + float f2 = 0.5F; + + if (!flag && flag1) { + f1 = 1.0F; + } else if (flag && !flag1) { + f1 = 0.0F; + } else if (flag && flag1) { + f2 = 0.0F; + } + + d8 += (double) ((float) j3 * f1 + f2 * (float) l2); + d4 += (double) ((float) k3 * f1 + f2 * (float) i3); + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + + if (i2 == j2) { + f3 = 1.0F; + f4 = 1.0F; + } else if (i2 == Direction.f[j2]) { + f3 = -1.0F; + f4 = -1.0F; + } else if (i2 == Direction.g[j2]) { + f5 = 1.0F; + f6 = -1.0F; + } else { + f5 = -1.0F; + f6 = 1.0F; + } + + double d10 = entity.motX; + double d11 = entity.motZ; + + entity.motX = d10 * (double) f3 + d11 * (double) f6; + entity.motZ = d10 * (double) f5 + d11 * (double) f4; + entity.yaw = f - (float) (j2 * 90) + (float) (i2 * 90); + } else { + entity.motX = entity.motY = entity.motZ = 0.0D; + } + + entity.setPositionRotation(d8, d9, d4, entity.yaw, entity.pitch); return true; - } else { - return false; } } - public boolean c(World world, Entity entity) { + public boolean a(World world, Entity entity) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor(entity.locX); @@ -150,7 +221,7 @@ public class PortalTravelAgent { d2 = (double) j2 + 0.5D - entity.locZ; label274: - for (l2 = world.L() - 1; l2 >= 0; --l2) { + for (l2 = world.O() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -201,7 +272,7 @@ public class PortalTravelAgent { d2 = (double) j2 + 0.5D - entity.locZ; label222: - for (l2 = world.L() - 1; l2 >= 0; --l2) { + for (l2 = world.O() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -257,8 +328,8 @@ public class PortalTravelAgent { i1 = 70; } - if (i1 > world.L() - 10) { - i1 = world.L() - 10; + if (i1 > world.O() - 10) { + i1 = world.O() - 10; } j5 = i1; diff --git a/src/main/java/net/minecraft/server/RecipesArmorDye.java b/src/main/java/net/minecraft/server/RecipesArmorDye.java new file mode 100644 index 00000000..22d8d328 --- /dev/null +++ b/src/main/java/net/minecraft/server/RecipesArmorDye.java @@ -0,0 +1,123 @@ +package net.minecraft.server; + +import java.util.ArrayList; + +public class RecipesArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + + // CraftBukkit start - delegate to new parent class with bogus info + public RecipesArmorDye() { + super(new ItemStack(Item.LEATHER_HELMET, 0, 0), java.util.Arrays.asList(new ItemStack(Item.INK_SACK, 0, 5))); + } + // CraftBukkit end + + public boolean a(InventoryCrafting inventorycrafting, World world) { + ItemStack itemstack = null; + ArrayList arraylist = new ArrayList(); + + for (int i = 0; i < inventorycrafting.getSize(); ++i) { + ItemStack itemstack1 = inventorycrafting.getItem(i); + + if (itemstack1 != null) { + if (itemstack1.getItem() instanceof ItemArmor) { + ItemArmor itemarmor = (ItemArmor) itemstack1.getItem(); + + if (itemarmor.d() != EnumArmorMaterial.CLOTH || itemstack != null) { + return false; + } + + itemstack = itemstack1; + } else { + if (itemstack1.id != Item.INK_SACK.id) { + return false; + } + + arraylist.add(itemstack1); + } + } + } + + return itemstack != null && !arraylist.isEmpty(); + } + + public ItemStack a(InventoryCrafting inventorycrafting) { + ItemStack itemstack = null; + int[] aint = new int[3]; + int i = 0; + int j = 0; + ItemArmor itemarmor = null; + + int k; + int l; + float f; + float f1; + int i1; + + for (k = 0; k < inventorycrafting.getSize(); ++k) { + ItemStack itemstack1 = inventorycrafting.getItem(k); + + if (itemstack1 != null) { + if (itemstack1.getItem() instanceof ItemArmor) { + itemarmor = (ItemArmor) itemstack1.getItem(); + if (itemarmor.d() != EnumArmorMaterial.CLOTH || itemstack != null) { + return null; + } + + itemstack = itemstack1.cloneItemStack(); + if (itemarmor.b_(itemstack1)) { + l = itemarmor.b(itemstack); + f = (float) (l >> 16 & 255) / 255.0F; + f1 = (float) (l >> 8 & 255) / 255.0F; + float f2 = (float) (l & 255) / 255.0F; + + i = (int) ((float) i + Math.max(f, Math.max(f1, f2)) * 255.0F); + aint[0] = (int) ((float) aint[0] + f * 255.0F); + aint[1] = (int) ((float) aint[1] + f1 * 255.0F); + aint[2] = (int) ((float) aint[2] + f2 * 255.0F); + ++j; + } + } else { + if (itemstack1.id != Item.INK_SACK.id) { + return null; + } + + float[] afloat = EntitySheep.d[BlockCloth.e_(itemstack1.getData())]; + int j1 = (int) (afloat[0] * 255.0F); + int k1 = (int) (afloat[1] * 255.0F); + + i1 = (int) (afloat[2] * 255.0F); + i += Math.max(j1, Math.max(k1, i1)); + aint[0] += j1; + aint[1] += k1; + aint[2] += i1; + ++j; + } + } + } + + if (itemarmor == null) { + return null; + } else { + k = aint[0] / j; + int l1 = aint[1] / j; + + l = aint[2] / j; + f = (float) i / (float) j; + f1 = (float) Math.max(k, Math.max(l1, l)); + k = (int) ((float) k * f / f1); + l1 = (int) ((float) l1 * f / f1); + l = (int) ((float) l * f / f1); + i1 = (k << 8) + l1; + i1 = (i1 << 8) + l; + itemarmor.b(itemstack, i1); + return itemstack; + } + } + + public int a() { + return 10; + } + + public ItemStack b() { + return null; + } +} diff --git a/src/main/java/net/minecraft/server/RecipesFurnace.java b/src/main/java/net/minecraft/server/RecipesFurnace.java index b055aab9..7abc4612 100644 --- a/src/main/java/net/minecraft/server/RecipesFurnace.java +++ b/src/main/java/net/minecraft/server/RecipesFurnace.java @@ -18,15 +18,16 @@ public class RecipesFurnace { this.registerRecipe(Block.GOLD_ORE.id, new ItemStack(Item.GOLD_INGOT), 1.0F); this.registerRecipe(Block.DIAMOND_ORE.id, new ItemStack(Item.DIAMOND), 1.0F); this.registerRecipe(Block.SAND.id, new ItemStack(Block.GLASS), 0.1F); - this.registerRecipe(Item.PORK.id, new ItemStack(Item.GRILLED_PORK), 0.3F); - this.registerRecipe(Item.RAW_BEEF.id, new ItemStack(Item.COOKED_BEEF), 0.3F); - this.registerRecipe(Item.RAW_CHICKEN.id, new ItemStack(Item.COOKED_CHICKEN), 0.3F); - this.registerRecipe(Item.RAW_FISH.id, new ItemStack(Item.COOKED_FISH), 0.3F); + this.registerRecipe(Item.PORK.id, new ItemStack(Item.GRILLED_PORK), 0.35F); + this.registerRecipe(Item.RAW_BEEF.id, new ItemStack(Item.COOKED_BEEF), 0.35F); + this.registerRecipe(Item.RAW_CHICKEN.id, new ItemStack(Item.COOKED_CHICKEN), 0.35F); + this.registerRecipe(Item.RAW_FISH.id, new ItemStack(Item.COOKED_FISH), 0.35F); this.registerRecipe(Block.COBBLESTONE.id, new ItemStack(Block.STONE), 0.1F); - this.registerRecipe(Item.CLAY_BALL.id, new ItemStack(Item.CLAY_BRICK), 0.2F); + this.registerRecipe(Item.CLAY_BALL.id, new ItemStack(Item.CLAY_BRICK), 0.3F); this.registerRecipe(Block.CACTUS.id, new ItemStack(Item.INK_SACK, 1, 2), 0.2F); - this.registerRecipe(Block.LOG.id, new ItemStack(Item.COAL, 1, 1), 0.1F); + this.registerRecipe(Block.LOG.id, new ItemStack(Item.COAL, 1, 1), 0.15F); this.registerRecipe(Block.EMERALD_ORE.id, new ItemStack(Item.EMERALD), 1.0F); + this.registerRecipe(Item.POTATO.id, new ItemStack(Item.POTATO_BAKED), 0.35F); this.registerRecipe(Block.COAL_ORE.id, new ItemStack(Item.COAL), 0.1F); this.registerRecipe(Block.REDSTONE_ORE.id, new ItemStack(Item.REDSTONE), 0.7F); this.registerRecipe(Block.LAPIS_ORE.id, new ItemStack(Item.INK_SACK, 1, 4), 0.2F); diff --git a/src/main/java/net/minecraft/server/RecipesMapClone.java b/src/main/java/net/minecraft/server/RecipesMapClone.java new file mode 100644 index 00000000..f9213730 --- /dev/null +++ b/src/main/java/net/minecraft/server/RecipesMapClone.java @@ -0,0 +1,82 @@ +package net.minecraft.server; + +// CraftBukkit start +import java.util.List; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; +// CraftBukkit end + +public class RecipesMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + + // CraftBukkit start - delegate to new parent class + public RecipesMapClone() { + super(new ItemStack(Item.MAP, 0, -1), java.util.Arrays.asList(new ItemStack(Item.MAP_EMPTY, 0, 0))); + } + // CraftBukkit end + + public boolean a(InventoryCrafting inventorycrafting, World world) { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < inventorycrafting.getSize(); ++j) { + ItemStack itemstack1 = inventorycrafting.getItem(j); + + if (itemstack1 != null) { + if (itemstack1.id == Item.MAP.id) { + if (itemstack != null) { + return false; + } + + itemstack = itemstack1; + } else { + if (itemstack1.id != Item.MAP_EMPTY.id) { + return false; + } + + ++i; + } + } + } + + return itemstack != null && i > 0; + } + + public ItemStack a(InventoryCrafting inventorycrafting) { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < inventorycrafting.getSize(); ++j) { + ItemStack itemstack1 = inventorycrafting.getItem(j); + + if (itemstack1 != null) { + if (itemstack1.id == Item.MAP.id) { + if (itemstack != null) { + return null; + } + + itemstack = itemstack1; + } else { + if (itemstack1.id != Item.MAP_EMPTY.id) { + return null; + } + + ++i; + } + } + } + + if (itemstack != null && i >= 1) { + return new ItemStack(Item.MAP, i + 1, itemstack.getData()); + } else { + return null; + } + } + + public int a() { + return 9; + } + + public ItemStack b() { + return null; + } +} diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManagerAbstract.java b/src/main/java/net/minecraft/server/ServerConfigurationManagerAbstract.java index c3aa44a1..93e8ef6f 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManagerAbstract.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManagerAbstract.java @@ -4,6 +4,7 @@ import java.io.File; import java.net.SocketAddress; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -91,10 +92,10 @@ public abstract class ServerConfigurationManagerAbstract { // this.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - handled in event this.c(entityplayer); netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); - this.server.ac().a(netserverhandler); - netserverhandler.sendPacket(new Packet4UpdateTime(worldserver.getTime())); + this.server.ae().a(netserverhandler); + netserverhandler.sendPacket(new Packet4UpdateTime(worldserver.getTime(), worldserver.F())); if (this.server.getTexturePack().length() > 0) { - entityplayer.a(this.server.getTexturePack(), this.server.R()); + entityplayer.a(this.server.getTexturePack(), this.server.S()); } Iterator iterator = entityplayer.getEffects().iterator(); @@ -114,7 +115,7 @@ public abstract class ServerConfigurationManagerAbstract { } public void a(EntityPlayer entityplayer, WorldServer worldserver) { - WorldServer worldserver1 = entityplayer.q(); + WorldServer worldserver1 = entityplayer.p(); if (worldserver != null) { worldserver.getPlayerManager().removePlayer(entityplayer); @@ -129,9 +130,9 @@ public abstract class ServerConfigurationManagerAbstract { } public void a(EntityPlayer entityplayer) { - NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().h(); // CraftBukkit + NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().i(); // CraftBukkit - if (entityplayer.getName().equals(this.server.G()) && nbttagcompound != null) { + if (entityplayer.getName().equals(this.server.H()) && nbttagcompound != null) { entityplayer.e(nbttagcompound); } else { this.playerFileData.load(entityplayer); @@ -195,7 +196,7 @@ public abstract class ServerConfigurationManagerAbstract { } public void d(EntityPlayer entityplayer) { - entityplayer.q().getPlayerManager().movePlayer(entityplayer); + entityplayer.p().getPlayerManager().movePlayer(entityplayer); } public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string @@ -207,7 +208,7 @@ public abstract class ServerConfigurationManagerAbstract { // CraftBukkit end this.b(entityplayer); - WorldServer worldserver = entityplayer.q(); + WorldServer worldserver = entityplayer.p(); worldserver.kill(entityplayer); worldserver.getPlayerManager().removePlayer(entityplayer); @@ -232,7 +233,7 @@ public abstract class ServerConfigurationManagerAbstract { // Instead of kicking then returning, we need to store the kick reason // in the event, check with plugins to see if it's ok, and THEN kick // depending on the outcome. - EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.L() ? new DemoItemInWorldManager(this.server.getWorldServer(0)) : new ItemInWorldManager(this.server.getWorldServer(0))); + EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, this.server.M() ? new DemoItemInWorldManager(this.server.getWorldServer(0)) : new ItemInWorldManager(this.server.getWorldServer(0))); Player player = entity.getBukkitEntity(); PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, netloginhandler.getSocket().getInetAddress()); @@ -304,7 +305,7 @@ public abstract class ServerConfigurationManagerAbstract { /* CraftBukkit start Object object; - if (this.server.L()) { + if (this.server.M()) { object = new DemoItemInWorldManager(this.server.getWorldServer(0)); } else { object = new ItemInWorldManager(this.server.getWorldServer(0)); @@ -323,12 +324,13 @@ public abstract class ServerConfigurationManagerAbstract { public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location) { // CraftBukkit end - entityplayer.q().getTracker().untrackPlayer(entityplayer); - // entityplayer.q().getTracker().untrackEntity(entityplayer); // CraftBukkit - entityplayer.q().getPlayerManager().removePlayer(entityplayer); + entityplayer.p().getTracker().untrackPlayer(entityplayer); + // entityplayer.p().getTracker().untrackEntity(entityplayer); // CraftBukkit + entityplayer.p().getPlayerManager().removePlayer(entityplayer); this.players.remove(entityplayer); this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); ChunkCoordinates chunkcoordinates = entityplayer.getBed(); + boolean flag1 = entityplayer.isRespawnForced(); // CraftBukkit start EntityPlayer entityplayer1 = entityplayer; @@ -342,12 +344,12 @@ public abstract class ServerConfigurationManagerAbstract { boolean isBedSpawn = false; CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); if (cworld != null && chunkcoordinates != null) { - chunkcoordinates1 = EntityHuman.getBed(cworld.getHandle(), chunkcoordinates); + chunkcoordinates1 = EntityHuman.getBed(cworld.getHandle(), chunkcoordinates, flag); if (chunkcoordinates1 != null) { isBedSpawn = true; location = new Location(cworld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5); } else { - entityplayer1.setRespawnPosition(null); + entityplayer1.setRespawnPosition(null, true); entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0, 0)); } } @@ -389,6 +391,7 @@ public abstract class ServerConfigurationManagerAbstract { chunkcoordinates1 = worldserver.getSpawn(); // CraftBukkit end entityplayer1.netServerHandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z)); + entityplayer1.netServerHandler.sendPacket(new Packet43SetExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); this.b(entityplayer1, worldserver); worldserver.getPlayerManager().addPlayer(entityplayer1); worldserver.addEntity(entityplayer1); @@ -485,6 +488,61 @@ public abstract class ServerConfigurationManagerAbstract { // CraftBukkit end } + public void a(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { + double d0 = entity.locX; + double d1 = entity.locZ; + double d2 = 8.0D; + double d3 = entity.locX; + double d4 = entity.locY; + double d5 = entity.locZ; + float f = entity.yaw; + + if (entity.dimension == -1) { + d0 /= d2; + d1 /= d2; + entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); + if (entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); + } + } else if (entity.dimension == 0) { + d0 *= d2; + d1 *= d2; + entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); + if (entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); + } + } else { + ChunkCoordinates chunkcoordinates; + + if (i == 1) { + chunkcoordinates = worldserver1.getSpawn(); + } else { + chunkcoordinates = worldserver1.getDimensionSpawn(); + } + + d0 = (double) chunkcoordinates.x; + entity.locY = (double) chunkcoordinates.y; + d1 = (double) chunkcoordinates.z; + entity.setPositionRotation(d0, entity.locY, d1, 90.0F, 0.0F); + if (entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); + } + } + + if (i != 1) { + d0 = (double) MathHelper.a((int) d0, -29999872, 29999872); + d1 = (double) MathHelper.a((int) d1, -29999872, 29999872); + if (entity.isAlive()) { + worldserver1.addEntity(entity); + entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); + worldserver1.entityJoinedWorld(entity, false); + (new PortalTravelAgent()).a(worldserver1, entity, d3, d4, d5, f); + } + } + + entity.spawnIn(worldserver1); + } + public void tick() { if (++this.o > 600) { this.o = 0; @@ -578,7 +636,7 @@ public abstract class ServerConfigurationManagerAbstract { public boolean isOp(String s) { // CraftBukkit - return this.operators.contains(s.trim().toLowerCase()) || this.server.H() && this.server.worlds.get(0).getWorldData().allowCommands() && this.server.G().equalsIgnoreCase(s) || this.n; + return this.operators.contains(s.trim().toLowerCase()) || this.server.I() && this.server.worlds.get(0).getWorldData().allowCommands() && this.server.H().equalsIgnoreCase(s) || this.n; } public EntityPlayer f(String s) { @@ -597,8 +655,51 @@ public abstract class ServerConfigurationManagerAbstract { return entityplayer; } + public List a(ChunkCoordinates chunkcoordinates, int i, int j, int k, int l, int i1, int j1) { + if (this.players.isEmpty()) { + return null; + } else { + Object object = new ArrayList(); + boolean flag = k < 0; + int k1 = i * i; + int l1 = j * j; + + k = MathHelper.a(k); + + for (int i2 = 0; i2 < this.players.size(); ++i2) { + EntityPlayer entityplayer = (EntityPlayer) this.players.get(i2); + + if (chunkcoordinates != null && (i > 0 || j > 0)) { + float f = chunkcoordinates.e(entityplayer.b()); + + if (i > 0 && f < (float) k1 || j > 0 && f > (float) l1) { + continue; + } + } + + if ((l == EnumGamemode.NONE.a() || l == entityplayer.itemInWorldManager.getGameMode().a()) && (i1 <= 0 || entityplayer.expLevel >= i1) && entityplayer.expLevel <= j1) { + ((List) object).add(entityplayer); + } + } + + if (chunkcoordinates != null) { + Collections.sort((List) object, new PlayerDistanceComparator(chunkcoordinates)); + } + + if (flag) { + Collections.reverse((List) object); + } + + if (k > 0) { + object = ((List) object).subList(0, Math.min(k, ((List) object).size())); + } + + return (List) object; + } + } + public void sendPacketNearby(double d0, double d1, double d2, double d3, int i, Packet packet) { - this.sendPacketNearby((EntityHuman) null, d0, d1, d2, d3, i, packet); + this.sendPacketNearby(d0, d1, d2, d3, i, packet, null); // CraftBukkit } // CraftBukkit start - Add support for entity who caused the packet @@ -663,15 +764,15 @@ public abstract class ServerConfigurationManagerAbstract { public void reloadWhitelist() {} public void b(EntityPlayer entityplayer, WorldServer worldserver) { - entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(worldserver.getTime())); - if (worldserver.J()) { + entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(worldserver.getTime(), worldserver.F())); + if (worldserver.M()) { entityplayer.netServerHandler.sendPacket(new Packet70Bed(1, 0)); } } public void updateClient(EntityPlayer entityplayer) { entityplayer.updateInventory(entityplayer.defaultContainer); - entityplayer.n(); + entityplayer.m(); } public int getPlayerCount() { @@ -701,7 +802,7 @@ public abstract class ServerConfigurationManagerAbstract { while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - if (entityplayer.r().equals(s)) { + if (entityplayer.q().equals(s)) { arraylist.add(entityplayer); } } diff --git a/src/main/java/net/minecraft/server/ShapedRecipes.java b/src/main/java/net/minecraft/server/ShapedRecipes.java index 83d4a176..0a48d45b 100644 --- a/src/main/java/net/minecraft/server/ShapedRecipes.java +++ b/src/main/java/net/minecraft/server/ShapedRecipes.java @@ -81,7 +81,7 @@ public class ShapedRecipes implements IRecipe { return this.result; } - public boolean a(InventoryCrafting inventorycrafting) { + public boolean a(InventoryCrafting inventorycrafting, World world) { for (int i = 0; i <= 3 - this.width; ++i) { for (int j = 0; j <= 3 - this.height; ++j) { if (this.a(inventorycrafting, i, j, true)) { @@ -133,8 +133,8 @@ public class ShapedRecipes implements IRecipe { return true; } - public ItemStack b(InventoryCrafting inventorycrafting) { - return new ItemStack(this.result.id, this.result.count, this.result.getData(), this.result.getEnchantments()); // CraftBukkit - copy enchantments + public ItemStack a(InventoryCrafting inventorycrafting) { + return this.b().cloneItemStack(); } public int a() { diff --git a/src/main/java/net/minecraft/server/ShapelessRecipes.java b/src/main/java/net/minecraft/server/ShapelessRecipes.java index 1ff6fdcd..f14d78be 100644 --- a/src/main/java/net/minecraft/server/ShapelessRecipes.java +++ b/src/main/java/net/minecraft/server/ShapelessRecipes.java @@ -37,7 +37,7 @@ public class ShapelessRecipes implements IRecipe { return this.result; } - public boolean a(InventoryCrafting inventorycrafting) { + public boolean a(InventoryCrafting inventorycrafting, World world) { ArrayList arraylist = new ArrayList(this.ingredients); for (int i = 0; i < 3; ++i) { @@ -68,7 +68,7 @@ public class ShapelessRecipes implements IRecipe { return arraylist.isEmpty(); } - public ItemStack b(InventoryCrafting inventorycrafting) { + public ItemStack a(InventoryCrafting inventorycrafting) { return this.result.cloneItemStack(); } diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java index e260863c..079a8270 100644 --- a/src/main/java/net/minecraft/server/Slot.java +++ b/src/main/java/net/minecraft/server/Slot.java @@ -4,15 +4,15 @@ public class Slot { public final int index; // CraftBukkit - private -> public public final IInventory inventory; - public int d; - public int e; - public int f; + public int g; + public int h; + public int i; public Slot(IInventory iinventory, int i, int j, int k) { this.inventory = iinventory; this.index = i; - this.e = j; - this.f = k; + this.h = j; + this.i = k; } public void a(ItemStack itemstack, ItemStack itemstack1) { @@ -29,9 +29,9 @@ public class Slot { protected void a(ItemStack itemstack, int i) {} - protected void c(ItemStack itemstack) {} + protected void b(ItemStack itemstack) {} - public void b(ItemStack itemstack) { + public void a(EntityHuman entityhuman, ItemStack itemstack) { this.e(); } @@ -67,4 +67,8 @@ public class Slot { public boolean a(IInventory iinventory, int i) { return iinventory == this.inventory && i == this.index; } + + public boolean a(EntityHuman entityhuman) { + return true; + } } diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java index efde3f71..52f9323e 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -21,12 +21,12 @@ public final class SpawnerCreature { Chunk chunk = world.getChunkAt(i, j); int k = i * 16 + world.random.nextInt(16); int l = j * 16 + world.random.nextInt(16); - int i1 = world.random.nextInt(chunk == null ? world.L() : chunk.h() + 16 - 1); + int i1 = world.random.nextInt(chunk == null ? world.O() : chunk.h() + 16 - 1); return new ChunkPosition(k, i1, l); } - public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1) { + public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1, boolean flag2) { if (!flag && !flag1) { return 0; } else { @@ -44,12 +44,12 @@ public final class SpawnerCreature { for (int l = -b0; l <= b0; ++l) { for (int i1 = -b0; i1 <= b0; ++i1) { - boolean flag2 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0; + boolean flag3 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0; // CraftBukkit start long chunkCoords = LongHash.toLong(l + k, i1 + j); - if (!flag2) { + if (!flag3) { b.put(chunkCoords, false); } else if (!b.containsKey(chunkCoords)) { b.put(chunkCoords, true); @@ -87,10 +87,10 @@ public final class SpawnerCreature { } // CraftBukkit end - if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits + if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits Iterator iterator = b.keySet().iterator(); - label108: + label110: while (iterator.hasNext()) { // CraftBukkit start long key = ((Long) iterator.next()).longValue(); @@ -116,7 +116,7 @@ public final class SpawnerCreature { while (true) { if (k3 < 4) { - label101: { + label103: { l2 += worldserver.random.nextInt(b1) - worldserver.random.nextInt(b1); i3 += worldserver.random.nextInt(1) - worldserver.random.nextInt(1); j3 += worldserver.random.nextInt(b1) - worldserver.random.nextInt(b1); @@ -135,7 +135,7 @@ public final class SpawnerCreature { if (biomemeta == null) { biomemeta = worldserver.a(enumcreaturetype, l2, i3, j3); if (biomemeta == null) { - break label101; + break label103; } } @@ -154,8 +154,8 @@ public final class SpawnerCreature { // CraftBukkit - added a reason for spawning this creature worldserver.addEntity(entityliving, SpawnReason.NATURAL); a(entityliving, worldserver, f, f1, f2); - if (j2 >= entityliving.bl()) { - continue label108; + if (j2 >= entityliving.bs()) { + continue label110; } } @@ -197,24 +197,7 @@ public final class SpawnerCreature { private static void a(EntityLiving entityliving, World world, float f, float f1, float f2) { if (entityliving.dead) return; // CraftBukkit - if (entityliving instanceof EntitySpider && world.random.nextInt(100) == 0) { - EntitySkeleton entityskeleton = new EntitySkeleton(world); - - entityskeleton.setPositionRotation((double) f, (double) f1, (double) f2, entityliving.yaw, 0.0F); - // CraftBukkit - added a reason for spawning this creature - world.addEntity(entityskeleton, SpawnReason.JOCKEY); - entityskeleton.mount(entityliving); - } else if (entityliving instanceof EntitySheep) { - ((EntitySheep) entityliving).setColor(EntitySheep.a(world.random)); - } else if (entityliving instanceof EntityOcelot && world.random.nextInt(7) == 0) { - for (int i = 0; i < 2; ++i) { - EntityOcelot entityocelot = new EntityOcelot(world); - - entityocelot.setPositionRotation((double) f, (double) f1, (double) f2, entityliving.yaw, 0.0F); - entityocelot.setAge(-24000); - world.addEntity(entityocelot, SpawnReason.NATURAL); // CraftBukkit - added SpawnReason - } - } + entityliving.bD(); } public static void a(World world, BiomeBase biomebase, int i, int j, int k, int l, Random random) { @@ -233,7 +216,7 @@ public final class SpawnerCreature { boolean flag = false; for (int k2 = 0; !flag && k2 < 4; ++k2) { - int l2 = world.h(j1, k1); + int l2 = world.i(j1, k1); if (a(EnumCreatureType.CREATURE, world, j1, l2, k1)) { float f = (float) j1 + 0.5F; diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java index 08a2703d..8bb1f71e 100644 --- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java +++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java @@ -28,7 +28,7 @@ class ThreadLoginVerifier extends Thread { public void run() { try { - String s = (new BigInteger(MinecraftEncryption.a(NetLoginHandler.a(this.netLoginHandler), NetLoginHandler.b(this.netLoginHandler).E().getPublic(), NetLoginHandler.c(this.netLoginHandler)))).toString(16); + String s = (new BigInteger(MinecraftEncryption.a(NetLoginHandler.a(this.netLoginHandler), NetLoginHandler.b(this.netLoginHandler).F().getPublic(), NetLoginHandler.c(this.netLoginHandler)))).toString(16); URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(NetLoginHandler.d(this.netLoginHandler), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8")); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); String s1 = bufferedreader.readLine(); diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java index 869e03c2..87d5cd26 100644 --- a/src/main/java/net/minecraft/server/TileEntity.java +++ b/src/main/java/net/minecraft/server/TileEntity.java @@ -28,11 +28,11 @@ public class TileEntity { } } - public void a(World world) { + public void b(World world) { this.world = world; } - public boolean m() { + public boolean o() { return this.world != null; } @@ -79,7 +79,7 @@ public class TileEntity { return tileentity; } - public int n() { + public int p() { if (this.p == -1) { this.p = this.world.getData(this.x, this.y, this.z); } @@ -94,19 +94,27 @@ public class TileEntity { } } - public Packet e() { + public Block q() { + if (this.q == null) { + this.q = Block.byId[this.world.getTypeId(this.x, this.y, this.z)]; + } + + return this.q; + } + + public Packet l() { return null; } - public boolean p() { + public boolean r() { return this.o; } - public void j() { + public void w_() { this.o = true; } - public void q() { + public void s() { this.o = false; } @@ -130,6 +138,9 @@ public class TileEntity { a(TileEntityBrewingStand.class, "Cauldron"); a(TileEntityEnchantTable.class, "EnchantTable"); a(TileEntityEnderPortal.class, "Airportal"); + a(TileEntityCommand.class, "Control"); + a(TileEntityBeacon.class, "Beacon"); + a(TileEntitySkull.class, "Skull"); } // CraftBukkit start diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java new file mode 100644 index 00000000..5478b059 --- /dev/null +++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java @@ -0,0 +1,251 @@ +package net.minecraft.server; + +import java.util.Iterator; +import java.util.List; + +// CraftBukkit start +import java.util.List; + +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + +public class TileEntityBeacon extends TileEntity implements IInventory { + + public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffectList.FASTER_MOVEMENT, MobEffectList.FASTER_DIG}, { MobEffectList.RESISTANCE, MobEffectList.JUMP}, { MobEffectList.INCREASE_DAMAGE}, { MobEffectList.REGENERATION}}; + private boolean d; + private int e = -1; + private int f; + private int g; + private ItemStack h; + // CraftBukkit start + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + private int maxStack = MAX_STACK; + + public ItemStack[] getContents() { + return null; + } + + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + public List<HumanEntity> getViewers() { + return transaction; + } + + public void setMaxStackSize(int size) { + maxStack = size; + } + // CraftBukkit end + + public TileEntityBeacon() {} + + public void g() { + if (this.world.getTime() % 80L == 0L) { + this.u(); + this.t(); + } + } + + private void t() { + if (this.d && this.e > 0 && !this.world.isStatic && this.f > 0) { + double d0 = (double) (this.e * 8 + 8); + byte b0 = 0; + + if (this.e >= 4 && this.f == this.g) { + b0 = 1; + } + + AxisAlignedBB axisalignedbb = AxisAlignedBB.a().a((double) this.x, (double) this.y, (double) this.z, (double) (this.x + 1), (double) (this.y + 1), (double) (this.z + 1)).grow(d0, d0, d0); + List list = this.world.a(EntityHuman.class, axisalignedbb); + Iterator iterator = list.iterator(); + + EntityHuman entityhuman; + + while (iterator.hasNext()) { + entityhuman = (EntityHuman) iterator.next(); + entityhuman.addEffect(new MobEffect(this.f, 180, b0, true)); + } + + if (this.e >= 4 && this.f != this.g && this.g > 0) { + iterator = list.iterator(); + + while (iterator.hasNext()) { + entityhuman = (EntityHuman) iterator.next(); + entityhuman.addEffect(new MobEffect(this.g, 180, 0, true)); + } + } + } + } + + private void u() { + if (!this.world.j(this.x, this.y + 1, this.z)) { + this.d = false; + this.e = 0; + } else { + this.d = true; + this.e = 0; + + for (int i = 1; i <= 4; this.e = i++) { + int j = this.y - i; + + if (j < 1) { + break; + } + + boolean flag = true; + + for (int k = this.x - i; k <= this.x + i && flag; ++k) { + for (int l = this.z - i; l <= this.z + i; ++l) { + int i1 = this.world.getTypeId(k, j, l); + + if (i1 != Block.EMERALD_BLOCK.id && i1 != Block.GOLD_BLOCK.id && i1 != Block.DIAMOND_BLOCK.id && i1 != Block.IRON_BLOCK.id) { + flag = false; + break; + } + } + } + + if (!flag) { + break; + } + } + + if (this.e == 0) { + this.d = false; + } + } + } + + public int i() { + return this.f; + } + + public int j() { + return this.g; + } + + public int k() { + return this.e; + } + + public void d(int i) { + this.f = 0; + + for (int j = 0; j < this.e && j < 3; ++j) { + MobEffectList[] amobeffectlist = a[j]; + int k = amobeffectlist.length; + + for (int l = 0; l < k; ++l) { + MobEffectList mobeffectlist = amobeffectlist[l]; + + if (mobeffectlist.id == i) { + this.f = i; + return; + } + } + } + } + + public void e(int i) { + this.g = 0; + if (this.e >= 4) { + for (int j = 0; j < 4; ++j) { + MobEffectList[] amobeffectlist = a[j]; + int k = amobeffectlist.length; + + for (int l = 0; l < k; ++l) { + MobEffectList mobeffectlist = amobeffectlist[l]; + + if (mobeffectlist.id == i) { + this.g = i; + return; + } + } + } + } + } + + public Packet l() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + this.b(nbttagcompound); + return new Packet132TileEntityData(this.x, this.y, this.z, 3, nbttagcompound); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.f = nbttagcompound.getInt("Primary"); + this.g = nbttagcompound.getInt("Secondary"); + this.e = nbttagcompound.getInt("Levels"); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.setInt("Primary", this.f); + nbttagcompound.setInt("Secondary", this.g); + nbttagcompound.setInt("Levels", this.e); + } + + public int getSize() { + return 1; + } + + public ItemStack getItem(int i) { + return i == 0 ? this.h : null; + } + + public ItemStack splitStack(int i, int j) { + if (i == 0 && this.h != null) { + if (j >= this.h.count) { + ItemStack itemstack = this.h; + + this.h = null; + return itemstack; + } else { + this.h.count -= j; + return new ItemStack(this.h.id, j, this.h.getData()); + } + } else { + return null; + } + } + + public ItemStack splitWithoutUpdate(int i) { + if (i == 0 && this.h != null) { + ItemStack itemstack = this.h; + + this.h = null; + return itemstack; + } else { + return null; + } + } + + public void setItem(int i, ItemStack itemstack) { + if (i == 0) { + this.h = itemstack; + } + } + + public String getName() { + return "container.beacon"; + } + + public int getMaxStackSize() { + return maxStack; // CraftBukkit + } + + public boolean a(EntityHuman entityhuman) { + return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D; + } + + public void startOpen() {} + + public void f() {} +} diff --git a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java b/src/main/java/net/minecraft/server/TileEntityBrewingStand.java index 29c5d28a..2126950e 100644 --- a/src/main/java/net/minecraft/server/TileEntityBrewingStand.java +++ b/src/main/java/net/minecraft/server/TileEntityBrewingStand.java @@ -54,7 +54,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { if (this.brewTime > 0) { --this.brewTime; if (this.brewTime == 0) { - this.r(); + this.t(); this.update(); } else if (!this.k()) { this.brewTime = 0; @@ -78,7 +78,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { super.g(); } - public int t_() { + public int x_() { return this.brewTime; } @@ -86,7 +86,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { if (this.items[3] != null && this.items[3].count > 0) { ItemStack itemstack = this.items[3]; - if (!Item.byId[itemstack.id].u()) { + if (!Item.byId[itemstack.id].v()) { return false; } else { boolean flag = false; @@ -118,7 +118,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { } } - private void r() { + private void t() { if (this.k()) { ItemStack itemstack = this.items[3]; @@ -149,8 +149,8 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { } } - if (Item.byId[itemstack.id].r()) { - this.items[3] = new ItemStack(Item.byId[itemstack.id].q()); + if (Item.byId[itemstack.id].s()) { + this.items[3] = new ItemStack(Item.byId[itemstack.id].r()); } else { --this.items[3].count; if (this.items[3].count <= 0) { @@ -161,7 +161,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory { } private int b(int i, ItemStack itemstack) { - return itemstack == null ? i : (Item.byId[itemstack.id].u() ? PotionBrewer.a(i, Item.byId[itemstack.id].t()) : i); + return itemstack == null ? i : (Item.byId[itemstack.id].v() ? PotionBrewer.a(i, Item.byId[itemstack.id].u()) : i); } public void a(NBTTagCompound nbttagcompound) { diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java index 1ea52c0a..91488ebc 100644 --- a/src/main/java/net/minecraft/server/TileEntityChest.java +++ b/src/main/java/net/minecraft/server/TileEntityChest.java @@ -271,9 +271,9 @@ public class TileEntityChest extends TileEntity implements IInventory { this.world.playNote(this.x, this.y, this.z, Block.CHEST.id, 1, this.h); } - public void j() { + public void w_() { this.h(); this.i(); - super.j(); + super.w_(); } } diff --git a/src/main/java/net/minecraft/server/TileEntityCommand.java b/src/main/java/net/minecraft/server/TileEntityCommand.java new file mode 100644 index 00000000..d9a04fae --- /dev/null +++ b/src/main/java/net/minecraft/server/TileEntityCommand.java @@ -0,0 +1,62 @@ +package net.minecraft.server; + +public class TileEntityCommand extends TileEntity implements ICommandListener { + + private String a = ""; + + public TileEntityCommand() {} + + public void b(String s) { + this.a = s; + this.update(); + } + + public void a(World world) { + if (!world.isStatic) { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + + if (minecraftserver != null && minecraftserver.getEnableCommandBlock()) { + // CraftBukkit start - disable command block TODO: hook this up to bukkit API + // ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); + + // icommandhandler.a(this, this.a); + // CraftBukkit end + } + } + } + + public String getName() { + return "@"; + } + + public void sendMessage(String s) {} + + public boolean a(int i, String s) { + return i <= 2; + } + + public String a(String s, Object... aobject) { + return s; + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.setString("Command", this.a); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.a = nbttagcompound.getString("Command"); + } + + public ChunkCoordinates b() { + return new ChunkCoordinates(this.x, this.y, this.z); + } + + public Packet l() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + this.b(nbttagcompound); + return new Packet132TileEntityData(this.x, this.y, this.z, 2, nbttagcompound); + } +} diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java index 7a28e37d..b8be7aa9 100644 --- a/src/main/java/net/minecraft/server/TileEntityDispenser.java +++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java @@ -106,7 +106,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory { this.update(); } - public int a(ItemStack itemstack) { + public int addItem(ItemStack itemstack) { for (int i = 0; i < this.items.length; ++i) { if (this.items[i] == null || this.items[i].id == 0) { this.items[i] = itemstack; diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 62bcc828..299c6864 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -189,7 +189,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { if (this.items[1] != null) { --this.items[1].count; if (this.items[1].count == 0) { - Item item = this.items[1].getItem().q(); + Item item = this.items[1].getItem().r(); this.items[1] = item != null ? new ItemStack(item) : null; } @@ -285,8 +285,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory { } } - return item instanceof ItemTool && ((ItemTool) item).e().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword) item).f().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe) item).f().equals("WOOD") ? 200 : (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))))))); - } + return item instanceof ItemTool && ((ItemTool) item).g().equals("WOOD") ? 200 : (item instanceof ItemSword && ((ItemSword) item).h().equals("WOOD") ? 200 : (item instanceof ItemHoe && ((ItemHoe) item).g().equals("WOOD") ? 200 : (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))))))); } } public static boolean isFuel(ItemStack itemstack) { diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java index 736477e2..0f3b7b03 100644 --- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java +++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java @@ -12,6 +12,9 @@ public class TileEntityMobSpawner extends TileEntity { private int minSpawnDelay = 200; private int maxSpawnDelay = 800; private int spawnCount = 4; + private int maxNearbyEntities = 6; + private int requiredPlayerRange = 16; + private int spawnRange = 4; public TileEntityMobSpawner() { this.spawnDelay = 20; @@ -22,7 +25,7 @@ public class TileEntityMobSpawner extends TileEntity { } public boolean b() { - return this.world.findNearbyPlayer((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D, 16.0D) != null; + return this.world.findNearbyPlayer((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D, (double) this.requiredPlayerRange) != null; } public void g() { @@ -32,13 +35,17 @@ public class TileEntityMobSpawner extends TileEntity { double d1 = (double) ((float) this.y + this.world.random.nextFloat()); double d2 = (double) ((float) this.z + this.world.random.nextFloat()); - 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); - this.c = this.b % 360.0D; - this.b += 4.545454502105713D; + this.world.addParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.world.addParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + if (this.spawnDelay > 0) { + --this.spawnDelay; + } + + this.c = this.b; + this.b = (this.b + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; } else { if (this.spawnDelay == -1) { - this.f(); + this.e(); } if (this.spawnDelay > 0) { @@ -53,17 +60,17 @@ public class TileEntityMobSpawner extends TileEntity { return; } - int j = this.world.a(entity.getClass(), AxisAlignedBB.a().a((double) this.x, (double) this.y, (double) this.z, (double) (this.x + 1), (double) (this.y + 1), (double) (this.z + 1)).grow(8.0D, 4.0D, 8.0D)).size(); + int j = this.world.a(entity.getClass(), AxisAlignedBB.a().a((double) this.x, (double) this.y, (double) this.z, (double) (this.x + 1), (double) (this.y + 1), (double) (this.z + 1)).grow((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size(); - if (j >= 6) { - this.f(); + if (j >= this.maxNearbyEntities) { + this.e(); return; } if (entity != null) { - double d3 = (double) this.x + (this.world.random.nextDouble() - this.world.random.nextDouble()) * 4.0D; + double d3 = (double) this.x + (this.world.random.nextDouble() - this.world.random.nextDouble()) * (double) this.spawnRange; double d4 = (double) (this.y + this.world.random.nextInt(3) - 1); - double d5 = (double) this.z + (this.world.random.nextDouble() - this.world.random.nextDouble()) * 4.0D; + double d5 = (double) this.z + (this.world.random.nextDouble() - this.world.random.nextDouble()) * (double) this.spawnRange; EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; entity.setPositionRotation(d3, d4, d5, this.world.random.nextFloat() * 360.0F, 0.0F); @@ -72,10 +79,10 @@ public class TileEntityMobSpawner extends TileEntity { this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit this.world.triggerEffect(2004, this.x, this.y, this.z, 0); if (entityliving != null) { - entityliving.aK(); + entityliving.aQ(); } - this.f(); + this.e(); } } } @@ -99,11 +106,14 @@ public class TileEntityMobSpawner extends TileEntity { } entity.e(nbttagcompound); + } else if (entity instanceof EntityLiving && entity.world != null) { + ((EntityLiving) entity).bD(); } } - private void f() { + private void e() { this.spawnDelay = this.minSpawnDelay + this.world.random.nextInt(this.maxSpawnDelay - this.minSpawnDelay); + this.world.playNote(this.x, this.y, this.z, this.q().id, 1, 0); } public void a(NBTTagCompound nbttagcompound) { @@ -121,6 +131,15 @@ public class TileEntityMobSpawner extends TileEntity { this.maxSpawnDelay = nbttagcompound.getShort("MaxSpawnDelay"); this.spawnCount = nbttagcompound.getShort("SpawnCount"); } + + if (nbttagcompound.hasKey("MaxNearbyEntities")) { + this.maxNearbyEntities = nbttagcompound.getShort("MaxNearbyEntities"); + this.requiredPlayerRange = nbttagcompound.getShort("RequiredPlayerRange"); + } + + if (nbttagcompound.hasKey("SpawnRange")) { + this.spawnRange = nbttagcompound.getShort("SpawnRange"); + } } public void b(NBTTagCompound nbttagcompound) { @@ -130,15 +149,24 @@ public class TileEntityMobSpawner extends TileEntity { nbttagcompound.setShort("MinSpawnDelay", (short) this.minSpawnDelay); nbttagcompound.setShort("MaxSpawnDelay", (short) this.maxSpawnDelay); nbttagcompound.setShort("SpawnCount", (short) this.spawnCount); + nbttagcompound.setShort("MaxNearbyEntities", (short) this.maxNearbyEntities); + nbttagcompound.setShort("RequiredPlayerRange", (short) this.requiredPlayerRange); + nbttagcompound.setShort("SpawnRange", (short) this.spawnRange); if (this.spawnData != null) { nbttagcompound.setCompound("SpawnData", this.spawnData); } } - public Packet e() { + public Packet l() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.b(nbttagcompound); return new Packet132TileEntityData(this.x, this.y, this.z, 1, nbttagcompound); } + + public void b(int i, int j) { + if (i == 1 && this.world.isStatic) { + this.spawnDelay = this.minSpawnDelay; + } + } } diff --git a/src/main/java/net/minecraft/server/TileEntityPiston.java b/src/main/java/net/minecraft/server/TileEntityPiston.java index a5d3246a..20d0cb0e 100644 --- a/src/main/java/net/minecraft/server/TileEntityPiston.java +++ b/src/main/java/net/minecraft/server/TileEntityPiston.java @@ -29,7 +29,7 @@ public class TileEntityPiston extends TileEntity { return this.a; } - public int n() { + public int p() { return this.b; } @@ -76,11 +76,11 @@ public class TileEntityPiston extends TileEntity { } } - public void i() { + public void f() { if (this.g < 1.0F && this.world != null) { this.g = this.f = 1.0F; this.world.q(this.x, this.y, this.z); - this.j(); + this.w_(); if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) { this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b); } @@ -94,7 +94,7 @@ public class TileEntityPiston extends TileEntity { if (this.g >= 1.0F) { this.a(1.0F, 0.25F); this.world.q(this.x, this.y, this.z); - this.j(); + this.w_(); if (this.world.getTypeId(this.x, this.y, this.z) == Block.PISTON_MOVING.id) { this.world.setTypeIdAndData(this.x, this.y, this.z, this.a, this.b); } diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java index 87cf6593..20457593 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 e() { + public Packet l() { String[] astring = new String[4]; // CraftBukkit start - limit sign text to 15 chars per line diff --git a/src/main/java/net/minecraft/server/Vec3D.java b/src/main/java/net/minecraft/server/Vec3D.java index 2122b93f..a668e18f 100644 --- a/src/main/java/net/minecraft/server/Vec3D.java +++ b/src/main/java/net/minecraft/server/Vec3D.java @@ -2,21 +2,18 @@ package net.minecraft.server; public class Vec3D { - private static final ThreadLocal d = new Vec3DPoolThreadLocal(); - public double a; - public double b; + public static final Vec3DPool a = new Vec3DPool(-1, -1); + public final Vec3DPool b; public double c; + public double d; + public double e; public Vec3D next; // CraftBukkit public static Vec3D a(double d0, double d1, double d2) { - return new Vec3D(d0, d1, d2); + return new Vec3D(a, d0, d1, d2); } - public static Vec3DPool a() { - return (Vec3DPool) d.get(); - } - - protected Vec3D(double d0, double d1, double d2) { + protected Vec3D(Vec3DPool vec3dpool, double d0, double d1, double d2) { if (d0 == -0.0D) { d0 = 0.0D; } @@ -29,127 +26,128 @@ public class Vec3D { d2 = 0.0D; } - this.a = d0; - this.b = d1; - this.c = d2; + this.c = d0; + this.d = d1; + this.e = d2; + this.b = vec3dpool; } protected Vec3D b(double d0, double d1, double d2) { - this.a = d0; - this.b = d1; - this.c = d2; + this.c = d0; + this.d = d1; + this.e = d2; return this; } - public Vec3D b() { - double d0 = (double) MathHelper.sqrt(this.a * this.a + this.b * this.b + this.c * this.c); + public Vec3D a() { + double d0 = (double) MathHelper.sqrt(this.c * this.c + this.d * this.d + this.e * this.e); - return d0 < 1.0E-4D ? a().create(0.0D, 0.0D, 0.0D) : a().create(this.a / d0, this.b / d0, this.c / d0); + return d0 < 1.0E-4D ? this.b.create(0.0D, 0.0D, 0.0D) : this.b.create(this.c / d0, this.d / d0, this.e / d0); } public double b(Vec3D vec3d) { - return this.a * vec3d.a + this.b * vec3d.b + this.c * vec3d.c; + return this.c * vec3d.c + this.d * vec3d.d + this.e * vec3d.e; } public Vec3D add(double d0, double d1, double d2) { - return a().create(this.a + d0, this.b + d1, this.c + d2); + return this.b.create(this.c + d0, this.d + d1, this.e + d2); } public double d(Vec3D vec3d) { - double d0 = vec3d.a - this.a; - double d1 = vec3d.b - this.b; - double d2 = vec3d.c - this.c; + double d0 = vec3d.c - this.c; + double d1 = vec3d.d - this.d; + double d2 = vec3d.e - this.e; return (double) MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2); } public double distanceSquared(Vec3D vec3d) { - double d0 = vec3d.a - this.a; - double d1 = vec3d.b - this.b; - double d2 = vec3d.c - this.c; + double d0 = vec3d.c - this.c; + double d1 = vec3d.d - this.d; + double d2 = vec3d.e - this.e; return d0 * d0 + d1 * d1 + d2 * d2; } public double d(double d0, double d1, double d2) { - double d3 = d0 - this.a; - double d4 = d1 - this.b; - double d5 = d2 - this.c; + double d3 = d0 - this.c; + double d4 = d1 - this.d; + double d5 = d2 - this.e; return d3 * d3 + d4 * d4 + d5 * d5; } - public double c() { - return (double) MathHelper.sqrt(this.a * this.a + this.b * this.b + this.c * this.c); + public double b() { + return (double) MathHelper.sqrt(this.c * this.c + this.d * this.d + this.e * this.e); } public Vec3D b(Vec3D vec3d, double d0) { - double d1 = vec3d.a - this.a; - double d2 = vec3d.b - this.b; - double d3 = vec3d.c - this.c; + double d1 = vec3d.c - this.c; + double d2 = vec3d.d - this.d; + double d3 = vec3d.e - this.e; if (d1 * d1 < 1.0000000116860974E-7D) { return null; } else { - double d4 = (d0 - this.a) / d1; + double d4 = (d0 - this.c) / d1; - return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + return d4 >= 0.0D && d4 <= 1.0D ? this.b.create(this.c + d1 * d4, this.d + d2 * d4, this.e + d3 * d4) : null; } } public Vec3D c(Vec3D vec3d, double d0) { - double d1 = vec3d.a - this.a; - double d2 = vec3d.b - this.b; - double d3 = vec3d.c - this.c; + double d1 = vec3d.c - this.c; + double d2 = vec3d.d - this.d; + double d3 = vec3d.e - this.e; if (d2 * d2 < 1.0000000116860974E-7D) { return null; } else { - double d4 = (d0 - this.b) / d2; + double d4 = (d0 - this.d) / d2; - return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + return d4 >= 0.0D && d4 <= 1.0D ? this.b.create(this.c + d1 * d4, this.d + d2 * d4, this.e + d3 * d4) : null; } } public Vec3D d(Vec3D vec3d, double d0) { - double d1 = vec3d.a - this.a; - double d2 = vec3d.b - this.b; - double d3 = vec3d.c - this.c; + double d1 = vec3d.c - this.c; + double d2 = vec3d.d - this.d; + double d3 = vec3d.e - this.e; if (d3 * d3 < 1.0000000116860974E-7D) { return null; } else { - double d4 = (d0 - this.c) / d3; + double d4 = (d0 - this.e) / d3; - return d4 >= 0.0D && d4 <= 1.0D ? a().create(this.a + d1 * d4, this.b + d2 * d4, this.c + d3 * d4) : null; + return d4 >= 0.0D && d4 <= 1.0D ? this.b.create(this.c + d1 * d4, this.d + d2 * d4, this.e + d3 * d4) : null; } } public String toString() { - return "(" + this.a + ", " + this.b + ", " + this.c + ")"; + return "(" + this.c + ", " + this.d + ", " + this.e + ")"; } public void a(float f) { float f1 = MathHelper.cos(f); float f2 = MathHelper.sin(f); - double d0 = this.a; - double d1 = this.b * (double) f1 + this.c * (double) f2; - double d2 = this.c * (double) f1 - this.b * (double) f2; + double d0 = this.c; + double d1 = this.d * (double) f1 + this.e * (double) f2; + double d2 = this.e * (double) f1 - this.d * (double) f2; - this.a = d0; - this.b = d1; - this.c = d2; + this.c = d0; + this.d = d1; + this.e = d2; } public void b(float f) { float f1 = MathHelper.cos(f); float f2 = MathHelper.sin(f); - double d0 = this.a * (double) f1 + this.c * (double) f2; - double d1 = this.b; - double d2 = this.c * (double) f1 - this.a * (double) f2; + double d0 = this.c * (double) f1 + this.e * (double) f2; + double d1 = this.d; + double d2 = this.e * (double) f1 - this.c * (double) f2; - this.a = d0; - this.b = d1; - this.c = d2; + this.c = d0; + this.d = d1; + this.e = d2; } } diff --git a/src/main/java/net/minecraft/server/Vec3DPool.java b/src/main/java/net/minecraft/server/Vec3DPool.java index 01bd659e..b99d9bd2 100644 --- a/src/main/java/net/minecraft/server/Vec3DPool.java +++ b/src/main/java/net/minecraft/server/Vec3DPool.java @@ -8,18 +8,16 @@ public class Vec3DPool { private final int a; private final int b; // CraftBukkit start - // private final List c = new ArrayList(); + // private final List pool = new ArrayList(); private Vec3D freelist = null; private Vec3D alloclist = null; private Vec3D freelisthead = null; private Vec3D alloclisthead = null; private int total_size = 0; - private int hit; - private int miss; // CraftBukkit end - private int d = 0; - private int e = 0; - private int f = 0; + private int position = 0; + private int largestSize = 0; + private int resizeTime = 0; public Vec3DPool(int i, int j) { this.a = i; @@ -27,11 +25,11 @@ public class Vec3DPool { } public final Vec3D create(double d0, double d1, double d2) { // CraftBukkit - add final - if (this.f == 0) return new Vec3D(d0, d1, d2); // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract + if (this.resizeTime == 0) return Vec3D.a(d0, d1, d2); // CraftBukkit - don't pool objects indefinitely if thread doesn't adhere to contract Vec3D vec3d; if (this.freelist == null) { // CraftBukkit - vec3d = new Vec3D(d0, d1, d2); + vec3d = new Vec3D(this, d0, d1, d2); this.total_size++; // CraftBukkit } else { // CraftBukkit start @@ -48,7 +46,7 @@ public class Vec3DPool { vec3d.next = this.alloclist; // add to allocated list this.alloclist = vec3d; // CraftBukkit end - ++this.d; + ++this.position; return vec3d; } @@ -60,14 +58,14 @@ public class Vec3DPool { if (this.freelist == null) this.freelisthead = v; v.next = this.freelist; this.freelist = v; - this.d--; + this.position--; } } // CraftBukkit end public void a() { - if (this.d > this.e) { - this.e = this.d; + if (this.position > this.largestSize) { + this.largestSize = this.position; } // CraftBukkit start - intelligent cache @@ -84,19 +82,31 @@ public class Vec3DPool { } this.alloclist = null; } - if ((this.f++ & 0xff) == 0) { + if ((this.resizeTime++ & 0xff) == 0) { int newSize = total_size - (total_size >> 3); - if (newSize > this.e) { // newSize will be 87.5%, but if we were not in that range, we clear some of the cache + if (newSize > this.largestSize) { // newSize will be 87.5%, but if we were not in that range, we clear some of the cache for (int i = total_size; i > newSize; i--) { freelist = freelist.next; } total_size = newSize; } - this.e = 0; + this.largestSize = 0; // this.f = 0; // We do not reset to zero; it doubles for a flag } // CraftBukkit end - this.d = 0; + this.position = 0; + } + + public int c() { + return this.total_size; // CraftBukkit + } + + public int d() { + return this.position; + } + + private boolean e() { + return this.b < 0 || this.a < 0; } } diff --git a/src/main/java/net/minecraft/server/Village.java b/src/main/java/net/minecraft/server/Village.java index 7b20b169..864559ca 100644 --- a/src/main/java/net/minecraft/server/Village.java +++ b/src/main/java/net/minecraft/server/Village.java @@ -3,10 +3,11 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.TreeMap; public class Village { - private final World world; + private World world; private final List doors = new ArrayList(); private final ChunkCoordinates c = new ChunkCoordinates(0, 0, 0); private final ChunkCoordinates center = new ChunkCoordinates(0, 0, 0); @@ -14,36 +15,44 @@ public class Village { private int f = 0; private int time = 0; private int population = 0; - private List i = new ArrayList(); - private int j = 0; + private int noBreedTicks; + private TreeMap playerStandings = new TreeMap(); + private List aggressors = new ArrayList(); + private int ironGolemCount = 0; + + public Village() {} public Village(World world) { this.world = world; } + public void a(World world) { + this.world = world; + } + public void tick(int i) { this.time = i; - this.k(); - this.j(); + this.m(); + this.l(); if (i % 20 == 0) { - this.i(); + this.k(); } if (i % 30 == 0) { this.countPopulation(); } - int j = this.population / 16; + int j = this.population / 10; - if (this.j < j && this.doors.size() > 20 && this.world.random.nextInt(7000) == 0) { + if (this.ironGolemCount < j && this.doors.size() > 20 && this.world.random.nextInt(7000) == 0) { Vec3D vec3d = this.a(MathHelper.d((float) this.center.x), MathHelper.d((float) this.center.y), MathHelper.d((float) this.center.z), 2, 4, 2); if (vec3d != null) { EntityIronGolem entityirongolem = new EntityIronGolem(this.world); - entityirongolem.setPosition(vec3d.a, vec3d.b, vec3d.c); + entityirongolem.setPosition(vec3d.c, vec3d.d, vec3d.e); this.world.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit - ++this.j; + ++this.ironGolemCount; } } } @@ -55,7 +64,7 @@ public class Village { int j2 = k + this.world.random.nextInt(16) - 8; if (this.a(l1, i2, j2) && this.b(l1, i2, j2, l, i1, j1)) { - return Vec3D.a().create((double) l1, (double) i2, (double) j2); + return this.world.getVec3DPool().create((double) l1, (double) i2, (double) j2); } } @@ -86,13 +95,16 @@ public class Village { private void countPopulation() { List list = this.world.a(EntityIronGolem.class, AxisAlignedBB.a().a((double) (this.center.x - this.size), (double) (this.center.y - 4), (double) (this.center.z - this.size), (double) (this.center.x + this.size), (double) (this.center.y + 4), (double) (this.center.z + this.size))); - this.j = list.size(); + this.ironGolemCount = list.size(); } - private void i() { + private void k() { List list = this.world.a(EntityVillager.class, AxisAlignedBB.a().a((double) (this.center.x - this.size), (double) (this.center.y - 4), (double) (this.center.z - this.size), (double) (this.center.x + this.size), (double) (this.center.y + 4), (double) (this.center.z + this.size))); this.population = list.size(); + if (this.population == 0) { + this.playerStandings.clear(); + } } public ChunkCoordinates getCenter() { @@ -190,7 +202,7 @@ public class Village { this.c.x += villagedoor.locX; this.c.y += villagedoor.locY; this.c.z += villagedoor.locZ; - this.l(); + this.n(); this.f = villagedoor.addedTime; } @@ -199,13 +211,13 @@ public class Village { } public void a(EntityLiving entityliving) { - Iterator iterator = this.i.iterator(); + Iterator iterator = this.aggressors.iterator(); VillageAggressor villageaggressor; do { if (!iterator.hasNext()) { - this.i.add(new VillageAggressor(this, entityliving, this.time)); + this.aggressors.add(new VillageAggressor(this, entityliving, this.time)); return; } @@ -218,7 +230,7 @@ public class Village { public EntityLiving b(EntityLiving entityliving) { double d0 = Double.MAX_VALUE; VillageAggressor villageaggressor = null; - Iterator iterator = this.i.iterator(); + Iterator iterator = this.aggressors.iterator(); while (iterator.hasNext()) { VillageAggressor villageaggressor1 = (VillageAggressor) iterator.next(); @@ -233,8 +245,33 @@ public class Village { return villageaggressor != null ? villageaggressor.a : null; } - private void j() { - Iterator iterator = this.i.iterator(); + public EntityHuman c(EntityLiving entityliving) { + double d0 = Double.MAX_VALUE; + EntityHuman entityhuman = null; + Iterator iterator = this.playerStandings.keySet().iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + + if (this.d(s)) { + EntityHuman entityhuman1 = this.world.a(s); + + if (entityhuman1 != null) { + double d1 = entityhuman1.e(entityliving); + + if (d1 <= d0) { + entityhuman = entityhuman1; + d0 = d1; + } + } + } + } + + return entityhuman; + } + + private void l() { + Iterator iterator = this.aggressors.iterator(); while (iterator.hasNext()) { VillageAggressor villageaggressor = (VillageAggressor) iterator.next(); @@ -245,7 +282,7 @@ public class Village { } } - private void k() { + private void m() { boolean flag = false; boolean flag1 = this.world.random.nextInt(50) == 0; Iterator iterator = this.doors.iterator(); @@ -262,13 +299,13 @@ public class Village { this.c.y -= villagedoor.locY; this.c.z -= villagedoor.locZ; flag = true; - villagedoor.g = true; + villagedoor.removed = true; iterator.remove(); } } if (flag) { - this.l(); + this.n(); } } @@ -278,7 +315,7 @@ public class Village { return l <= 0 ? false : l == Block.WOODEN_DOOR.id; } - private void l() { + private void n() { int i = this.doors.size(); if (i == 0) { @@ -297,4 +334,116 @@ public class Village { this.size = Math.max(32, (int) Math.sqrt((double) j) + 1); } } + + public int a(String s) { + Integer integer = (Integer) this.playerStandings.get(s); + + return integer != null ? integer.intValue() : 0; + } + + public int a(String s, int i) { + int j = this.a(s); + int k = MathHelper.a(j + i, -30, 10); + + this.playerStandings.put(s, Integer.valueOf(k)); + return k; + } + + public boolean d(String s) { + return this.a(s) <= -15; + } + + public void a(NBTTagCompound nbttagcompound) { + this.population = nbttagcompound.getInt("PopSize"); + this.size = nbttagcompound.getInt("Radius"); + this.ironGolemCount = nbttagcompound.getInt("Golems"); + this.f = nbttagcompound.getInt("Stable"); + this.time = nbttagcompound.getInt("Tick"); + this.noBreedTicks = nbttagcompound.getInt("MTick"); + this.center.x = nbttagcompound.getInt("CX"); + this.center.y = nbttagcompound.getInt("CY"); + this.center.z = nbttagcompound.getInt("CZ"); + this.c.x = nbttagcompound.getInt("ACX"); + this.c.y = nbttagcompound.getInt("ACY"); + this.c.z = nbttagcompound.getInt("ACZ"); + NBTTagList nbttaglist = nbttagcompound.getList("Doors"); + + for (int i = 0; i < nbttaglist.size(); ++i) { + NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i); + VillageDoor villagedoor = new VillageDoor(nbttagcompound1.getInt("X"), nbttagcompound1.getInt("Y"), nbttagcompound1.getInt("Z"), nbttagcompound1.getInt("IDX"), nbttagcompound1.getInt("IDZ"), nbttagcompound1.getInt("TS")); + + this.doors.add(villagedoor); + } + + NBTTagList nbttaglist1 = nbttagcompound.getList("Players"); + + for (int j = 0; j < nbttaglist1.size(); ++j) { + NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.get(j); + + this.playerStandings.put(nbttagcompound2.getString("Name"), Integer.valueOf(nbttagcompound2.getInt("S"))); + } + } + + public void b(NBTTagCompound nbttagcompound) { + nbttagcompound.setInt("PopSize", this.population); + nbttagcompound.setInt("Radius", this.size); + nbttagcompound.setInt("Golems", this.ironGolemCount); + nbttagcompound.setInt("Stable", this.f); + nbttagcompound.setInt("Tick", this.time); + nbttagcompound.setInt("MTick", this.noBreedTicks); + nbttagcompound.setInt("CX", this.center.x); + nbttagcompound.setInt("CY", this.center.y); + nbttagcompound.setInt("CZ", this.center.z); + nbttagcompound.setInt("ACX", this.c.x); + nbttagcompound.setInt("ACY", this.c.y); + nbttagcompound.setInt("ACZ", this.c.z); + NBTTagList nbttaglist = new NBTTagList("Doors"); + Iterator iterator = this.doors.iterator(); + + while (iterator.hasNext()) { + VillageDoor villagedoor = (VillageDoor) iterator.next(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound("Door"); + + nbttagcompound1.setInt("X", villagedoor.locX); + nbttagcompound1.setInt("Y", villagedoor.locY); + nbttagcompound1.setInt("Z", villagedoor.locZ); + nbttagcompound1.setInt("IDX", villagedoor.d); + nbttagcompound1.setInt("IDZ", villagedoor.e); + nbttagcompound1.setInt("TS", villagedoor.addedTime); + nbttaglist.add(nbttagcompound1); + } + + nbttagcompound.set("Doors", nbttaglist); + NBTTagList nbttaglist1 = new NBTTagList("Players"); + Iterator iterator1 = this.playerStandings.keySet().iterator(); + + while (iterator1.hasNext()) { + String s = (String) iterator1.next(); + NBTTagCompound nbttagcompound2 = new NBTTagCompound(s); + + nbttagcompound2.setString("Name", s); + nbttagcompound2.setInt("S", ((Integer) this.playerStandings.get(s)).intValue()); + nbttaglist1.add(nbttagcompound2); + } + + nbttagcompound.set("Players", nbttaglist1); + } + + public void h() { + this.noBreedTicks = this.time; + } + + public boolean i() { + return this.noBreedTicks == 0 || this.time - this.noBreedTicks >= 3600; + } + + public void b(int i) { + Iterator iterator = this.playerStandings.keySet().iterator(); + + while (iterator.hasNext()) { + String s = (String) iterator.next(); + + this.a(s, i); + } + } } diff --git a/src/main/java/net/minecraft/server/VillageSiege.java b/src/main/java/net/minecraft/server/VillageSiege.java index 5d137dbc..86dc599d 100644 --- a/src/main/java/net/minecraft/server/VillageSiege.java +++ b/src/main/java/net/minecraft/server/VillageSiege.java @@ -28,7 +28,7 @@ public class VillageSiege { return; } } else { - if (this.world.s()) { + if (this.world.t()) { this.c = 0; return; } @@ -139,12 +139,14 @@ public class VillageSiege { try { entityzombie = new EntityZombie(this.world); + entityzombie.bD(); + entityzombie.setVillager(false); } catch (Exception exception) { exception.printStackTrace(); return false; } - entityzombie.setPositionRotation(vec3d.a, vec3d.b, vec3d.c, this.world.random.nextFloat() * 360.0F, 0.0F); + entityzombie.setPositionRotation(vec3d.c, vec3d.d, vec3d.e, this.world.random.nextFloat() * 360.0F, 0.0F); this.world.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit ChunkCoordinates chunkcoordinates = this.f.getCenter(); @@ -160,7 +162,7 @@ public class VillageSiege { int k1 = k + this.world.random.nextInt(16) - 8; if (this.f.a(i1, j1, k1) && SpawnerCreature.a(EnumCreatureType.MONSTER, this.world, i1, j1, k1)) { - return Vec3D.a().create((double) i1, (double) j1, (double) k1); + return this.world.getVec3DPool().create((double) i1, (double) j1, (double) k1); } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 311be0e7..e902c535 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -1,10 +1,13 @@ package net.minecraft.server; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.concurrent.Callable; // CraftBukkit start @@ -24,39 +27,41 @@ import org.bukkit.event.weather.ThunderChangeEvent; public abstract class World implements IBlockAccess { - public boolean e = false; + public boolean d = false; public List entityList = new ArrayList(); - protected List g = new ArrayList(); + protected List f = new ArrayList(); public List tileEntityList = new ArrayList(); private List a = new ArrayList(); private List b = new ArrayList(); public List players = new ArrayList(); - public List j = new ArrayList(); + public List i = new ArrayList(); private long c = 16777215L; - public int k = 0; - protected int l = (new Random()).nextInt(); - protected final int m = 1013904223; + public int j = 0; + protected int k = (new Random()).nextInt(); + protected final int l = 1013904223; + protected float m; protected float n; protected float o; protected float p; - protected float q; - protected int r = 0; - public int s = 0; + protected int q = 0; + public int r = 0; public boolean suppressPhysics = false; public int difficulty; public Random random = new Random(); public WorldProvider worldProvider; // CraftBukkit - remove final - protected List x = new ArrayList(); + protected List w = new ArrayList(); public IChunkProvider chunkProvider; // CraftBukkit - protected -> public protected final IDataManager dataManager; public WorldData worldData; // CraftBukkit - protected -> public public boolean isLoading; public WorldMapCollection worldMaps; - public final VillageCollection villages = new VillageCollection(this); + public final VillageCollection villages; protected final VillageSiege siegeManager = new VillageSiege(this); public final MethodProfiler methodProfiler; - private UnsafeList d = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList - private boolean L; + private final Vec3DPool K = new Vec3DPool(300, 2000); + private final Calendar L = Calendar.getInstance(); + private UnsafeList M = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList + private boolean N; // CraftBukkit start - public, longhashset public boolean allowMonsters = true; public boolean allowAnimals = true; @@ -64,9 +69,9 @@ public abstract class World implements IBlockAccess { public long ticksPerAnimalSpawns; public long ticksPerMonsterSpawns; // CraftBukkit end - private int M; - int[] J; - private List N; + private int O; + int[] I; + private List P; public boolean isStatic; public BiomeBase getBiome(int i, int j) { @@ -74,15 +79,15 @@ public abstract class World implements IBlockAccess { Chunk chunk = this.getChunkAtWorldCoords(i, j); if (chunk != null) { - return chunk.a(i & 15, j & 15, this.worldProvider.c); + return chunk.a(i & 15, j & 15, this.worldProvider.d); } } - return this.worldProvider.c.getBiome(i, j); + return this.worldProvider.d.getBiome(i, j); } public WorldChunkManager getWorldChunkManager() { - return this.worldProvider.c; + return this.worldProvider.d; } // CraftBukkit start @@ -111,9 +116,9 @@ public abstract class World implements IBlockAccess { this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit // CraftBukkit end - this.M = this.random.nextInt(12000); - this.J = new int['\u8000']; - this.N = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList + this.O = this.random.nextInt(12000); + this.I = new int['\u8000']; + this.P = new UnsafeList(); // CraftBukkit - ArrayList -> UnsafeList this.isStatic = false; this.dataManager = idatamanager; this.methodProfiler = methodprofiler; @@ -121,8 +126,8 @@ public abstract class World implements IBlockAccess { this.worldData = idatamanager.getWorldData(); if (worldprovider != null) { this.worldProvider = worldprovider; - } else if (this.worldData != null && this.worldData.i() != 0) { - this.worldProvider = WorldProvider.byDimension(this.worldData.i()); + } else if (this.worldData != null && this.worldData.j() != 0) { + this.worldProvider = WorldProvider.byDimension(this.worldData.j()); } else { this.worldProvider = WorldProvider.byDimension(0); } @@ -134,19 +139,29 @@ public abstract class World implements IBlockAccess { } this.worldProvider.a(this); - this.chunkProvider = this.i(); + this.chunkProvider = this.j(); if (!this.worldData.isInitialized()) { this.a(worldsettings); this.worldData.d(true); } - this.v(); + VillageCollection villagecollection = (VillageCollection) this.worldMaps.get(VillageCollection.class, "villages"); + + if (villagecollection == null) { + this.villages = new VillageCollection(this); + this.worldMaps.a("villages", this.villages); + } else { + this.villages = villagecollection; + this.villages.a(this); + } + + this.w(); this.a(); this.getServer().addWorld(this.world); // CraftBukkit } - protected abstract IChunkProvider i(); + protected abstract IChunkProvider j(); protected void a(WorldSettings worldsettings) { this.worldData.d(true); @@ -177,7 +192,7 @@ public abstract class World implements IBlockAccess { public boolean isTileEntity(int i, int j, int k) { int l = this.getTypeId(i, j, k); - return Block.byId[l] != null && Block.byId[l].s(); + return Block.byId[l] != null && Block.byId[l].u(); } public boolean isLoaded(int i, int j, int k) { @@ -185,10 +200,10 @@ public abstract class World implements IBlockAccess { } public boolean areChunksLoaded(int i, int j, int k, int l) { - return this.c(i - l, j - l, k - l, i + l, j + l, k + l); + return this.d(i - l, j - l, k - l, i + l, j + l, k + l); } - public boolean c(int i, int j, int k, int l, int i1, int j1) { + public boolean d(int i, int j, int k, int l, int i1, int j1) { if (i1 >= 0 && j < 256) { i >>= 4; k >>= 4; @@ -327,7 +342,7 @@ public abstract class World implements IBlockAccess { int j1 = k & 15; boolean flag = chunk.b(i1, j, j1, l); - if (flag && (this.isStatic || chunk.seenByPlayer && Block.r[chunk.getTypeId(i1, j, j1) & 4095])) { + if (flag && (this.isStatic || chunk.seenByPlayer && Block.u[chunk.getTypeId(i1, j, j1) & 4095])) { this.notify(i, j, k); } @@ -360,7 +375,7 @@ public abstract class World implements IBlockAccess { } public void notify(int i, int j, int k) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -382,17 +397,17 @@ public abstract class World implements IBlockAccess { k = i1; } - if (!this.worldProvider.e) { + if (!this.worldProvider.f) { for (i1 = k; i1 <= l; ++i1) { this.c(EnumSkyBlock.SKY, i, i1, j); } } - this.d(i, k, j, i, l, j); + this.e(i, k, j, i, l, j); } public void i(int i, int j, int k) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -401,8 +416,8 @@ public abstract class World implements IBlockAccess { } } - public void d(int i, int j, int k, int l, int i1, int j1) { - Iterator iterator = this.x.iterator(); + public void e(int i, int j, int k, int l, int i1, int j1) { + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -505,7 +520,7 @@ public abstract class World implements IBlockAccess { i &= 15; k &= 15; - return chunk.c(i, j, k, this.k); + return chunk.c(i, j, k, this.j); } } else { return 15; @@ -526,6 +541,20 @@ public abstract class World implements IBlockAccess { } } + public int g(int i, int j) { + if (i >= -30000000 && j >= -30000000 && i < 30000000 && j < 30000000) { + if (!this.isChunkLoaded(i >> 4, j >> 4)) { + return 0; + } else { + Chunk chunk = this.getChunkAt(i >> 4, j >> 4); + + return chunk.p; + } + } else { + return 0; + } + } + public int b(EnumSkyBlock enumskyblock, int i, int j, int k) { if (j < 0) { j = 0; @@ -559,7 +588,7 @@ public abstract class World implements IBlockAccess { Chunk chunk = this.getChunkAt(i >> 4, k >> 4); chunk.a(enumskyblock, i & 15, j, k & 15, l); - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -573,7 +602,7 @@ public abstract class World implements IBlockAccess { } public void n(int i, int j, int k) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -583,11 +612,11 @@ public abstract class World implements IBlockAccess { } public float o(int i, int j, int k) { - return this.worldProvider.f[this.getLightLevel(i, j, k)]; + return this.worldProvider.g[this.getLightLevel(i, j, k)]; } - public boolean s() { - return this.k < 4; + public boolean t() { + return this.j < 4; } public MovingObjectPosition a(Vec3D vec3d, Vec3D vec3d1) { @@ -599,14 +628,14 @@ public abstract class World implements IBlockAccess { } public MovingObjectPosition rayTrace(Vec3D vec3d, Vec3D vec3d1, boolean flag, boolean flag1) { - if (!Double.isNaN(vec3d.a) && !Double.isNaN(vec3d.b) && !Double.isNaN(vec3d.c)) { - if (!Double.isNaN(vec3d1.a) && !Double.isNaN(vec3d1.b) && !Double.isNaN(vec3d1.c)) { - int i = MathHelper.floor(vec3d1.a); - int j = MathHelper.floor(vec3d1.b); - int k = MathHelper.floor(vec3d1.c); - int l = MathHelper.floor(vec3d.a); - int i1 = MathHelper.floor(vec3d.b); - int j1 = MathHelper.floor(vec3d.c); + if (!Double.isNaN(vec3d.c) && !Double.isNaN(vec3d.d) && !Double.isNaN(vec3d.e)) { + if (!Double.isNaN(vec3d1.c) && !Double.isNaN(vec3d1.d) && !Double.isNaN(vec3d1.e)) { + int i = MathHelper.floor(vec3d1.c); + int j = MathHelper.floor(vec3d1.d); + int k = MathHelper.floor(vec3d1.e); + int l = MathHelper.floor(vec3d.c); + int i1 = MathHelper.floor(vec3d.d); + int j1 = MathHelper.floor(vec3d.e); int k1 = this.getTypeId(l, i1, j1); int l1 = this.getData(l, i1, j1); Block block = Block.byId[k1]; @@ -622,7 +651,7 @@ public abstract class World implements IBlockAccess { k1 = 200; while (k1-- >= 0) { - if (Double.isNaN(vec3d.a) || Double.isNaN(vec3d.b) || Double.isNaN(vec3d.c)) { + if (Double.isNaN(vec3d.c) || Double.isNaN(vec3d.d) || Double.isNaN(vec3d.e)) { return null; } @@ -664,20 +693,20 @@ public abstract class World implements IBlockAccess { double d3 = 999.0D; double d4 = 999.0D; double d5 = 999.0D; - double d6 = vec3d1.a - vec3d.a; - double d7 = vec3d1.b - vec3d.b; - double d8 = vec3d1.c - vec3d.c; + double d6 = vec3d1.c - vec3d.c; + double d7 = vec3d1.d - vec3d.d; + double d8 = vec3d1.e - vec3d.e; if (flag2) { - d3 = (d0 - vec3d.a) / d6; + d3 = (d0 - vec3d.c) / d6; } if (flag3) { - d4 = (d1 - vec3d.b) / d7; + d4 = (d1 - vec3d.d) / d7; } if (flag4) { - d5 = (d2 - vec3d.c) / d8; + d5 = (d2 - vec3d.e) / d8; } boolean flag5 = false; @@ -690,9 +719,9 @@ public abstract class World implements IBlockAccess { b0 = 5; } - vec3d.a = d0; - vec3d.b += d7 * d3; - vec3d.c += d8 * d3; + vec3d.c = d0; + vec3d.d += d7 * d3; + vec3d.e += d8 * d3; } else if (d4 < d5) { if (j > i1) { b0 = 0; @@ -700,9 +729,9 @@ public abstract class World implements IBlockAccess { b0 = 1; } - vec3d.a += d6 * d4; - vec3d.b = d1; - vec3d.c += d8 * d4; + vec3d.c += d6 * d4; + vec3d.d = d1; + vec3d.e += d8 * d4; } else { if (k > j1) { b0 = 2; @@ -710,29 +739,29 @@ public abstract class World implements IBlockAccess { b0 = 3; } - vec3d.a += d6 * d5; - vec3d.b += d7 * d5; - vec3d.c = d2; + vec3d.c += d6 * d5; + vec3d.d += d7 * d5; + vec3d.e = d2; } - Vec3D vec3d2 = Vec3D.a().create(vec3d.a, vec3d.b, vec3d.c); + Vec3D vec3d2 = this.getVec3DPool().create(vec3d.c, vec3d.d, vec3d.e); - l = (int) (vec3d2.a = (double) MathHelper.floor(vec3d.a)); + l = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c)); if (b0 == 5) { --l; - ++vec3d2.a; + ++vec3d2.c; } - i1 = (int) (vec3d2.b = (double) MathHelper.floor(vec3d.b)); + i1 = (int) (vec3d2.d = (double) MathHelper.floor(vec3d.d)); if (b0 == 1) { --i1; - ++vec3d2.b; + ++vec3d2.d; } - j1 = (int) (vec3d2.c = (double) MathHelper.floor(vec3d.c)); + j1 = (int) (vec3d2.e = (double) MathHelper.floor(vec3d.e)); if (b0 == 3) { --j1; - ++vec3d2.c; + ++vec3d2.e; } int i2 = this.getTypeId(l, i1, j1); @@ -743,11 +772,11 @@ public abstract class World implements IBlockAccess { MovingObjectPosition movingobjectposition1 = block1.a(this, l, i1, j1, vec3d, vec3d1); if (movingobjectposition1 != null) { - Vec3D.a().release(vec3d2); // CraftBukkit + vec3d2.b.release(vec3d2); // CraftBukkit return movingobjectposition1; } } - Vec3D.a().release(vec3d2); // CraftBukkit + vec3d2.b.release(vec3d2); // CraftBukkit } return null; @@ -761,7 +790,7 @@ public abstract class World implements IBlockAccess { public void makeSound(Entity entity, String s, float f, float f1) { if (entity != null && s != null) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -773,7 +802,7 @@ public abstract class World implements IBlockAccess { public void makeSound(double d0, double d1, double d2, String s, float f, float f1) { if (s != null) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -783,8 +812,10 @@ public abstract class World implements IBlockAccess { } } + public void b(double d0, double d1, double d2, String s, float f, float f1) {} + public void a(String s, int i, int j, int k) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -793,8 +824,8 @@ public abstract class World implements IBlockAccess { } } - public void a(String s, double d0, double d1, double d2, double d3, double d4, double d5) { - Iterator iterator = this.x.iterator(); + public void addParticle(String s, double d0, double d1, double d2, double d3, double d4, double d5) { + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -804,7 +835,7 @@ public abstract class World implements IBlockAccess { } public boolean strikeLightning(Entity entity) { - this.j.add(entity); + this.i.add(entity); return true; } @@ -871,7 +902,7 @@ public abstract class World implements IBlockAccess { } protected void a(Entity entity) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -883,7 +914,7 @@ public abstract class World implements IBlockAccess { } protected void b(Entity entity) { - Iterator iterator = this.x.iterator(); + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); @@ -917,10 +948,10 @@ public abstract class World implements IBlockAccess { this.everyoneSleeping(); } - int i = entity.ah; - int j = entity.aj; + int i = entity.ai; + int j = entity.ak; - if (entity.ag && this.isChunkLoaded(i, j)) { + if (entity.ah && this.isChunkLoaded(i, j)) { this.getChunkAt(i, j).b(entity); } @@ -929,11 +960,11 @@ public abstract class World implements IBlockAccess { } public void addIWorldAccess(IWorldAccess iworldaccess) { - this.x.add(iworldaccess); + this.w.add(iworldaccess); } public List getCubes(Entity entity, AxisAlignedBB axisalignedbb) { - this.d.clear(); + this.M.clear(); int i = MathHelper.floor(axisalignedbb.a); int j = MathHelper.floor(axisalignedbb.d + 1.0D); int k = MathHelper.floor(axisalignedbb.b); @@ -948,7 +979,7 @@ public abstract class World implements IBlockAccess { Block block = Block.byId[this.getTypeId(k1, i2, l1)]; if (block != null) { - block.a(this, k1, i2, l1, axisalignedbb, this.d, entity); + block.a(this, k1, i2, l1, axisalignedbb, this.M, entity); } } } @@ -964,20 +995,20 @@ public abstract class World implements IBlockAccess { AxisAlignedBB axisalignedbb1 = entity1.E(); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.d.add(axisalignedbb1); + this.M.add(axisalignedbb1); } axisalignedbb1 = entity.g(entity1); if (axisalignedbb1 != null && axisalignedbb1.a(axisalignedbb)) { - this.d.add(axisalignedbb1); + this.M.add(axisalignedbb1); } } - return this.d; + return this.M; } public List a(AxisAlignedBB axisalignedbb) { - this.d.clear(); + this.M.clear(); int i = MathHelper.floor(axisalignedbb.a); int j = MathHelper.floor(axisalignedbb.d + 1.0D); int k = MathHelper.floor(axisalignedbb.b); @@ -992,14 +1023,14 @@ public abstract class World implements IBlockAccess { Block block = Block.byId[this.getTypeId(k1, i2, l1)]; if (block != null) { - block.a(this, k1, i2, l1, axisalignedbb, this.d, (Entity) null); + block.a(this, k1, i2, l1, axisalignedbb, this.M, (Entity) null); } } } } } - return this.d; + return this.M; } public int a(float f) { @@ -1022,14 +1053,14 @@ public abstract class World implements IBlockAccess { } public float c(float f) { - return this.worldProvider.a(this.worldData.getTime(), f); + return this.worldProvider.a(this.worldData.g(), f); } - public int g(int i, int j) { + public int h(int i, int j) { return this.getChunkAtWorldCoords(i, j).d(i & 15, j & 15); } - public int h(int i, int j) { + public int i(int i, int j) { Chunk chunk = this.getChunkAtWorldCoords(i, j); int k = chunk.h() + 15; @@ -1048,6 +1079,8 @@ public abstract class World implements IBlockAccess { public void a(int i, int j, int k, int l, int i1) {} + public void a(int i, int j, int k, int l, int i1, int j1) {} + public void b(int i, int j, int k, int l, int i1) {} public void tickEntities() { @@ -1057,8 +1090,8 @@ public abstract class World implements IBlockAccess { int i; Entity entity; - for (i = 0; i < this.j.size(); ++i) { - entity = (Entity) this.j.get(i); + for (i = 0; i < this.i.size(); ++i) { + entity = (Entity) this.i.get(i); // CraftBukkit start - fixed an NPE, don't process entities in chunks queued for unload if (entity == null) { continue; @@ -1069,36 +1102,37 @@ public abstract class World implements IBlockAccess { continue; } // CraftBukkit end - entity.h_(); + + entity.j_(); if (entity.dead) { - this.j.remove(i--); + this.i.remove(i--); } } this.methodProfiler.c("remove"); - this.entityList.removeAll(this.g); - Iterator iterator = this.g.iterator(); + this.entityList.removeAll(this.f); + Iterator iterator = this.f.iterator(); int j; int k; while (iterator.hasNext()) { entity = (Entity) iterator.next(); - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) { + j = entity.ai; + k = entity.ak; + if (entity.ah && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } } - iterator = this.g.iterator(); + iterator = this.f.iterator(); while (iterator.hasNext()) { entity = (Entity) iterator.next(); this.b(entity); } - this.g.clear(); + this.f.clear(); this.methodProfiler.c("regular"); for (i = 0; i < this.entityList.size(); ++i) { @@ -1128,9 +1162,9 @@ public abstract class World implements IBlockAccess { this.methodProfiler.b(); this.methodProfiler.a("remove"); if (entity.dead) { - j = entity.ah; - k = entity.aj; - if (entity.ag && this.isChunkLoaded(j, k)) { + j = entity.ai; + k = entity.ak; + if (entity.ah && this.isChunkLoaded(j, k)) { this.getChunkAt(j, k).b(entity); } @@ -1142,12 +1176,11 @@ public abstract class World implements IBlockAccess { } this.methodProfiler.c("tileEntities"); - this.L = true; + this.N = true; iterator = this.tileEntityList.iterator(); while (iterator.hasNext()) { TileEntity tileentity = (TileEntity) iterator.next(); - // CraftBukkit start - don't tick entities in chunks queued for unload ChunkProviderServer chunkProviderServer = ((WorldServer) this).chunkProviderServer; if (chunkProviderServer.unloadQueue.contains(tileentity.x >> 4, tileentity.z >> 4)) { @@ -1155,11 +1188,11 @@ public abstract class World implements IBlockAccess { } // CraftBukkit end - if (!tileentity.p() && tileentity.m() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { + if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) { tileentity.g(); } - if (tileentity.p()) { + if (tileentity.r()) { iterator.remove(); if (this.isChunkLoaded(tileentity.x >> 4, tileentity.z >> 4)) { Chunk chunk = this.getChunkAt(tileentity.x >> 4, tileentity.z >> 4); @@ -1171,7 +1204,7 @@ public abstract class World implements IBlockAccess { } } - this.L = false; + this.N = false; if (!this.b.isEmpty()) { this.tileEntityList.removeAll(this.b); this.b.clear(); @@ -1184,7 +1217,7 @@ public abstract class World implements IBlockAccess { while (iterator1.hasNext()) { TileEntity tileentity1 = (TileEntity) iterator1.next(); - if (!tileentity1.p()) { + if (!tileentity1.r()) { /* CraftBukkit start - order matters, moved down if (!this.tileEntityList.contains(tileentity1)) { this.tileEntityList.add(tileentity1); @@ -1216,7 +1249,7 @@ public abstract class World implements IBlockAccess { } public void a(Collection collection) { - if (this.L) { + if (this.N) { this.a.addAll(collection); } else { this.tileEntityList.addAll(collection); @@ -1232,31 +1265,31 @@ public abstract class World implements IBlockAccess { int j = MathHelper.floor(entity.locZ); byte b0 = 32; - if (!flag || this.c(i - b0, 0, j - b0, i + b0, 0, j + b0)) { - entity.S = entity.locX; - entity.T = entity.locY; - entity.U = entity.locZ; + if (!flag || this.d(i - b0, 0, j - b0, i + b0, 0, j + b0)) { + entity.T = entity.locX; + entity.U = entity.locY; + entity.V = entity.locZ; entity.lastYaw = entity.yaw; entity.lastPitch = entity.pitch; - if (flag && entity.ag) { + if (flag && entity.ah) { if (entity.vehicle != null) { entity.U(); } else { - entity.h_(); + entity.j_(); } } this.methodProfiler.a("chunkCheck"); if (Double.isNaN(entity.locX) || Double.isInfinite(entity.locX)) { - entity.locX = entity.S; + entity.locX = entity.T; } if (Double.isNaN(entity.locY) || Double.isInfinite(entity.locY)) { - entity.locY = entity.T; + entity.locY = entity.U; } if (Double.isNaN(entity.locZ) || Double.isInfinite(entity.locZ)) { - entity.locZ = entity.U; + entity.locZ = entity.V; } if (Double.isNaN((double) entity.pitch) || Double.isInfinite((double) entity.pitch)) { @@ -1271,21 +1304,21 @@ public abstract class World implements IBlockAccess { int l = MathHelper.floor(entity.locY / 16.0D); int i1 = MathHelper.floor(entity.locZ / 16.0D); - if (!entity.ag || entity.ah != k || entity.ai != l || entity.aj != i1) { - if (entity.ag && this.isChunkLoaded(entity.ah, entity.aj)) { - this.getChunkAt(entity.ah, entity.aj).a(entity, entity.ai); + if (!entity.ah || entity.ai != k || entity.aj != l || entity.ak != i1) { + if (entity.ah && this.isChunkLoaded(entity.ai, entity.ak)) { + this.getChunkAt(entity.ai, entity.ak).a(entity, entity.aj); } if (this.isChunkLoaded(k, i1)) { - entity.ag = true; + entity.ah = true; this.getChunkAt(k, i1).a(entity); } else { - entity.ag = false; + entity.ah = false; } } this.methodProfiler.b(); - if (flag && entity.ag && entity.passenger != null) { + if (flag && entity.ah && entity.passenger != null) { if (!entity.passenger.dead && entity.passenger.vehicle == entity) { this.playerJoinedWorld(entity.passenger); } else { @@ -1395,7 +1428,7 @@ public abstract class World implements IBlockAccess { int i1 = MathHelper.floor(axisalignedbb.c); int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - if (this.c(i, k, i1, j, l, j1)) { + if (this.d(i, k, i1, j, l, j1)) { for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { for (int i2 = i1; i2 < j1; ++i2) { @@ -1420,11 +1453,11 @@ public abstract class World implements IBlockAccess { int i1 = MathHelper.floor(axisalignedbb.c); int j1 = MathHelper.floor(axisalignedbb.f + 1.0D); - if (!this.c(i, k, i1, j, l, j1)) { + if (!this.d(i, k, i1, j, l, j1)) { return false; } else { boolean flag = false; - Vec3D vec3d = Vec3D.a().create(0.0D, 0.0D, 0.0D); + Vec3D vec3d = this.getVec3DPool().create(0.0D, 0.0D, 0.0D); for (int k1 = i; k1 < j; ++k1) { for (int l1 = k; l1 < l; ++l1) { @@ -1443,15 +1476,15 @@ public abstract class World implements IBlockAccess { } } - if (vec3d.c() > 0.0D) { - vec3d = vec3d.b(); + if (vec3d.b() > 0.0D) { + vec3d = vec3d.a(); double d1 = 0.014D; - entity.motX += vec3d.a * d1; - entity.motY += vec3d.b * d1; - entity.motZ += vec3d.c * d1; + entity.motX += vec3d.c * d1; + entity.motY += vec3d.d * d1; + entity.motZ += vec3d.e * d1; } - Vec3D.a().release(vec3d); // CraftBukkit - pop it - we're done + vec3d.b.release(vec3d); // CraftBukkit - pop it - we're done return flag; } @@ -1512,14 +1545,15 @@ public abstract class World implements IBlockAccess { return false; } - public Explosion explode(Entity entity, double d0, double d1, double d2, float f) { - return this.createExplosion(entity, d0, d1, d2, f, false); + public Explosion explode(Entity entity, double d0, double d1, double d2, float f, boolean flag) { + return this.createExplosion(entity, d0, d1, d2, f, false, flag); } - public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) { + public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { Explosion explosion = new Explosion(this, entity, d0, d1, d2, f); explosion.a = flag; + explosion.b = flag1; explosion.a(); explosion.a(true); return explosion; @@ -1532,7 +1566,7 @@ public abstract class World implements IBlockAccess { int i = 0; int j = 0; - Vec3D vec3d2 = Vec3D.a().create(0, 0, 0); // CraftBukkit + Vec3D vec3d2 = vec3d.b.create(0, 0, 0); // CraftBukkit for (float f = 0.0F; f <= 1.0F; f = (float) ((double) f + d0)) { for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) ((double) f1 + d1)) { for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) ((double) f2 + d2)) { @@ -1548,7 +1582,7 @@ public abstract class World implements IBlockAccess { } } } - Vec3D.a().release(vec3d2); // CraftBukkit + vec3d2.b.release(vec3d2); // CraftBukkit return (float) i / (float) j; } @@ -1604,7 +1638,7 @@ public abstract class World implements IBlockAccess { while (iterator.hasNext()) { TileEntity tileentity1 = (TileEntity) iterator.next(); - if (!tileentity1.p() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { + if (!tileentity1.r() && tileentity1.x == i && tileentity1.y == j && tileentity1.z == k) { tileentity = tileentity1; break; } @@ -1617,8 +1651,8 @@ public abstract class World implements IBlockAccess { } public void setTileEntity(int i, int j, int k, TileEntity tileentity) { - if (tileentity != null && !tileentity.p()) { - if (this.L) { + if (tileentity != null && !tileentity.r()) { + if (this.N) { tileentity.x = i; tileentity.y = j; tileentity.z = k; @@ -1637,8 +1671,8 @@ public abstract class World implements IBlockAccess { public void q(int i, int j, int k) { TileEntity tileentity = this.getTileEntity(i, j, k); - if (tileentity != null && this.L) { - tileentity.j(); + if (tileentity != null && this.N) { + tileentity.w_(); this.a.remove(tileentity); } else { if (tileentity != null) { @@ -1661,7 +1695,7 @@ public abstract class World implements IBlockAccess { public boolean r(int i, int j, int k) { Block block = Block.byId[this.getTypeId(i, j, k)]; - return block == null ? false : block.d(); + return block == null ? false : block.c(); } public boolean s(int i, int j, int k) { @@ -1671,7 +1705,7 @@ public abstract class World implements IBlockAccess { public boolean t(int i, int j, int k) { Block block = Block.byId[this.getTypeId(i, j, k)]; - return block == null ? false : (block.material.k() && block.c() ? true : (block instanceof BlockStairs ? (this.getData(i, j, k) & 4) == 4 : (block instanceof BlockStepAbstract ? (this.getData(i, j, k) & 8) == 8 : false))); + return block == null ? false : (block.material.k() && block.b() ? true : (block instanceof BlockStairs ? (this.getData(i, j, k) & 4) == 4 : (block instanceof BlockStepAbstract ? (this.getData(i, j, k) & 8) == 8 : false))); } public boolean b(int i, int j, int k, boolean flag) { @@ -1681,7 +1715,7 @@ public abstract class World implements IBlockAccess { if (chunk != null && !chunk.isEmpty()) { Block block = Block.byId[this.getTypeId(i, j, k)]; - return block == null ? false : block.material.k() && block.c(); + return block == null ? false : block.material.k() && block.b(); } else { return flag; } @@ -1690,11 +1724,11 @@ public abstract class World implements IBlockAccess { } } - public void v() { + public void w() { int i = this.a(1.0F); - if (i != this.k) { - this.k = i; + if (i != this.j) { + this.j = i; } } @@ -1704,22 +1738,22 @@ public abstract class World implements IBlockAccess { } public void doTick() { - this.m(); + this.n(); } private void a() { if (this.worldData.hasStorm()) { - this.o = 1.0F; + this.n = 1.0F; if (this.worldData.isThundering()) { - this.q = 1.0F; + this.p = 1.0F; } } } - protected void m() { - if (!this.worldProvider.e) { - if (this.r > 0) { - --this.r; + protected void n() { + if (!this.worldProvider.f) { + if (this.q > 0) { + --this.q; } int i = this.worldData.getThunderDuration(); @@ -1767,43 +1801,43 @@ public abstract class World implements IBlockAccess { } } - this.n = this.o; + this.m = this.n; if (this.worldData.hasStorm()) { - this.o = (float) ((double) this.o + 0.01D); + this.n = (float) ((double) this.n + 0.01D); } else { - this.o = (float) ((double) this.o - 0.01D); + this.n = (float) ((double) this.n - 0.01D); } - if (this.o < 0.0F) { - this.o = 0.0F; + if (this.n < 0.0F) { + this.n = 0.0F; } - if (this.o > 1.0F) { - this.o = 1.0F; + if (this.n > 1.0F) { + this.n = 1.0F; } - this.p = this.q; + this.o = this.p; if (this.worldData.isThundering()) { - this.q = (float) ((double) this.q + 0.01D); + this.p = (float) ((double) this.p + 0.01D); } else { - this.q = (float) ((double) this.q - 0.01D); + this.p = (float) ((double) this.p - 0.01D); } - if (this.q < 0.0F) { - this.q = 0.0F; + if (this.p < 0.0F) { + this.p = 0.0F; } - if (this.q > 1.0F) { - this.q = 1.0F; + if (this.p > 1.0F) { + this.p = 1.0F; } } } - public void w() { + public void x() { this.worldData.setWeatherDuration(1); } - protected void x() { + protected void y() { // this.chunkTickList.clear(); // CraftBukkit - removed this.methodProfiler.a("buildList"); @@ -1833,8 +1867,8 @@ public abstract class World implements IBlockAccess { } this.methodProfiler.b(); - if (this.M > 0) { - --this.M; + if (this.O > 0) { + --this.O; } this.methodProfiler.a("playerCheckLight"); @@ -1853,9 +1887,9 @@ public abstract class World implements IBlockAccess { protected void a(int i, int j, Chunk chunk) { this.methodProfiler.c("moodSound"); - if (this.M == 0) { - this.l = this.l * 3 + 1013904223; - int k = this.l >> 2; + if (this.O == 0 && !this.isStatic) { + this.k = this.k * 3 + 1013904223; + int k = this.k >> 2; int l = k & 15; int i1 = k >> 8 & 15; int j1 = k >> 16 & 255; // CraftBukkit - 127 -> 255 @@ -1868,7 +1902,7 @@ public abstract class World implements IBlockAccess { if (entityhuman != null && entityhuman.e((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D) > 4.0D) { this.makeSound((double) l + 0.5D, (double) j1 + 0.5D, (double) i1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.random.nextFloat() * 0.2F); - this.M = this.random.nextInt(12000) + 6000; + this.O = this.random.nextInt(12000) + 6000; } } } @@ -1878,7 +1912,7 @@ public abstract class World implements IBlockAccess { } protected void g() { - this.x(); + this.y(); } public boolean u(int i, int j, int k) { @@ -1953,14 +1987,14 @@ public abstract class World implements IBlockAccess { } public void x(int i, int j, int k) { - if (!this.worldProvider.e) { + if (!this.worldProvider.f) { this.c(EnumSkyBlock.SKY, i, j, k); } this.c(EnumSkyBlock.BLOCK, i, j, k); } - private int a(int i, int j, int k, int l, int i1, int j1) { + private int b(int i, int j, int k, int l, int i1, int j1) { int k1 = 0; if (this.j(j, k, l)) { @@ -2005,7 +2039,7 @@ public abstract class World implements IBlockAccess { return k1; } - private int f(int i, int j, int k, int l, int i1, int j1) { + private int g(int i, int j, int k, int l, int i1, int j1) { int k1 = Block.lightEmission[i1]; int l1 = this.b(EnumSkyBlock.BLOCK, j - 1, k, l) - j1; int i2 = this.b(EnumSkyBlock.BLOCK, j + 1, k, l) - j1; @@ -2060,9 +2094,9 @@ public abstract class World implements IBlockAccess { int i2; if (enumskyblock == EnumSkyBlock.SKY) { - i2 = this.a(j1, i, j, k, k1, l1); + i2 = this.b(j1, i, j, k, k1, l1); } else { - i2 = this.f(j1, i, j, k, k1, l1); + i2 = this.g(j1, i, j, k, k1, l1); } int j2; @@ -2075,16 +2109,16 @@ public abstract class World implements IBlockAccess { int i4; if (i2 > j1) { - this.J[i1++] = 133152; + this.I[i1++] = 133152; } else if (i2 < j1) { if (enumskyblock != EnumSkyBlock.BLOCK) { ; } - this.J[i1++] = 133152 + (j1 << 18); + this.I[i1++] = 133152 + (j1 << 18); while (l < i1) { - k1 = this.J[l++]; + k1 = this.I[l++]; l1 = (k1 & 63) - 32 + i; i2 = (k1 >> 6 & 63) - 32 + j; j2 = (k1 >> 12 & 63) - 32 + k; @@ -2122,8 +2156,8 @@ public abstract class World implements IBlockAccess { i5 = 1; } - if (l2 == k2 - i5 && i1 < this.J.length) { - this.J[i1++] = j4 - i + 32 + (k4 - j + 32 << 6) + (l4 - k + 32 << 12) + (k2 - i5 << 18); + if (l2 == k2 - i5 && i1 < this.I.length) { + this.I[i1++] = j4 - i + 32 + (k4 - j + 32 << 6) + (l4 - k + 32 << 12) + (k2 - i5 << 18); } } } @@ -2135,10 +2169,10 @@ public abstract class World implements IBlockAccess { } this.methodProfiler.b(); - this.methodProfiler.a("tcp < tcc"); + this.methodProfiler.a("checkedPosition < toCheckCount"); while (l < i1) { - k1 = this.J[l++]; + k1 = this.I[l++]; l1 = (k1 & 63) - 32 + i; i2 = (k1 >> 6 & 63) - 32 + j; j2 = (k1 >> 12 & 63) - 32 + k; @@ -2152,9 +2186,9 @@ public abstract class World implements IBlockAccess { boolean flag2 = false; if (enumskyblock == EnumSkyBlock.SKY) { - k3 = this.a(k2, l1, i2, j2, l2, i3); + k3 = this.b(k2, l1, i2, j2, l2, i3); } else { - k3 = this.f(k2, l1, i2, j2, l2, i3); + k3 = this.g(k2, l1, i2, j2, l2, i3); } if (k3 != k2) { @@ -2175,29 +2209,29 @@ public abstract class World implements IBlockAccess { l3 = -l3; } - if (j3 + i4 + l3 < 17 && i1 < this.J.length - 6) { + if (j3 + i4 + l3 < 17 && i1 < this.I.length - 6) { if (this.b(enumskyblock, l1 - 1, i2, j2) < k3) { - this.J[i1++] = l1 - 1 - i + 32 + (i2 - j + 32 << 6) + (j2 - k + 32 << 12); + this.I[i1++] = l1 - 1 - i + 32 + (i2 - j + 32 << 6) + (j2 - k + 32 << 12); } if (this.b(enumskyblock, l1 + 1, i2, j2) < k3) { - this.J[i1++] = l1 + 1 - i + 32 + (i2 - j + 32 << 6) + (j2 - k + 32 << 12); + this.I[i1++] = l1 + 1 - i + 32 + (i2 - j + 32 << 6) + (j2 - k + 32 << 12); } if (this.b(enumskyblock, l1, i2 - 1, j2) < k3) { - this.J[i1++] = l1 - i + 32 + (i2 - 1 - j + 32 << 6) + (j2 - k + 32 << 12); + this.I[i1++] = l1 - i + 32 + (i2 - 1 - j + 32 << 6) + (j2 - k + 32 << 12); } if (this.b(enumskyblock, l1, i2 + 1, j2) < k3) { - this.J[i1++] = l1 - i + 32 + (i2 + 1 - j + 32 << 6) + (j2 - k + 32 << 12); + this.I[i1++] = l1 - i + 32 + (i2 + 1 - j + 32 << 6) + (j2 - k + 32 << 12); } if (this.b(enumskyblock, l1, i2, j2 - 1) < k3) { - this.J[i1++] = l1 - i + 32 + (i2 - j + 32 << 6) + (j2 - 1 - k + 32 << 12); + this.I[i1++] = l1 - i + 32 + (i2 - j + 32 << 6) + (j2 - 1 - k + 32 << 12); } if (this.b(enumskyblock, l1, i2, j2 + 1) < k3) { - this.J[i1++] = l1 - i + 32 + (i2 - j + 32 << 6) + (j2 + 1 - k + 32 << 12); + this.I[i1++] = l1 - i + 32 + (i2 - j + 32 << 6) + (j2 + 1 - k + 32 << 12); } } } @@ -2217,7 +2251,7 @@ public abstract class World implements IBlockAccess { } public List getEntities(Entity entity, AxisAlignedBB axisalignedbb) { - this.N.clear(); + this.P.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); @@ -2226,15 +2260,19 @@ public abstract 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.N); + this.getChunkAt(i1, j1).a(entity, axisalignedbb, this.P); } } } - return this.N; + return this.P; } public List a(Class oclass, AxisAlignedBB axisalignedbb) { + return this.a(oclass, axisalignedbb, (IEntitySelector) null); + } + + public List a(Class oclass, AxisAlignedBB axisalignedbb, IEntitySelector ientityselector) { 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); @@ -2244,7 +2282,7 @@ public abstract 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(oclass, axisalignedbb, arraylist); + this.getChunkAt(i1, j1).a(oclass, axisalignedbb, arraylist, ientityselector); } } } @@ -2274,6 +2312,8 @@ public abstract class World implements IBlockAccess { return entity1; } + public abstract Entity getEntity(int i); + public void b(int i, int j, int k, TileEntity tileentity) { if (this.isLoaded(i, j, k)) { this.getChunkAtWorldCoords(i, k).e(); @@ -2309,7 +2349,7 @@ public abstract class World implements IBlockAccess { } public void b(List list) { - this.g.addAll(list); + this.f.addAll(list); } public boolean mayPlace(int i, int j, int k, int l, boolean flag, int i1, Entity entity) { @@ -2331,7 +2371,8 @@ public abstract class World implements IBlockAccess { block = null; } - defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); + // CraftBukkit + defaultReturn = block != null && block.material == Material.ORIENTABLE && block1 == Block.ANVIL ? true : i > 0 && block == null && block1.canPlace(this, j, k, l, i1); } // CraftBukkit start @@ -2396,7 +2437,7 @@ public abstract class World implements IBlockAccess { } else { int i1 = this.getTypeId(i, j, k); - return i1 == 0 ? false : Block.byId[i1].a(this, i, j, k, l); + return i1 == 0 ? false : Block.byId[i1].b(this, i, j, k, l); } } @@ -2448,8 +2489,23 @@ public abstract class World implements IBlockAccess { if (!entityhuman1.abilities.isInvulnerable) { double d5 = entityhuman1.e(d0, d1, d2); + double d6 = d3; - if ((d3 < 0.0D || d5 < d3 * d3) && (d4 == -1.0D || d5 < d4)) { + if (entityhuman1.isSneaking()) { + d6 = d3 * 0.800000011920929D; + } + + if (entityhuman1.isInvisible()) { + float f = entityhuman1.bO(); + + if (f < 0.1F) { + f = 0.1F; + } + + d6 *= (double) (0.7F * f); + } + + if ((d3 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)) { d4 = d5; entityhuman = entityhuman1; } @@ -2469,14 +2525,10 @@ public abstract class World implements IBlockAccess { return null; } - public void B() throws ExceptionWorldConflict { // CraftBukkit - added throws + public void C() throws ExceptionWorldConflict { // CraftBukkit - added throws this.dataManager.checkSession(); } - public void setTime(long i) { - this.worldData.b(i); - } - public long getSeed() { return this.worldData.getSeed(); } @@ -2485,6 +2537,14 @@ public abstract class World implements IBlockAccess { return this.worldData.getTime(); } + public long F() { + return this.worldData.g(); + } + + public void setTime(long i) { + this.worldData.c(i); + } + public ChunkCoordinates getSpawn() { return new ChunkCoordinates(this.worldData.c(), this.worldData.d(), this.worldData.e()); } @@ -2495,7 +2555,7 @@ public abstract class World implements IBlockAccess { public void broadcastEntityEffect(Entity entity, byte b0) {} - public IChunkProvider F() { + public IChunkProvider H() { return this.chunkProvider; } @@ -2513,9 +2573,13 @@ public abstract class World implements IBlockAccess { return this.worldData; } + public GameRules getGameRules() { + return this.worldData.getGameRules(); + } + public void everyoneSleeping() {} - // CraftBukkit start + // CraftBukkit start // Calls the method that checks to see if players are sleeping // Called by CraftPlayer.setPermanentSleeping() public void checkSleepStatus() { @@ -2526,27 +2590,27 @@ public abstract class World implements IBlockAccess { // CraftBukkit end public float i(float f) { - return (this.p + (this.q - this.p) * f) * this.j(f); + return (this.o + (this.p - this.o) * f) * this.j(f); } public float j(float f) { - return this.n + (this.o - this.n) * f; + return this.m + (this.n - this.m) * f; } - public boolean I() { + public boolean L() { return (double) this.i(1.0F) > 0.9D; } - public boolean J() { + public boolean M() { return (double) this.j(1.0F) > 0.2D; } public boolean B(int i, int j, int k) { - if (!this.J()) { + if (!this.M()) { return false; } else if (!this.j(i, j, k)) { return false; - } else if (this.g(i, k) > j) { + } else if (this.h(i, k) > j) { return false; } else { BiomeBase biomebase = this.getBiome(i, k); @@ -2573,13 +2637,19 @@ public abstract class World implements IBlockAccess { return this.worldMaps.a(s); } + public void e(int i, int j, int k, int l, int i1) { + for (int j1 = 0; j1 < this.w.size(); ++j1) { + ((IWorldAccess) this.w.get(j1)).a(i, j, k, l, i1); + } + } + public void triggerEffect(int i, int j, int k, int l, int i1) { this.a((EntityHuman) null, i, j, k, l, i1); } public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) { - for (int j1 = 0; j1 < this.x.size(); ++j1) { - ((IWorldAccess) this.x.get(j1)).a(entityhuman, i, j, k, l, i1); + for (int j1 = 0; j1 < this.w.size(); ++j1) { + ((IWorldAccess) this.w.get(j1)).a(entityhuman, i, j, k, l, i1); } } @@ -2587,8 +2657,12 @@ public abstract class World implements IBlockAccess { return 256; } - public int L() { - return this.worldProvider.e ? 128 : 256; + public int O() { + return this.worldProvider.f ? 128 : 256; + } + + public IUpdatePlayerListBox a(EntityMinecart entityminecart) { + return null; } public Random D(int i, int j, int k) { @@ -2598,12 +2672,8 @@ public abstract class World implements IBlockAccess { return this.random; } - public boolean updateLights() { - return false; - } - public ChunkPosition b(String s, int i, int j, int k) { - return this.F().findNearestMapFeature(this, s, i, j, k); + return this.H().findNearestMapFeature(this, s, i, j, k); } public CrashReport a(CrashReport crashreport) { @@ -2613,13 +2683,22 @@ public abstract class World implements IBlockAccess { return crashreport; } - public void f(int i, int j, int k, int l, int i1) { - Iterator iterator = this.x.iterator(); + public void g(int i, int j, int k, int l, int i1) { + Iterator iterator = this.w.iterator(); while (iterator.hasNext()) { IWorldAccess iworldaccess = (IWorldAccess) iterator.next(); - iworldaccess.a(i, j, k, l, i1); + iworldaccess.b(i, j, k, l, i1); } } + + public Vec3DPool getVec3DPool() { + return this.K; + } + + public Calendar S() { + this.L.setTimeInMillis(System.currentTimeMillis()); + return this.L; + } } diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java index c1c3f0bc..2ca7a7ff 100644 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ b/src/main/java/net/minecraft/server/WorldGenForest.java @@ -70,7 +70,7 @@ public class WorldGenForest extends WorldGenerator implements BlockSapling.TreeG for (int k2 = k - k1; k2 <= k + k1; ++k2) { int l2 = k2 - k; - if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.n[world.getTypeId(l1, i2, k2)]) { + if ((Math.abs(j2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.q[world.getTypeId(l1, i2, k2)]) { this.setTypeAndData(world, l1, i2, k2, Block.LEAVES.id, 2); } } diff --git a/src/main/java/net/minecraft/server/WorldGenGroundBush.java b/src/main/java/net/minecraft/server/WorldGenGroundBush.java index 88555fb6..b0a5a7ef 100644 --- a/src/main/java/net/minecraft/server/WorldGenGroundBush.java +++ b/src/main/java/net/minecraft/server/WorldGenGroundBush.java @@ -43,7 +43,7 @@ public class WorldGenGroundBush extends WorldGenerator implements BlockSapling.T for (int k2 = k - l1; k2 <= k + l1; ++k2) { int l2 = k2 - k; - if ((Math.abs(j2) != l1 || Math.abs(l2) != l1 || random.nextInt(2) != 0) && !Block.n[world.getTypeId(i2, j1, k2)]) { + if ((Math.abs(j2) != l1 || Math.abs(l2) != l1 || random.nextInt(2) != 0) && !Block.q[world.getTypeId(i2, j1, k2)]) { this.setTypeAndData(world, i2, j1, k2, Block.LEAVES.id, this.a); } } diff --git a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java index 2d4fd608..9f00271e 100644 --- a/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java +++ b/src/main/java/net/minecraft/server/WorldGenHugeMushroom.java @@ -162,7 +162,7 @@ public class WorldGenHugeMushroom extends WorldGenerator implements BlockSapling l2 = 0; } - if ((l2 != 0 || j >= j + i1 - 1) && !Block.n[world.getTypeId(i2, k1, k2)]) { + if ((l2 != 0 || j >= j + i1 - 1) && !Block.q[world.getTypeId(i2, k1, k2)]) { // CraftBukkit start if (event == null) { this.setTypeAndData(world, i2, k1, k2, Block.BIG_MUSHROOM_1.id + l, l2); @@ -180,7 +180,7 @@ public class WorldGenHugeMushroom extends WorldGenerator implements BlockSapling for (k1 = 0; k1 < i1; ++k1) { l1 = world.getTypeId(i, j + k1, k); - if (!Block.n[l1]) { + if (!Block.q[l1]) { // CraftBukkit start if (event == null) { this.setTypeAndData(world, i, j + k1, k, Block.BIG_MUSHROOM_1.id + l, 10); diff --git a/src/main/java/net/minecraft/server/WorldGenMegaTree.java b/src/main/java/net/minecraft/server/WorldGenMegaTree.java index bccccbed..a49bcf4f 100644 --- a/src/main/java/net/minecraft/server/WorldGenMegaTree.java +++ b/src/main/java/net/minecraft/server/WorldGenMegaTree.java @@ -167,7 +167,7 @@ public class WorldGenMegaTree extends WorldGenerator implements BlockSapling.Tre for (int j2 = j - k1; j2 <= j + k1 + 1; ++j2) { int k2 = j2 - j; - if ((i2 >= 0 || k2 >= 0 || i2 * i2 + k2 * k2 <= k1 * k1) && (i2 <= 0 && k2 <= 0 || i2 * i2 + k2 * k2 <= (k1 + 1) * (k1 + 1)) && (random.nextInt(4) != 0 || i2 * i2 + k2 * k2 <= (k1 - 1) * (k1 - 1)) && !Block.n[world.getTypeId(l1, i1, j2)]) { + if ((i2 >= 0 || k2 >= 0 || i2 * i2 + k2 * k2 <= k1 * k1) && (i2 <= 0 && k2 <= 0 || i2 * i2 + k2 * k2 <= (k1 + 1) * (k1 + 1)) && (random.nextInt(4) != 0 || i2 * i2 + k2 * k2 <= (k1 - 1) * (k1 - 1)) && !Block.q[world.getTypeId(l1, i1, j2)]) { this.setTypeAndData(world, l1, i1, j2, Block.LEAVES.id, this.c); } } diff --git a/src/main/java/net/minecraft/server/WorldGenSwampTree.java b/src/main/java/net/minecraft/server/WorldGenSwampTree.java index 904a3ade..bdf85d8b 100644 --- a/src/main/java/net/minecraft/server/WorldGenSwampTree.java +++ b/src/main/java/net/minecraft/server/WorldGenSwampTree.java @@ -78,7 +78,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.Tr for (int k2 = k - k1; k2 <= k + k1; ++k2) { int l2 = k2 - k; - if ((Math.abs(i2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.n[world.getTypeId(l1, j2, k2)]) { + if ((Math.abs(i2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.q[world.getTypeId(l1, j2, k2)]) { this.setType(world, l1, j2, k2, Block.LEAVES.id); } } diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga1.java b/src/main/java/net/minecraft/server/WorldGenTaiga1.java index ddf0c1e1..1c579257 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga1.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga1.java @@ -66,7 +66,7 @@ public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeG for (int i3 = k - l2; i3 <= k + l2; ++i3) { int j3 = i3 - k; - if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.n[world.getTypeId(j2, i2, i3)]) { + if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.q[world.getTypeId(j2, i2, i3)]) { this.setTypeAndData(world, j2, i2, i3, Block.LEAVES.id, 1); } } diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga2.java b/src/main/java/net/minecraft/server/WorldGenTaiga2.java index 3a37ce2a..40ae1664 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -74,7 +74,7 @@ public class WorldGenTaiga2 extends WorldGenerator implements BlockSapling.TreeG for (int l3 = k - k2; l3 <= k + k2; ++l3) { int i4 = l3 - k; - if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.n[world.getTypeId(i3, j3, l3)]) { + if ((Math.abs(k3) != k2 || Math.abs(i4) != k2 || k2 <= 0) && !Block.q[world.getTypeId(i3, j3, l3)]) { this.setTypeAndData(world, i3, j3, l3, Block.LEAVES.id, 1); } } diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index 71f3fed0..4124d941 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -86,7 +86,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe for (int l2 = k - i2; l2 <= k + i2; ++l2) { int i3 = l2 - k; - if ((Math.abs(k2) != i2 || Math.abs(i3) != i2 || random.nextInt(2) != 0 && k1 != 0) && !Block.n[world.getTypeId(j2, j1, l2)]) { + if ((Math.abs(k2) != i2 || Math.abs(i3) != i2 || random.nextInt(2) != 0 && k1 != 0) && !Block.q[world.getTypeId(j2, j1, l2)]) { this.setTypeAndData(world, j2, j1, l2, Block.LEAVES.id, this.d); } } @@ -150,7 +150,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe for (k1 = 0; k1 < 4; ++k1) { if (random.nextInt(4 - j1) == 0) { i2 = random.nextInt(3); - this.setTypeAndData(world, i + Direction.a[Direction.e[k1]], j + l - 5 + j1, k + Direction.b[Direction.e[k1]], Block.COCOA.id, i2 << 2 | k1); + this.setTypeAndData(world, i + Direction.a[Direction.f[k1]], j + l - 5 + j1, k + Direction.b[Direction.f[k1]], Block.COCOA.id, i2 << 2 | k1); } } } diff --git a/src/main/java/net/minecraft/server/WorldGenerator.java b/src/main/java/net/minecraft/server/WorldGenerator.java index 88e29c77..506a1c6a 100644 --- a/src/main/java/net/minecraft/server/WorldGenerator.java +++ b/src/main/java/net/minecraft/server/WorldGenerator.java @@ -7,6 +7,7 @@ import org.bukkit.BlockChangeDelegate; // CraftBukkit public abstract class WorldGenerator { private final boolean a; + private int b = 1; public WorldGenerator() { this.a = false; diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java index ba67e77d..5bab0870 100644 --- a/src/main/java/net/minecraft/server/WorldManager.java +++ b/src/main/java/net/minecraft/server/WorldManager.java @@ -45,10 +45,14 @@ public class WorldManager implements IWorldAccess { public void a(EntityHuman entityhuman, int i, int j, int k, int l, int i1) { // CraftBukkit - this.world.dimension - this.server.getServerConfigurationManager().sendPacketNearby(entityhuman, (double) j, (double) k, (double) l, 64.0D, this.world.dimension, new Packet61WorldEvent(i, j, k, l, i1)); + this.server.getServerConfigurationManager().sendPacketNearby(entityhuman, (double) j, (double) k, (double) l, 64.0D, this.world.dimension, new Packet61WorldEvent(i, j, k, l, i1, false)); } public void a(int i, int j, int k, int l, int i1) { + this.server.getServerConfigurationManager().sendAll(new Packet61WorldEvent(i, j, k, l, i1, true)); + } + + public void b(int i, int j, int k, int l, int i1) { Iterator iterator = this.server.getServerConfigurationManager().players.iterator(); while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java index c6aa7d95..7b3976f9 100644 --- a/src/main/java/net/minecraft/server/WorldMap.java +++ b/src/main/java/net/minecraft/server/WorldMap.java @@ -2,6 +2,7 @@ package net.minecraft.server; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -20,10 +21,9 @@ public class WorldMap extends WorldMapBase { public byte map; public byte scale; public byte[] colors = new byte[16384]; - public int f; - public List g = new ArrayList(); - private Map j = new HashMap(); - public List decorations = new ArrayList(); + public List f = new ArrayList(); + private Map i = new HashMap(); + public Map g = new LinkedHashMap(); // CraftBukkit start public final CraftMapView mapView; @@ -133,58 +133,91 @@ public class WorldMap extends WorldMapBase { } public void a(EntityHuman entityhuman, ItemStack itemstack) { - if (!this.j.containsKey(entityhuman)) { + if (!this.i.containsKey(entityhuman)) { WorldMapHumanTracker worldmaphumantracker = new WorldMapHumanTracker(this, entityhuman); - this.j.put(entityhuman, worldmaphumantracker); - this.g.add(worldmaphumantracker); + this.i.put(entityhuman, worldmaphumantracker); + this.f.add(worldmaphumantracker); } - this.decorations.clear(); + if (!entityhuman.inventory.c(itemstack)) { + this.g.remove(entityhuman.getName()); + } - for (int i = 0; i < this.g.size(); ++i) { - WorldMapHumanTracker worldmaphumantracker1 = (WorldMapHumanTracker) this.g.get(i); + for (int i = 0; i < this.f.size(); ++i) { + WorldMapHumanTracker worldmaphumantracker1 = (WorldMapHumanTracker) this.f.get(i); - if (!worldmaphumantracker1.trackee.dead && worldmaphumantracker1.trackee.inventory.c(itemstack)) { - float f = (float) (worldmaphumantracker1.trackee.locX - (double) this.centerX) / (float) (1 << this.scale); - float f1 = (float) (worldmaphumantracker1.trackee.locZ - (double) this.centerZ) / (float) (1 << this.scale); - byte b0 = 64; - byte b1 = 64; + if (!worldmaphumantracker1.trackee.dead && (worldmaphumantracker1.trackee.inventory.c(itemstack) || itemstack.y())) { + if (!itemstack.y() && worldmaphumantracker1.trackee.dimension == this.map) { + this.a(0, worldmaphumantracker1.trackee.world, worldmaphumantracker1.trackee.getName(), worldmaphumantracker1.trackee.locX, worldmaphumantracker1.trackee.locZ, (double) worldmaphumantracker1.trackee.yaw); + } + } else { + this.i.remove(worldmaphumantracker1.trackee); + this.f.remove(worldmaphumantracker1); + } + } - if (f >= (float) (-b0) && f1 >= (float) (-b1) && f <= (float) b0 && f1 <= (float) b1) { - byte b2 = 0; - byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D)); - byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D)); - byte b5 = (byte) ((int) ((double) worldmaphumantracker1.trackee.yaw * 16.0D / 360.0D)); + if (itemstack.y()) { + this.a(1, entityhuman.world, "frame-" + itemstack.z().id, (double) itemstack.z().x, (double) itemstack.z().z, (double) (itemstack.z().direction * 90)); + } + } - if (this.map < 0) { - int j = this.f / 10; + private void a(int i, World world, String s, double d0, double d1, double d2) { + int j = 1 << this.scale; + float f = (float) (d0 - (double) this.centerX) / (float) j; + float f1 = (float) (d1 - (double) this.centerZ) / (float) j; + byte b0 = (byte) ((int) ((double) (f * 2.0F) + 0.5D)); + byte b1 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D)); + byte b2 = 63; + byte b3; + + if (f >= (float) (-b2) && f1 >= (float) (-b2) && f <= (float) b2 && f1 <= (float) b2) { + d2 += d2 < 0.0D ? -8.0D : 8.0D; + b3 = (byte) ((int) (d2 * 16.0D / 360.0D)); + if (this.map < 0) { + int k = (int) (world.getWorldData().g() / 10L); + + b3 = (byte) (k * k * 34187121 + k * 121 >> 15 & 15); + } + } else { + if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F) { + this.g.remove(s); + return; + } - b5 = (byte) (j * j * 34187121 + j * 121 >> 15 & 15); - } + i = 6; + b3 = 0; + if (f <= (float) (-b2)) { + b0 = (byte) ((int) ((double) (b2 * 2) + 2.5D)); + } - if (worldmaphumantracker1.trackee.dimension == this.map) { - this.decorations.add(new WorldMapDecoration(this, b2, b3, b4, b5)); - } - } - } else { - this.j.remove(worldmaphumantracker1.trackee); - this.g.remove(worldmaphumantracker1); + if (f1 <= (float) (-b2)) { + b1 = (byte) ((int) ((double) (b2 * 2) + 2.5D)); + } + + if (f >= (float) b2) { + b0 = (byte) (b2 * 2 + 1); + } + + if (f1 >= (float) b2) { + b1 = (byte) (b2 * 2 + 1); } } + + this.g.put(s, new WorldMapDecoration(this, (byte) i, b0, b1, b3)); } public byte[] getUpdatePacket(ItemStack itemstack, World world, EntityHuman entityhuman) { - WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.j.get(entityhuman); + WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.i.get(entityhuman); return worldmaphumantracker == null ? null : worldmaphumantracker.a(itemstack); } public void flagDirty(int i, int j, int k) { - super.a(); + super.c(); - for (int l = 0; l < this.g.size(); ++l) { - WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.g.get(l); + for (int l = 0; l < this.f.size(); ++l) { + WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.f.get(l); if (worldmaphumantracker.b[i] < 0 || worldmaphumantracker.b[i] > j) { worldmaphumantracker.b[i] = j; @@ -195,4 +228,16 @@ public class WorldMap extends WorldMapBase { } } } + + public WorldMapHumanTracker a(EntityHuman entityhuman) { + WorldMapHumanTracker worldmaphumantracker = (WorldMapHumanTracker) this.i.get(entityhuman); + + if (worldmaphumantracker == null) { + worldmaphumantracker = new WorldMapHumanTracker(this, entityhuman); + this.i.put(entityhuman, worldmaphumantracker); + this.f.add(worldmaphumantracker); + } + + return worldmaphumantracker; + } } diff --git a/src/main/java/net/minecraft/server/WorldMapHumanTracker.java b/src/main/java/net/minecraft/server/WorldMapHumanTracker.java index 69779683..3aeb3e96 100644 --- a/src/main/java/net/minecraft/server/WorldMapHumanTracker.java +++ b/src/main/java/net/minecraft/server/WorldMapHumanTracker.java @@ -1,13 +1,17 @@ package net.minecraft.server; +import java.util.Iterator; + public class WorldMapHumanTracker { public final EntityHuman trackee; public int[] b; public int[] c; - private int e; private int f; - private byte[] g; + private int g; + private byte[] h; + public int d; + private boolean i; final WorldMap worldMap; @@ -15,8 +19,9 @@ public class WorldMapHumanTracker { this.worldMap = worldmap; this.b = new int[128]; this.c = new int[128]; - this.e = 0; this.f = 0; + this.g = 0; + this.i = false; this.trackee = entityhuman; for (int i = 0; i < this.b.length; ++i) { @@ -26,70 +31,78 @@ public class WorldMapHumanTracker { } public byte[] a(ItemStack itemstack) { - int i; - int j; - - org.bukkit.craftbukkit.map.RenderData render = this.worldMap.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) trackee.getBukkitEntity()); // CraftBukkit - - if (--this.f < 0) { - this.f = 4; - byte[] abyte = new byte[render.cursors.size() * 3 + 1]; // CraftBukkit - - abyte[0] = 1; - - // CraftBukkit start - for (i = 0; i < render.cursors.size(); ++i) { - org.bukkit.map.MapCursor cursor = render.cursors.get(i); - if (!cursor.isVisible()) continue; - - byte value = (byte) (((cursor.getRawType() == 0 || cursor.getDirection() < 8 ? cursor.getDirection() : cursor.getDirection() - 1) & 15) * 16); - abyte[i * 3 + 1] = (byte) (value | (cursor.getRawType() != 0 && value < 0 ? 16 - cursor.getRawType() : cursor.getRawType())); - abyte[i * 3 + 2] = (byte) cursor.getX(); - abyte[i * 3 + 3] = (byte) cursor.getY(); - } - // CraftBukkit end + byte[] abyte; + + if (!this.i) { + abyte = new byte[] { (byte) 2, this.worldMap.scale}; + this.i = true; + return abyte; + } else { + int i; + int j; + + org.bukkit.craftbukkit.map.RenderData render = this.worldMap.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) trackee.getBukkitEntity()); // CraftBukkit + + if (--this.g < 0) { + this.g = 4; + abyte = new byte[render.cursors.size() * 3 + 1]; // CraftBukkit + abyte[0] = 1; + i = 0; + + // CraftBukkit start + for (i = 0; i < render.cursors.size(); ++i) { + org.bukkit.map.MapCursor cursor = render.cursors.get(i); + if (!cursor.isVisible()) continue; + + byte value = (byte) (((cursor.getRawType() == 0 || cursor.getDirection() < 8 ? cursor.getDirection() : cursor.getDirection() - 1) & 15) * 16); + abyte[i * 3 + 1] = (byte) (value | (cursor.getRawType() != 0 && value < 0 ? 16 - cursor.getRawType() : cursor.getRawType())); + abyte[i * 3 + 2] = (byte) cursor.getX(); + abyte[i * 3 + 3] = (byte) cursor.getY(); + } + // CraftBukkit end - boolean flag = true; + boolean flag = !itemstack.y(); - if (this.g != null && this.g.length == abyte.length) { - for (j = 0; j < abyte.length; ++j) { - if (abyte[j] != this.g[j]) { - flag = false; - break; + if (this.h != null && this.h.length == abyte.length) { + for (j = 0; j < abyte.length; ++j) { + if (abyte[j] != this.h[j]) { + flag = false; + break; + } } + } else { + flag = false; } - } else { - flag = false; - } - if (!flag) { - this.g = abyte; - return abyte; + if (!flag) { + this.h = abyte; + return abyte; + } } - } - for (int k = 0; k < 10; ++k) { - i = this.e * 11 % 128; - ++this.e; - if (this.b[i] >= 0) { - j = this.c[i] - this.b[i] + 1; - int l = this.b[i]; - byte[] abyte1 = new byte[j + 3]; + for (int k = 0; k < 1; ++k) { + i = this.f++ * 11 % 128; + if (this.b[i] >= 0) { + int l = this.c[i] - this.b[i] + 1; - abyte1[0] = 0; - abyte1[1] = (byte) i; - abyte1[2] = (byte) l; + j = this.b[i]; + byte[] abyte1 = new byte[l + 3]; - for (int i1 = 0; i1 < abyte1.length - 3; ++i1) { - abyte1[i1 + 3] = render.buffer[(i1 + l) * 128 + i]; // CraftBukkit - } + abyte1[0] = 0; + abyte1[1] = (byte) i; + abyte1[2] = (byte) j; + + for (int i1 = 0; i1 < abyte1.length - 3; ++i1) { + abyte1[i1 + 3] = render.buffer[(i1 + j) * 128 + i]; // CraftBukkit + } - this.c[i] = -1; - this.b[i] = -1; - return abyte1; + this.c[i] = -1; + this.b[i] = -1; + return abyte1; + } } - } - return null; + return null; + } } } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 16db56b4..bb17c7e1 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -24,16 +24,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate private final MinecraftServer server; public EntityTracker tracker; // CraftBukkit - private final -> public private final PlayerManager manager; - private Set N; - private TreeSet O; + private Set M; + private TreeSet N; public ChunkProviderServer chunkProviderServer; - public boolean weirdIsOpCache = false; public boolean savingDisabled; - private boolean P; + private boolean O; private int emptyTime = 0; - private NoteDataList[] R = new NoteDataList[] { new NoteDataList((EmptyClass2) null), new NoteDataList((EmptyClass2) null)}; - private int S = 0; - private static final StructurePieceTreasure[] T = new StructurePieceTreasure[] { new StructurePieceTreasure(Item.STICK.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.WOOD.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.LOG.id, 0, 1, 3, 10), new StructurePieceTreasure(Item.STONE_AXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_AXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.STONE_PICKAXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_PICKAXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.APPLE.id, 0, 2, 3, 5), new StructurePieceTreasure(Item.BREAD.id, 0, 2, 3, 3)}; + private NoteDataList[] Q = new NoteDataList[] { new NoteDataList((EmptyClass2) null), new NoteDataList((EmptyClass2) null)}; + private int R = 0; + private static final StructurePieceTreasure[] S = new StructurePieceTreasure[] { new StructurePieceTreasure(Item.STICK.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.WOOD.id, 0, 1, 3, 10), new StructurePieceTreasure(Block.LOG.id, 0, 1, 3, 10), new StructurePieceTreasure(Item.STONE_AXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_AXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.STONE_PICKAXE.id, 0, 1, 1, 3), new StructurePieceTreasure(Item.WOOD_PICKAXE.id, 0, 1, 1, 5), new StructurePieceTreasure(Item.APPLE.id, 0, 2, 3, 5), new StructurePieceTreasure(Item.BREAD.id, 0, 2, 3, 3)}; private IntHashMap entitiesById; // CraftBukkit start @@ -51,12 +50,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.entitiesById = new IntHashMap(); } - if (this.N == null) { - this.N = new HashSet(); + if (this.M == null) { + this.M = new HashSet(); } - if (this.O == null) { - this.O = new TreeSet(); + if (this.N == null) { + this.N = new TreeSet(); } } @@ -132,7 +131,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.difficulty = 3; } - this.worldProvider.c.b(); + this.worldProvider.d.b(); if (this.everyoneDeeplySleeping()) { boolean flag = false; @@ -141,9 +140,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } if (!flag) { - long i = this.worldData.getTime() + 24000L; + long i = this.worldData.g() + 24000L; - this.worldData.b(i - i % 24000L); + this.worldData.c(i - i % 24000L); this.d(); } } @@ -151,20 +150,21 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.methodProfiler.a("mobSpawner"); // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals long time = this.worldData.getTime(); - if ((this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { - SpawnerCreature.spawnEntities(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L)); + if (this.getGameRules().getBoolean("doMobSpawning") && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { + SpawnerCreature.spawnEntities(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L); } // CraftBukkit end this.methodProfiler.c("chunkSource"); this.chunkProvider.unloadChunks(); int j = this.a(1.0F); - if (j != this.k) { - this.k = j; + if (j != this.j) { + this.j = j; } - this.Q(); + this.U(); this.worldData.b(this.worldData.getTime() + 1L); + this.worldData.c(this.worldData.g() + 1L); this.methodProfiler.c("tickPending"); this.a(false); this.methodProfiler.c("tickTiles"); @@ -175,31 +175,31 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.villages.tick(); this.siegeManager.a(); this.methodProfiler.b(); - this.Q(); + this.U(); } public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) { - List list = this.F().getMobsFor(enumcreaturetype, i, j, k); + List list = this.H().getMobsFor(enumcreaturetype, i, j, k); return list != null && !list.isEmpty() ? (BiomeMeta) WeightedRandom.a(this.random, (Collection) list) : null; } public void everyoneSleeping() { - this.P = !this.players.isEmpty(); + this.O = !this.players.isEmpty(); Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { EntityHuman entityhuman = (EntityHuman) iterator.next(); if (!entityhuman.isSleeping() && !entityhuman.fauxSleeping) { // CraftBukkit - this.P = false; + this.O = false; break; } } } protected void d() { - this.P = false; + this.O = false; Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -210,10 +210,10 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } } - this.P(); + this.T(); } - private void P() { + private void T() { // CraftBukkit start WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false); this.getServer().getPluginManager().callEvent(weather); @@ -232,7 +232,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } public boolean everyoneDeeplySleeping() { - if (this.P && !this.isStatic) { + if (this.O && !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 @@ -263,9 +263,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate super.g(); int i = 0; int j = 0; - // Iterator iterator = this.chunkTickList.iterator(); // CraftBukkit - // CraftBukkit start + // Iterator iterator = this.chunkTickList.iterator(); + for (long chunkCoord : this.chunkTickList.popAll()) { int chunkX = LongHash.msw(chunkCoord); int chunkZ = LongHash.lsw(chunkCoord); @@ -286,15 +286,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate int k1; int l1; - if (this.random.nextInt(100000) == 0 && this.J() && this.I()) { - this.l = this.l * 3 + 1013904223; - i1 = this.l >> 2; + if (this.random.nextInt(100000) == 0 && this.M() && this.L()) { + this.k = this.k * 3 + 1013904223; + i1 = this.k >> 2; j1 = k + (i1 & 15); k1 = l + (i1 >> 8 & 15); - l1 = this.g(j1, k1); + l1 = this.h(j1, k1); if (this.B(j1, l1, k1)) { this.strikeLightning(new EntityLightning(this, (double) j1, (double) l1, (double) k1)); - this.r = 2; + this.q = 2; } } @@ -302,11 +302,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate int i2; if (this.random.nextInt(16) == 0) { - this.l = this.l * 3 + 1013904223; - i1 = this.l >> 2; + this.k = this.k * 3 + 1013904223; + i1 = this.k >> 2; j1 = i1 & 15; k1 = i1 >> 8 & 15; - l1 = this.g(j1 + k, k1 + l); + l1 = this.h(j1 + k, k1 + l); if (this.v(j1 + k, l1 - 1, k1 + l)) { // CraftBukkit start BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1 - 1, k1 + l).getState(); @@ -320,7 +320,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate // CraftBukkit end } - if (this.J() && this.w(j1 + k, l1, k1 + l)) { + if (this.M() && this.w(j1 + k, l1, k1 + l)) { // CraftBukkit start BlockState blockState = this.getWorld().getBlockAt(j1 + k, l1, k1 + l).getState(); blockState.setTypeId(Block.SNOW.id); @@ -333,7 +333,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate // CraftBukkit end } - if (this.J()) { + if (this.M()) { BiomeBase biomebase = this.getBiome(j1 + k, k1 + l); if (biomebase.d()) { @@ -355,8 +355,8 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate if (chunksection != null && chunksection.b()) { for (int j2 = 0; j2 < 3; ++j2) { - this.l = this.l * 3 + 1013904223; - i2 = this.l >> 2; + this.k = this.k * 3 + 1013904223; + i2 = this.k >> 2; int k2 = i2 & 15; int l2 = i2 >> 8 & 15; int i3 = i2 >> 16 & 15; @@ -365,7 +365,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate ++j; Block block = Block.byId[j3]; - if (block != null && block.r()) { + if (block != null && block.isTicking()) { ++i; block.b(this, k2 + k, i3 + chunksection.d(), l2 + l, this.random); } @@ -378,27 +378,38 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } public void a(int i, int j, int k, int l, int i1) { + this.a(i, j, k, l, i1, 0); + } + + public void a(int i, int j, int k, int l, int i1, int j1) { NextTickListEntry nextticklistentry = new NextTickListEntry(i, j, k, l); byte b0 = 8; - if (this.e) { - if (this.c(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { - int j1 = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); + if (this.d && l > 0) { + if (Block.byId[l].l()) { + if (this.d(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { + int k1 = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); - if (j1 == nextticklistentry.d && j1 > 0) { - Block.byId[j1].b(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random); + if (k1 == nextticklistentry.d && k1 > 0) { + Block.byId[k1].b(this, nextticklistentry.a, nextticklistentry.b, nextticklistentry.c, this.random); + } } + + return; } - } else { - if (this.c(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { - if (l > 0) { - nextticklistentry.a((long) i1 + this.worldData.getTime()); - } - if (!this.N.contains(nextticklistentry)) { - this.N.add(nextticklistentry); - this.O.add(nextticklistentry); - } + i1 = 1; + } + + if (this.d(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) { + if (l > 0) { + nextticklistentry.a((long) i1 + this.worldData.getTime()); + nextticklistentry.a(j1); + } + + if (!this.M.contains(nextticklistentry)) { + this.M.add(nextticklistentry); + this.N.add(nextticklistentry); } } } @@ -410,28 +421,32 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate nextticklistentry.a((long) i1 + this.worldData.getTime()); } - if (!this.N.contains(nextticklistentry)) { + if (!this.M.contains(nextticklistentry)) { + this.M.add(nextticklistentry); this.N.add(nextticklistentry); - this.O.add(nextticklistentry); } } public void tickEntities() { if (false && this.players.isEmpty()) { // CraftBukkit - this prevents entity cleanup, other issues on servers with no players - if (this.emptyTime++ >= 60) { + if (this.emptyTime++ >= 1200) { return; } } else { - this.emptyTime = 0; + this.i(); } super.tickEntities(); } + public void i() { + this.emptyTime = 0; + } + public boolean a(boolean flag) { - int i = this.O.size(); + int i = this.N.size(); - if (i != this.N.size()) { + if (i != this.M.size()) { throw new IllegalStateException("TickNextTick list out of synch"); } else { if (i > 1000) { @@ -445,17 +460,17 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } for (int j = 0; j < i; ++j) { - NextTickListEntry nextticklistentry = (NextTickListEntry) this.O.first(); + NextTickListEntry nextticklistentry = (NextTickListEntry) this.N.first(); if (!flag && nextticklistentry.e > this.worldData.getTime()) { break; } - this.O.remove(nextticklistentry); this.N.remove(nextticklistentry); + this.M.remove(nextticklistentry); byte b0 = 8; - if (this.c(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { + if (this.d(nextticklistentry.a - b0, nextticklistentry.b - b0, nextticklistentry.c - b0, nextticklistentry.a + b0, nextticklistentry.b + b0, nextticklistentry.c + b0)) { int k = this.getTypeId(nextticklistentry.a, nextticklistentry.b, nextticklistentry.c); if (k == nextticklistentry.d && k > 0) { @@ -464,7 +479,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } } - return !this.O.isEmpty(); + return !this.N.isEmpty(); } } @@ -475,14 +490,14 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate int j = i + 16; int k = chunkcoordintpair.z << 4; int l = k + 16; - Iterator iterator = this.O.iterator(); + Iterator iterator = this.N.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.N.remove(nextticklistentry); + this.M.remove(nextticklistentry); iterator.remove(); } @@ -516,7 +531,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate super.entityJoinedWorld(entity, flag); } - protected IChunkProvider i() { + protected IChunkProvider j() { IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); // CraftBukkit start @@ -562,7 +577,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } // CraftBukkit - Configurable spawn protection - return i1 > this.getServer().getSpawnRadius() || this.server.getServerConfigurationManager().isOp(entityhuman.name) || this.server.H(); + return i1 > this.getServer().getSpawnRadius() || this.server.getServerConfigurationManager().isOp(entityhuman.name) || this.server.I(); } protected void a(WorldSettings worldsettings) { @@ -570,12 +585,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.entitiesById = new IntHashMap(); } - if (this.N == null) { - this.N = new HashSet(); + if (this.M == null) { + this.M = new HashSet(); } - if (this.O == null) { - this.O = new TreeSet(); + if (this.N == null) { + this.N = new TreeSet(); } this.b(worldsettings); @@ -587,7 +602,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.worldData.setSpawn(0, this.worldProvider.getSeaLevel(), 0); } else { this.isLoading = true; - WorldChunkManager worldchunkmanager = this.worldProvider.c; + WorldChunkManager worldchunkmanager = this.worldProvider.d; List list = worldchunkmanager.a(); Random random = new Random(this.getSeed()); ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random); @@ -621,8 +636,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate int l = 0; - // CraftBukkit - use our own canSpawn - while (!this.canSpawn(i, k)) { + while (!this.canSpawn(i, k)) { // CraftBukkit - use our own canSpawn i += random.nextInt(64) - random.nextInt(64); k += random.nextInt(64) - random.nextInt(64); ++l; @@ -634,18 +648,18 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.worldData.setSpawn(i, j, k); this.isLoading = false; if (worldsettings.c()) { - this.j(); + this.k(); } } } - protected void j() { - WorldGenBonusChest worldgenbonuschest = new WorldGenBonusChest(T, 10); + protected void k() { + WorldGenBonusChest worldgenbonuschest = new WorldGenBonusChest(S, 10); for (int i = 0; i < 10; ++i) { int j = this.worldData.c() + this.random.nextInt(6) - this.random.nextInt(6); int k = this.worldData.e() + this.random.nextInt(6) - this.random.nextInt(6); - int l = this.h(j, k) + 1; + int l = this.i(j, k) + 1; if (worldgenbonuschest.a(this, this.random, j, l, k)) { break; @@ -673,7 +687,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } protected void a() throws ExceptionWorldConflict { // CraftBukkit - added throws - this.B(); + this.C(); this.dataManager.saveWorldData(this.worldData, this.server.getServerConfigurationManager().q()); this.worldMaps.a(); } @@ -681,7 +695,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate protected void a(Entity entity) { super.a(entity); this.entitiesById.a(entity.id, entity); - Entity[] aentity = entity.al(); + Entity[] aentity = entity.ao(); if (aentity != null) { Entity[] aentity1 = aentity; @@ -698,7 +712,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate protected void b(Entity entity) { super.b(entity); this.entitiesById.d(entity.id); - Entity[] aentity = entity.al(); + Entity[] aentity = entity.ao(); if (aentity != null) { Entity[] aentity1 = aentity; @@ -740,9 +754,9 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.getTracker().sendPacketToEntity(entity, packet38entitystatus); } - public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) { + public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { // CraftBukkit start - Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag); + Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag, flag1); if (explosion.wasCanceled) { return explosion; @@ -750,10 +764,15 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate /* Remove explosion.a = flag; + explosion.b = flag1; explosion.a(); explosion.a(false); + if (!flag1) { + explosion.blocks.clear(); + } */ - // CraftBukkit end + // CraftBukkit end - TODO: Check if explosions are still properly implemented + Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { @@ -769,13 +788,13 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate public void playNote(int i, int j, int k, int l, int i1, int j1) { NoteBlockData noteblockdata = new NoteBlockData(i, j, k, l, i1, j1); - Iterator iterator = this.R[this.S].iterator(); + Iterator iterator = this.Q[this.R].iterator(); NoteBlockData noteblockdata1; do { if (!iterator.hasNext()) { - this.R[this.S].add(noteblockdata); + this.Q[this.R].add(noteblockdata); return; } @@ -784,12 +803,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } - private void Q() { - while (!this.R[this.S].isEmpty()) { - int i = this.S; + private void U() { + while (!this.Q[this.R].isEmpty()) { + int i = this.R; - this.S ^= 1; - Iterator iterator = this.R[i].iterator(); + this.R ^= 1; + Iterator iterator = this.Q[i].iterator(); while (iterator.hasNext()) { NoteBlockData noteblockdata = (NoteBlockData) iterator.next(); @@ -800,7 +819,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate } } - this.R[i].clear(); + this.Q[i].clear(); } } @@ -819,11 +838,11 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate this.dataManager.a(); } - protected void m() { - boolean flag = this.J(); + protected void n() { + boolean flag = this.M(); - super.m(); - if (flag != this.J()) { + super.n(); + if (flag != this.M()) { // 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) { @@ -842,29 +861,6 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate return this.tracker; } - public void setTimeAndFixTicklists(long i) { - long j = i - this.worldData.getTime(); - - NextTickListEntry nextticklistentry; - - for (Iterator iterator = this.N.iterator(); iterator.hasNext(); nextticklistentry.e += j) { - nextticklistentry = (NextTickListEntry) iterator.next(); - } - - Block[] ablock = Block.byId; - int k = ablock.length; - - for (int l = 0; l < k; ++l) { - Block block = ablock[l]; - - if (block != null) { - block.a(this, j, i); - } - } - - this.setTime(i); - } - public PlayerManager getPlayerManager() { return this.manager; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 853c240b..24b20f12 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -731,10 +731,6 @@ public final class CraftServer implements Server { ChunkCoordinates chunkcoordinates = internal.getSpawn(); internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4); - - while (internal.updateLights()) { - ; - } } } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index a8c8a609..46027e84 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -429,16 +429,20 @@ public class CraftWorld implements World { CraftPlayer cp = (CraftPlayer) p; if (cp.getHandle().netServerHandler == null) continue; - cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime())); + cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime(), cp.getHandle().world.F())); } } public boolean createExplosion(double x, double y, double z, float power) { - return createExplosion(x, y, z, power, false); + return createExplosion(x, y, z, power, false, true); } public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { - return !world.createExplosion(null, x, y, z, power, setFire).wasCanceled; + return createExplosion(x, y, z, power, setFire, true); + } + + public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) { + return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks).wasCanceled; } public boolean createExplosion(Location loc, float power) { @@ -755,7 +759,7 @@ public class CraftWorld implements World { Validate.notNull(effect, "Effect cannot be null"); Validate.notNull(location.getWorld(), "World cannot be null"); int packetData = effect.getId(); - Packet61WorldEvent packet = new Packet61WorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data); + Packet61WorldEvent packet = new Packet61WorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false); int distance; radius *= radius; @@ -834,7 +838,7 @@ public class CraftWorld implements World { if (SmallFireball.class.isAssignableFrom(clazz)) { entity = new EntitySmallFireball(world); } else { - entity = new EntityFireball(world); + entity = new EntityLargeFireball(world); } ((EntityFireball) entity).setPositionRotation(x, y, z, yaw, pitch); Vector direction = location.getDirection().multiply(10); diff --git a/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java index 47a3c787..e01e7366 100644 --- a/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java +++ b/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java @@ -93,7 +93,7 @@ public class PortalTravelAgent implements TravelAgent { for (int k1 = i1 - this.searchRadius; k1 <= i1 + this.searchRadius; ++k1) { double d3 = (double) k1 + 0.5D - location.getZ(); - for (int l1 = world.L() - 1; l1 >= 0; --l1) { + for (int l1 = world.O() - 1; l1 >= 0; --l1) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { --l1; @@ -200,7 +200,7 @@ public class PortalTravelAgent implements TravelAgent { d2 = (double) j2 + 0.5D - location.getZ(); label271: - for (l2 = world.L() - 1; l2 >= 0; --l2) { + for (l2 = world.O() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -251,7 +251,7 @@ public class PortalTravelAgent implements TravelAgent { d2 = (double) j2 + 0.5D - location.getZ(); label219: - for (l2 = world.L() - 1; l2 >= 0; --l2) { + for (l2 = world.O() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -312,8 +312,8 @@ public class PortalTravelAgent implements TravelAgent { i1 = 70; } - if (i1 > world.L() - 10) { - i1 = world.L() - 10; + if (i1 > world.O() - 10) { + i1 = world.O() - 10; } j5 = i1; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 368cea99..c5c11fdd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -372,7 +372,7 @@ public class CraftBlock implements Block { for (int i = 0; i < count; ++i) { int item = block.getDropType(data, chunk.getHandle().world.random, 0); if (item > 0) { - drops.add(new ItemStack(item, 1, (short) net.minecraft.server.Block.getDropData(block, data))); + drops.add(new ItemStack(item, 1, (short) block.getDropData(data))); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java index dac99f3c..c94b43d1 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDispenser.java @@ -32,7 +32,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser { if (block.getType() == Material.DISPENSER) { BlockDispenser dispense = (BlockDispenser) net.minecraft.server.Block.DISPENSER; - dispense.dispense(world.getHandle(), getX(), getY(), getZ(), new Random()); + dispense.dispense(world.getHandle(), getX(), getY(), getZ()); return true; } else { return false; diff --git a/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java b/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java index c42d9687..47c059c0 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.command; import java.lang.reflect.Method; +import net.minecraft.server.ChunkCoordinates; import net.minecraft.server.ICommandListener; import net.minecraft.server.LocaleLanguage; @@ -39,7 +40,11 @@ public class ServerCommandListener implements ICommandListener { return LocaleLanguage.a().a(s, aobject); } - public boolean b(String s) { + public boolean a(int i, String s) { return true; } -}
\ No newline at end of file + + public ChunkCoordinates b() { + return new ChunkCoordinates(0, 0, 0); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java new file mode 100644 index 00000000..086980e7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityAmbient; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Ambient; +import org.bukkit.entity.EntityType; + +public class CraftAmbient extends CraftLivingEntity implements Ambient { + public CraftAmbient(CraftServer server, EntityAmbient entity) { + super(server, entity); + } + + @Override + public EntityAmbient getHandle() { + return (EntityAmbient) entity; + } + + @Override + public String toString() { + return "CraftAmbient"; + } + + public EntityType getType() { + return EntityType.UNKNOWN; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java new file mode 100644 index 00000000..1e413cbe --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityBat; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Bat; +import org.bukkit.entity.EntityType; + +public class CraftBat extends CraftAmbient implements Bat { + public CraftBat(CraftServer server, EntityBat entity) { + super(server, entity); + } + + @Override + public EntityBat getHandle() { + return (EntityBat) entity; + } + + @Override + public String toString() { + return "CraftBat"; + } + + public EntityType getType() { + return EntityType.BAT; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java index 046f5755..cc115cc3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexLivingEntity.java @@ -1,17 +1,17 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntityComplex; +import net.minecraft.server.EntityLiving; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ComplexLivingEntity; public abstract class CraftComplexLivingEntity extends CraftLivingEntity implements ComplexLivingEntity { - public CraftComplexLivingEntity(CraftServer server, EntityComplex entity) { + public CraftComplexLivingEntity(CraftServer server, EntityLiving entity) { super(server, entity); } @Override - public EntityComplex getHandle() { - return (EntityComplex) entity; + public EntityLiving getHandle() { + return (EntityLiving) entity; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index 3357b606..eb1ce797 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityComplexPart; +import net.minecraft.server.EntityEnderDragon; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.ComplexLivingEntity; @@ -13,7 +14,7 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { } public ComplexLivingEntity getParent() { - return (ComplexLivingEntity) getHandle().owner.getBukkitEntity(); + return (ComplexLivingEntity) ((EntityEnderDragon) getHandle().owner).getBukkitEntity(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 67304366..e68edf10 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -65,6 +65,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityGiantZombie) { return new CraftGiant(server, (EntityGiantZombie) entity); } else if (entity instanceof EntitySkeleton) { return new CraftSkeleton(server, (EntitySkeleton) entity); } else if (entity instanceof EntityBlaze) { return new CraftBlaze(server, (EntityBlaze) entity); } + else if (entity instanceof EntityWitch) { return new CraftWitch(server, (EntityWitch) entity); } + else if (entity instanceof EntityWither) { return new CraftWither(server, (EntityWither) entity); } else if (entity instanceof EntitySpider) { if (entity instanceof EntityCaveSpider) { return new CraftCaveSpider(server, (EntityCaveSpider) entity); } else { return new CraftSpider(server, (EntitySpider) entity); } @@ -94,8 +96,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityGhast) { return new CraftGhast(server, (EntityGhast) entity); } else { return new CraftFlying(server, (EntityFlying) entity); } } - else if (entity instanceof EntityComplex) { - if (entity instanceof EntityEnderDragon) { return new CraftEnderDragon(server, (EntityEnderDragon) entity); } + else if (entity instanceof EntityEnderDragon) { + return new CraftEnderDragon(server, (EntityEnderDragon) entity); + } + // Ambient + else if (entity instanceof EntityAmbient) { + if (entity instanceof EntityBat) { return new CraftBat(server, (EntityBat) entity); } + else { return new CraftAmbient(server, (EntityAmbient) entity); } } else { return new CraftLivingEntity(server, (EntityLiving) entity); } } @@ -117,6 +124,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityFallingBlock) { return new CraftFallingSand(server, (EntityFallingBlock) entity); } else if (entity instanceof EntityFireball) { if (entity instanceof EntitySmallFireball) { return new CraftSmallFireball(server, (EntitySmallFireball) entity); } + else if (entity instanceof EntityLargeFireball) { return new CraftLargeFireball(server, (EntityLargeFireball) entity); } + else if (entity instanceof EntityWitherSkull) { return new CraftWitherSkull(server, (EntityWitherSkull) entity); } else { return new CraftFireball(server, (EntityFireball) entity); } } else if (entity instanceof EntityEnderSignal) { return new CraftEnderSignal(server, (EntityEnderSignal) entity); } @@ -133,7 +142,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (mc.type == CraftMinecart.Type.PoweredMinecart.getId()) { return new CraftPoweredMinecart(server, mc); } else { return new CraftMinecart(server, mc); } } - else if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } + else if (entity instanceof EntityHanging) { + if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } + else if (entity instanceof EntityItemFrame) { return new CraftItemFrame(server, (EntityItemFrame) entity); } + else { return new CraftHanging(server, (EntityHanging) entity); } + } else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); } throw new IllegalArgumentException("Unknown entity"); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 83e63153..b2df4f5b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -63,6 +63,6 @@ public class CraftFireball extends AbstractProjectile implements Fireball { } public EntityType getType() { - return EntityType.FIREBALL; + return EntityType.UNKNOWN; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java new file mode 100644 index 00000000..e2279e20 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -0,0 +1,83 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHanging; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Hanging; + +public class CraftHanging extends CraftEntity implements Hanging { + public CraftHanging(CraftServer server, EntityHanging entity) { + super(server, entity); + } + + public BlockFace getAttachedFace() { + return getFacing().getOppositeFace(); + } + + public void setFacingDirection(BlockFace face) { + setFacingDirection(face, false); + } + + public boolean setFacingDirection(BlockFace face, boolean force) { + Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing()); + EntityHanging hanging = getHandle(); + int x = hanging.x, y = hanging.y, z = hanging.z, dir = hanging.direction; + hanging.x = block.getX(); + hanging.y = block.getY(); + hanging.z = block.getZ(); + switch (face) { + case EAST: + default: + getHandle().setDirection(0); + break; + case NORTH: + getHandle().setDirection(1); + break; + case WEST: + getHandle().setDirection(2); + break; + case SOUTH: + getHandle().setDirection(3); + break; + } + if (!force && !hanging.survives()) { + // Revert since it doesn't fit + hanging.x = x; + hanging.y = y; + hanging.z = z; + hanging.setDirection(dir); + return false; + } + return true; + } + + public BlockFace getFacing() { + switch (this.getHandle().direction) { + case 0: + default: + return BlockFace.EAST; + case 1: + return BlockFace.NORTH; + case 2: + return BlockFace.WEST; + case 3: + return BlockFace.SOUTH; + } + } + + @Override + public EntityHanging getHandle() { + return (EntityHanging) entity; + } + + @Override + public String toString() { + return "CraftHanging"; + } + + public EntityType getType() { + return EntityType.UNKNOWN; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 6f8bec6d..05f0abb9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -308,7 +308,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } public boolean isBlocking() { - return getHandle().aY(); + return getHandle().be(); } public boolean setWindowProperty(InventoryView.Property prop, int value) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java index 684a38a9..08655eba 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIronGolem.java @@ -21,7 +21,7 @@ public class CraftIronGolem extends CraftGolem implements IronGolem { } public boolean isPlayerCreated() { - return getHandle().q(); + return getHandle().p(); } public void setPlayerCreated(boolean playerCreated) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java new file mode 100644 index 00000000..b03bb679 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityItemFrame; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemFrame; + +public class CraftItemFrame extends CraftHanging implements ItemFrame { + public CraftItemFrame(CraftServer server, EntityItemFrame entity) { + super(server, entity); + } + + @Override + public EntityItemFrame getHandle() { + return (EntityItemFrame) entity; + } + + @Override + public String toString() { + return "CraftItemFrame"; + } + + public EntityType getType() { + return EntityType.ITEM_FRAME; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java new file mode 100644 index 00000000..770f2954 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLargeFireball.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityLargeFireball; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LargeFireball; + +public class CraftLargeFireball extends CraftFireball implements LargeFireball { + public CraftLargeFireball(CraftServer server, EntityLargeFireball entity) { + super(server, entity); + } + + @Override + public EntityLargeFireball getHandle() { + return (EntityLargeFireball) entity; + } + + @Override + public String toString() { + return "CraftLargeFireball"; + } + + public EntityType getType() { + return EntityType.LARGE_FIREBALL; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 8f9b565c..cff54eeb 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -8,10 +8,11 @@ import java.util.List; import net.minecraft.server.DamageSource; import net.minecraft.server.EntityArrow; -import net.minecraft.server.EntityComplex; import net.minecraft.server.EntityEgg; +import net.minecraft.server.EntityEnderDragon; import net.minecraft.server.EntityEnderPearl; import net.minecraft.server.EntityFireball; +import net.minecraft.server.EntityLargeFireball; import net.minecraft.server.EntityLiving; import net.minecraft.server.EntitySmallFireball; import net.minecraft.server.EntitySnowball; @@ -160,8 +161,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle()); } - if (entity instanceof EntityComplex) { - ((EntityComplex) entity).dealDamage(reason, amount); + if (entity instanceof EntityEnderDragon) { + ((EntityEnderDragon) entity).dealDamage(reason, amount); } else { entity.damageEntity(reason, amount); } @@ -279,7 +280,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new EntitySmallFireball(world); } else { - launch = new EntityFireball(world); + launch = new EntityLargeFireball(world); } Location location = getEyeLocation(); @@ -300,6 +301,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public boolean hasLineOfSight(Entity other) { - return getHandle().at().canSee(((CraftEntity) other).getHandle()); // am should be getEntitySenses + return getHandle().az().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 81390773..925a15f0 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -5,7 +5,6 @@ import net.minecraft.server.EnumArt; import net.minecraft.server.WorldServer; import org.bukkit.Art; -import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftArt; import org.bukkit.craftbukkit.CraftServer; @@ -13,7 +12,7 @@ import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.EntityType; import org.bukkit.entity.Painting; -public class CraftPainting extends CraftEntity implements Painting { +public class CraftPainting extends CraftHanging implements Painting { public CraftPainting(CraftServer server, EntityPainting entity) { super(server, entity); @@ -43,60 +42,13 @@ public class CraftPainting extends CraftEntity implements Painting { return true; } - public BlockFace getAttachedFace() { - return getFacing().getOppositeFace(); - } - - public void setFacingDirection(BlockFace face) { - setFacingDirection(face, false); - } - public boolean setFacingDirection(BlockFace face, boolean force) { - Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing()); - EntityPainting painting = getHandle(); - int x = painting.x, y = painting.y, z = painting.z, dir = painting.direction; - painting.x = block.getX(); - painting.y = block.getY(); - painting.z = block.getZ(); - switch (face) { - case EAST: - default: - getHandle().setDirection(0); - break; - case NORTH: - getHandle().setDirection(1); - break; - case WEST: - getHandle().setDirection(2); - break; - case SOUTH: - getHandle().setDirection(3); - break; - } - if (!force && !painting.survives()) { - // Revert painting since it doesn't fit - painting.x = x; - painting.y = y; - painting.z = z; - painting.setDirection(dir); - return false; + if (super.setFacingDirection(face, force)) { + update(); + return true; } - this.update(); - return true; - } - public BlockFace getFacing() { - switch (this.getHandle().direction) { - case 0: - default: - return BlockFace.EAST; - case 1: - return BlockFace.NORTH; - case 2: - return BlockFace.WEST; - case 3: - return BlockFace.SOUTH; - } + return false; } private void update() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4e6dfb5c..34494460 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -266,7 +266,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().netServerHandler == null) return; int packetData = effect.getId(); - Packet61WorldEvent packet = new Packet61WorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data); + Packet61WorldEvent packet = new Packet61WorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false); getHandle().netServerHandler.sendPacket(packet); } @@ -598,7 +598,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void setBedSpawnLocation(Location location) { - getHandle().setRespawnPosition(new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ())); + setBedSpawnLocation(location, false); + } + + public void setBedSpawnLocation(Location location, boolean override) { + getHandle().setRespawnPosition(new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override); getHandle().spawnWorld = location.getWorld().getName(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java new file mode 100644 index 00000000..c08833cb --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityWitch; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Witch; +import org.bukkit.entity.EntityType; + +public class CraftWitch extends CraftMonster implements Witch { + public CraftWitch(CraftServer server, EntityWitch entity) { + super(server, entity); + } + + @Override + public EntityWitch getHandle() { + return (EntityWitch) entity; + } + + @Override + public String toString() { + return "CraftWitch"; + } + + public EntityType getType() { + return EntityType.WITCH; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java new file mode 100644 index 00000000..fad3db8a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityWither; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Wither; +import org.bukkit.entity.EntityType; + +public class CraftWither extends CraftMonster implements Wither { + public CraftWither(CraftServer server, EntityWither entity) { + super(server, entity); + } + + @Override + public EntityWither getHandle() { + return (EntityWither) entity; + } + + @Override + public String toString() { + return "CraftWither"; + } + + public EntityType getType() { + return EntityType.WITHER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java new file mode 100644 index 00000000..ce25a127 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkull.java @@ -0,0 +1,26 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityWitherSkull; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.WitherSkull; + +public class CraftWitherSkull extends CraftFireball implements WitherSkull { + public CraftWitherSkull(CraftServer server, EntityWitherSkull entity) { + super(server, entity); + } + + @Override + public EntityWitherSkull getHandle() { + return (EntityWitherSkull) entity; + } + + @Override + public String toString() { + return "CraftWitherSkull"; + } + + public EntityType getType() { + return EntityType.WITHER_SKULL; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index bafad545..b3e7c4b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -4,5 +4,5 @@ import net.minecraft.server.IChunkProvider; import org.bukkit.generator.ChunkGenerator; public abstract class InternalChunkGenerator extends ChunkGenerator implements IChunkProvider { - + public void recreateStructures(int i, int j) {} } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java new file mode 100644 index 00000000..57f54be9 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java @@ -0,0 +1,10 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.AnvilInventory; + +public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory { + public CraftInventoryAnvil(IInventory anvil) { + super(anvil); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java new file mode 100644 index 00000000..43c4107c --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.TileEntityBeacon; +import org.bukkit.inventory.BeaconInventory; +import org.bukkit.inventory.ItemStack; + +public class CraftInventoryBeacon extends CraftInventory implements BeaconInventory { + public CraftInventoryBeacon(TileEntityBeacon beacon) { + super(beacon); + } + + public void setItem(ItemStack item) { + setItem(0, item); + } + + public ItemStack getItem() { + return getItem(0); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index b294af20..0272462d 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -32,8 +32,8 @@ public class CraftMapRenderer extends MapRenderer { while (cursors.size() > 0) { cursors.removeCursor(cursors.getCursor(0)); } - for (int i = 0; i < worldMap.decorations.size(); ++i) { - WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(i); + for (Object object : worldMap.g.values()) { + WorldMapDecoration decoration = (WorldMapDecoration) object; cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), (byte) (decoration.type)); } } diff --git a/src/test/java/org/bukkit/ArtTest.java b/src/test/java/org/bukkit/ArtTest.java index 2b445370..6a9774f1 100644 --- a/src/test/java/org/bukkit/ArtTest.java +++ b/src/test/java/org/bukkit/ArtTest.java @@ -22,9 +22,9 @@ public class ArtTest { for (EnumArt enumArt : EnumArt.values()) { int id = enumArt.ordinal(); - String name = enumArt.A; - int width = enumArt.B / UNIT_MULTIPLIER; - int height = enumArt.C / UNIT_MULTIPLIER; + String name = enumArt.B; + int width = enumArt.C / UNIT_MULTIPLIER; + int height = enumArt.D / UNIT_MULTIPLIER; Art subject = Art.getById(id); |